<?php
include "config/init.php";
include "template/header.php";
include "system/airtime/airtime.php";
//Main Header
include "template/main-header.php";
//Left side column. contains the logo and sidebar -->
include "template/main-sidebar.php";


$cus = get_customer_by_id($dbc,$_GET['user']);

//Update Customer Information
if(isset($_POST['update_cus'])){
    $cuData = get_customer_by_id($dbc,$_GET['user']);
    $phoneNum = $cuData['phoneNum'];
    $fullName = html_filter($dbc,$_POST['fullName']);
    $email = html_filter($dbc,$_POST['email']);
    $gender = html_filter($dbc,$_POST['gender']);
    $idType = html_filter($dbc,$_POST['idType']);
    $accountType = html_filter($dbc,$_POST['accountType']);
    $uGroup = html_filter($dbc,$_POST['uGroup']);
    $idNumber = html_filter($dbc,$_POST['idNumber']);
    $dob = html_filter($dbc,$_POST['dob']);
    $address = html_filter($dbc,$_POST['address']);
    $kyc = html_filter($dbc,$_POST['kyc']);
    $postCode = html_filter($dbc,$_POST['postCode']);
    $companyName = html_filter($dbc,$_POST['companyName']);
    $companyRegNumber = html_filter($dbc,$_POST['companyRegNumber']);
    $companyRegDate = html_filter($dbc,$_POST['companyRegDate']);
    $status = html_filter($dbc,$_POST['status']);
    
   
    

    if(update_customer_new_admin($dbc, $phoneNum, $fullName, $idType, $idNumber, $address, $email,$postCode,$companyName,$companyRegNumber,$companyRegDate,$accountType,$kyc,$uGroup,$status,$dob,$gender)){
        $result = "<p class='alert alert-success'>Customer Information Updated</p>".$q;
    } else{
        $result = "<p class='alert alert-danger'>An error occured, Please Contact System Administrator</p>".$q;
    }
}

if(!isset($_GET['user'])){
    header("Location:customers.php");
    exit();
}



if($cus['id'] == ''){
    header("Location:customers.php");
    exit();
}

//Set session
$_SESSION["profile"] = $_GET['user'];

// Update customer password
if(isset($_POST['change_password'])){
    if(!empty($_POST['password']) && !empty($_POST['c_password'])){
        
        //$password = passwordHash($_POST['password'],$mySalt);
        //$c_password = passwordHash($_POST['c_password'],$mySalt);
        
        $password = $_POST['password'];
        $c_password = $_POST['c_password'];
        
        if($password == $c_password){
            $cuData = get_customer_by_id($dbc,$_GET['user']);
            $process = backendPassswordReset($cuData['email'],$password);
            if($process['statusCode']==200){
                $result = "<p class='alert alert-success'>Password changed was successful</p>";
                activity_log($dbc,"Customer with phoneNumber ({$cuData['phoneNum']}) password was changed",'PASSWORD-CHANGE');
            }else{
             $result = "<p class='alert alert-danger'>Passwords change was unsuccessful</p>";    
            }
        } else{
            $result = "<p class='alert alert-danger'>Passwords do not match</p>";
        }
    } else{
        $result = "<p class='alert alert-danger'>Please All fields are required</p>";
    }
}
// Update customer PIN
if(isset($_POST['change_pin'])){
    if(!empty($_POST['pin']) && !empty($_POST['c_pin'])){
        $pin = ($_POST['pin']);
        $c_pin = ($_POST['c_pin']);
        if($pin == $c_pin){
            $cuData = get_customer_by_id($dbc,$_GET['user']);
            if(change_customer_ussd_pin($dbc,$_GET['user'],$pin)){
                $result = "<p class='alert alert-success'>Pin Changed</p>";
                activity_log($dbc,"Customer with phoneNumber ({$cuData['phoneNum']}) PIN was changed",'PIN-CHANGE');
            }
        } else{
            $result = "<p class='alert alert-danger'>PIN do not match</p>";
        }
    } else{
        $result = "<p class='alert alert-danger'>Please All fields are required</p>";
    }
}
// Update Hubtel Pull
if(isset($_POST['hubtel_pull_save'])) {
    $hubtel_pull_status = html_filter($dbc, $_POST['hubtel_pull_status']);
    $cusID = html_filter($dbc, $cus['id']);
	$cuData = get_customer_by_id($dbc,$_GET['user']);
    if (!empty($hubtel_pull_status) AND !empty($cusID)) {
        if (update_customer_hubtel_pull($dbc, $cusID, $hubtel_pull_status)) {
			activity_log($dbc,"Activated momo pull for {$cuData['phoneNum']}","MOMO-PULL-ACCESS");
            $result = '<p class="alert alert-success">Hubtel Pull Feature Activated</p>';
        } else {
            $result = '<p class="alert alert-danger">Error Updating Pull Feature</p>';
        }
    } else {
        $result = '<p class="alert alert-danger">Please Select an option</p>';
    }
}
//Update Hubtel Push
if(isset($_POST['hubtel_push_save'])){
    $hubtel_push_status = html_filter($dbc,$_POST['hubtel_push_status']);
    $cusID = html_filter($dbc,$cus['id']);
	$cuData = get_customer_by_id($dbc,$_GET['user']);
    if(!empty($hubtel_push_status) AND !empty($cusID)){
        if(update_customer_hubtel_push($dbc,$cusID,$hubtel_push_status)){
			activity_log($dbc,"Activated momo push for {$cuData['phoneNum']}","MOMO-PUSH-ACCESS");
            $result = '<p class="alert alert-success">Hubtel Push Feature Activated</p>';
        } else{
            $result = '<p class="alert alert-danger">Error Updating Push Feature</p>';
        }
    }else{
        $result = '<p class="alert alert-danger">Please Select an option</p>';
    }
}


