<?php
require_once("../app/config.php");
$title="User Dashboard";
require_once('include/user_header.php');
require_once('include/user_navbar.php');
require_once('include/user_sidebar.php');
$tran1 = mysqli_fetch_row(mysqli_query($dbc, "SELECT SUM(amount) FROM transfers WHERE status=1 AND sender_id='".$row['id']."'"));
$tran2 = mysqli_fetch_row(mysqli_query($dbc, "SELECT SUM(amount) FROM int_transfer WHERE status=1 AND user_id='".$row['id']."'"));
$deposit_1 = mysqli_fetch_row(mysqli_query($dbc, "SELECT SUM(amount) FROM deposits WHERE status=1 AND user_id='".$row['id']."'"));
$deposit_0 = mysqli_fetch_row(mysqli_query($dbc, "SELECT SUM(amount) FROM deposits WHERE status=0 AND user_id='".$row['id']."'"));
$withdraw_0 = mysqli_fetch_row(mysqli_query($dbc, "SELECT SUM(amount) FROM w_history WHERE status=0 AND user_id='".$row['id']."'"));  
$withdraw_1 = mysqli_fetch_row(mysqli_query($dbc, "SELECT SUM(amount) FROM w_history WHERE status=1 AND user_id='".$row['id']."'"));
$support= mysqli_num_rows(mysqli_query($dbc,"SELECT * FROM support WHERE user_id='".$row['id']."'"));  
$support_1= mysqli_num_rows(mysqli_query($dbc,"SELECT * FROM support WHERE status=0 AND user_id='".$row['id']."'"));
$support_0=mysqli_num_rows(mysqli_query($dbc,"SELECT * FROM support WHERE status=1 AND user_id='".$row['id']."'"));
?>
<!-- Main content -->
<div class="content-wrapper">

        <!-- Page header -->
        <div class="page-header">
          <div class="page-header-content header-elements-md-inline">
          </div>
        </div>
        <!-- /page header -->
        <!-- Content area -->
        <div class="content">
<?php if ($row['2fa_status']==0){?>
        <div class="alert bg-blue alert-dismissible">
          <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
          <h6 class="alert-heading font-weight-semibold mb-1 text-uppercase">2fa Security</h6>
          To set up 2fa security, <a class="text-white" href='<?php echo $url."/user/2fa";?>'>Click here</a>
          </div>
<?php }?>
<?php 
if(!empty($_SESSION['exchange_userhome'])){?>
        <div class="row">
            <div class="col-lg-12">
              <div class="alert <?php if($_SESSION['exchange_userhome']=='email_versent') {echo 'bg-success';}else{echo 'bg-danger';}?> text-white alert-styled-left alert-dismissible">
                <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
          <?php if($_SESSION['exchange_userhome']=='email_verfailed') {
            echo'An error occured while sending verification email, try again later.';
          } else if($_SESSION['exchange_userhome']=='email_versent') {
            echo'Verification email was successfully sent.';
          }?>                 
                </div>
              </div>
          </div>
<?php
}if($row['active']==0){
  if($set['email_activation']==1){
    if($eset['status']==1){?>
        <div class="alert bg-light alert-styled-left alert-arrow-left alert-dismissible">
          <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
          <h6 class="alert-heading font-weight-semibold mb-1">Email verification</h6>
          User account has not yet been verified. <a class="" href='<?php echo $url."/app/user?id=sendver&del=2&status=".$row['token'];?>'>Click here</a> to verify your account
          </div>
<?php
    }
  }
}?>
<?php if ($set['kyc']==1){?>
<?php if (($row['kyc_status']==0) || ($row['add_status']==0)){?>
        <div class="alert bg-white alert-dismissible">
          <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
          <h6 class="alert-heading font-weight-semibold mb-1 text-uppercase">Identity verification</h6>
          Kindly submit your KYC and Proof Of Address for proper verification.. <a class="text-blue-800" href='<?php echo $url."/user/profile/0";?>'>Click here</a> to upload documents
          </div>
<?php }}?>
<div class="row">
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0">#<?php echo $row['acct_no'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Account no</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-sphere3 icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div>
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php echo number_format($row['dep_balance']).$scan2['currency'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Current Balance</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-folder icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div> 
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php echo number_format($deposit_1[0]).$scan2['currency'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Total deposits</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-cart-add2 icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div> 
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php echo number_format($deposit_0[0]).$scan2['currency'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Pending deposits</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-history icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div>
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php
            $c=$tran1[0]+$tran2[0];
           echo number_format($c).$scan2['currency'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Total transactions</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-balance icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div>  
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php echo number_format($withdraw_1[0]).$scan2['currency'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Total withdrawal</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-upload7 icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div> 
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php echo number_format($withdraw_0[0]).$scan2['currency'];?></h3>
          <span class="text-uppercase font-size-sm text-muted">Pending withdrawal</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-sync icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div> 
  <div class="col-md-3">
    <div class="card card-body">
      <div class="media">
        <div class="media-body">
          <h3 class="font-weight-semibold mb-0"><?php if($row['2fa_status']=='1'){echo'Active';}else{echo'Disabled';}?></h3>
          <span class="text-uppercase font-size-sm text-muted">2fa Status</span>
        </div>
        <div class="ml-3 align-self-center">
          <i class="icon-shield2 icon-2x text-danger-800"></i>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
<?php require_once('include/user_footer.php');?>
