File: /var/www/grapossconnect/center-admin/wallet-ledger.php
<?php
include_once('header.php');
//wallet ledger details
$getLedgeData = "(SELECT txn_id as txn,deduct_amount as amt,before_payment as last_bal,txn_date as tx_date,'Dr' as w_type FROM grp_agents_transaction where agent_id='$AGENT_ID')
UNION
(SELECT credit_id as txn,amount as amt,last_balance as last_bal,credit_date as tx_date,'Cr' as w_type FROM grp_agents_credit_history where agent_id='$AGENT_ID') order by tx_date desc";
$fetchData = $wpdb->get_results($getLedgeData);
//wallet current balance
$walletBalance = $wpdb->get_var("SELECT balance_amount from grp_agents_wallet where agent_id='$AGENT_ID'");
?>
<div class="page-inner">
<div class="page-title">
<div class="page-breadcrumb">
<ol class="breadcrumb">
<li><a href="home">Home</a></li>
<li class="active">Passbook</li>
</ol>
</div>
<h3>Wallet Ledger</h3>
</div>
<div id="main-wrapper">
<section class="recharge-history-section">
<div class="row m-0">
<div class="col-md-6 col-sm-6 col-xs-12 p-0">
<div class="recharge-history-head">
<h4>Wallet Ledger</h4>
<p>List of wallet transactions</p>
</div>
<div class="recharge-history-table">
<table>
<?php
if (sizeof($fetchData) > 0) {
foreach ($fetchData as $fl) {
if ($fl->w_type == 'Dr') {
$txnNum = 'TxnId:' . $fl->txn;
$txnType = 'Purchase';
$icon = 'fa fa-minus-circle';
$color = 'red';
} else if ($fl->w_type == 'Cr') {
$txnNum = 'CrId:' . $fl->txn;
$txnType = 'Recharge';
$icon = 'fa fa-plus-circle';
$color = '#1fb138';
}
?>
<tr onclick="openCity(event, '<?php echo $txnNum; ?>')">
<td><i class="<?php echo $icon; ?>"></i></td>
<td><?php echo $txnNum; ?>
<p class="m-0"><?php echo date('d F Y', strtotime($fl->tx_date)); ?> <span><?php echo $txnType; ?></span></p>
</td>
<td class="text-right">₹ <?php echo $fl->amt; ?> <span style="color: <?php echo $color; ?>;font-weight: 800;margin-left: 8px;"><?php echo $fl->w_type; ?>.</span></td>
</tr>
<?php }
} else {
echo "No Ledger Information";
} ?>
</table>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12 p-0">
<div class="recharge-history-details">
<?php
if (sizeof($fetchData) > 0) {
$i = 1;
foreach ($fetchData as $sfl) {
if ($sfl->w_type == 'Dr') {
$txnNum = 'TxnId:' . $sfl->txn;
$txnType = 'Purchase';
$color = 'red';
$productData = $wpdb->get_row("SELECT p.product_name FROM grp_agents_transaction as t LEFT JOIN grp_product as p on p.product_id=t.product_id where t.txn_id='$sfl->txn'");
} else if ($sfl->w_type == 'Cr') {
$txnNum = 'CrId:' . $sfl->txn;
$txnType = 'TopUp';
$color = '#1fb138';
}
?>
<div id="<?php echo $txnNum; ?>" class="tabcontent" <?php if ($i == 1) { ?> style="display:block;" <?php } else { ?> style='display:none;' <?php } ?>>
<div class="recharge-history-div">
<h3><?php echo $txnNum; ?> <span><?php echo $txnType; ?></span></h3>
<p><?php echo date('d F Y', strtotime($sfl->tx_date)); ?></p>
</div>
<p class="transaction-amount-label" style="background: #eaeaea;color: #000;font-size: 11px;">CURRENT BALANCE <span style="font-weight: bold;color: #1fb138;font-size: 18px;margin-left: 14px;"> ₹ <?php echo $walletBalance; ?></span></p>
<div class="steps" id="steps">
<div class="step">
<div class="number completed">
<i class="fa fa-calendar"></i>
</div>
<div class="info">
<h6>Transaction On</h6>
<p class="title" style="color: #007ea7;"><?php echo date('d F Y H:i:s', strtotime($sfl->tx_date)); ?></p>
</div>
</div>
<div class="step">
<div class="number rupee" style="background: #eaeaea;color: #797979;"><i class="fa fa-rupee"></i></div>
<div class="info">
<h6>Transaction Type</h6>
<p class="title" style="color: <?php echo $color; ?>;"><?php echo $txnType; ?></p>
</div>
</div>
<div class="step">
<div class="number rupee"><i class="fa fa-rupee"></i></div>
<div class="info">
<h6>Payment</h6>
<p class="title" style="color: <?php echo $color; ?>;">₹ <?php echo $sfl->amt; ?></p>
</div>
</div>
<?php if ($sfl->w_type == 'Dr') { ?>
<div class="step">
<div class="number shield"><i class="fa fa-shopping-cart"></i></div>
<div class="info">
<h6>Product</h6>
<p class="title" style="color: #018de5;"><?php echo $productData->product_name; ?></p>
</div>
</div>
<?php } ?>
<div class="step">
<div class="number spinner"><i class="fa fa-rupee"></i></div>
<div class="info">
<h6>Balance at time of transaction</h6>
<p class="title"><?php echo $sfl->last_bal; ?></p>
</div>
</div>
</div>
</div>
<?php $i++;
}
} ?>
</div>
</div>
</div>
</section>
</div><!-- Main Wrapper -->
<div class="page-footer">
<p class="no-s">grapossconnect.com</p>
</div>
</div>
<!-- Page Inner -->
<script>
// function openCity(evt, cityName) {
// var i, x, tablinks;
// x = document.getElementsByClassName("city");
// for (i = 0; i < x.length; i++) {
// x[i].style.display = "none";
// }
// tablinks = document.getElementsByClassName("tablink");
// for (i = 0; i < x.length; i++) {
// tablinks[i].className = tablinks[i].className.replace(" w3-red", "");
// }
// document.getElementById(cityName).style.display = "block";
// evt.currentTarget.className += " w3-red";
// }
</script>
<script>
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
console.log(cityName);
//scroll
jQuery('html, body').animate({
scrollTop: jQuery(".recharge-history-details").offset().top
}, 2000);
//end scroll
}
</script>
<?php
include_once('footer.php');
?>