From ef85bdb02f748e2afd2b73c204f06b585d68f71b Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 12:12:36 +0700 Subject: [PATCH] Invoice number not Random --- system/autoload/Package.php | 14 +++++++------- system/controllers/export.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 0e153b5..49ab694 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -44,7 +44,7 @@ class Package if ($router_name == 'balance') { // insert table transactions - $inv = "INV-" . Package::_raid(5); + $inv = "INV-" . Package::_raid(); $t = ORM::for_table('tbl_transactions')->create(); $t->invoice = $inv; $t->username = $c['username']; @@ -188,7 +188,7 @@ class Package // insert table transactions $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); + $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; $t->price = $p['price']; @@ -260,7 +260,7 @@ class Package // insert table transactions $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); + $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; if ($p['validity_unit'] == 'Period') { @@ -373,7 +373,7 @@ class Package // insert table transactions $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); + $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; $t->price = $p['price']; @@ -444,7 +444,7 @@ class Package // insert table transactions $t = ORM::for_table('tbl_transactions')->create(); - $t->invoice = "INV-" . Package::_raid(5); + $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; if ($p['validity_unit'] == 'Period') { @@ -588,9 +588,9 @@ class Package } - public static function _raid($l) + public static function _raid() { - return substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l); + return ORM::for_table('tbl_transactions')->max('id')+1; } /** diff --git a/system/controllers/export.php b/system/controllers/export.php index 6508fa7..e2da4ff 100644 --- a/system/controllers/export.php +++ b/system/controllers/export.php @@ -170,7 +170,7 @@ $style $html EOF; $mpdf->WriteHTML($nhtml); - $mpdf->Output(date('Y-m-d') . Package::_raid(4) . '.pdf', 'D'); + $mpdf->Output(date('Ymd_His') . '.pdf', 'D'); } else { echo 'No Data'; } @@ -344,7 +344,7 @@ $style $html EOF; $mpdf->WriteHTML($nhtml); - $mpdf->Output(date('Y-m-d') . Package::_raid(4) . '.pdf', 'D'); + $mpdf->Output(date('Ymd_His') . '.pdf', 'D'); } else { echo 'No Data'; }