diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 499067a8..1cb6473a 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -102,6 +102,23 @@ class Package Mikrotik::addHotspotUser($client, $p, $c); } + if ($b['namebp'] == $p['name_plan']) { + // if it same internet plan, expired will extend + if ($p['validity_unit'] == 'Months') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + } else if ($p['validity_unit'] == 'Days') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); + } else if ($p['validity_unit'] == 'Hrs') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } else if ($p['validity_unit'] == 'Mins') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } + } + $b->customer_id = $id_customer; $b->username = $c['username']; $b->plan_id = $plan_id; @@ -182,6 +199,24 @@ class Package Mikrotik::addPpoeUser($client, $p, $c); } + + if ($b['namebp'] == $p['name_plan']) { + // if it same internet plan, expired will extend + if ($p['validity_unit'] == 'Months') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); + } else if ($p['validity_unit'] == 'Days') { + $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); + } else if ($p['validity_unit'] == 'Hrs') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } else if ($p['validity_unit'] == 'Mins') { + $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes'))); + $date_exp = $datetime[0]; + $time = $datetime[1]; + } + } + $b->customer_id = $id_customer; $b->username = $c['username']; $b->plan_id = $plan_id; diff --git a/system/controllers/voucher.php b/system/controllers/voucher.php index f40ee9a5..3f2c8993 100644 --- a/system/controllers/voucher.php +++ b/system/controllers/voucher.php @@ -28,9 +28,9 @@ switch ($action) { $v1 = ORM::for_table('tbl_voucher')->where('code', $code)->where('status', 0)->find_one(); run_hook('customer_activate_voucher'); #HOOK if ($v1) { - if (Package::rechargeUser($user, $v1['routers'], $v1['id_plan'], "Activation", "Voucher")) { + if (Package::rechargeUser($user['id'], $v1['routers'], $v1['id_plan'], "Activation", "Voucher")) { $v1->status = "1"; - $v1->user = $c['username']; + $v1->user = $user['username']; $v1->save(); r2(U . "voucher/list-activated", 's', $_L['Activation_Vouchers_Successfully']); } else {