Fix Voucher Permission
This commit is contained in:
parent
8047ed9555
commit
ae83cbeef4
@ -18,12 +18,16 @@ class Paginator
|
|||||||
$page = (int)(empty(_get('p')) ? 1 : _get('p'));
|
$page = (int)(empty(_get('p')) ? 1 : _get('p'));
|
||||||
$pagination = "";
|
$pagination = "";
|
||||||
foreach($colVal as $k=>$v) {
|
foreach($colVal as $k=>$v) {
|
||||||
if(strpos($v,'%') === false) {
|
if(!is_array($v) && strpos($v,'%') === false) {
|
||||||
$table = $table->where($k, $v);
|
$table = $table->where($k, $v);
|
||||||
|
}else{
|
||||||
|
if(is_array($v)){
|
||||||
|
$table = $table->where_in($k, $v);
|
||||||
}else{
|
}else{
|
||||||
$table = $table->where_like($k, $v);
|
$table = $table->where_like($k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$totalReq = $table->count();
|
$totalReq = $table->count();
|
||||||
$page = ($page == 0 ? 1 : $page);
|
$page = ($page == 0 ? 1 : $page);
|
||||||
$next = $page + 1;
|
$next = $page + 1;
|
||||||
|
@ -273,24 +273,55 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'voucher':
|
case 'voucher':
|
||||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/voucher.js"></script>');
|
|
||||||
$ui->assign('_title', Lang::T('Prepaid Vouchers'));
|
$ui->assign('_title', Lang::T('Prepaid Vouchers'));
|
||||||
$code = _post('code');
|
$limit = 10;
|
||||||
if ($code != '') {
|
$page = _get('p', 0);
|
||||||
$ui->assign('code', $code);
|
$pageNow = $page * $limit;
|
||||||
$paginator = Paginator::build(ORM::for_table('tbl_voucher'), ['code' => '%' . $code . '%'], $code);
|
$search = _req('search');
|
||||||
|
if ($search != '') {
|
||||||
|
if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
$d = ORM::for_table('tbl_plans')->where('enabled', '1')
|
$d = ORM::for_table('tbl_plans')->where('enabled', '1')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where_like('tbl_voucher.code', '%' . $code . '%')
|
->where_like('tbl_voucher.code', '%' . $search . '%')
|
||||||
->offset($paginator['startpoint'])
|
->offset($pageNow)
|
||||||
->limit($paginator['limit'])
|
->limit($limit)
|
||||||
->find_many();
|
->findArray();
|
||||||
|
} else if ($admin['user_type'] == 'Agent') {
|
||||||
|
$sales = [];
|
||||||
|
$sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray();
|
||||||
|
foreach ($sls as $s) {
|
||||||
|
$sales[] = $s['id'];
|
||||||
|
}
|
||||||
|
$sales[] = $admin['id'];
|
||||||
|
$d = ORM::for_table('tbl_plans')
|
||||||
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
|
->where_in('generated_by', $sales)
|
||||||
|
->where_like('tbl_voucher.code', '%' . $search . '%')
|
||||||
|
->offset($pageNow)
|
||||||
|
->limit($limit)
|
||||||
|
->findArray();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$paginator = Paginator::build(ORM::for_table('tbl_voucher'));
|
if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
$d = ORM::for_table('tbl_plans')->where('enabled', '1')
|
$d = ORM::for_table('tbl_plans')->where('enabled', '1')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->offset($paginator['startpoint'])
|
->offset($pageNow)
|
||||||
->limit($paginator['limit'])->find_many();
|
->limit($limit)
|
||||||
|
->findArray();
|
||||||
|
} else if ($admin['user_type'] == 'Agent') {
|
||||||
|
$sales = [];
|
||||||
|
$sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray();
|
||||||
|
foreach ($sls as $s) {
|
||||||
|
$sales[] = $s['id'];
|
||||||
|
}
|
||||||
|
$sales[] = $admin['id'];
|
||||||
|
$d = ORM::for_table('tbl_plans')
|
||||||
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
|
->where_in('generated_by', $sales)
|
||||||
|
->offset($pageNow)
|
||||||
|
->limit($limit)
|
||||||
|
->findArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// extract admin
|
// extract admin
|
||||||
$admins = [];
|
$admins = [];
|
||||||
@ -316,8 +347,8 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
$ui->assign('admins', $admins);
|
$ui->assign('admins', $admins);
|
||||||
$ui->assign('d', $d);
|
$ui->assign('d', $d);
|
||||||
$ui->assign('_code', $code);
|
$ui->assign('search', $search);
|
||||||
$ui->assign('paginator', $paginator);
|
$ui->assign('page', $page);
|
||||||
run_hook('view_list_voucher'); #HOOK
|
run_hook('view_list_voucher'); #HOOK
|
||||||
$ui->display('voucher.tpl');
|
$ui->display('voucher.tpl');
|
||||||
break;
|
break;
|
||||||
@ -371,48 +402,53 @@ switch ($action) {
|
|||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->where('tbl_plans.id', $planid)
|
->where('tbl_plans.id', $planid)
|
||||||
->where_gt('tbl_voucher.id', $from_id)
|
->where_gt('tbl_voucher.id', $from_id)
|
||||||
->limit($limit)
|
->limit($limit);
|
||||||
->find_many();
|
|
||||||
$vc = ORM::for_table('tbl_plans')
|
$vc = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->where('tbl_plans.id', $planid)
|
->where('tbl_plans.id', $planid)
|
||||||
->where_gt('tbl_voucher.id', $from_id)
|
->where_gt('tbl_voucher.id', $from_id);
|
||||||
->count();
|
|
||||||
} else if ($from_id == 0 && $planid > 0) {
|
} else if ($from_id == 0 && $planid > 0) {
|
||||||
$v = ORM::for_table('tbl_plans')
|
$v = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->where('tbl_plans.id', $planid)
|
->where('tbl_plans.id', $planid)
|
||||||
->limit($limit)
|
->limit($limit);
|
||||||
->find_many();
|
|
||||||
$vc = ORM::for_table('tbl_plans')
|
$vc = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->where('tbl_plans.id', $planid)
|
->where('tbl_plans.id', $planid);
|
||||||
->count();
|
|
||||||
} else if ($from_id > 0 && $planid == 0) {
|
} else if ($from_id > 0 && $planid == 0) {
|
||||||
$v = ORM::for_table('tbl_plans')
|
$v = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->where_gt('tbl_voucher.id', $from_id)
|
->where_gt('tbl_voucher.id', $from_id)
|
||||||
->limit($limit)
|
->limit($limit);
|
||||||
->find_many();
|
|
||||||
$vc = ORM::for_table('tbl_plans')
|
$vc = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->where_gt('tbl_voucher.id', $from_id)
|
->where_gt('tbl_voucher.id', $from_id);
|
||||||
->count();
|
|
||||||
} else {
|
} else {
|
||||||
$v = ORM::for_table('tbl_plans')
|
$v = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0')
|
||||||
->limit($limit)
|
->limit($limit);
|
||||||
->find_many();
|
|
||||||
$vc = ORM::for_table('tbl_plans')
|
$vc = ORM::for_table('tbl_plans')
|
||||||
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
->join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
|
||||||
->where('tbl_voucher.status', '0')
|
->where('tbl_voucher.status', '0');
|
||||||
->count();
|
}
|
||||||
|
if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
|
$v = $v->find_many();
|
||||||
|
$vc = $vc->count();
|
||||||
|
} else {
|
||||||
|
$sales = [];
|
||||||
|
$sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray();
|
||||||
|
foreach ($sls as $s) {
|
||||||
|
$sales[] = $s['id'];
|
||||||
|
}
|
||||||
|
$sales[] = $admin['id'];
|
||||||
|
$v = $v->where_in('generated_by', $sales)->find_many();
|
||||||
|
$vc = $vc->where_in('generated_by', $sales)->count();
|
||||||
}
|
}
|
||||||
$template = file_get_contents("pages/Voucher.html");
|
$template = file_get_contents("pages/Voucher.html");
|
||||||
$template = str_replace('[[company_name]]', $config['CompanyName'], $template);
|
$template = str_replace('[[company_name]]', $config['CompanyName'], $template);
|
||||||
@ -509,10 +545,24 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'voucher-view':
|
case 'voucher-view':
|
||||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
$id = $routes[2];
|
||||||
|
if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
$voucher = ORM::for_table('tbl_voucher')->find_one($id);
|
$voucher = ORM::for_table('tbl_voucher')->find_one($id);
|
||||||
} else {
|
} else {
|
||||||
$voucher = ORM::for_table('tbl_voucher')->where('generated_by', $admin['id'])->find_one($id);
|
$sales = [];
|
||||||
|
$sls = ORM::for_table('tbl_users')->select('id')->where('root', $admin['id'])->findArray();
|
||||||
|
foreach ($sls as $s) {
|
||||||
|
$sales[] = $s['id'];
|
||||||
|
}
|
||||||
|
$sales[] = $admin['id'];
|
||||||
|
$voucher = ORM::for_table('tbl_voucher')
|
||||||
|
->find_one($id);
|
||||||
|
if (!in_array($voucher['generated_by'], $sales)) {
|
||||||
|
r2(U . 'prepaid/voucher/', 'e', Lang::T('Voucher Not Found'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$voucher) {
|
||||||
|
r2(U . 'prepaid/voucher/', 'e', Lang::T('Voucher Not Found'));
|
||||||
}
|
}
|
||||||
$plan = ORM::for_table('tbl_plans')->find_one($d['id_plan']);
|
$plan = ORM::for_table('tbl_plans')->find_one($d['id_plan']);
|
||||||
if ($voucher && $plan) {
|
if ($voucher && $plan) {
|
||||||
|
@ -425,5 +425,7 @@
|
|||||||
"Add_User": "Add User",
|
"Add_User": "Add User",
|
||||||
"Send_Notification": "Send Notification",
|
"Send_Notification": "Send Notification",
|
||||||
"Code": "Code",
|
"Code": "Code",
|
||||||
"Send_To_Customer": "Send To Customer"
|
"Send_To_Customer": "Send To Customer",
|
||||||
|
"Prev": "Prev",
|
||||||
|
"Voucher_Not_Found": "Voucher Not Found"
|
||||||
}
|
}
|
@ -41,6 +41,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 40em) {
|
||||||
|
thead th:not(:first-child) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
td,
|
||||||
|
th {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
td[data-th]:before {
|
||||||
|
content: attr(data-th);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.text1line {
|
.text1line {
|
||||||
display: block;
|
display: block;
|
||||||
/* or inline-block */
|
/* or inline-block */
|
||||||
|
2
ui/ui/styles/modern-AdminLTE.min.css
vendored
2
ui/ui/styles/modern-AdminLTE.min.css
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user