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

  <body>
  <!-- container section start -->
  <section id="container" class="">
      
	<?php require_once('header.php'); ?>	

	<?php require_once('sidebar.php'); ?>
      
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">

			  <div class="row">
                  <div class="col-lg-12">
                      <!--breadcrumbs start -->
                      <ul class="breadcrumb">
                          <li><a href="dashboard.php"><i class="icon_house_alt"></i> Accounts</a></li>
                          <li class="active"> Home</li>
						  <li class="pull-right"> <i class="icon_calendar"></i>
							 <?php echo date('l jS F Y'); ?></li>
                      </ul>
                      <!--breadcrumbs end -->
                  </div>
              </div>		  
			  
			  <!-- knob charts -->
            <div class="row">
                  <div class="col-lg-12">                      
                      <aside class="profile-nav alt">
                          <section class="panel">
                            <div class="">
                              <div class="user-heading alt bg-layer profile-widget-info">                                
                                  <a href="#">
                                      <img alt="<?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?>" src="users/<?php echo user_photo(preg_replace('/\s/', '', $_SESSION['user_login'])); ?>">
                                  </a>
                                  <h1><?php echo WEB_NAME ?></h1>
                                  <h4>Welcome, <?php echo $row['first_name']; ?> <?php echo $row['last_name']; ?></h4>
                                  </div>
                              </div>

                              <div class="weather-category profile-widget-data">
                                      <ul>
                                          <li class="active">
                                              <h5>Last login on:</h5>
											  <?php if ($row['last_ts'] == "0000-00-00 00:00:00") { echo ""; }else{ echo date('l jS F Y', strtotime($row['last_ts']));} ?>
                                          </li>
                                          <li>
                                              <h5>Last login From:</h5>
																															<a href="http://api.hostip.info/get_html.php?ip=<?php echo $row['last_ip']; ?>" target="_blank">
											  <img src="http://api.hostip.info/flag.php?ip=<?php echo $row['last_ip']; ?>" alt="Country" width="39" height="24">
											  </a>
                                          </li>
                                          <li>
                                              <h5>Last login IP:</h5>
                                              <?php echo $row['last_ip']; ?>
                                          </li>
                                      </ul>
                                  </div>

                          </section>
                      </aside>                                            
                  </div>
                </div>
				
				
				<div class="row">
                  <div class="col-lg-12">
                      <!--account status start -->
                      <?php
                        $status = strtoupper($row['user_active']);
						if ($row['user_active'] == "active"){ echo '';}
						else{ echo '

								<div class="alert fade in alert-danger">
									<i class="icon-warning-sign"></i>
									Your Account is <strong>'.$status.',</strong> please contact your account officer for assistance.
									<a href="messages.php">Click here <i class="icon-angle-right"></i></a>
								</div>
							';}
						?>
                      <!--account status end -->
                  </div>
              </div>
			  
              <!--overview start-->
              <div class="row state-overview">
                <!-- statics start -->
                <div class="state col-lg-12">
                    <div class="row">
                      <div class="col-lg-6 col-sm-6">
                          <section class="panel">
                              <div class="symbol">
                                  <i class="icon_balance"></i>
                              </div>
                              <div class="value">
                                  <h1>
									<?php echo $_SESSION['currency']; ?> 
									<?php
									$credit = sum_credits($_SESSION['user_acc']);
									$debit = sum_debits($_SESSION['user_acc']);
									$bal = $credit - $debit;
									echo number_format($bal,2);
									?>
								  </h1>
                                  <p>TOTAL BOOKED BALANCE</p>
                              </div>
                          </section>
                      </div>
                      <div class="col-lg-6 col-sm-6">
                          <section class="panel">
                              <div class="symbol">
                                  <i class="icon-money"></i>
                              </div>
                              <div class="value">
                                  <h1>
									<?php echo $_SESSION['currency']; ?> 
									<?php
									$credit = sum_credits($_SESSION['user_acc']);
									$debit = sum_debits($_SESSION['user_acc']);
									$bal = $credit - $debit;
									echo number_format($bal,2);
									?>
								  </h1>
                                  <p>TOTAL AVAILABLE BALANCE</p>
                              </div>
                          </section>
                      </div>
                    </div>
                </div>    
                <!-- statics end -->
              </div>
              <!--overview end-->


			  <div class="row">
                  <div class="col-lg-12">
                      <!--Project Activity start-->
                      <section class="panel">
                          <div class="panel-body progress-panel">
                            <div class="row">
                              <div class="col-lg-8 task-progress pull-left">
                                  <h1>BALANCE IN ACCOUNTS</h1>                                  
                              </div>
                              <div class="col-lg-4">                               
                              </div>
                            </div>
                          </div>
                          <table class="table table-hover personal-task">
                              <tbody>
                              <tr>
                                  <td><?php echo $_SESSION['user_acc']; ?></td>
                                  <td>
									<?php echo $_SESSION['currency']; ?>
								    <?php
									$credit = sum_credits($_SESSION['user_acc']);
									$debit = sum_debits($_SESSION['user_acc']);
									$bal = $credit - $debit;
									echo number_format($bal,2);
									?></td>
                              </tr>
                              </tbody>
                          </table>
                      </section>
                      <!--Project Activity end-->
                  </div>
              </div>
              <!-- project team & activity end -->
			  
			  <!-- Recent Transactions Starts -->
			  <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading">
                              Recent Transactions
                          </header>
                          <div class="table-responsive">
                            <table class="table">
                              <thead>
                                <tr>
									<th>#</th>
									<th>Date</th>
									<th>Account Number</th>
									<th>Details</th>
									<th>Credit</th>
									<th>Debit</th>
                                </tr>
                              </thead>
                              <tbody>
								<?php
									$pos = 1;
									dbconnect();
									$sql = "SELECT * FROM `".TRANS_TABLE_NAME."` WHERE user_acc='{$_SESSION['user_acc']}' ORDER BY trans_id DESC LIMIT 5";
									$stmt = $pdo->query($sql);
									while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ 
								?>
                                <tr>
									<td><?php echo $pos; ?></td>
									<td><?php echo date('jS F Y', strtotime($row['trans_date'])); ?></td>
									<td><?php echo $row['user_acc']; ?></td>
									<td class="hidden-xs"><?php echo $row['trans_details']; ?></td>
									<td><?php if ($row['credit'] == "") { echo ''; }else{ echo number_format($row['credit'],2);} ?></td>
									<td><?php if ($row['debit'] == "") { echo ''; }else{ echo number_format($row['debit'],2);} ?></td>
                                </tr>
								<?php 
								$pos++;
								} 
								?>
                              </tbody>
                            </table>
                          </div>

                      </section>
                  </div>
              </div>
			  <!-- Recent Transactions end -->

              

          </section>
      </section>
      <!--main content end-->
  </section>
  <!-- container section start -->

    <!-- javascripts -->
    <script src="js/jquery.js"></script>
    <script src="js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
    <!-- bootstrap -->
    <script src="js/bootstrap.min.js"></script>
    <!-- nice scroll -->
    <script src="js/jquery.scrollTo.min.js"></script>
    <script src="js/jquery.nicescroll.js" type="text/javascript"></script>
    <!-- charts scripts -->
    <script src="assets/jquery-knob/js/jquery.knob.js"></script>
    <script src="js/jquery.sparkline.js" type="text/javascript"></script>
    <script src="assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js"></script>
    <script src="js/owl.carousel.js" ></script>
    <!-- jQuery full calendar -->
    <script src="assets/fullcalendar/fullcalendar/fullcalendar.min.js"></script>
    <!--script for this page only-->
    <script src="js/calendar-custom.js"></script>
    <!-- custom select -->
    <script src="js/jquery.customSelect.min.js" ></script>
    <!--custome script for all page-->
    <script src="js/scripts.js"></script>
    <!-- custom script for this page-->
    <script src="js/sparkline-chart.js"></script>
    <script src="js/easy-pie-chart.js"></script>

  <script>

      //knob
      $(function() {
        $(".knob").knob({
          'draw' : function () { 
            $(this.i).val(this.cv + '%')
          }
        })
      });

      //carousel
      $(document).ready(function() {
          $("#owl-slider").owlCarousel({
              navigation : true,
              slideSpeed : 300,
              paginationSpeed : 400,
              singleItem : true

          });
      });

      //custom select box

      $(function(){
          $('select.styled').customSelect();
      });

  </script>

  </body>
</html>