diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php
index 83759307..e9782bd4 100644
--- a/system/controllers/prepaid.php
+++ b/system/controllers/prepaid.php
@@ -156,11 +156,16 @@ switch ($action) {
case 'print':
- $id = _post('id');
- $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one();
- $ui->assign('in', $d);
+ $content = $_POST['content'];
+ if(!empty($content)){
+ $ui->assign('content', $content);
+ }else{
+ $id = _post('id');
+ $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one();
+ $ui->assign('in', $d);
+ $ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time']));
+ }
- $ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time']));
run_hook('print_invoice'); #HOOK
$ui->display('invoice-print.tpl');
break;
@@ -282,7 +287,29 @@ switch ($action) {
->offset($paginator['startpoint'])
->limit($paginator['limit'])->find_many();
}
-
+ // extract admin
+ $admins = [];
+ foreach ($d as $k) {
+ if(!empty($k['generated_by'])){
+ $admins[] = $k['generated_by'];
+ }
+ }
+ if(count($admins) > 0){
+ $adms = ORM::for_table('tbl_users')->where_in('id', $admins)->find_many();
+ unset($admins);
+ foreach($adms as $adm){
+ $tipe = $adm['user_type'];
+ if($tipe == 'Sales'){
+ $tipe = ' [S]';
+ }else if($tipe == 'Agent'){
+ $tipe = ' [A]';
+ }else{
+ $tipe == '';
+ }
+ $admins[$adm['id']] = $adm['fullname'].$tipe;
+ }
+ }
+ $ui->assign('admins', $admins);
$ui->assign('d', $d);
$ui->assign('_code', $code);
$ui->assign('paginator', $paginator);
@@ -466,6 +493,9 @@ switch ($action) {
$d->generated_by = $admin['id'];
$d->save();
}
+ if($numbervoucher == 1){
+ r2(U . 'prepaid/voucher-view/'.$d->id(), 's', Lang::T('Create Vouchers Successfully'));
+ }
r2(U . 'prepaid/voucher', 's', Lang::T('Create Vouchers Successfully'));
} else {
@@ -473,6 +503,47 @@ switch ($action) {
}
break;
+ case 'voucher-view':
+ if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
+ $voucher = ORM::for_table('tbl_voucher')->find_one($id);
+ }else{
+ $voucher = ORM::for_table('tbl_voucher')->where('generated_by', $admin['id'])->find_one($id);
+ }
+ $plan = ORM::for_table('tbl_plans')->find_one($d['id_plan']);
+ if ($voucher && $plan) {
+ $content = Lang::pad($config['CompanyName'],' ', 2)."\n";
+ $content .= Lang::pad($config['address'],' ', 2)."\n";
+ $content .= Lang::pad($config['phone'],' ', 2)."\n";
+ $content .= Lang::pad("", '=')."\n";
+ $content .= Lang::pads('ID', $voucher['id'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Code'), $voucher['code'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Plan Name'), $plan['name_plan'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Type'), $voucher['type'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($plan['price']), ' ')."\n";
+ $content .= Lang::pads(Lang::T('Sales'), $admin['fullname'].' #'.$admin['id'], ' ')."\n";
+ $content .= Lang::pad("", '=')."\n";
+ $content .= Lang::pad($config['note'],' ', 2)."\n";
+ $ui->assign('print', $content);
+ $config['printer_cols'] = 30;
+ $content = Lang::pad($config['CompanyName'],' ', 2)."\n";
+ $content .= Lang::pad($config['address'],' ', 2)."\n";
+ $content .= Lang::pad($config['phone'],' ', 2)."\n";
+ $content .= Lang::pad("", '=')."\n";
+ $content .= Lang::pads('ID', $voucher['id'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Code'), $voucher['code'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Plan Name'), $plan['name_plan'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Type'), $voucher['type'], ' ')."\n";
+ $content .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($plan['price']), ' ')."\n";
+ $content .= Lang::pads(Lang::T('Sales'), $admin['fullname'].' #'.$admin['id'], ' ')."\n";
+ $content .= Lang::pad("", '=')."\n";
+ $content .= Lang::pad($config['note'],' ', 2)."\n";
+ $ui->assign('_title', Lang::T('View'));
+ $ui->assign('wa', urlencode("```$content```"));
+ $ui->display('voucher-view.tpl');
+ }else{
+ r2(U . 'prepaid/voucher/', 'e', Lang::T('Voucher Not Found'));
+ }
+ break;
case 'voucher-delete':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));
diff --git a/system/controllers/settings.php b/system/controllers/settings.php
index 2c3108df..e4c85b2c 100644
--- a/system/controllers/settings.php
+++ b/system/controllers/settings.php
@@ -129,6 +129,7 @@ switch ($action) {
$d = ORM::for_table('tbl_users')
->where_like('username', '%' . $username . '%')
->where('root', $admin['id'])
+ ->where('id', $admin['id'])
->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->find_many();
}
@@ -145,7 +146,12 @@ switch ($action) {
])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
} else {
$paginator = Paginator::build(ORM::for_table('tbl_users'));
- $d = ORM::for_table('tbl_users')->where('root', $admin['id'])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
+ $d = ORM::for_table('tbl_users')
+ ->where_any_is([
+ ['id' => $admin['id']],
+ ['root' => $admin['id']]
+ ])
+ ->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->find_many();
}
}
@@ -255,7 +261,7 @@ switch ($action) {
$d->ward = $ward;
$d->status = 'Active';
$d->creationdate = $date_now;
- if($admin['user_type']=='Agent'){
+ if ($admin['user_type'] == 'Agent') {
$d->root = $admin['id'];
}
$d->save();
@@ -324,7 +330,7 @@ switch ($action) {
if ($d['username'] != $username) {
$c = ORM::for_table('tbl_users')->where('username', $username)->find_one();
if ($c) {
- $msg .= "$username ".Lang::T('Account already axist') . '
';
+ $msg .= "$username " . Lang::T('Account already axist') . '
';
}
}
run_hook('edit_admin'); #HOOK
diff --git a/system/lan/english.json b/system/lan/english.json
index b976ab02..ba1370ad 100644
--- a/system/lan/english.json
+++ b/system/lan/english.json
@@ -408,5 +408,8 @@
"SuperAdmin": "SuperAdmin",
"Admin": "Admin",
"Report": "Report",
- "Agent": "Agent"
+ "Agent": "Agent",
+ "Send To Customer": "Send To Customer",
+ "Code": "Code",
+ "Generated By": "Generated By"
}
\ No newline at end of file
diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl
index 651bddd1..32812082 100644
--- a/ui/ui/customers.tpl
+++ b/ui/ui/customers.tpl
@@ -4,11 +4,13 @@
+ {if $content}{$content}{else} {Lang::pad($_c['CompanyName'],' ', 2)} {Lang::pad($_c['address'],' ', 2)} {Lang::pad($_c['phone'],' ', 2)} @@ -42,6 +43,7 @@ {/if} {Lang::pad("", '=')} {Lang::pad($_c['note'],' ', 2)}+{/if} |
{Lang::pad($_c['CompanyName'],' ', 2)} +-