//Restore commission 
if(isset($_POST['restore_comm'])){
	
		$cusID = html_filter($dbc,$cus['id']);
	$cuData = get_customer_by_id($dbc,$_GET['user']);
	
	$query_recd =mysqli_query($dbc,"SELECT sum(sendersAmount) as credit FROM `maintransaction_tbl` WHERE `transactionTypes`='MT-CARD' and `transactionStatus`='COMPLETED' and `recipientID`='$cus[id]'");
	
	$query_sent =mysqli_query($dbc,"SELECT sum(sendersAmount) as debit FROM `maintransaction_tbl` WHERE `transactionTypes`<>'MT-CARD' and `transactionStatus`='COMPLETED' and `senderID`='$cus[id]'");
	
	while ($row_recd = mysqli_fetch_assoc($query_recd)){
        $recd = $row_recd["credit"];
    }
	
	while ($row_sent = mysqli_fetch_assoc($query_sent)){
        $sent = $row_sent["debit"];
    }
	
	$balance = ($recd - $sent) * 1;
	
	//var_dump("ojjefpojfjkgkwgpokwgrojkwpowgokgkjwpgjwjwjwjwowjowjow Received: ".$recd." Sent: ".$sent);

     $restored = restore_updated_account_special($dbc,$cus['id'],$recd,$sent,$balance,$cus['countryCode']);

	
	
	
        if($restored ){
			activity_log($dbc,"Restored commission for {$cuData['phoneNum']}","RESTORE-BALANCE");
            $result = '<p class="alert alert-success">Successfully reconciled customer account balance!!!</p>';
        } else{
            $result = '<p class="alert alert-danger">Error restoring customer commission</p>';
        }
	
	
 	
	
   
}




$cus_acc = get_cus_account_info_by_customerID($dbc,$cus['id'],$cus['countryCode']);

if($cus['countryCode']=="lr" or $cus['countryCode']=="lr1"){

if($cus['countryCode']=="lr"){
$reff = "lr1";	
}elseif($cus['countryCode']=="lr1"){
$reff = "lr";	
}
	
$cus_acc1 = get_cus_account_info_by_customerID($dbc,$cus['id'],$reff);
$countryData1 = get_country_code_with_currency($dbc,$reff);
}

$accountTypeData = get_accountType_by_id($dbc,$cus['accountType']);
$countryData = get_country_code_with_currency($dbc,$cus['countryCode']);




