Compare commits

...

18 Commits

Author SHA1 Message Date
66432eda56 2024.2.7 2024-02-07 13:35:23 +07:00
92eee8245d timeElapsed 2024-02-07 13:32:33 +07:00
f62f07d102 add Hide Dashboard Content 2024-02-07 12:02:39 +07:00
671154d146 add sub sales 2024-02-07 10:11:30 +07:00
ac84e4b235 settimezone 2024-02-07 09:39:49 +07:00
db7c6014dc Fix invoice keyword 2024-02-06 17:41:45 +07:00
21b57ef471 Fix price for logging 2024-02-06 16:54:57 +07:00
79e5c72ca2 2024.2.6 2024-02-06 16:48:59 +07:00
5921fef67e cache Voucher stocks for 5 Minutes 2024-02-06 16:46:50 +07:00
1e0b246d74 Cache for 12 hours 2024-02-06 16:43:06 +07:00
009c890ab6 Fix router_name for log 2024-02-06 16:41:41 +07:00
f3d7687cdb cache dashboard graph 2024-02-06 16:41:26 +07:00
80cecabfb0 Fix Calculation 2024-02-05 14:25:23 +07:00
00ac91903f Merge pull request #103 from Focuslinkstech/master
Dashboard Updates
2024-02-05 14:19:37 +07:00
500f3de6a9 Update dashboard.tpl
fixed inactive users in graph
2024-02-05 08:17:10 +01:00
6c2658bf03 Update dashboard.tpl
change all users to total users
2024-02-05 07:41:15 +01:00
59de353353 Merge branch 'hotspotbilling:master' into master 2024-02-05 07:33:47 +01:00
d5ea56d078 Update dashboard.tpl
change active users to All Users Insight
add All users to graph
2024-02-05 07:24:32 +01:00
16 changed files with 492 additions and 341 deletions

View File

@ -2,6 +2,14 @@
# CHANGELOG
## 2024.2.7
- Hide Dashboard content
## 2024.2.6
- Cache graph for faster opening graph
## 2024.2.5
- Admin Dashboard Update

View File

