diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index ee0a4b20..80db1fe9 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -188,6 +188,8 @@ CREATE TABLE `tb_languages` ( `id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +ALTER TABLE `tbl_voucher` ADD `generated_by` INT NOT NULL DEFAULT '0' COMMENT 'id admin' AFTER `status`; +ALTER TABLE `tbl_users` ADD `root` INT NOT NULL DEFAULT '0' COMMENT 'for sub account' AFTER `id`; ALTER TABLE `tbl_appconfig` ADD PRIMARY KEY (`id`); diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 8f1e5c78..f803cae2 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -51,26 +51,28 @@ if (empty($c_all)) { } $ui->assign('c_all', $c_all); -//user expire -$paginator = Paginator::build(ORM::for_table('tbl_user_recharges')); -$expire = ORM::for_table('tbl_user_recharges') - ->where_lte('expiration', $mdate) - ->offset($paginator['startpoint']) - ->limit($paginator['limit']) - ->order_by_desc('expiration') - ->find_many(); +if($config['hide_uet'] != 'yes'){ + //user expire + $paginator = Paginator::build(ORM::for_table('tbl_user_recharges')); + $expire = ORM::for_table('tbl_user_recharges') + ->where_lte('expiration', $mdate) + ->offset($paginator['startpoint']) + ->limit($paginator['limit']) + ->order_by_desc('expiration') + ->find_many(); -// Get the total count of expired records for pagination -$totalCount = ORM::for_table('tbl_user_recharges') - ->where_lte('expiration', $mdate) - ->count(); + // Get the total count of expired records for pagination + $totalCount = ORM::for_table('tbl_user_recharges') + ->where_lte('expiration', $mdate) + ->count(); -// Pass the total count and current page to the paginator -$paginator['total_count'] = $totalCount; + // Pass the total count and current page to the paginator + $paginator['total_count'] = $totalCount; -// Assign the pagination HTML to the template variable -$ui->assign('paginator', $paginator); -$ui->assign('expire', $expire); + // Assign the pagination HTML to the template variable + $ui->assign('paginator', $paginator); + $ui->assign('expire', $expire); +} //activity log $dlog = ORM::for_table('tbl_logs')->limit(5)->order_by_desc('id')->find_many(); @@ -79,36 +81,38 @@ $log = ORM::for_table('tbl_logs')->count(); $ui->assign('log', $log); -$cacheStocksfile = File::pathFixer('system/cache/VoucherStocks.temp'); -$cachePlanfile = File::pathFixer('system/cache/VoucherPlans.temp'); -//Cache for 5 minutes -if(file_exists($cacheStocksfile) && time()- filemtime($cacheStocksfile) < 600){ - $stocks = json_decode(file_get_contents($cacheStocksfile), true); - $plans = json_decode(file_get_contents($cachePlanfile), true); -}else{ - // Count stock - $tmp = $v = ORM::for_table('tbl_plans')->select('id')->select('name_plan')->find_many(); - $plans = array(); - $stocks = array("used" => 0, "unused" => 0); - $n = 0; - foreach ($tmp as $plan) { - $unused = ORM::for_table('tbl_voucher') - ->where('id_plan', $plan['id']) - ->where('status', 0)->count(); - $used = ORM::for_table('tbl_voucher') - ->where('id_plan', $plan['id']) - ->where('status', 1)->count(); - if ($unused > 0 || $used > 0) { - $plans[$n]['name_plan'] = $plan['name_plan']; - $plans[$n]['unused'] = $unused; - $plans[$n]['used'] = $used; - $stocks["unused"] += $unused; - $stocks["used"] += $used; - $n++; +if($config['hide_vs'] != 'yes'){ + $cacheStocksfile = File::pathFixer('system/cache/VoucherStocks.temp'); + $cachePlanfile = File::pathFixer('system/cache/VoucherPlans.temp'); + //Cache for 5 minutes + if(file_exists($cacheStocksfile) && time()- filemtime($cacheStocksfile) < 600){ + $stocks = json_decode(file_get_contents($cacheStocksfile), true); + $plans = json_decode(file_get_contents($cachePlanfile), true); + }else{ + // Count stock + $tmp = $v = ORM::for_table('tbl_plans')->select('id')->select('name_plan')->find_many(); + $plans = array(); + $stocks = array("used" => 0, "unused" => 0); + $n = 0; + foreach ($tmp as $plan) { + $unused = ORM::for_table('tbl_voucher') + ->where('id_plan', $plan['id']) + ->where('status', 0)->count(); + $used = ORM::for_table('tbl_voucher') + ->where('id_plan', $plan['id']) + ->where('status', 1)->count(); + if ($unused > 0 || $used > 0) { + $plans[$n]['name_plan'] = $plan['name_plan']; + $plans[$n]['unused'] = $unused; + $plans[$n]['used'] = $used; + $stocks["unused"] += $unused; + $stocks["used"] += $used; + $n++; + } } + file_put_contents($cacheStocksfile, json_encode($stocks)); + file_put_contents($cachePlanfile, json_encode($plans)); } - file_put_contents($cacheStocksfile, json_encode($stocks)); - file_put_contents($cachePlanfile, json_encode($plans)); } $cacheMRfile = File::pathFixer('system/cache/monthlyRegistered.temp'); @@ -181,7 +185,6 @@ if(file_exists($cacheMSfile) && time()- filemtime($cacheMSfile) < 43200){ // Assign the monthly sales data to Smarty $ui->assign('monthlySales', $monthlySales); -$ui->assign('xheader', ''); $ui->assign('xfooter', ''); $ui->assign('monthlyRegistered', $monthlyRegistered); $ui->assign('stocks', $stocks); diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 97d66404..307fc25c 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -299,6 +299,23 @@ switch ($action) { } } + //checkbox + $checks = ['hide_mrc','hide_tms','hide_aui','hide_al','hide_uet','hide_vs','hide_pg']; + foreach ($checks as $check) { + if(!isset($_POST[$check])){ + $d = ORM::for_table('tbl_appconfig')->where('setting', $check)->find_one(); + if ($d) { + $d->value = 'no'; + $d->save(); + } else { + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = $check; + $d->value = 'no'; + $d->save(); + } + } + } + _log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], 'Admin', $admin['id']); r2(U . 'settings/app', 's', $_L['Settings_Saved_Successfully']); diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index fc91a6f6..8b15e535 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -86,6 +86,24 @@

edit at config.php

+
+
+ +
+ Hide Dashboard Content +
+
+
+ + + + + + + +
+
-
+ {*
@@ -444,7 +462,7 @@ class="btn btn-xs btn-primary">View MarketPlace
-
+
*}
diff --git a/ui/ui/dashboard.tpl b/ui/ui/dashboard.tpl index c74a1c10..9e769068 100644 --- a/ui/ui/dashboard.tpl +++ b/ui/ui/dashboard.tpl @@ -61,129 +61,144 @@
-
-
- +{if $_c['hide_mrc'] != 'yes'} +
+
+ -

{Lang::T('Monthly Registered Customers')}

+

{Lang::T('Monthly Registered Customers')}

-
- - +
+ + +
+
+
+
-
- -
-
+{/if} + -
-
- +{if $_c['hide_tms'] != 'yes'} +
+
+ -

{Lang::T('Total Monthly Sales')}

+

{Lang::T('Total Monthly Sales')}

-
- - +
+ + +
+
+
+
-
- -
-
+{/if}
{if $_c['disable_voucher'] != 'yes' && $stocks['unused']>0 || $stocks['used']>0} -
-
Vouchers Stock
+ {if $_c['hide_vs'] != 'yes'} +
+
Vouchers Stock
+
+ + + + + + + + + + {foreach $plans as $stok} + + + + + + + {/foreach} + + + + + +
{$_L['Plan_Name']}unusedused
{$stok['name_plan']}{$stok['unused']}{$stok['used']}
Total{$stocks['unused']}{$stocks['used']}
+
+
+ {/if} + {/if} + {if $_c['hide_uet'] != 'yes'} +
+
{$_L['User_Expired_Today']}
- - - + + + + - {foreach $plans as $stok} + {$no = 1} + {foreach $expire as $expired} - - - + + + + {/foreach} - - - - -
{$_L['Plan_Name']}unusedusedId{$_L['Username']}{$_L['Created_On']}{$_L['Expires_On']}
{$stok['name_plan']}{$stok['unused']}{$stok['used']}{$no++}{$expired['username']}{Lang::dateAndTimeFormat($expired['recharged_on'],$expired['recharged_time'])} + {Lang::dateAndTimeFormat($expired['expiration'],$expired['time'])} +
Total{$stocks['unused']}{$stocks['used']}
+   {$paginator['contents']}
{/if} -
-
{$_L['User_Expired_Today']}
-
- - - - - - - - - - - {$no = 1} - {foreach $expire as $expired} - - - - - - - - {/foreach} -
Id{$_L['Username']}{$_L['Created_On']}{$_L['Expires_On']}
{$no++}{$expired['username']}{Lang::dateAndTimeFormat($expired['recharged_on'],$expired['recharged_time'])} - {Lang::dateAndTimeFormat($expired['expiration'],$expired['time'])} -
-
-   {$paginator['contents']} -
-
-
{Lang::T('Payment Gateway')}: {$_c['payment_gateway']}
-
-
-
{Lang::T('All Users Insights')}
-
- + {if $_c['hide_pg'] != 'yes'} +
+
{Lang::T('Payment Gateway')}: {$_c['payment_gateway']}
-
-
- -
-
    - {foreach $dlog as $dlogs} -
  • - - {time_elapsed_string($dlogs['date'],true)} -

    {$dlogs['description']}

    -
  • - {/foreach} -
+ {/if} + {if $_c['hide_aui'] != 'yes'} +
+
{Lang::T('All Users Insights')}
+
+ +
-
+ {/if} + {if $_c['hide_al'] != 'yes'} +
+ +
+
    + {foreach $dlog as $dlogs} +
  • + + {time_elapsed_string($dlogs['date'],true)} +

    {$dlogs['description']}

    +
  • + {/foreach} +
+
+
+ {/if}
@@ -191,162 +206,168 @@ -{literal} - - - -{/literal} + {/literal} + {/if} +