fix change plan when customer plan not active
This commit is contained in:
parent
1fbd393fa3
commit
f08d8e127e
@ -322,11 +322,12 @@ switch ($action) {
|
|||||||
$d->status = 'on';
|
$d->status = 'on';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($d['status'] == 'on' && $oldPlanID != $id_plan) {
|
if ($oldPlanID != $id_plan) {
|
||||||
$d->plan_id = $newPlan['id'];
|
$d->plan_id = $newPlan['id'];
|
||||||
$d->namebp = $newPlan['name_plan'];
|
$d->namebp = $newPlan['name_plan'];
|
||||||
$customer = User::_info($d['customer_id']);
|
$customer = User::_info($d['customer_id']);
|
||||||
//remove from old plan
|
//remove from old plan
|
||||||
|
if ($d['status'] == 'on') {
|
||||||
$p = ORM::for_table('tbl_plans')->find_one($oldPlanID);
|
$p = ORM::for_table('tbl_plans')->find_one($oldPlanID);
|
||||||
$dvc = Package::getDevice($p);
|
$dvc = Package::getDevice($p);
|
||||||
if ($_app_stage != 'demo') {
|
if ($_app_stage != 'demo') {
|
||||||
@ -348,6 +349,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$d->save();
|
$d->save();
|
||||||
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']);
|
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['namebp'] . '][' . Lang::moneyFormat($p['price']) . ']', $admin['user_type'], $admin['id']);
|
||||||
r2(U . 'plan/list', 's', Lang::T('Data Updated Successfully'));
|
r2(U . 'plan/list', 's', Lang::T('Data Updated Successfully'));
|
||||||
@ -393,9 +395,9 @@ switch ($action) {
|
|||||||
$ui->assign('customers', ORM::for_table('tbl_voucher')->distinct()->select("user")->whereNotEqual("user", '0')->findArray());
|
$ui->assign('customers', ORM::for_table('tbl_voucher')->distinct()->select("user")->whereNotEqual("user", '0')->findArray());
|
||||||
// option plans
|
// option plans
|
||||||
$plns = ORM::for_table('tbl_voucher')->distinct()->select("id_plan")->findArray();
|
$plns = ORM::for_table('tbl_voucher')->distinct()->select("id_plan")->findArray();
|
||||||
if(count($plns)>0){
|
if (count($plns) > 0) {
|
||||||
$ui->assign('plans', ORM::for_table('tbl_plans')->selects(["id", 'name_plan'])->where_in('id', array_column($plns, 'id_plan'))->findArray());
|
$ui->assign('plans', ORM::for_table('tbl_plans')->selects(["id", 'name_plan'])->where_in('id', array_column($plns, 'id_plan'))->findArray());
|
||||||
}else{
|
} else {
|
||||||
$ui->assign('plans', []);
|
$ui->assign('plans', []);
|
||||||
}
|
}
|
||||||
$ui->assign('routers', array_column(ORM::for_table('tbl_voucher')->distinct()->select("routers")->findArray(), 'routers'));
|
$ui->assign('routers', array_column(ORM::for_table('tbl_voucher')->distinct()->select("routers")->findArray(), 'routers'));
|
||||||
@ -873,15 +875,15 @@ switch ($action) {
|
|||||||
|
|
||||||
$plns = ORM::for_table('tbl_user_recharges')->distinct()->select("plan_id")->findArray();
|
$plns = ORM::for_table('tbl_user_recharges')->distinct()->select("plan_id")->findArray();
|
||||||
$ids = array_column($plns, 'plan_id');
|
$ids = array_column($plns, 'plan_id');
|
||||||
if(count($ids)){
|
if (count($ids)) {
|
||||||
$ui->assign('plans', ORM::for_table('tbl_plans')->select("id")->select('name_plan')->where_id_in($ids)->findArray());
|
$ui->assign('plans', ORM::for_table('tbl_plans')->select("id")->select('name_plan')->where_id_in($ids)->findArray());
|
||||||
}else{
|
} else {
|
||||||
$ui->assign('plans', []);
|
$ui->assign('plans', []);
|
||||||
}
|
}
|
||||||
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');
|
$query = ORM::for_table('tbl_user_recharges')->order_by_desc('id');
|
||||||
|
|
||||||
if ($search != '') {
|
if ($search != '') {
|
||||||
$query->where_like("username","%$search%");
|
$query->where_like("username", "%$search%");
|
||||||
}
|
}
|
||||||
if (!empty($router)) {
|
if (!empty($router)) {
|
||||||
$query->where('routers', $router);
|
$query->where('routers', $router);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user