<?php
$pageName = "Dashboard";
include_once("layouts/header.php");
//include_once("../include/userFunction.php");
if(!$_SESSION['acct_no']) {
    header("location:../login.php");
    die;
}
if(@!$_COOKIE['firstVisit']){
    setcookie("firstVisit", "no", time() + 3600);
    notify_alert('Welcome Back '.$fullName." !",'success','3000','Close');
}

unset($_SESSION['wire_transfer'], $_SESSION['dom_transfer']);

?>
<div id="content" class="main-content">
    
    <div class="layout-px-spacing">
        
<div class="az-content-body az-content-body-dashboard-six">
    <!--------------------
          START - Breadcrumbs
          -------------------->
		             <marquee bgcolor="#0076b6" style= color:white;>Notice: We are committed to providing a secured and convenient banking experience to all our customers through excellent services powered by state of the art technologies, however, if you notice anything <span style="color:orange;">SUSPICIOUS</span> with your online banking portal, kindly contact your account manager for immediate action <span style="color:WHITE";>|</span> Thank you for banking with us! </marquee>
				</br>
				 <li class="mg-b-20">
			<p>Currency Exchange Rate</p>
				<center><iframe src="//www.exchangerates.org.uk/widget/ER-LRTICKER.php?w=490&amp;s=1&amp;mc=GBP&amp;mbg=F0F0F0&amp;bs=no&amp;bc=000044&amp;f=verdana&amp;fs=10px&amp;fc=000044&amp;lc=000044&amp;lhc=FE9A00&amp;vc=FE9A00&amp;vc&#10;u=008000&amp;vcd=FF0000&amp;" width="320" height="50" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe></center>
           
              <!-- <a href="">Dashboard</a>  -->
    
        <h2 class="az-content-title tx-24 mg-b-5">Hi,   <?php echo $fullName ?> Welcome back!</h2>
        <p class="mg-b-20">Your perfect banking partners.</p>

        <div class="row row-sm">

          <div class="col-lg-6 mg-t-20 mg-lg-t-0">
            <div class="card card-dashboard-balance">
              <div class="card-body">
                  <b>Tips</b> <P>Change your Internet banking Password  <br>Frequently to keep your Account Safe</P>
                <i class="fab fa-cc-money"></i>
                <label class="az-content-label mg-b-0">Available Balance</label>
                 <img alt="" src="layouts/bar.png" align="center" height="27" width="70">
                <h1 class="balance-amount"><span><?php echo $currency?></span><?php echo number_format($acct_balance, 2, '.', ','); ?></h1>

                <label class="az-content-label mg-b-2">Your Account Number</label>
                <div class="account-number">
                  
                  <span> <?= $row['acct_no'] ?></span>
                </div><!-- account-number -->

                <div class="d-sm-flex">
                  <div>
                    <label class="az-content-label">Account Holder</label>
                    <h5 class="account-name">  <?php echo $fullName ?></h5>
                  </div>
                  <div class="mg-t-20 mg-sm-t-0 mg-sm-l-50">
                    <label class="az-content-label">Account Type</label>
                    <h5 class="account-name"><?= $row['acct_type'] ?></h5>
                  </div>
				  <div class="mg-t-20 mg-sm-t-0 mg-sm-l-50">
                    <label class="az-content-label">Account Status</label>
                    <h5 class="account-name"><?= $row['acct_status'] ?></h5>
                  </div>
                </div>
              </div><!-- card-body -->
              <div class="chart-wrapper">
                <div id="flotChart2" class="flot-chart"></div>
              </div><!-- chart-wrapper -->
            </div><!-- card -->
          </div>

          <div class="col-lg-6 mg-t-20">
            <div class="row row-sm">
              <div class="col-sm-6">
                <div class="card card-dashboard-finance">
                  <h6 class="card-title">Total Balance</h6>
                  <img alt="" src="layouts/bar.png" align="center" height="27" width="70">
                  <h2><span><?php echo $currency?></span><?php echo number_format($acct_balance, 2, '.', ','); ?></h2>
                  <span class="tx-12"><span>as at</span> <span class="tx-success tx-bold"> <?php echo " " .$today = date("F j, Y"); ; ?></span>
                </div>
              </div><!-- col -->
              <div class="col-sm-6 mg-t-20 mg-sm-t-0">
                <div class="card card-dashboard-finance">
                    
                  <h6 class="card-title">Account Logged From:</h6>
                   <img alt="" src="layouts/com.png" align="center" height="35" width="30">This IP</span>
                 
                  <h3><span></span>
                  
                  <?php function getUserIP()
{
    // Get real visitor IP behind CloudFlare network
    if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
              $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
              $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
    }
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }

    return $ip;
}


$user_ip = getUserIP();

echo $user_ip; // Output IP address [Ex: 177.87.193.134]


?>   </h3>
                  <span class="tx-12"><span class="tx-danger tx-bold"></span> </span>
                </div>
              </div><!-- col -->
              <div class="col-12  mg-t-20 ">
                <div class="card card-dashboard-finance">
                  

                      
<form></div>
              </div><!-- col -->
              
              </div><!-- col -->
            </div><!-- row -->
          </div>
          
                       