?>

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <?php
	//echo $net_comm;$result = "<p class='alert alert-danger'>Please All fields are required</p>";
    if(isset($result)){echo $result; }
    ?>
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Customer Profile |
            <small class="text-aqua">Registered On: <?=$cus['dateTime']?></small> |
            <small class="text-aqua">Account Type: <?=$accountTypeData['accountType']?></small> |
            <small class="text-aqua">Country: <?=$cus['countryCode']?></small> |
            <!--<small class="text-red">Commission: <i class="btn btn-danger"><?=$countryData['currency']?> <?=moneyFormat($cus_acc['commissionAccount'])?></i></small>--> 
			
			<small class="text-aqua" ><i class="btn btn-success"><a style="color:white" target="_blank" href="https://app.pgsterling.com/<?=$cus['idFile']?>">Identity<a/> </i></small> |
			<small class="text-aqua"><i class="btn btn-info"><a style="color:white" target="_blank" href="https://app.pgsterling.com/<?=$cus['addressFile']?>">Address<a/> </i></small> |
			<small class="text-aqua"><i class="btn btn-danger"><a style="color:white" target="_blank" href="https://app.pgsterling.com/<?=$cus['proofFundFile']?>">Funds<a/> </i></small> |
			
			<?php
						//$_SESSION[userCountry]
						if(($_SESSION['role'] == 'ADMINISTRATORS' || $_SESSION['role'] == 'SYSTEMADMIN') AND $_SESSION["userCountry"] == 'gb') {
                ?>
						<small class="text-red">Reconcile: <i class="btn btn-danger"><form method="post" role="form"><input type="submit" value="RESTORE" name="restore_comm" class="btn btn-primary"></form></i></small> |
						
				 <?php
            }
            ?>		
			
			
			
					<?php
 if($cus['countryCode']=="lr" or $cus['countryCode']=="lr1"){
			echo "<small class='text-aqua'>Other Account Balance: <i class='btn btn-success'>".$countryData1['currency']." ". moneyFormat($cus_acc1['balance'])."</i></small>|";
	 		echo "<small class='text-red'>Other Account Commission: <i class='btn btn-danger'>".$countryData1['currency']." ". moneyFormat($cus_acc1['commissionAccount'])."</i></small>";
			}      
 ?>
			
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li class="active">Customer Profile</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-4">
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h3><?=$cus['phoneNum']?></h3>
                        <p>Phone Number</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-phone"></i>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h4 style= "font-size:25px"><b><?=isset($cus["fullName"])?ucwords($cus["fullName"]):ucwords($cus["surname"])." ".ucwords($cus["firstName"])." ".ucwords($cus["middleName"])?></b></h4>
                        <p>Customer Name</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-user"></i>
                    </div>
                </div>

                <div class="myBox bg-red">
                    <h4>Total Debited Amount</h4>
                    <h5><?=$countryData['currency']?> <?=moneyFormat($cus_acc['debit'])?><?php if($cus['countryCode']=="lr" or $cus['countryCode']=="lr1"){ echo " / ".$countryData1['currency'];}?> <?php if($cus['countryCode']=="lr" or $cus['countryCode']=="lr1"){ echo "".moneyFormat($cus_acc1['debit']);}?></h5>
                </div>
            </div>
            <div class="col-md-4">
                <div class="small-box bg-green-gradient">
                    <div class="inner">
                        <h3><?=$countryData['currency']?> <?=moneyFormat($cus_acc['balance'])?></h3>
                        <p>Virtual Balance. </p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-user"></i>
                    </div>
                </div>
                <div class="myBox bg-red">
                    <h4>Total Credited Amount</h4>
                    <!--<h5><?=$countryData['currency']?> <?=moneyFormat($cus_acc['credit'])?></h5>-->
					<h5><?=$countryData['currency']?> <?=moneyFormat($cus_acc['credit'])?><?php if($cus['countryCode']=="lr" or $cus['countryCode']=="lr1"){ echo " / ".$countryData1['currency'];}?> <?php if($cus['countryCode']=="lr" or $cus['countryCode']=="lr1"){ echo "".moneyFormat($cus_acc1['credit']);}?></h5>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-4">
                <!-- Update customer Issues -->
                <div class="box box-primary">
                    <div class="box-header with-border">Customer Profile</div>
                    <div class="box-body">
                        <form method="post" role="form">
                            <div class="form-group">
                                <label for="fullName">Full Name</label>
                                <input type="text" required name="fullName" id="fullName" class="form-control" value="<?=isset($cus["fullName"])?ucwords($cus["fullName"]):ucwords($cus["surname"])." ".ucwords($cus["firstName"])." ".ucwords($cus["middleName"])?>">
                            </div>
                            <div class="form-group">
                                <label for="gender">Gender</label>
                                <select class="form-control" name="gender" id="gender">
                                    <option value="<?=$cus['gender']?>"><?=$cus['gender']?></option>
                                    <option value="MALE">Male</option>
                                    <option value="FEMALE">Female</option>
                                    <option value="Other">Other</option>
                                </select>
                            </div>
                            
                            <div class="form-group">
                                <label for="email">Email</label>
                                <input type="text" name="email" id="email" class="form-control" value="<?=$cus['email']?>">
                            </div>
                            
                            <div class="form-group">
                                <label for="idType">ID Type</label>
                                <input type="text" name="idType" id="idType" class="form-control" value="<?=$cus['idType']?>">
                            </div>
                           <div class="form-group">
                                <label for="idNumber">ID Number</label>
                                <input type="text"  name="idNumber" id="idNumber" class="form-control" value="<?=$cus['idNumber']?>">
                            </div>
                            <div class="form-group">
                                <label for="dob">Birth Date</label>
                                <input type="text" name="dob" id="dob" class="form-control" value="<?=$cus['dob']?>">
                            </div>
                            <div class="form-group">
                                <label for="address">Address</label>
                                <input type="text" name="address" id="address" class="form-control" value="<?=$cus['address']?>">
                            </div>
                            <div class="form-group">
                                <label for="postcode">Post Code</label>
                                <input type="text" name="postcode" id="postcode" class="form-control" value="<?=$cus['postcode']?>">
                            </div>
                            <div class="form-group">
                                <label for="companyName">Company Name</label>
                                <input type="text" name="companyName" id="companyName" class="form-control" value="<?=$cus['companyName']?>">
                            </div>
                            <div class="form-group">
                                <label for="companyRegNumber">Company Registration Number</label>
                                <input type="text" name="companyRegNumber" id="companyRegNumber" class="form-control" value="<?=$cus['companyRegNumber']?>">
                            </div>
                            <div class="form-group">
                                <label for="companyRegDate">Company Registration Date</label>
                                <input type="text" name="companyRegDate" id="companyRegDate" class="form-control" value="<?=$cus['companyRegDate']?>">
                            </div>
                            <div class="form-group">
                                <label for="accountType">Account Type</label>
                                <select class="form-control" name="accountType" required id="accountType">
                                    <?php
                                    $accountTypeData = get_accountType_by_id($dbc,$cus['accountType']);
                                    echo"<option value='{$accountTypeData['id']}'>{$accountTypeData['accountType']}</option>";
                                    $accTypes = get_all_from_accountType($dbc);
                                    foreach ($accTypes as $accType){
                                        echo "<option value='{$accType['id']}'>{$accType['accountType']}</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                           
                            <div class="form-group">
                                <label for="kycType">KYC Type</label>
                                <select class="form-control" name="kyc" required id="kyc">
                                    <?php
                                    $accountKycData = get_KYC_by_id($dbc,$cus['accountKYC'],$cus['countryCode']);
                                    echo"<option value='{$accountKycData['id']}'>{$accountKycData['name']} {$accountKycData['countryCode']}</option>";
                                    $kycTypes = get_all_from_kyc($dbc);
                                    foreach ($kycTypes as $kycType){
                                        echo "<option value='{$kycType['id']}'>{$kycType['name']} {$kycType['countryCode']}</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="uGroup">uGroup</label>
                                <select class="form-control" name="uGroup" required id="uGroup">
                                    <?php
                                    $uGroupData = get_uGroup_by_id($dbc,$cus['uGroup']);
                                    echo "<option value='{$uGroupData['id']}'>{$uGroupData['groupName']}</option>";
                                    $uGroups = get_all_from_uGroup($dbc);
                                    foreach ($uGroups as $uGroup){
                                        echo "<option value='{$uGroup['id']}'>{$uGroup['groupName']}</option>";
                                    }
                                    ?>
                                </select>
                            </div>

                           
                            <div class="form-group">
                                <label for="status">Status</label>
                                <select class="form-control" name="status" required id="status">
                                    <option value="<?=ucwords($cus['status'])?>"><?=$cus['status']?></option>
                                    <option value="ACTIVE">Active</option>
                                    <option value="INACTIVE">Inactive</option>
                                    <option value="SUSPENDED">Suspended</option>
                                </select>
                            </div>
							
							<?php
            //
            if($_SESSION['role'] == 'SYSTEMADMIN' || $_SESSION['role'] == 'ADMINISTRATORS' || $_SESSION['role'] == 'ADMINISTRATORS-1' || $_SESSION['role'] == 'FRONTDESK') {
                ?>
                            <input type="submit" value="Update Info" name="update_cus" class="btn btn-primary">
						    <?php
            }
            ?>
							
                        </form>
                    </div>
                </div>
                <!-- Update customer Password -->
                <div class="box box-primary">
                    <div class="box-header">Change Password</div>
                    <div class="box-body">
                        <form method="post" role="form">
                            <div class="form-group">
                                <label for="password">Password</label>
                                <input type="password" name="password" class="form-control" id="password" required>
                            </div>
                            <div class="form-group">
                                <label for="c_password">Confirm Password</label>
                                <input type="password" name="c_password" class="form-control" id="c_password" required>
                            </div>
							
											<?php
            //
            if($_SESSION['role'] == 'SYSTEMADMIN'  || $_SESSION['role'] == 'ADMINISTRATORS' || $_SESSION['role'] == 'FRONTDESK' || $_SESSION['role'] == 'ADMINISTRATORS-1') {
                ?>
							
                            <input type="submit" name="change_password" value="Change Password" class="btn btn-primary">
							
						    <?php
            }
            ?>
                        </form>
                    </div>
                </div>
                <!-- Update customer USSD PIN 
                <div class="box box-primary">
                    <div class="box-header">Change USSD PIN</div>
                    <div class="box-body">
                        <form method="post" role="form">
                            <div class="form-group">
                                <label for="pin">PIN</label>
                                <input type="password" name="pin" class="form-control" id="pin" required>
                            </div>
                            <div class="form-group">
                                <label for="c_pin">Confirm PIN</label>
                                <input type="password" name="c_pin" class="form-control" id="c_pin" required>
                            </div>

										<?php
            //
            if($_SESSION['role'] == 'SYSTEMADMIN'  || $_SESSION['role'] == 'ADMINISTRATORS' || $_SESSION['role'] == 'FRONTDESK') {
                ?>	
							
							
                            <input type="submit" name="change_pin" class="btn btn-primary">
							
						    <?php
            }
            ?>	
                        </form>
                    </div>
                </div>



                <!-- Update Hubtel Access -->
                <?php
	// || $_SESSION['role'] == 'ADMINISTRATORS'
                    if($_SESSION['role'] == 'SYSTEMADMIN') {
                        ?>
                        <!--<div class="box box-primary">
                            <div class="box-header">Hubtel Pull Access Level</div>
                            <div class="box-body">
                                <form class="form-inline" method="post">
                                    <label class="radio-inline">
                                        <input type="radio" name="hubtel_pull_status" id="hubtel_pull_status"
                                               value="ON" <?php if ($cus['hubtel_pull_status'] == 'ON') {
                                            echo 'checked';
                                        } ?> > TURN ON
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="hubtel_pull_status" id="hubtel_pull_status"
                                               value="OFF" <?php if ($cus['hubtel_pull_status'] == 'OFF') {
                                            echo 'checked';
                                        } ?> > TURN OFF
                                    </label>
                                    <label class="radio-inline">
                                        <button type="submit" class="btn btn-primary btn-sm" name="hubtel_pull_save">
                                            SAVE
                                        </button>
                                    </label>
                                </form>
                            </div>
                        </div>-->

                        <!--<div class="box box-primary">
                            <div class="box-header">Hubtel Push Access Level</div>
                            <div class="box-body">
                                <form class="form-inline" method="post">
                                    <label class="radio-inline">
                                        <input type="radio" name="hubtel_push_status" id="hubtel_push_status"
                                               value="ON" <?php if ($cus['hubtel_push_status'] == 'ON') {
                                            echo 'checked';
                                        } ?> > TURN ON
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="hubtel_push_status" id="hubtel_push_status"
                                               value="OFF" <?php if ($cus['hubtel_push_status'] == 'OFF') {
                                            echo 'checked';
                                        } ?> > TURN OFF
                                    </label>
                                    <label class="radio-inline">
                                        <button type="submit" class="btn btn-primary btn-sm" name="hubtel_push_save">
                                            SAVE
                                        </button>
                                    </label>
                                </form>
                            </div>
                        </div>-->
                        <?php
                    }
                ?>
            </div>
            <div class="col-md-8">
                <!-- /Main transations Tab -->
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#sentTrans" data-toggle="tab">Sent Transaction</a></li>
                        <li><a href="#receivedTrans" data-toggle="tab">Received Transaction</a></li>
                        <!--<li><a href="#airtime" data-toggle="tab">Airtime</a></li>
                        <li><a href="#token" data-toggle="tab">Token</a></li>-->
                        <?php
                            if($cus['accountType'] == 4 OR $cus['accountType'] == 2){
                               // echo "<li><a href='#global_acc' data-toggle='tab'>Global Transaction</a></li>";
                               // echo "<li><a href='#commission' data-toggle='tab'>Commission Transaction</a></li>";
                                //echo "<li><a href='#com_to_wallet' data-toggle='tab'>Commission to Wallet</a></li>";
                            }
                        ?>


                    </ul>
                    <div class="tab-content">
                        <div class="active tab-pane" id="sentTrans">
                            <div class="box box-danger">
                                <div class="box-header with-border">Sent Transactions</div>
                                <div class="box-body">
                                    <table class="table table-striped" id="single-maintransaction-sender-list">
                                        <thead>
                                        <tr>
                                            <th>Date Time</th>
                                            <th>trans Type</th>
                                            <th>Status</th>
                                            <th>Sender</th>
                                            <th>Recipient</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Bill Code</th>
                                            <th>Transaction ID</th>
                                            <th>AT Number</th>
                                            <th>AT Channel</th>
                                            <th>AT Balance</th>
                                            <th>Sender Balance</th>
                                        </tr>
                                        </thead>
                                    </table>

                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="receivedTrans">
                            <div class="box box-danger">
                                <div class="box-header with-border">Received Transactions</div>
                                <div class="box-body">
                                    <table class="table table-striped" id="single-maintransaction-receiive-list">
                                        <thead>
                                        <tr>
                                            <th>Date Time</th>
                                            <th>trans Type</th>
                                            <th>Status</th>
                                            <th>Sender</th>
                                            <th>Recipient</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Bill Code</th>
                                            <th>Transaction ID</th>
                                            <th>AT Number</th>
                                            <th>AT Channel</th>
                                            <th>AT Balance</th>
                                            <th>Recipient Balance</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="airtime">
                            <div class="box box-danger">
                                <div class="box-header with-border">Airtime Transactions</div>
                                <div class="box-body">
                                    <table class="table table-striped" id="t3">
                                        <thead>
                                        <tr>
                                            <th>Date Time</th>
                                            <th>Sender</th>
                                            <th>Country</th>
                                            <th>Phone Number</th>
                                            <th>Amount</th>
                                            <th>Transaction ID</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $airTimeTransaction_data = get_airtime_transaction_by_customer($dbc,$_GET['user']);
                                        foreach($airTimeTransaction_data as $value){
                                            $customerData = get_customer_by_id($dbc,$value['senderID']);
                                            ?>
                                            <tr>
                                                <td><?=$value['dateTime'] ?></td>
                                                <td><?=$customerData['fullName'] ?></td>
                                                <td><?=$value['country'] ?></td>
                                                <td><?=$value['phoneNumber'] ?></td>
                                                <td><?=$countryData['currency']?> <?=moneyFormat($value['amount']) ?></td>
                                                <td><?=$value['transaction_uid'] ?></td>
                                            </tr>
                                            <?php
                                        }
                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <?php
                            if($cus['accountType'] == 4 OR $cus['accountType'] == 2){
                        ?>
                                <div class="tab-pane" id="global_acc">
                                    <div class="box box-danger">
                                        <div class="box-header with-border">Transactions Received from Pay Global Account</div>
                                        <div class="box-body">
                                            <table class="table table-striped" id="t4">
                                                <thead>
                                                <tr>
                                                    <th>Date</th>
                                                    <th>Recipient</th>
                                                    <th>Sender</th>
                                                    <th>Amount</th>
                                                    <th>Transaction ID</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <?php
                                                $superAgent_data = get_superAgent_globalAccount_transaction_by_superAgentID($dbc,$_GET['user']);
                                                foreach($superAgent_data as $value){
                                                    $customerData = get_customer_by_id($dbc,$value['superAgent']);
                                                    $globalAccount = get_all_from_gloAccount_by_id($dbc,$value['globalAccount']);
                                                    $user = get_user_by_id($dbc,$value['user_by']);
                                                    $currency = get_country_code_with_currency($dbc,$customerData['countryCode']);
                                                    ?>
                                                    <tr>
                                                        <td><?=$value['dateTime'] ?></td>
                                                        <td><?=$customerData['companyName'] ?></td>
                                                        <td><?=$globalAccount['accountName'] ?></td>
                                                        <td><?=$currency['currency']." ".moneyFormat($value['amount']) ?></td>
                                                        <td><?=$value['transaction_uid'] ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                
                                                ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>

                                <div class="tab-pane" id="commission">
                                    <div class="box box-danger">
                                        <div class="box-header with-border">Transactions Received from Pay Global Account</div>
                                        <div class="box-body">
                                            <table class="table table-striped" id="t5">
                                                <thead>
                                                <tr>
                                                    <th>Date</th>
                                                    <th>Amount</th>
                                                    <th>Service Type</th>
                                                    <th>Transaction ID</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <?php
                                                $commissions = get_commission_by_customer($dbc,$_GET['user']);
                                                foreach($commissions as $value){
                                                    ?>
                                                    <tr>
                                                        <td><?=$value['dateTime'] ?></td>
                                                        <td><?=$countryData['currency']." ".moneyFormat($value['amount']) ?></td>
                                                        <td><?=$value['serviceType'] ?></td>
                                                        <td><?=$value['transaction_uid'] ?></td>
                                                    </tr>
                                                    <?php
                                                }

                                                ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>

                                <div class="tab-pane" id="com_to_wallet">
                                    <div class="box box-danger">
                                        <div class="box-header with-border">Transactions from Commission to wallet</div>
                                        <div class="box-body">
                                            <table class="table table-striped" id="t6">
                                                <thead>
                                                <tr>
                                                    <th>Date</th>
                                                    <th>Amount</th>
                                                    <th>Device Type</th>
                                                    <th>Transaction ID</th>
                                                </tr>
                                                </thead>
                                                <tbody>

                                                <?php

                                                $commissionTrans = get_agent_commission_to_wallet_transaction($dbc,$_GET['user']);
                                                foreach($commissionTrans as $value){
                                                    ?>
                                                    <tr>
                                                        <td><?=$value['dateTime'] ?></td>
                                                        <td><?=$countryData['currency']." ".moneyFormat($value['amount']) ?></td>
                                                        <td><?=$value['deviceType'] ?></td>
                                                        <td><?=$value['transaction_uid'] ?></td>
                                                    </tr>
                                                    <?php
                                                }

                                                ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </
                                    >
                                </div>
                        <?php
                            }
                        ?>
                        <div class="tab-pane" id="token">
                            <div class="box box-danger">
                                <div class="box-header with-border">Token Transactions</div>
                                <div class="box-body">
                                    <table class="table table-striped" id="t9">
                                        <thead>
                                        <tr>
                                            <th>Date Time</th>
                                            <th>Sender</th>
                                            <th>Sender Country</th>
                                            <th>Recipient</th>
                                            <th>Recipient Country</th>
                                            <th>Sender Amount</th>
                                            <th>Recipient Amount</th>
                                            <th>Fee</th>
                                            <th>Status</th>
                                            <th>Claimed Date</th>
                                            <th>Transaction ID</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php

                                        $token_data = get_token_view_transaction_by_customer($dbc,$_GET['user']);
                                        foreach($token_data as $value){
                                            $senderData = get_customer_by_id($dbc,$value['senderID']);
                                            $recipientData = get_customer_by_id($dbc,$value['recipientID']);
                                            ?>
                                            <tr>
                                                <td><?=$value['dateTime'] ?></td>
                                                <td><?=$senderData['fullName'] ?></td>
                                                <td><?=$senderData['countryCode'] ?></td>
                                                <td><?=$recipientData['fullName'] ?></td>
                                                <td><?=$recipientData['countryCode'] ?></td>
                                                <td><?=moneyFormat($value['senderAmount']) ?></td>
                                                <td><?=moneyFormat($value['recipientAmount']) ?></td>
                                                <td><?=moneyFormat($value['fee']) ?></td>
                                                <td><?=$value['status'] ?></td>
                                                <td><?=$value['claimedDate'] ?></td>
                                                <td><?=$value['transaction_uid'] ?></td>
                                            </tr>
                                            <?php
                                        }

                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>

                    </div>
                    <!-- /.tab-content -->
                </div>
                <!-- /End of main transaction Tab-->

                <!-- /Bank transactions Bar 
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#wtb" data-toggle="tab">Wallet to Bank</a></li>
                        <li><a href="#btw" data-toggle="tab">Bank to Wallet</a></li>
                        <li><a href="#btb" data-toggle="tab">GN Bank to GN bank</a></li>
                        <li><a href="#push" data-toggle="tab">Hubtel Push</a></li>
                        <li><a href="#pull" data-toggle="tab">Hubtel Pull</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="wtb">
                            <div class="panel panel-default">
                                <!-- List of All Payout
                                <div class="panel-heading">This is a list of All Wallet to bank</div>
                                <div class="panel-body">
                                    <table class="table table-striped" id="single-wtb-list">
                                        <thead>
                                        <tr>
                                            <th>Time</th>
                                            <th>Name</th>
                                            <th>Account No.</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Transaction ID</th>
                                            <th>Status</th>
                                            <th>Device Type</th>
                                            <th>Reference</th>
                                        </tr>
                                        </thead>
                                    </table>
                                    <hr>
                                </div>
                            </div>
                        </div>
                        <!-- /.tab-pane 
                        <div class="tab-pane" id="btw">
                            <div class="panel panel-default">
                                <!-- List of All Payout 
                                <div class="panel-heading">This is a list of All Bank to Wallet</div>
                                <div class="panel-body">
                                    <table class="table table-striped" id="single-btw-list">
                                        <thead>
                                        <tr>
                                            <th>Time</th>
                                            <th>Name</th>
                                            <th>Account No.</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Transaction ID</th>
                                            <th>Status</th>
                                            <th>Device Type</th>
                                            <th>Reference</th>
                                        </tr>
                                        </thead>
                                    </table>
                                    <hr>
                                </div>
                            </div>
                        </div>
                        <!-- /.tab-pane 
                        <div class="tab-pane" id="btb">
                            <div class="panel panel-default">
                                <!-- List of All Payout 
                                <div class="panel-heading">This is a list of All Bank to Bank</div>
                                <div class="panel-body">
                                    <table class="table table-striped" id="single-btb-list">
                                        <thead>
                                        <tr>
                                            <th>Time</th>
                                            <th>Name</th>
                                            <th>Sender Account No.</th>
                                            <th>Recipient Account No.</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Transaction ID</th>
                                            <th>Status</th>
                                            <th>Device Type</th>
                                            <th>Reference</th>
                                        </tr>
                                        </thead>
                                    </table>
                                    <hr>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="push">
                            <div class="panel panel-default">
                                <!-- List of All Payout 
                                <div class="panel-heading">This is a list of Push to other Mobile Money</div>
                                <div class="panel-body">
                                    <table class="table table-striped" id="single-push-list">
                                        <thead>
                                        <tr>
                                            <th>Time</th>
                                            <th>Name</th>
                                            <th>Customer Number</th>
                                            <th>Channel</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Transaction ID</th>
                                            <th>Recipient Number</th>
                                            <th>Reference</th>
                                            <th>status</th>
                                        </tr>
                                        </thead>
                                    </table>
                                    <hr>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="pull">
                            <div class="panel panel-default">
                                <!-- List of All Payout
                                <div class="panel-heading">This is a list of Pull to other Mobile Money</div>
                                <div class="panel-body">
                                    <table class="table table-striped" id="single-pull-list">
                                        <thead>
                                        <tr>
                                            <th>Time</th>
                                            <th>Name</th>
                                            <th>Customer Number</th>
                                            <th>Channel</th>
                                            <th>Amount</th>
                                            <th>Fee</th>
                                            <th>Transaction ID</th>
                                            <th>Recipient Number</th>
                                            <th>Reference</th>
                                            <th>status</th>
                                        </tr>
                                        </thead>
                                    </table>
                                    <hr>
                                </div>
                            </div>
                        </div>
                        <!-- /.tab-pane 
                    </div>
                    <!-- /.tab-content 
                </div>-->
                <!-- / End Bank transactions Bar -->
            </div>
        </div>
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php include "template/footer.php"?>