@ -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`);

View File

@ -56,6 +56,24 @@ class Lang
return date($config['date_format'] . ' H:i', strtotime("$date $time"));
}
public static function timeElapsed($time){
$s = $time%60;
$m = floor(($time%3600)/60);
$h = floor(($time%86400)/3600);
$d = floor(($time%2592000)/86400);
$M = floor($time/2592000);
$result = '';
if($M>0){
$result = $M.'m ';
}
if($d>0){
$result .= $d.'d ';
}else if($M>0){
$result .= '0d ';
}
return "$result$h:$m:$s";
}
public static function nl2br($text)
{
return nl2br($text);

View File

@ -111,8 +111,9 @@ class Message
$textInvoice = str_replace('[[phone]]', $config['phone'], $textInvoice);
$textInvoice = str_replace('[[invoice]]', $trx['invoice'], $textInvoice);
$textInvoice = str_replace('[[date]]', Lang::dateAndTimeFormat($trx['recharged_on'], $trx['recharged_time']), $textInvoice);
$textInvoice = str_replace('[[payment_gateway]]', $config['gateway'], $textInvoice);
$textInvoice = str_replace('[[payment_channel]]', $config['channel'], $textInvoice);
$gc = explode("-", $trx['method']);
$textInvoice = str_replace('[[payment_gateway]]', trim($gc[0]), $textInvoice);
$textInvoice = str_replace('[[payment_channel]]', trim($gc[1]), $textInvoice);
$textInvoice = str_replace('[[type]]', $trx['type'], $textInvoice);
$textInvoice = str_replace('[[plan_name]]', $trx['plan_name'], $textInvoice);
$textInvoice = str_replace('[[plan_price]]', Lang::moneyFormat($trx['price']), $textInvoice);

View File

@ -514,4 +514,37 @@ class Mikrotik
->setArgument('message', $message);
$client->sendSync($smsRequest);
}
public static function addIpToAddressList($client, $ip, $listName, $comment = '')
{
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ip/firewall/address-list/add');
$client->sendSync(
$addRequest
->setArgument('address', $ip)
->setArgument('comment', $comment)
->setArgument('list', $listName)
);
}
public static function removeIpFromAddressList($client, $ip)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request(
'/ip firewall address-list print .proplist=.id',
RouterOS\Query::where('address', $ip)
);
$id = $client->sendSync($printRequest)->getProperty('.id');
$removeRequest = new RouterOS\Request('/ip/firewall/address-list/remove');
$client->sendSync(
$removeRequest
->setArgument('numbers', $id)
);
}
}

View File

@ -59,8 +59,8 @@ class Package
$textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice);
$textInvoice = str_replace('[[invoice]]', $inv, $textInvoice);
$textInvoice = str_replace('[[date]]', Lang::dateTimeFormat($date_now), $textInvoice);
$textInvoice = str_replace('[[payment_gateway]]', $_c['gateway'], $textInvoice);
$textInvoice = str_replace('[[payment_channel]]', $_c['channel'], $textInvoice);
$textInvoice = str_replace('[[payment_gateway]]', $gateway, $textInvoice);
$textInvoice = str_replace('[[payment_channel]]', $channel, $textInvoice);
$textInvoice = str_replace('[[type]]', 'Balance', $textInvoice);
$textInvoice = str_replace('[[plan_name]]', $p['name_plan'], $textInvoice);
$textInvoice = str_replace('[[plan_price]]', Lang::moneyFormat($p['price']), $textInvoice);
@ -316,8 +316,7 @@ class Package
"\nPrice: " . Lang::moneyFormat($p['price']));
}
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
Message::sendInvoice($c, $in);
Message::sendInvoice($c, $t);
return true;
}

View File

@ -51,6 +51,7 @@ if (empty($c_all)) {
}
$ui->assign('c_all', $c_all);
if($config['hide_uet'] != 'yes'){
//user expire
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges'));
$expire = ORM::for_table('tbl_user_recharges')
@ -71,6 +72,7 @@ $paginator['total_count'] = $totalCount;
// 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();
@ -78,6 +80,15 @@ $ui->assign('dlog', $dlog);
$log = ORM::for_table('tbl_logs')->count();
$ui->assign('log', $log);
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();
@ -99,7 +110,16 @@ foreach ($tmp as $plan) {
$n++;
}
}
file_put_contents($cacheStocksfile, json_encode($stocks));
file_put_contents($cachePlanfile, json_encode($plans));
}
}
$cacheMRfile = File::pathFixer('system/cache/monthlyRegistered.temp');
//Cache for 1 hour
if(file_exists($cacheMRfile) && time()- filemtime($cacheMRfile) < 3600){
$monthlyRegistered = json_decode(file_get_contents($cacheMRfile), true);
}else{
//Monthly Registered Customers
$result = ORM::for_table('tbl_customers')
->select_expr('MONTH(created_at)', 'month')
@ -108,25 +128,29 @@ $result = ORM::for_table('tbl_customers')
->group_by_expr('MONTH(created_at)')
->find_many();
$counts = [];
$monthlyRegistered = [];
foreach ($result as $row) {
$counts[] = [
$monthlyRegistered[] = [
'date' => $row->month,
'count' => $row->count
];
}
file_put_contents($cacheMRfile, json_encode($monthlyRegistered));
}
$cacheMSfile = File::pathFixer('system/cache/monthlySales.temp');
//Cache for 12 hours
if(file_exists($cacheMSfile) && time()- filemtime($cacheMSfile) < 43200){
$monthlySales = json_decode(file_get_contents($cacheMSfile), true);
}else{
// Query to retrieve monthly data
$query = ORM::for_table('tbl_transactions')
$results = ORM::for_table('tbl_transactions')
->select_expr('MONTH(recharged_on)', 'month')
->select_expr('SUM(price)', 'total')
->where_raw("YEAR(recharged_on) = YEAR(CURRENT_DATE())") // Filter by the current year
->group_by_expr('MONTH(recharged_on)')
->find_many();
// Execute the query and retrieve the monthly sales data
$results = $query->find_many();
// Create an array to hold the monthly sales data
$monthlySales = array();
@ -156,12 +180,13 @@ ksort($monthlySales);
// Reindex the array
$monthlySales = array_values($monthlySales);
file_put_contents($cacheMSfile, json_encode($monthlySales));
}
// Assign the monthly sales data to Smarty
$ui->assign('monthlySales', $monthlySales);
$ui->assign('xheader', '<script src="https://cdn.jsdelivr.net/npm/apexcharts@3.28.0/dist/apexcharts.min.js"></script>');
$ui->assign('xfooter', '');
$ui->assign('counts', $counts);
$ui->assign('monthlyRegistered', $monthlyRegistered);
$ui->assign('stocks', $stocks);
$ui->assign('plans', $plans);

View File

@ -247,7 +247,7 @@ switch ($action) {
if($d['status'] == 'on'){
Package::changeTo($username, $id_plan, $id);
}
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($d['price']) . ']', 'Admin', $admin['id']);
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', 'Admin', $admin['id']);
r2(U . 'prepaid/list', 's', $_L['Updated_Successfully']);
} else {
r2(U . 'prepaid/edit/' . $id, 'e', $msg);
@ -452,6 +452,7 @@ switch ($action) {
$d->code = $prefix.$code;
$d->user = '0';
$d->status = '0';
$d->generated_by = $admin['id'];
$d->save();
}

View File

@ -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']);

View File

@ -81,6 +81,7 @@ $result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
date_default_timezone_set($config['timezone']);
if (!empty($radius_user) && $config['radius_enable']) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
@ -100,7 +101,6 @@ while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$_c = $config;
date_default_timezone_set($config['timezone']);
$textExpired = Lang::getNotifText('expired');
@ -153,7 +153,7 @@ foreach ($d as $ds) {
echo "plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
echo "auto renewall Failed\n";
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
"\nRouter: " . $router_name .
"\nRouter: " . $p['routers'] .
"\nPrice: " . $p['price']);
}
} else {
@ -208,7 +208,7 @@ foreach ($d as $ds) {
echo "plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
echo "auto renewall Failed\n";
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #PPPOE \n" . $p['name_plan'] .
"\nRouter: " . $router_name .
"\nRouter: " . $p['routers'] .
"\nPrice: " . $p['price']);
}
}

View File

@ -427,3 +427,4 @@ $_L['Buy_this_your_active_package_will_be_overwrite'] = 'Buy this? your active p
$_L['Monthly_Registered_Customers'] = 'Monthly Registered Customers';
$_L['Total_Monthly_Sales'] = 'Total Monthly Sales';
$_L['Active_Users'] = 'Active Users';
$_L['All_Users_Insights'] = 'All Users Insights';

View File

@ -41,5 +41,9 @@
],
"2024.1.11": [
"ALTER TABLE `tbl_plans` ADD `allow_purchase` ENUM('yes','no') DEFAULT 'yes' COMMENT 'allow to show package in buy package page' AFTER `enabled`;"
],
"2024.2.7": [
"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`;"
]
}

