Discount price requested by Fiberwan

This commit is contained in:
Ibnu Maksum
2024-09-23 16:43:24 +07:00
parent 8e3a16a123
commit aa0432df38
14 changed files with 749 additions and 622 deletions

View File

@ -83,9 +83,9 @@ switch ($action) {
$bws = ORM::for_table('tbl_plans')->distinct()->select("id_bw")->where('tbl_plans.type', 'Hotspot')->findArray();
$ids = array_column($bws, 'id_bw');
if(count($ids)){
if (count($ids)) {
$ui->assign('bws', ORM::for_table('tbl_bandwidth')->select("id")->select('name_bw')->where_id_in($ids)->findArray());
}else{
} else {
$ui->assign('bws', []);
}
$ui->assign('type2s', ORM::for_table('tbl_plans')->getEnum("plan_type"));
@ -321,6 +321,7 @@ switch ($action) {
$id_bw = _post('id_bw');
$typebp = _post('typebp');
$price = _post('price');
$price_old = _post('price_old');
$limit_type = _post('limit_type');
$time_limit = _post('time_limit');
$time_unit = _post('time_unit');
@ -353,6 +354,11 @@ switch ($action) {
} else {
$msg .= Lang::T('Data Not Found') . '<br>';
}
if ($price_old <= $price) {
$price_old = '';
}
run_hook('edit_plan'); #HOOK
if ($msg == '') {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
@ -378,6 +384,7 @@ switch ($action) {
$d->name_plan = $name;
$d->id_bw = $id_bw;
$d->price = $price; // Set price with or without tax based on configuration
$d->price_old = $price_old;
$d->typebp = $typebp;
$d->limit_type = $limit_type;
$d->time_limit = $time_limit;
@ -453,9 +460,9 @@ switch ($action) {
$bws = ORM::for_table('tbl_plans')->distinct()->select("id_bw")->where('tbl_plans.type', 'PPPOE')->findArray();
$ids = array_column($bws, 'id_bw');
if(count($ids)){
if (count($ids)) {
$ui->assign('bws', ORM::for_table('tbl_bandwidth')->select("id")->select('name_bw')->where_id_in($ids)->findArray());
}else{
} else {
$ui->assign('bws', []);
}
$ui->assign('type2s', ORM::for_table('tbl_plans')->getEnum("plan_type"));
@ -705,6 +712,7 @@ switch ($action) {
$name = _post('name_plan');
$id_bw = _post('id_bw');
$price = _post('price');
$price_old = _post('price_old');
$validity = _post('validity');
$validity_unit = _post('validity_unit');
$routers = _post('routers');
@ -728,6 +736,10 @@ switch ($action) {
$msg .= Lang::T('All field is required') . '<br>';
}
if ($price_old <= $price) {
$price_old = '';
}
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
$old = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
if ($d) {
@ -758,6 +770,7 @@ switch ($action) {
$d->name_plan = $name;
$d->id_bw = $id_bw;
$d->price = $price;
$d->price_old = $price_old;
$d->plan_type = $plan_type;
$d->validity = $validity;
$d->validity_unit = $validity_unit;
@ -835,6 +848,7 @@ switch ($action) {
$id = _post('id');
$name = _post('name');
$price = _post('price');
$price_old = _post('price_old');
$enabled = _post('enabled');
$prepaid = _post('prepaid');
@ -851,11 +865,15 @@ switch ($action) {
} else {
$msg .= Lang::T('Data Not Found') . '<br>';
}
if ($price_old <= $price) {
$price_old = '';
}
run_hook('edit_ppoe'); #HOOK
if ($msg == '') {
$d->name_plan = $name;
$d->price = $price;
$d->enabled = $enabled;
$d->price_old = $price_old;
$d->prepaid = 'yes';
$d->save();
@ -935,9 +953,9 @@ switch ($action) {
$bws = ORM::for_table('tbl_plans')->distinct()->select("id_bw")->where('tbl_plans.type', 'VPN')->findArray();
$ids = array_column($bws, 'id_bw');
if(count($ids)){
if (count($ids)) {
$ui->assign('bws', ORM::for_table('tbl_bandwidth')->select("id")->select('name_bw')->where_id_in($ids)->findArray());
}else{
} else {
$ui->assign('bws', []);
}
$ui->assign('type2s', ORM::for_table('tbl_plans')->getEnum("plan_type"));
@ -1187,6 +1205,7 @@ switch ($action) {
$name = _post('name_plan');
$id_bw = _post('id_bw');
$price = _post('price');
$price_old = _post('price_old');
$validity = _post('validity');
$validity_unit = _post('validity_unit');
$routers = _post('routers');
@ -1210,6 +1229,10 @@ switch ($action) {
$msg .= Lang::T('All field is required') . '<br>';
}
if($price_old<=$price){
$price_old = '';
}
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
$old = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
if ($d) {
@ -1240,6 +1263,7 @@ switch ($action) {
$d->name_plan = $name;
$d->id_bw = $id_bw;
$d->price = $price;
$d->price_old = $price_old;
$d->plan_type = $plan_type;
$d->validity = $validity;
$d->validity_unit = $validity_unit;