<?php
session_start();
require_once('config/config.php');
require_once('class/functions.php');
dbconnect();

if (!is_user()) {
    redirect(LOGIN);
}

$page = "Own Account Transfer"; 
$geo = ip2location($_SERVER['REMOTE_ADDR']);
$country = $geo->country;
$city = $geo->city;
visit_log($_SERVER['REMOTE_ADDR'], $country, $city, $_SERVER['HTTP_USER_AGENT'], getBrowser($_SERVER['HTTP_USER_AGENT']), getOS($_SERVER['HTTP_USER_AGENT']), $page, $_SESSION['user_login']);


require_once('head.php');
?>

<body>
  <div class="app" id="app">

<!-- ############ LAYOUT START-->
  <!-- aside -->
  <?php require_once('aside.php'); ?>
  <!-- / aside -->



  <!-- content -->
  <div id="content" class="app-content box-shadow-z3" role="main">

    <?php require_once('header.php'); ?>

    <?php require_once('footer.php'); ?>

    <div ui-view class="app-body" id="view">
    <!-- ############ PAGE START-->

    <?php require_once('topbar.php'); ?>


    <?php
    $notify = get_alerts($_SESSION['user_login'], 'all');
    foreach($notify as $ntfy){
    echo "<div class=\"alert alert-warning\" role=\"alert\">
    <strong>".date('l jS F Y', strtotime($ntfy['alrt_date']))."</strong><br>".$ntfy['alrt_cnt']."
    </div>";
    }
    ?>

    <?php if (!empty($_SESSION['msg_text'])) {
    $msg = create_alert($_SESSION['msg_text'], $_SESSION['msg_type']);
    echo $msg;
    clear_msg(); }
    ?>


    <div class="padding">
      <div class="p-x-lg">
        <div class="row">
        <div class="col-lg-8 offset-lg-2">
          <div class="box">
            <div class="box-header">
              <h2>Own Account Transfer</h2>
              <small>Transfer from one account to another account you own.</small>
            </div>
            <div class="box-divider m-a-0"></div>
            <div class="box-body p-v-md">
            <form id="Stmnt" method="post" action="<?php echo OWNCONFIRM ?>" autocomplete="off" enctype="multipart/form-data" ui-jp="parsley">
              <div class="row row-sm">
                <div class="col-sm-12">
                    <div class="md-form-group">
                      <select name="fmAcc" class="md-input" data-parsley-error-message="Select From Account" required>
                        <option value="">Select Account to transfer from </option>
                        <?php
            				$accounts = get_accs($_SESSION['user_number']);
                            if (empty($accounts)) {
                            echo '<option value="">No account exist</option>';
                            }else{
            				foreach($accounts as $acc)
            				{
            				echo '
                            <option value="'.$acc['acc_no'].'">'.$acc['acc_no'].' (Balance: '.$acc['currency'].''.number_format(get_balance($acc['acc_no']),2).')</option>
            				';
            				}
                            }
            			?>
        			  </select>
                      <label>Select From Account</label>
                    </div>
                </div>
              </div>
              <div class="row row-sm">
                <div class="col-sm-12">
                    <div class="md-form-group">
                      <select name="toAcc" class="md-input" data-parsley-error-message="Select To Account" required>
                        <option value="">Select Account to transfer to </option>
                        <?php
            				$accounts = get_accs($_SESSION['user_number']);
                            if (empty($accounts)) {
                            echo '<option value="">No account exist</option>';
                            }else{
            				foreach($accounts as $acc)
            				{
            				echo '
                            <option value="'.$acc['acc_no'].'">'.$acc['acc_no'].' (Balance: '.$acc['currency'].''.number_format(get_balance($acc['acc_no']),2).')</option>
            				';
            				}
                            }
            			?>
        			  </select>
                      <label>Select To Account</label>
                    </div>
                </div>
              </div>
              <div class="row row-sm">
                <div class="col-sm-6">
                    <div class="md-form-group float-label">
                      <input type="text" id="Amnt" name="tfAmt" class="md-input" data-parsley-error-message="Enter Transfer Amount" required>
                      <label>Amount</label>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="md-form-group float-label">
                      <input type="password" name="uSeca" class="md-input" data-parsley-error-message="Enter Answer to Security Question" required>
                      <label>Answer to Security Question</label>
                    </div>
                </div>
              </div>
              <div class="row row-sm">
                <div class="col-sm-12">
                  <button type="submit" class="btn rounded btn-outline main mainbd p-x-md">Transfer</button>
                </div>
              </div>
            </form>
            </div>
          </div>
        </div>
        </div>
      </div>
    </div>


    <!-- ############ PAGE END-->
    </div>



    </div>
<!-- ############ LAYOUT END-->

  </div>
<!-- build:js scripts/app.html.js -->
<!-- jQuery -->
  <script src="libs/jquery/jquery/dist/jquery.js"></script>
  <script src="scripts/jquery.maskMoney.js"></script>
  <script>
    $(function() {
        $("#Amnt").maskMoney();
    });
  </script>

<!-- Bootstrap -->
  <script src="libs/jquery/tether/dist/js/tether.min.js"></script>
  <script src="libs/jquery/bootstrap/dist/js/bootstrap.js"></script>
<!-- core -->
  <script src="libs/jquery/underscore/underscore-min.js"></script>
  <script src="libs/jquery/jQuery-Storage-API/jquery.storageapi.min.js"></script>
  <script src="libs/jquery/PACE/pace.min.js"></script>

  <script src="scripts/config.lazyload.js"></script>

  <script src="scripts/palette.js"></script>
  <script src="scripts/ui-load.js"></script>
  <script src="scripts/ui-jp.js"></script>
  <script src="scripts/ui-include.js"></script>
  <script src="scripts/ui-device.js"></script>
  <script src="scripts/ui-form.js"></script>
  <script src="scripts/ui-nav.js"></script>
  <script src="scripts/ui-screenfull.js"></script>
  <script src="scripts/ui-scroll-to.js"></script>
  <script src="scripts/ui-toggle-class.js"></script>

  <script src="scripts/app.js"></script>

  <!-- ajax -->
  <script src="libs/jquery/jquery-pjax/jquery.pjax.js"></script>
  <script src="scripts/ajax.js"></script>
<!-- endbuild -->
</body>
</html>