View File

@ -86,6 +86,24 @@
<p class="help-block col-md-4">edit at config.php</p>
</div>
</div>
<div class="panel-heading">
<div class="btn-group pull-right">
<button class="btn btn-primary btn-xs" title="save" type="submit"><span
class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></button>
</div>
Hide Dashboard Content
</div>
<div class="panel-body">
<div class="form-group">
<label class="col-md-3 control-label"><input type="checkbox" name="hide_mrc" value="yes" {if $_c['hide_mrc'] eq 'yes'}checked{/if}> {Lang::T('Monthly Registered Customers')}</label>
<label class="col-md-2 control-label"><input type="checkbox" name="hide_tms" value="yes" {if $_c['hide_tms'] eq 'yes'}checked{/if}> {Lang::T('Total Monthly Sales')}</label>
<label class="col-md-2 control-label"><input type="checkbox" name="hide_aui" value="yes" {if $_c['hide_aui'] eq 'yes'}checked{/if}> {Lang::T('All Users Insights')}</label>
<label class="col-md-2 control-label"><input type="checkbox" name="hide_al" value="yes" {if $_c['hide_al'] eq 'yes'}checked{/if}> {$_L['Activity_Log']}</label>
<label class="col-md-2 control-label"><input type="checkbox" name="hide_uet" value="yes" {if $_c['hide_uet'] eq 'yes'}checked{/if}> {$_L['User_Expired_Today']}</label>
<label class="col-md-2 control-label"><input type="checkbox" name="hide_vs" value="yes" {if $_c['hide_vs'] eq 'yes'}checked{/if}> Vouchers Stock</label>
<label class="col-md-2 control-label"><input type="checkbox" name="hide_pg" value="yes" {if $_c['hide_pg'] eq 'yes'}checked{/if}> Payment Gateway</label>
</div>
</div>
<div class="panel-heading">
<div class="btn-group pull-right">
<button class="btn btn-primary btn-xs" title="save" type="submit"><span
@ -417,7 +435,7 @@
</div>
</div>
</div>
<div class="panel-heading" id="envato">
{* <div class="panel-heading" id="envato">
<div class="btn-group pull-right">
<button class="btn btn-primary btn-xs" title="save" type="submit"><span
class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></button>
@ -444,7 +462,7 @@
class="btn btn-xs btn-primary">View MarketPlace</a>
</label>
</div>
</div>
</div> *}
</div>
<div class="panel-body">

View File

