diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 08de07e5..25e0539a 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -355,13 +355,16 @@ switch ($action) { $ui->assign('planid', $planid); $voucher = []; + $n = 1; foreach ($v as $vs) { $temp = $template; $temp = str_replace('[[qrcode]]', '', $temp); $temp = str_replace('[[price]]', Lang::moneyFormat($vs['price']), $temp); $temp = str_replace('[[voucher_code]]', $vs['code'], $temp); $temp = str_replace('[[plan]]', $vs['name_plan'], $temp); + $temp = str_replace('[[counter]]', $n, $temp); $voucher[] = $temp; + $n++; } $ui->assign('voucher',$voucher); diff --git a/system/controllers/reports.php b/system/controllers/reports.php index 0060dd16..06dcb487 100644 --- a/system/controllers/reports.php +++ b/system/controllers/reports.php @@ -1,4 +1,5 @@ assign('_admin', $admin); -if($admin['user_type'] != 'Admin' AND $admin['user_type'] != 'Sales'){ - r2(U."dashboard",'e',$_L['Do_Not_Access']); +if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') { + r2(U . "dashboard", 'e', $_L['Do_Not_Access']); } $mdate = date('Y-m-d'); @@ -26,24 +27,44 @@ $month_n = date('n'); switch ($action) { case 'by-date': - 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'); + case 'activation': + $q = (_post('q') ? _post('q') : _get('q')); + $keep = _post('keep'); + 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('dr',$dr); - $ui->assign('mdate',$mdate); - $ui->assign('mtime',$mtime); - $ui->assign('paginator',$paginator); + $ui->assign('activation', $d); + $ui->assign('q', $q); + $ui->assign('paginator', $paginator); + $ui->display('reports-activation.tpl'); + 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 $ui->display('reports-daily.tpl'); break; case 'by-period': - $ui->assign('mdate',$mdate); - $ui->assign('mtime',$mtime); - $ui->assign('tdate', $tdate); + $ui->assign('mdate', $mdate); + $ui->assign('mtime', $mtime); + $ui->assign('tdate', $tdate); run_hook('view_reports_by_period'); #HOOK $ui->display('reports-period.tpl'); break; @@ -54,33 +75,33 @@ switch ($action) { $stype = _post('stype'); $d = ORM::for_table('tbl_transactions'); - if ($stype != ''){ - $d->where('type', $stype); - } + if ($stype != '') { + $d->where('type', $stype); + } $d->where_gte('recharged_on', $fdate); $d->where_lte('recharged_on', $tdate); $d->order_by_desc('id'); $x = $d->find_many(); - $dr = ORM::for_table('tbl_transactions'); - if ($stype != ''){ - $dr->where('type', $stype); - } + $dr = ORM::for_table('tbl_transactions'); + if ($stype != '') { + $dr->where('type', $stype); + } $dr->where_gte('recharged_on', $fdate); $dr->where_lte('recharged_on', $tdate); - $xy = $dr->sum('price'); + $xy = $dr->sum('price'); - $ui->assign('d',$x); - $ui->assign('dr',$xy); - $ui->assign('fdate',$fdate); - $ui->assign('tdate',$tdate); - $ui->assign('stype',$stype); + $ui->assign('d', $x); + $ui->assign('dr', $xy); + $ui->assign('fdate', $fdate); + $ui->assign('tdate', $tdate); + $ui->assign('stype', $stype); run_hook('view_reports_period'); #HOOK $ui->display('reports-period-view.tpl'); break; default: $ui->display('a404.tpl'); -} \ No newline at end of file +} diff --git a/ui/ui/customers-view.tpl b/ui/ui/customers-view.tpl index d3336e0c..e82b8a15 100644 --- a/ui/ui/customers-view.tpl +++ b/ui/ui/customers-view.tpl @@ -124,6 +124,7 @@ {if Lang::arrayCount($activation)} + {$_L['Invoice']} {$_L['Username']} {$_L['Plan_Name']} {$_L['Plan_Price']} @@ -136,6 +137,7 @@ {foreach $activation as $ds} + {$ds['invoice']} {$ds['username']} {$ds['plan_name']} {Lang::moneyFormat($ds['price'])} diff --git a/ui/ui/page-edit.tpl b/ui/ui/page-edit.tpl index 7360a4ed..fc3c3a19 100644 --- a/ui/ui/page-edit.tpl +++ b/ui/ui/page-edit.tpl @@ -31,6 +31,7 @@ [[price]] Plan Price.
[[voucher_code]] Voucher Code.
[[plan]] Voucher Plan.
+ [[counter]] Counter.

{/if} diff --git a/ui/ui/reports-activation.tpl b/ui/ui/reports-activation.tpl new file mode 100644 index 00000000..b4a42e46 --- /dev/null +++ b/ui/ui/reports-activation.tpl @@ -0,0 +1,70 @@ +{include file="sections/header.tpl"} + +
+
+
+
+ Activity Log +
+
+
+
+ +
+
+ +
  +
+
+
+ + + + + + + + + + + + + + + {foreach $activation as $ds} + + + + + + + + + + + {/foreach} + +
{$_L['Invoice']}{$_L['Username']}{$_L['Plan_Name']}{$_L['Plan_Price']}{$_L['Type']}{$_L['Created_On']}{$_L['Expires_On']}{$_L['Method']}
{$ds['invoice']}{$ds['username']}{$ds['plan_name']}{Lang::moneyFormat($ds['price'])}{$ds['type']} + {Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])} + {Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])}{$ds['method']}
+
+ {$paginator['contents']} +
+
+
+
+ +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index bb5de551..514305da 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -183,6 +183,8 @@ href="{$_url}reports/daily-report">{$_L['Daily_Report']}
  • {$_L['Period_Reports']}
  • +
  • {Lang::T('Activation History')}
  • {$_MENU_REPORTS}