don't delete customer when plan not change

This commit is contained in:
Ibnu Maksum 2024-04-29 13:18:07 +07:00
parent 4c1e5da601
commit f7deb828ac
No known key found for this signature in database
GPG key ID: 7FC82848810579E5

View file

@ -185,9 +185,12 @@ class Package
$date_exp = $datetime[0];
$time = $datetime[1];
}
$isChangePlan = false;
if ($p['type'] == 'Hotspot') {
if ($b) {
if($plan_id!=$b['plan_id']){
$isChangePlan = true;
}
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
// if it same internet plan, expired will extend
if ($p['validity_unit'] == 'Months') {
@ -210,13 +213,15 @@ class Package
}
}
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time");
} else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::addHotspotUser($client, $p, $c);
if($isChangePlan){
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time");
} else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::addHotspotUser($client, $p, $c);
}
}
$b->customer_id = $id_customer;
@ -384,6 +389,9 @@ class Package
} else {
if ($b) {
if($plan_id!=$b['plan_id']){
$isChangePlan = true;
}
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
// if it same internet plan, expired will extend
if ($p['validity_unit'] == 'Months') {
@ -406,13 +414,15 @@ class Package
}
}
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time");
} else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
Mikrotik::addPpoeUser($client, $p, $c);
if($isChangePlan){
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time");
} else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
Mikrotik::addPpoeUser($client, $p, $c);
}
}
$b->customer_id = $id_customer;