@ -61,6 +61,7 @@
</div>
</div>
<!-- solid sales graph -->
{if $_c['hide_mrc'] != 'yes'}
<div class="box box-solid ">
<div class="box-header">
<i class="fa fa-th"></i>
@ -78,7 +79,10 @@
<canvas class="chart" id="chart" style="height: 250px;"></canvas>
</div>
</div>
{/if}
<!-- solid sales graph -->
{if $_c['hide_tms'] != 'yes'}
<div class="box box-solid ">
<div class="box-header">
<i class="fa fa-inbox"></i>
@ -96,9 +100,11 @@
<canvas class="chart" id="salesChart" style="height: 250px;"></canvas>
</div>
</div>
{/if}
<div class="row">
<div class="col-md-7">
{if $_c['disable_voucher'] != 'yes' && $stocks['unused']>0 || $stocks['used']>0}
{if $_c['hide_vs'] != 'yes'}
<div class="panel panel-primary mb20 panel-hovered project-stats table-responsive">
<div class="panel-heading">Vouchers Stock</div>
<div class="table-responsive">
@ -128,6 +134,8 @@
</div>
</div>
{/if}
{/if}
{if $_c['hide_uet'] != 'yes'}
<div class="panel panel-warning mb20 panel-hovered project-stats table-responsive">
<div class="panel-heading">{$_L['User_Expired_Today']}</div>
<div class="table-responsive">
@ -157,19 +165,25 @@
</div>
&nbsp; {$paginator['contents']}
</div>
{/if}
</div>
<div class="col-md-5">
{if $_c['hide_pg'] != 'yes'}
<div class="panel panel-success panel-hovered mb20 activities">
<div class="panel-heading">{Lang::T('Payment Gateway')}: {$_c['payment_gateway']}</div>
</div>
{/if}
{if $_c['hide_aui'] != 'yes'}
<div class="panel panel-info panel-hovered mb20 activities">
<div class="panel-heading">{Lang::T('Active Users')}</div>
<div class="panel-heading">{Lang::T('All Users Insights')}</div>
<div class="panel-body">
<canvas id="userRechargesChart"></canvas>
</div>
</div>
{/if}
{if $_c['hide_al'] != 'yes'}
<div class="panel panel-info panel-hovered mb20 activities">
<div class="panel-heading"><a href="{$_url}logs">{$_L['Activity_Log']}</a></div>
<div class="panel-body">
@ -184,6 +198,7 @@
</ul>
</div>
</div>
{/if}
</div>
@ -191,10 +206,12 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js"></script>
{literal}
<script type="text/javascript">
{if $_c['hide_mrc'] != 'yes'}
{literal}
document.addEventListener("DOMContentLoaded", function() {
var counts = JSON.parse('{/literal}{$counts|json_encode}{literal}');
var counts = JSON.parse('{/literal}{$monthlyRegistered|json_encode}{literal}');
var monthNames = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@ -241,9 +258,10 @@
}
});
});
</script>
<script type="text/javascript">
{/literal}
{/if}
{if $_c['hide_tmc'] != 'yes'}
{literal}
document.addEventListener("DOMContentLoaded", function() {
var monthlySales = JSON.parse('{/literal}{$monthlySales|json_encode}{literal}');
@ -301,21 +319,26 @@
}
return null;
}
{/literal}
{/if}
{if $_c['hide_aui'] != 'yes'}
{literal}
document.addEventListener("DOMContentLoaded", function() {
// Get the data from PHP and assign it to JavaScript variables
var u_act = '{/literal}{$u_act}{literal}';
var c_all = '{/literal}{$c_all}{literal}';
var u_all = '{/literal}{$u_all}{literal}';
//lets calculate the inactive users as reported
var expired = u_all - u_act;
var inactive = c_all - u_all;
// Create the chart data
var data = {
labels: ['Active Users', 'Inactive Users'],
labels: ['Active Users', 'Expired Users', 'Inactive Users'],
datasets: [{
label: 'User Recharges',
data: [parseInt(u_act), parseInt(u_all)],
backgroundColor: ['rgba(4, 191, 13)', 'rgba(191, 35, 4)'],
borderColor: ['rgba(0, 255, 0, 1)', 'rgba(255, 99, 132, 1)'],
data: [parseInt(u_act), parseInt(expired), parseInt(inactive)],
backgroundColor: ['rgba(4, 191, 13)', 'rgba(191, 35, 4)', 'rgba(0, 0, 255, 0.5'],
borderColor: ['rgba(0, 255, 0, 1)', 'rgba(255, 99, 132, 1)', 'rgba(0, 0, 255, 0.7'],
borderWidth: 1
}]
};
@ -342,8 +365,9 @@
options: options
});
});
</script>
{/literal}
{/if}
</script>
<script>
window.addEventListener('DOMContentLoaded', function() {
$.getJSON("./version.json?" + Math.random(), function(data) {

View File

@ -279,10 +279,10 @@
<a href="{$_url}pluginmanager"><i class="glyphicon glyphicon-tasks"></i>
{Lang::T('Plugin Manager')} <small class="label pull-right">Free</small></a>
</li>
<li {if $_routes[0] eq 'codecanyon'}class="active" {/if}>
{* <li {if $_routes[0] eq 'codecanyon'}class="active" {/if}>
<a href="{$_url}codecanyon"><i class="glyphicon glyphicon-shopping-cart"></i>
Codecanyon.net <small class="label pull-right">Paid</small></a>
</li>
</li> *}
</ul>
</li>
{$_MENU_AFTER_SETTINGS}

View File

@ -1,3 +1,3 @@
{
"version": "2024.2.5"
"version": "2024.2.7"
}