diff --git a/system/autoload/Http.php b/system/autoload/Http.php
index 7fd20223..c170824b 100644
--- a/system/autoload/Http.php
+++ b/system/autoload/Http.php
@@ -20,8 +20,8 @@ class Http
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 100);
if (is_array($headers) && count($headers) > 0) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
@@ -56,8 +56,8 @@ class Http
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
if (!empty($http_proxy)) {
@@ -99,8 +99,8 @@ class Http
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
if (!empty($http_proxy)) {
diff --git a/system/controllers/export.php b/system/controllers/export.php
index e2da4ff8..cce7c36f 100644
--- a/system/controllers/export.php
+++ b/system/controllers/export.php
@@ -28,16 +28,56 @@ switch ($action) {
case 'print-by-date':
$mdate = date('Y-m-d');
- $d = ORM::for_table('tbl_transactions');
- $d->where('recharged_on', $mdate);
- $d->order_by_desc('id');
- $x = $d->find_many();
+ $types = ORM::for_table('tbl_transactions')->getEnum('type');
+ $methods = array_column(ORM::for_table('tbl_transactions')->rawQuery("SELECT DISTINCT SUBSTRING_INDEX(`method`, ' - ', 1) as method FROM tbl_transactions;")->findArray(), 'method');
+ $routers = array_column(ORM::for_table('tbl_transactions')->select('routers')->distinct('routers')->find_array(), 'routers');
+ $plans = array_column(ORM::for_table('tbl_transactions')->select('plan_name')->distinct('plan_name')->find_array(), 'plan_name');
+ $reset_day = $config['reset_day'];
+ if (empty($reset_day)) {
+ $reset_day = 1;
+ }
+ //first day of month
+ if (date("d") >= $reset_day) {
+ $start_date = date('Y-m-' . $reset_day);
+ } else {
+ $start_date = date('Y-m-' . $reset_day, strtotime("-1 MONTH"));
+ }
+ $tps = ($_GET['tps']) ? $_GET['tps'] : $types;
+ $mts = ($_GET['mts']) ? $_GET['mts'] : $methods;
+ $rts = ($_GET['rts']) ? $_GET['rts'] : $routers;
+ $plns = ($_GET['plns']) ? $_GET['plns'] : $plans;
+ $sd = _req('sd', $start_date);
+ $ed = _req('ed', $mdate);
+ $ts = _req('ts', '00:00:00');
+ $te = _req('te', '23:59:59');
- $dr = ORM::for_table('tbl_transactions');
- $dr->where('recharged_on', $mdate);
- $dr->order_by_desc('id');
- $xy = $dr->sum('price');
+ $query = ORM::for_table('tbl_transactions')
+ ->whereRaw("UNIX_TIMESTAMP(CONCAT(`recharged_on`,' ',`recharged_time`)) >= " . strtotime("$sd $ts"))
+ ->whereRaw("UNIX_TIMESTAMP(CONCAT(`recharged_on`,' ',`recharged_time`)) <= " . strtotime("$ed $te"))
+ ->order_by_desc('id');
+ if (count($tps) > 0) {
+ $query->where_in('type', $tps);
+ }
+ if (count($mts) > 0) {
+ if (count($mts) != count($methods)) {
+ foreach ($mts as $mt) {
+ $query->where_like('method', "$mt - %");
+ }
+ }
+ }
+ if (count($rts) > 0) {
+ $query->where_in('routers', $rts);
+ }
+ if (count($plns) > 0) {
+ $query->where_in('plan_name', $plns);
+ }
+ $x = $query->find_array();
+ $xy = $query->sum('price');
+ $ui->assign('sd', $sd);
+ $ui->assign('ed', $ed);
+ $ui->assign('ts', $ts);
+ $ui->assign('te', $te);
$ui->assign('d', $x);
$ui->assign('dr', $xy);
$ui->assign('mdate', $mdate);
@@ -48,16 +88,51 @@ switch ($action) {
case 'pdf-by-date':
$mdate = date('Y-m-d');
+ $types = ORM::for_table('tbl_transactions')->getEnum('type');
+ $methods = array_column(ORM::for_table('tbl_transactions')->rawQuery("SELECT DISTINCT SUBSTRING_INDEX(`method`, ' - ', 1) as method FROM tbl_transactions;")->findArray(), 'method');
+ $routers = array_column(ORM::for_table('tbl_transactions')->select('routers')->distinct('routers')->find_array(), 'routers');
+ $plans = array_column(ORM::for_table('tbl_transactions')->select('plan_name')->distinct('plan_name')->find_array(), 'plan_name');
+ $reset_day = $config['reset_day'];
+ if (empty($reset_day)) {
+ $reset_day = 1;
+ }
+ //first day of month
+ if (date("d") >= $reset_day) {
+ $start_date = date('Y-m-' . $reset_day);
+ } else {
+ $start_date = date('Y-m-' . $reset_day, strtotime("-1 MONTH"));
+ }
+ $tps = ($_GET['tps']) ? $_GET['tps'] : $types;
+ $mts = ($_GET['mts']) ? $_GET['mts'] : $methods;
+ $rts = ($_GET['rts']) ? $_GET['rts'] : $routers;
+ $plns = ($_GET['plns']) ? $_GET['plns'] : $plans;
+ $sd = _req('sd', $start_date);
+ $ed = _req('ed', $mdate);
+ $ts = _req('ts', '00:00:00');
+ $te = _req('te', '23:59:59');
- $d = ORM::for_table('tbl_transactions');
- $d->where('recharged_on', $mdate);
- $d->order_by_desc('id');
- $x = $d->find_many();
-
- $dr = ORM::for_table('tbl_transactions');
- $dr->where('recharged_on', $mdate);
- $dr->order_by_desc('id');
- $xy = $dr->sum('price');
+ $query = ORM::for_table('tbl_transactions')
+ ->whereRaw("UNIX_TIMESTAMP(CONCAT(`recharged_on`,' ',`recharged_time`)) >= " . strtotime("$sd $ts"))
+ ->whereRaw("UNIX_TIMESTAMP(CONCAT(`recharged_on`,' ',`recharged_time`)) <= " . strtotime("$ed $te"))
+ ->order_by_desc('id');
+ if (count($tps) > 0) {
+ $query->where_in('type', $tps);
+ }
+ if (count($mts) > 0) {
+ if (count($mts) != count($methods)) {
+ foreach ($mts as $mt) {
+ $query->where_like('method', "$mt - %");
+ }
+ }
+ }
+ if (count($rts) > 0) {
+ $query->where_in('routers', $rts);
+ }
+ if (count($plns) > 0) {
+ $query->where_in('plan_name', $plns);
+ }
+ $x = $query->find_array();
+ $xy = $query->sum('price');
$title = ' Reports [' . $mdate . ']';
$title = str_replace('-', ' ', $title);
@@ -79,7 +154,7 @@ switch ($action) {

-
+
' . Lang::T('Username') . ' |
@@ -98,8 +173,8 @@ switch ($action) {
$plan_name = $value['plan_name'];
$type = $value['type'];
$price = $config['currency_code'] . ' ' . number_format($value['price'], 0, $config['dec_point'], $config['thousands_sep']);
- $recharged_on = date($config['date_format'], strtotime($value['recharged_on']));
- $expiration = date($config['date_format'], strtotime($value['expiration']));
+ $recharged_on = Lang::dateAndTimeFormat($value['recharged_on'], $value['recharged_time']);
+ $expiration = Lang::dateAndTimeFormat($value['expiration'], $value['time']);
$time = $value['time'];
$method = $value['method'];
$routers = $value['routers'];
@@ -110,7 +185,7 @@ switch ($action) {
$type |
$price |
$recharged_on |
- $expiration $time |
+ $expiration |
$method |
$routers |
";
@@ -170,7 +245,7 @@ $style
$html
EOF;
$mpdf->WriteHTML($nhtml);
- $mpdf->Output(date('Ymd_His') . '.pdf', 'D');
+ $mpdf->Output('phpnuxbill_reports_'.date('Ymd_His') . '.pdf', 'D');
} else {
echo 'No Data';
}
diff --git a/system/controllers/reports.php b/system/controllers/reports.php
index 2983fc1f..cf30ac70 100644
--- a/system/controllers/reports.php
+++ b/system/controllers/reports.php
@@ -41,18 +41,6 @@ switch ($action) {
$ui->assign('q', $q);
$ui->display('reports-activation.tpl');
break;
- case 'daily-report':
- $query = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->order_by_desc('id');
- $d = Paginator::findMany($query);
- $dr = $query->sum('price');
-
- $ui->assign('d', $d);
- $ui->assign('dr', $dr);
- $ui->assign('mdate', $mdate);
- $ui->assign('mtime', $mtime);
- run_hook('view_daily_reports'); #HOOK
- $ui->display('reports-daily.tpl');
- break;
case 'by-period':
$ui->assign('mdate', $mdate);
@@ -95,6 +83,77 @@ switch ($action) {
$ui->display('reports-period-view.tpl');
break;
+ case 'daily-report':
default:
- $ui->display('a404.tpl');
+ $types = ORM::for_table('tbl_transactions')->getEnum('type');
+ $methods = array_column(ORM::for_table('tbl_transactions')->rawQuery("SELECT DISTINCT SUBSTRING_INDEX(`method`, ' - ', 1) as method FROM tbl_transactions;")->findArray(), 'method');
+ $routers = array_column(ORM::for_table('tbl_transactions')->select('routers')->distinct('routers')->find_array(), 'routers');
+ $plans = array_column(ORM::for_table('tbl_transactions')->select('plan_name')->distinct('plan_name')->find_array(), 'plan_name');
+ $reset_day = $config['reset_day'];
+ if (empty($reset_day)) {
+ $reset_day = 1;
+ }
+ //first day of month
+ if (date("d") >= $reset_day) {
+ $start_date = date('Y-m-' . $reset_day);
+ } else {
+ $start_date = date('Y-m-' . $reset_day, strtotime("-1 MONTH"));
+ }
+ $tps = ($_GET['tps']) ? $_GET['tps'] : $types;
+ $mts = ($_GET['mts']) ? $_GET['mts'] : $methods;
+ $rts = ($_GET['rts']) ? $_GET['rts'] : $routers;
+ $plns = ($_GET['plns']) ? $_GET['plns'] : $plans;
+ $sd = _req('sd', $start_date);
+ $ed = _req('ed', $mdate);
+ $ts = _req('ts', '00:00:00');
+ $te = _req('te', '23:59:59');
+ $urlquery = str_replace('_route=reports&', '', $_SERVER['QUERY_STRING']);
+
+
+ $query = ORM::for_table('tbl_transactions')
+ ->whereRaw("UNIX_TIMESTAMP(CONCAT(`recharged_on`,' ',`recharged_time`)) >= " . strtotime("$sd $ts"))
+ ->whereRaw("UNIX_TIMESTAMP(CONCAT(`recharged_on`,' ',`recharged_time`)) <= " . strtotime("$ed $te"))
+ ->order_by_desc('id');
+ if (count($tps) > 0) {
+ $query->where_in('type', $tps);
+ }
+ if (count($mts) > 0) {
+ if (count($mts) != count($methods)) {
+ foreach ($mts as $mt) {
+ $query->where_like('method', "$mt - %");
+ }
+ }
+ }
+ if (count($rts) > 0) {
+ $query->where_in('routers', $rts);
+ }
+ if (count($plns) > 0) {
+ $query->where_in('plan_name', $plns);
+ }
+ $d = Paginator::findMany($query, [], 100, $urlquery);
+ $dr = $query->sum('price');
+
+ $ui->assign('methods', $methods);
+ $ui->assign('types', $types);
+ $ui->assign('routers', $routers);
+ $ui->assign('plans', $plans);
+ $ui->assign('filter', $urlquery);
+
+ // time
+ $ui->assign('sd', $sd);
+ $ui->assign('ed', $ed);
+ $ui->assign('ts', $ts);
+ $ui->assign('te', $te);
+
+ $ui->assign('mts', $mts);
+ $ui->assign('tps', $tps);
+ $ui->assign('rts', $rts);
+ $ui->assign('plns', $plns);
+
+ $ui->assign('d', $d);
+ $ui->assign('dr', $dr);
+ $ui->assign('mdate', $mdate);
+ run_hook('view_daily_reports'); #HOOK
+ $ui->display('reports-daily.tpl');
+ break;
}
diff --git a/system/lan/english.json b/system/lan/english.json
index 61af7a3d..283df2cf 100644
--- a/system/lan/english.json
+++ b/system/lan/english.json
@@ -662,5 +662,15 @@
"": "",
"Additional_Billing": "Additional Billing",
"_": "-",
- "Used_Date": "Used Date"
+ "Used_Date": "Used Date",
+ "Filter": "Filter",
+ "Start_time": "Start time",
+ "End_Time": "End Time",
+ "Internet_Plans": "Internet Plans",
+ "Methods": "Methods",
+ "Hap_Lite": "Hap Lite",
+ "balance": "balance",
+ "radius": "radius",
+ "Start_Date": "Start Date",
+ "End_Date": "End Date"
}
\ No newline at end of file
diff --git a/ui/ui/print-by-date.tpl b/ui/ui/print-by-date.tpl
index 6d655e7c..f11745a0 100644
--- a/ui/ui/print-by-date.tpl
+++ b/ui/ui/print-by-date.tpl
@@ -22,7 +22,7 @@
-
{Lang::T('All Transactions at Date')}: {date($_c['date_format'], strtotime($mdate))}
+
{Lang::T('All Transactions at Date')}: {Lang::dateAndTimeFormat($sd, $ts)} - {Lang::dateAndTimeFormat($ed, $te)}
{Lang::T('Username')} |
diff --git a/ui/ui/reports-daily.tpl b/ui/ui/reports-daily.tpl
index 998b3e83..1bffc50d 100644
--- a/ui/ui/reports-daily.tpl
+++ b/ui/ui/reports-daily.tpl
@@ -1,29 +1,65 @@
{include file="sections/header.tpl"}
-
-
-
-
-
- {Lang::T('Daily Reports')}
-
-
-
-
-
{Lang::T('All Transactions at Date')}:
-
{date($_c['date_format'], strtotime($mdate))} {$mtime}
+