Transaction list

This commit is contained in:
Ibnu Maksum 2023-10-20 14:31:56 +07:00
parent d037b2bef4
commit 51ab4a35c5
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
6 changed files with 127 additions and 28 deletions

View File

@ -355,13 +355,16 @@ switch ($action) {
$ui->assign('planid', $planid); $ui->assign('planid', $planid);
$voucher = []; $voucher = [];
$n = 1;
foreach ($v as $vs) { foreach ($v as $vs) {
$temp = $template; $temp = $template;
$temp = str_replace('[[qrcode]]', '<img src="qrcode/?data=' . $vs['code'] . '">', $temp); $temp = str_replace('[[qrcode]]', '<img src="qrcode/?data=' . $vs['code'] . '">', $temp);
$temp = str_replace('[[price]]', Lang::moneyFormat($vs['price']), $temp); $temp = str_replace('[[price]]', Lang::moneyFormat($vs['price']), $temp);
$temp = str_replace('[[voucher_code]]', $vs['code'], $temp); $temp = str_replace('[[voucher_code]]', $vs['code'], $temp);
$temp = str_replace('[[plan]]', $vs['name_plan'], $temp); $temp = str_replace('[[plan]]', $vs['name_plan'], $temp);
$temp = str_replace('[[counter]]', $n, $temp);
$voucher[] = $temp; $voucher[] = $temp;
$n++;
} }
$ui->assign('voucher',$voucher); $ui->assign('voucher',$voucher);

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -12,8 +13,8 @@ $action = $routes['1'];
$admin = Admin::_info(); $admin = Admin::_info();
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if($admin['user_type'] != 'Admin' AND $admin['user_type'] != 'Sales'){ if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
r2(U."dashboard",'e',$_L['Do_Not_Access']); r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
} }
$mdate = date('Y-m-d'); $mdate = date('Y-m-d');
@ -26,24 +27,44 @@ $month_n = date('n');
switch ($action) { switch ($action) {
case 'by-date': case 'by-date':
case 'daily-report': case 'activation':
$paginator = Paginator::bootstrap('tbl_transactions','recharged_on',$mdate); $q = (_post('q') ? _post('q') : _get('q'));
$d = ORM::for_table('tbl_transactions')->where('recharged_on',$mdate)->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $keep = _post('keep');
$dr = ORM::for_table('tbl_transactions')->where('recharged_on',$mdate)->sum('price'); if (!empty($keep)) {
ORM::raw_execute("DELETE FROM tbl_transactions WHERE date < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $keep DAY))");
r2(U . "logs/list/", 's', "Delete logs older than $keep days");
}
if ($q != '') {
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['invoice' => '%' . $q . '%'], $q);
$d = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else {
$paginator = Paginator::build(ORM::for_table('tbl_transactions'));
$d = ORM::for_table('tbl_transactions')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
}
$ui->assign('d',$d); $ui->assign('activation', $d);
$ui->assign('dr',$dr); $ui->assign('q', $q);
$ui->assign('mdate',$mdate); $ui->assign('paginator', $paginator);
$ui->assign('mtime',$mtime); $ui->display('reports-activation.tpl');
$ui->assign('paginator',$paginator); break;
case 'daily-report':
$paginator = Paginator::bootstrap('tbl_transactions', 'recharged_on', $mdate);
$d = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
$dr = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->sum('price');
$ui->assign('d', $d);
$ui->assign('dr', $dr);
$ui->assign('mdate', $mdate);
$ui->assign('mtime', $mtime);
$ui->assign('paginator', $paginator);
run_hook('view_daily_reports'); #HOOK run_hook('view_daily_reports'); #HOOK
$ui->display('reports-daily.tpl'); $ui->display('reports-daily.tpl');
break; break;
case 'by-period': case 'by-period':
$ui->assign('mdate',$mdate); $ui->assign('mdate', $mdate);
$ui->assign('mtime',$mtime); $ui->assign('mtime', $mtime);
$ui->assign('tdate', $tdate); $ui->assign('tdate', $tdate);
run_hook('view_reports_by_period'); #HOOK run_hook('view_reports_by_period'); #HOOK
$ui->display('reports-period.tpl'); $ui->display('reports-period.tpl');
break; break;
@ -54,29 +75,29 @@ switch ($action) {
$stype = _post('stype'); $stype = _post('stype');
$d = ORM::for_table('tbl_transactions'); $d = ORM::for_table('tbl_transactions');
if ($stype != ''){ if ($stype != '') {
$d->where('type', $stype); $d->where('type', $stype);
} }
$d->where_gte('recharged_on', $fdate); $d->where_gte('recharged_on', $fdate);
$d->where_lte('recharged_on', $tdate); $d->where_lte('recharged_on', $tdate);
$d->order_by_desc('id'); $d->order_by_desc('id');
$x = $d->find_many(); $x = $d->find_many();
$dr = ORM::for_table('tbl_transactions'); $dr = ORM::for_table('tbl_transactions');
if ($stype != ''){ if ($stype != '') {
$dr->where('type', $stype); $dr->where('type', $stype);
} }
$dr->where_gte('recharged_on', $fdate); $dr->where_gte('recharged_on', $fdate);
$dr->where_lte('recharged_on', $tdate); $dr->where_lte('recharged_on', $tdate);
$xy = $dr->sum('price'); $xy = $dr->sum('price');
$ui->assign('d',$x); $ui->assign('d', $x);
$ui->assign('dr',$xy); $ui->assign('dr', $xy);
$ui->assign('fdate',$fdate); $ui->assign('fdate', $fdate);
$ui->assign('tdate',$tdate); $ui->assign('tdate', $tdate);
$ui->assign('stype',$stype); $ui->assign('stype', $stype);
run_hook('view_reports_period'); #HOOK run_hook('view_reports_period'); #HOOK
$ui->display('reports-period-view.tpl'); $ui->display('reports-period-view.tpl');
break; break;

View File

@ -124,6 +124,7 @@
{if Lang::arrayCount($activation)} {if Lang::arrayCount($activation)}
<thead> <thead>
<tr> <tr>
<th>{$_L['Invoice']}</th>
<th>{$_L['Username']}</th> <th>{$_L['Username']}</th>
<th>{$_L['Plan_Name']}</th> <th>{$_L['Plan_Name']}</th>
<th>{$_L['Plan_Price']}</th> <th>{$_L['Plan_Price']}</th>
@ -136,6 +137,7 @@
<tbody> <tbody>
{foreach $activation as $ds} {foreach $activation as $ds}
<tr onclick="window.location.href = '{$_url}prepaid/view/{$ds['id']}'" style="cursor:pointer;"> <tr onclick="window.location.href = '{$_url}prepaid/view/{$ds['id']}'" style="cursor:pointer;">
<td>{$ds['invoice']}</td>
<td>{$ds['username']}</td> <td>{$ds['username']}</td>
<td>{$ds['plan_name']}</td> <td>{$ds['plan_name']}</td>
<td>{Lang::moneyFormat($ds['price'])}</td> <td>{Lang::moneyFormat($ds['price'])}</td>

View File

@ -31,6 +31,7 @@
<b>[[price]]</b> Plan Price.<br> <b>[[price]]</b> Plan Price.<br>
<b>[[voucher_code]]</b> Voucher Code.<br> <b>[[voucher_code]]</b> Voucher Code.<br>
<b>[[plan]]</b> Voucher Plan.<br> <b>[[plan]]</b> Voucher Plan.<br>
<b>[[counter]]</b> Counter.<br>
</p> </p>
</div> </div>
{/if} {/if}

View File

@ -0,0 +1,70 @@
{include file="sections/header.tpl"}
<!-- pool -->
<div class="row">
<div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">
Activity Log
</div>
<div class="panel-body">
<div class="text-center" style="padding: 15px">
<div class="col-md-4">
<form id="site-search" method="post" action="{$_url}reports/activation">
<div class="input-group">
<div class="input-group-addon">
<span class="fa fa-search"></span>
</div>
<input type="text" name="q" class="form-control" value="{$q}"
placeholder="{$_L['Invoice']}...">
<div class="input-group-btn">
<button class="btn btn-success" type="submit">{$_L['Search']}</button>
</div>
</div>
</form>
</div>
<div class="col-md-8">
</div>&nbsp;
</div>
<br>
<div class="table-responsive">
<table id="datatable" class="table table-bordered table-striped">
<thead>
<tr>
<th>{$_L['Invoice']}</th>
<th>{$_L['Username']}</th>
<th>{$_L['Plan_Name']}</th>
<th>{$_L['Plan_Price']}</th>
<th>{$_L['Type']}</th>
<th>{$_L['Created_On']}</th>
<th>{$_L['Expires_On']}</th>
<th>{$_L['Method']}</th>
</tr>
</thead>
<tbody>
{foreach $activation as $ds}
<tr>
<td onclick="window.location.href = '{$_url}prepaid/view/{$ds['id']}'"
style="cursor:pointer;">{$ds['invoice']}</td>
<td onclick="window.location.href = '{$_url}customers/viewu/{$ds['username']}'"
style="cursor:pointer;">{$ds['username']}</td>
<td>{$ds['plan_name']}</td>
<td>{Lang::moneyFormat($ds['price'])}</td>
<td>{$ds['type']}</td>
<td class="text-success">
{Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])}
</td>
<td class="text-danger">{Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])}</td>
<td>{$ds['method']}</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{$paginator['contents']}
</div>
</div>
</div>
</div>
{include file="sections/footer.tpl"}

View File

@ -183,6 +183,8 @@
href="{$_url}reports/daily-report">{$_L['Daily_Report']}</a></li> href="{$_url}reports/daily-report">{$_L['Daily_Report']}</a></li>
<li {if $_routes[1] eq 'by-period'}class="active" {/if}><a <li {if $_routes[1] eq 'by-period'}class="active" {/if}><a
href="{$_url}reports/by-period">{$_L['Period_Reports']}</a></li> href="{$_url}reports/by-period">{$_L['Period_Reports']}</a></li>
<li {if $_routes[1] eq 'activation'}class="active" {/if}><a
href="{$_url}reports/activation">{Lang::T('Activation History')}</a></li>
{$_MENU_REPORTS} {$_MENU_REPORTS}
</ul> </ul>
</li> </li>