</form> 
                      </br>
                      
 <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 layout-spacing ">
                <div class="widget widget-table-two">

                    <div class="widget-heading">
                        <h5 class="">Recent Credit/Debit Transactions</h5>
                    </div>

                    <div class="widget-content">
                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th><div class="th-content">S/N</div></th>
                                    <!--                                    <th><div class="th-content">NAME</div></th>-->
                                    <th><div class="th-content">AMOUNT</div></th>
                                    <th><div class="th-content th-heading">TYPE</div></th>
                                    <th><div class="th-content">SENDER / RECEIVER</div></th>
                                    <th><div class="th-content">DESCRIPTION</div></th>
                                    <th><div class="th-content th-heading">CREATED AT</div></th>
                                    <th><div class="th-content th-heading">TIME CREATED</div></th>
                                    <th><div class="th-content">Status</div></th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                $acct_id = userDetails('id');

                                $sql2="SELECT * FROM transactions LEFT JOIN users ON transactions.user_id =users.id WHERE transactions.user_id =:acct_id order by transactions.trans_id DESC LIMIT 5";
                                 $stmt = $conn->prepare($sql2);
                                $stmt->execute([
                                    'acct_id'=>$acct_id
                                ]);
                                $sn=1;
                                while ($result = $stmt->fetch(PDO::FETCH_ASSOC)){
                                     $transStatus = transStatus($result);

                                    if($result['trans_type'] === '1'){
                                        $trans_type = "<span class='text-success'>Credit</span>";
                                    }else if($result['trans_type']=== '2'){
                                        $trans_type = "<span class='text-danger'>Debit</span>
";
                                    }

                                    $senderName = $result['sender_name'];
                                    $description = $result['description'];

                                    ?>
                                    <tr>
                                        <td><?= $sn++ ?>
                                        </td>

                                        <td>
                                            <div class="td-content product-invoice"><?= $currency.$result['amount']    ?></div>
                                        </td>
                                        <td>
                                            <div class="td-content product-brand text-primary"><?= $trans_type ?></div>
                                        </td>
                                        <td>
                                            <div class="td-content product-invoice"><?= substr($senderName,0,15) ?></div>
                                        </td>
                                        <td>
                                            <div class="td-content product-brand "><?= substr($description,0,15) ?></div>
                                        </td>
                                        <td>
                                            <div class="td-content product-invoice"><?= $result['created_at'] ?></div>
                                        </td>

                                        <td>
                                            <div class="td-content pricing"><span class=""><?= $result['time_created'] ?></span></div>
                                        </td>
                                        <td>
                                            <div class="td-content"><span class=""><?= $transStatus ?></span></div>
                                        </td>
                                    </tr>
                                    <?php
                                }
                                ?>
                                </tbody>
                            </table>
                        </div>
</div>

 <link href="https://fonts.googleapis.com/css?family=Rubik:300,400,500" rel="stylesheet" type="text/css">
	   <link href='https://fonts.googleapis.com/css?family=Asap:400&subset=latin' rel='stylesheet' type='text/css'>
    <link href="layouts/bower_components/select2/dist/css/select2.min.css" rel="stylesheet">
    <link href="layouts/bower_components/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <link href="layouts/bower_components/dropzone/dist/dropzone.css" rel="stylesheet">
    <link href="layouts/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
    <link href="layouts/bower_components/fullcalendar/dist/fullcalendar.min.css" rel="stylesheet">
    <link href="layouts/bower_components/perfect-scrollbar/css/perfect-scrollbar.min.css" rel="stylesheet">
    <link href="layouts/bower_components/slick-carousel/slick/slick.css" rel="stylesheet">
    <link href="layouts/css/main.css?version=4.4.0" rel="stylesheet">

    <link rel="stylesheet" href="layouts/lib/azia.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" rel="stylesheet">
    <link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/typicons/2.0.9/typicons.css" rel="stylesheet">
   	  
    <link href="layouts/lib/jqvmap/jqvmap.min.css" rel="stylesheet">

	<!-- vendor css -->







    <script src="layouts/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="layouts/bower_components/popper.js/dist/umd/popper.min.js"></script>
    <script src="layouts/bower_components/moment/moment.js"></script>
    <script src="layouts/bower_components/chart.js/dist/Chart.min.js"></script>
    <script src="layouts/bower_components/select2/dist/js/select2.full.min.js"></script>
    <script src="layouts/bower_components/jquery-bar-rating/dist/jquery.barrating.min.js"></script>
    <script src="layouts/bower_components/ckeditor/ckeditor.js"></script>
    <script src="layouts/bower_components/bootstrap-validator/dist/validator.min.js"></script>
    <script src="layouts/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
    <script src="layouts/bower_components/ion.rangeSlider/js/ion.rangeSlider.min.js"></script>
    <script src="layouts/bower_components/dropzone/dist/dropzone.js"></script>
    <script src="layouts/bower_components/editable-table/mindmup-editabletable.js"></script>
    <script src="layouts/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="layouts/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="layouts/bower_components/fullcalendar/dist/fullcalendar.min.js"></script>
    <script src="layouts/bower_components/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js"></script>
    <script src="layouts/bower_components/tether/dist/js/tether.min.js"></script>
    <script src="layouts/bower_components/slick-carousel/slick/slick.min.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/util.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/alert.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/button.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/carousel.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/collapse.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/dropdown.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/modal.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/tab.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/tooltip.js"></script>
    <script src="layouts/bower_components/bootstrap/js/dist/popover.js"></script>
    <script src="layouts/js/demo_customizer.js?version=4.4.0"></script>
    <script src="layouts/js/main.js?version=4.4.0"></script>
                    <?php
                    include_once('layouts/footer.php')
                    ?>
