Bugs Fixes
fix extend expiry bug
This commit is contained in:
parent
fec7780f50
commit
b7fdc90aa7
@ -195,266 +195,268 @@ class Package
|
|||||||
|
|
||||||
if ($b) {
|
if ($b) {
|
||||||
$lastExpired = Lang::dateAndTimeFormat($b['expiration'], $b['time']);
|
$lastExpired = Lang::dateAndTimeFormat($b['expiration'], $b['time']);
|
||||||
$isChangePlan = false;
|
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on' && $config['extend_expiry'] == 'yes') {
|
||||||
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
|
|
||||||
// if it same internet plan, expired will extend
|
// if it same internet plan, expired will extend
|
||||||
if ($p['validity_unit'] == 'Months') {
|
switch ($p['validity_unit']) {
|
||||||
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
|
case 'Months':
|
||||||
$time = $b['time'];
|
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
|
||||||
} else if ($p['validity_unit'] == 'Period') {
|
$time = $b['time'];
|
||||||
$date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
|
break;
|
||||||
$time = date("23:59:00");
|
case 'Period':
|
||||||
} else if ($p['validity_unit'] == 'Days') {
|
$date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
|
||||||
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days'));
|
$time = date("23:59:00");
|
||||||
$time = $b['time'];
|
break;
|
||||||
} else if ($p['validity_unit'] == 'Hrs') {
|
case 'Days':
|
||||||
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours')));
|
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days'));
|
||||||
$date_exp = $datetime[0];
|
$time = $b['time'];
|
||||||
$time = $datetime[1];
|
break;
|
||||||
} else if ($p['validity_unit'] == 'Mins') {
|
case 'Hrs':
|
||||||
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes')));
|
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours')));
|
||||||
$date_exp = $datetime[0];
|
$date_exp = $datetime[0];
|
||||||
$time = $datetime[1];
|
$time = $datetime[1];
|
||||||
|
break;
|
||||||
|
case '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];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$isChangePlan = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if ($b['status'] == 'on') {
|
$dvc = Package::getDevice($p);
|
||||||
$dvc = Package::getDevice($p);
|
if ($_app_stage != 'Demo') {
|
||||||
if ($_app_stage != 'demo') {
|
try {
|
||||||
try {
|
if (file_exists($dvc)) {
|
||||||
if (file_exists($dvc)) {
|
require_once $dvc;
|
||||||
require_once $dvc;
|
(new $p['device'])->add_customer($c, $p);
|
||||||
(new $p['device'])->add_customer($c, $p);
|
} else {
|
||||||
} else {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
new Exception(Lang::T("Devices Not Found"));
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Message::sendTelegram(
|
||||||
|
"System Error. When activate Package. You need to sync manually\n" .
|
||||||
|
"Router: $router_name\n" .
|
||||||
|
"Customer: u$c[username]\n" .
|
||||||
|
"Plan: p$p[name_plan]\n" .
|
||||||
|
$e->getMessage() . "\n" .
|
||||||
|
$e->getTraceAsString()
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Message::sendTelegram(
|
||||||
|
"System Error. When activate Package. You need to sync manually\n" .
|
||||||
|
"Router: $router_name\n" .
|
||||||
|
"Customer: u$c[username]\n" .
|
||||||
|
"Plan: p$p[name_plan]\n" .
|
||||||
|
$e->getMessage() . "\n" .
|
||||||
|
$e->getTraceAsString()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (Throwable $e) {
|
|
||||||
Message::sendTelegram(
|
|
||||||
"Sistem Error. When activate Package. You need to sync manually\n" .
|
|
||||||
"Router: $router_name\n" .
|
|
||||||
"Customer: u$c[username]\n" .
|
|
||||||
"Plan: p$p[name_plan]\n" .
|
|
||||||
$e->getMessage() . "\n" .
|
|
||||||
$e->getTraceAsString()
|
|
||||||
);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Message::sendTelegram(
|
|
||||||
"Sistem Error. When activate Package. You need to sync manually\n" .
|
|
||||||
"Router: $router_name\n" .
|
|
||||||
"Customer: u$c[username]\n" .
|
|
||||||
"Plan: p$p[name_plan]\n" .
|
|
||||||
$e->getMessage() . "\n" .
|
|
||||||
$e->getTraceAsString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//}
|
|
||||||
|
|
||||||
// if contains 'mikrotik', 'hotspot', 'pppoe', 'radius' then recharge it
|
|
||||||
if (Validator::containsKeyword($p['device'])) {
|
|
||||||
$b->customer_id = $id_customer;
|
|
||||||
$b->username = $c['username'];
|
|
||||||
$b->plan_id = $plan_id;
|
|
||||||
$b->namebp = $p['name_plan'];
|
|
||||||
$b->recharged_on = $date_only;
|
|
||||||
$b->recharged_time = $time_only;
|
|
||||||
$b->expiration = $date_exp;
|
|
||||||
$b->time = $time;
|
|
||||||
$b->status = "on";
|
|
||||||
$b->method = "$gateway - $channel";
|
|
||||||
$b->routers = $router_name;
|
|
||||||
$b->type = $p['type'];
|
|
||||||
if ($admin) {
|
|
||||||
$b->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
|
||||||
} else {
|
|
||||||
$b->admin_id = '0';
|
|
||||||
}
|
|
||||||
$b->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert table transactions
|
// if contains 'mikrotik', 'hotspot', 'pppoe', 'radius' then recharge it
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
if (Validator::containsKeyword($p['device'])) {
|
||||||
$t->invoice = $inv = "INV-" . Package::_raid();
|
$b->customer_id = $id_customer;
|
||||||
$t->username = $c['username'];
|
$b->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$b->plan_id = $plan_id;
|
||||||
if ($gateway == 'Voucher' && User::isUserVoucher($channel)) {
|
$b->namebp = $p['name_plan'];
|
||||||
//its already paid
|
$b->recharged_on = $date_only;
|
||||||
$t->price = 0;
|
$b->recharged_time = $time_only;
|
||||||
} else {
|
$b->expiration = $date_exp;
|
||||||
if ($p['validity_unit'] == 'Period') {
|
$b->time = $time;
|
||||||
// Postpaid price from field
|
$b->status = "on";
|
||||||
$add_inv = User::getAttribute("Invoice", $id_customer);
|
$b->method = "$gateway - $channel";
|
||||||
if (empty($add_inv) or $add_inv == 0) {
|
$b->routers = $router_name;
|
||||||
$t->price = $p['price'] + $add_cost;
|
$b->type = $p['type'];
|
||||||
|
if ($admin) {
|
||||||
|
$b->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
||||||
} else {
|
} else {
|
||||||
$t->price = $add_inv + $add_cost;
|
$b->admin_id = '0';
|
||||||
}
|
}
|
||||||
} else {
|
$b->save();
|
||||||
$t->price = $p['price'] + $add_cost;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$t->recharged_on = $date_only;
|
|
||||||
$t->recharged_time = $time_only;
|
|
||||||
$t->expiration = $date_exp;
|
|
||||||
$t->time = $time;
|
|
||||||
$t->method = "$gateway - $channel";
|
|
||||||
$t->routers = $router_name;
|
|
||||||
$t->note = $note;
|
|
||||||
$t->type = $p['type'];
|
|
||||||
if ($admin) {
|
|
||||||
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
|
||||||
} else {
|
|
||||||
$t->admin_id = '0';
|
|
||||||
}
|
|
||||||
$t->save();
|
|
||||||
|
|
||||||
if ($p['validity_unit'] == 'Period') {
|
// insert table transactions
|
||||||
// insert price to fields for invoice next month
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
$t->invoice = $inv = "INV-" . Package::_raid();
|
||||||
if (!$fl) {
|
$t->username = $c['username'];
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->create();
|
$t->plan_name = $p['name_plan'];
|
||||||
$fl->customer_id = $c['id'];
|
if ($gateway == 'Voucher' && User::isUserVoucher($channel)) {
|
||||||
$fl->field_name = 'Invoice';
|
//its already paid
|
||||||
$fl->field_value = $p['price'];
|
|
||||||
$fl->save();
|
|
||||||
} else {
|
|
||||||
$fl->customer_id = $c['id'];
|
|
||||||
$fl->field_value = $p['price'];
|
|
||||||
$fl->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Message::sendTelegram("#u$c[username] $c[fullname] #recharge #$p[type] \n" . $p['name_plan'] .
|
|
||||||
"\nRouter: " . $router_name .
|
|
||||||
"\nGateway: " . $gateway .
|
|
||||||
"\nChannel: " . $channel .
|
|
||||||
"\nLast Expired: $lastExpired" .
|
|
||||||
"\nNew Expired: " . Lang::dateAndTimeFormat($date_exp, $time) .
|
|
||||||
"\nPrice: " . Lang::moneyFormat($p['price'] + $add_cost) .
|
|
||||||
"\nNote:\n" . $note);
|
|
||||||
} else {
|
|
||||||
// active plan not exists
|
|
||||||
$dvc = Package::getDevice($p);
|
|
||||||
if ($_app_stage != 'demo') {
|
|
||||||
try {
|
|
||||||
if (file_exists($dvc)) {
|
|
||||||
require_once $dvc;
|
|
||||||
(new $p['device'])->add_customer($c, $p);
|
|
||||||
} else {
|
|
||||||
new Exception(Lang::T("Devices Not Found"));
|
|
||||||
}
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
Message::sendTelegram(
|
|
||||||
"Sistem Error. When activate Package. You need to sync manually\n" .
|
|
||||||
"Router: $router_name\n" .
|
|
||||||
"Customer: u$c[username]\n" .
|
|
||||||
"Plan: p$p[name_plan]\n" .
|
|
||||||
$e->getMessage() . "\n" .
|
|
||||||
$e->getTraceAsString()
|
|
||||||
);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Message::sendTelegram(
|
|
||||||
"Sistem Error. When activate Package. You need to sync manually\n" .
|
|
||||||
"Router: $router_name\n" .
|
|
||||||
"Customer: u$c[username]\n" .
|
|
||||||
"Plan: p$p[name_plan]\n" .
|
|
||||||
$e->getMessage() . "\n" .
|
|
||||||
$e->getTraceAsString()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if contains 'mikrotik', 'hotspot', 'pppoe', 'radius' then recharge it
|
|
||||||
if (Validator::containsKeyword($p['device'])) {
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
|
||||||
$d->customer_id = $id_customer;
|
|
||||||
$d->username = $c['username'];
|
|
||||||
$d->plan_id = $plan_id;
|
|
||||||
$d->namebp = $p['name_plan'];
|
|
||||||
$d->recharged_on = $date_only;
|
|
||||||
$d->recharged_time = $time_only;
|
|
||||||
$d->expiration = $date_exp;
|
|
||||||
$d->time = $time;
|
|
||||||
$d->status = "on";
|
|
||||||
$d->method = "$gateway - $channel";
|
|
||||||
$d->routers = $router_name;
|
|
||||||
$d->type = $p['type'];
|
|
||||||
if ($admin) {
|
|
||||||
$d->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
|
||||||
} else {
|
|
||||||
$d->admin_id = '0';
|
|
||||||
}
|
|
||||||
$d->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert table transactions
|
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
|
||||||
$t->invoice = $inv = "INV-" . Package::_raid();
|
|
||||||
$t->username = $c['username'];
|
|
||||||
$t->plan_name = $p['name_plan'];
|
|
||||||
if ($gateway == 'Voucher' && User::isUserVoucher($channel)) {
|
|
||||||
$t->price = 0;
|
|
||||||
// its already paid
|
|
||||||
} else {
|
|
||||||
if ($p['validity_unit'] == 'Period') {
|
|
||||||
// Postpaid price always zero for first time
|
|
||||||
$note = '';
|
|
||||||
$bills = [];
|
|
||||||
$t->price = 0;
|
$t->price = 0;
|
||||||
} else {
|
} else {
|
||||||
$t->price = $p['price'] + $add_cost;
|
switch ($p['validity_unit']) {
|
||||||
}
|
case 'Period':
|
||||||
}
|
$add_inv = User::getAttribute("Invoice", $id_customer);
|
||||||
$t->recharged_on = $date_only;
|
$t->price = (empty($add_inv) or $add_inv == 0) ? $p['price'] + $add_cost : $add_inv + $add_cost;
|
||||||
$t->recharged_time = $time_only;
|
break;
|
||||||
$t->expiration = $date_exp;
|
default:
|
||||||
$t->time = $time;
|
$t->price = $p['price'] + $add_cost;
|
||||||
$t->method = "$gateway - $channel";
|
break;
|
||||||
$t->note = $note;
|
|
||||||
$t->routers = $router_name;
|
|
||||||
if ($admin) {
|
|
||||||
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
|
||||||
} else {
|
|
||||||
$t->admin_id = '0';
|
|
||||||
}
|
|
||||||
$t->type = $p['type'];
|
|
||||||
$t->save();
|
|
||||||
|
|
||||||
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
|
||||||
// insert price to fields for invoice next month
|
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
|
||||||
if (!$fl) {
|
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->create();
|
|
||||||
$fl->customer_id = $c['id'];
|
|
||||||
$fl->field_name = 'Invoice';
|
|
||||||
// Calculating Price
|
|
||||||
$sd = new DateTime("$date_only");
|
|
||||||
$ed = new DateTime("$date_exp");
|
|
||||||
$td = $ed->diff($sd);
|
|
||||||
$fd = $td->format("%a");
|
|
||||||
$gi = ($p['price'] / (30 * $p['validity'])) * $fd;
|
|
||||||
if ($gi > $p['price']) {
|
|
||||||
$fl->field_value = $p['price'];
|
|
||||||
} else {
|
|
||||||
$fl->field_value = $gi;
|
|
||||||
}
|
}
|
||||||
$fl->save();
|
|
||||||
} else {
|
|
||||||
$fl->customer_id = $c['id'];
|
|
||||||
$fl->field_value = $p['price'];
|
|
||||||
$fl->save();
|
|
||||||
}
|
}
|
||||||
}
|
$t->recharged_on = $date_only;
|
||||||
|
$t->recharged_time = $time_only;
|
||||||
|
$t->expiration = $date_exp;
|
||||||
|
$t->time = $time;
|
||||||
|
$t->method = "$gateway - $channel";
|
||||||
|
$t->routers = $router_name;
|
||||||
|
$t->note = $note;
|
||||||
|
$t->type = $p['type'];
|
||||||
|
if ($admin) {
|
||||||
|
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
||||||
|
} else {
|
||||||
|
$t->admin_id = '0';
|
||||||
|
}
|
||||||
|
$t->save();
|
||||||
|
|
||||||
Message::sendTelegram("#u$c[username] $c[fullname] #buy #$p[type] \n" . $p['name_plan'] .
|
if ($p['validity_unit'] == 'Period') {
|
||||||
"\nRouter: " . $router_name .
|
// insert price to fields for invoice next month
|
||||||
"\nGateway: " . $gateway .
|
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
||||||
"\nChannel: " . $channel .
|
if (!$fl) {
|
||||||
"\nExpired: " . Lang::dateAndTimeFormat($date_exp, $time) .
|
$fl = ORM::for_table('tbl_customers_fields')->create();
|
||||||
"\nPrice: " . Lang::moneyFormat($p['price'] + $add_cost) .
|
$fl->customer_id = $c['id'];
|
||||||
"\nNote:\n" . $note);
|
$fl->field_name = 'Invoice';
|
||||||
|
$fl->field_value = $p['price'];
|
||||||
|
$fl->save();
|
||||||
|
} else {
|
||||||
|
$fl->customer_id = $c['id'];
|
||||||
|
$fl->field_value = $p['price'];
|
||||||
|
$fl->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Message::sendTelegram("#u$c[username] $c[fullname] #recharge #$p[type] \n" . $p['name_plan'] .
|
||||||
|
"\nRouter: " . $router_name .
|
||||||
|
"\nGateway: " . $gateway .
|
||||||
|
"\nChannel: " . $channel .
|
||||||
|
"\nLast Expired: $lastExpired" .
|
||||||
|
"\nNew Expired: " . Lang::dateAndTimeFormat($date_exp, $time) .
|
||||||
|
"\nPrice: " . Lang::moneyFormat($p['price'] + $add_cost) .
|
||||||
|
"\nNote:\n" . $note);
|
||||||
|
} else {
|
||||||
|
// active plan not exists
|
||||||
|
$dvc = Package::getDevice($p);
|
||||||
|
if ($_app_stage != 'Demo') {
|
||||||
|
try {
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
(new $p['device'])->add_customer($c, $p);
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Message::sendTelegram(
|
||||||
|
"System Error. When activate Package. You need to sync manually\n" .
|
||||||
|
"Router: $router_name\n" .
|
||||||
|
"Customer: u$c[username]\n" .
|
||||||
|
"Plan: p$p[name_plan]\n" .
|
||||||
|
$e->getMessage() . "\n" .
|
||||||
|
$e->getTraceAsString()
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Message::sendTelegram(
|
||||||
|
"System Error. When activate Package. You need to sync manually\n" .
|
||||||
|
"Router: $router_name\n" .
|
||||||
|
"Customer: u$c[username]\n" .
|
||||||
|
"Plan: p$p[name_plan]\n" .
|
||||||
|
$e->getMessage() . "\n" .
|
||||||
|
$e->getTraceAsString()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if contains 'mikrotik', 'hotspot', 'pppoe', 'radius' then recharge it
|
||||||
|
if (Validator::containsKeyword($p['device'])) {
|
||||||
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
|
$d->customer_id = $id_customer;
|
||||||
|
$d->username = $c['username'];
|
||||||
|
$d->plan_id = $plan_id;
|
||||||
|
$d->namebp = $p['name_plan'];
|
||||||
|
$d->recharged_on = $date_only;
|
||||||
|
$d->recharged_time = $time_only;
|
||||||
|
$d->expiration = $date_exp;
|
||||||
|
$d->time = $time;
|
||||||
|
$d->status = "on";
|
||||||
|
$d->method = "$gateway - $channel";
|
||||||
|
$d->routers = $router_name;
|
||||||
|
$d->type = $p['type'];
|
||||||
|
if ($admin) {
|
||||||
|
$d->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
||||||
|
} else {
|
||||||
|
$d->admin_id = '0';
|
||||||
|
}
|
||||||
|
$d->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert table transactions
|
||||||
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
|
$t->invoice = $inv = "INV-" . Package::_raid();
|
||||||
|
$t->username = $c['username'];
|
||||||
|
$t->plan_name = $p['name_plan'];
|
||||||
|
if ($gateway == 'Voucher' && User::isUserVoucher($channel)) {
|
||||||
|
$t->price = 0;
|
||||||
|
// its already paid
|
||||||
|
} else {
|
||||||
|
switch ($p['validity_unit']) {
|
||||||
|
case 'Period':
|
||||||
|
$note = '';
|
||||||
|
$bills = [];
|
||||||
|
$t->price = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$t->price = $p['price'] + $add_cost;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$t->recharged_on = $date_only;
|
||||||
|
$t->recharged_time = $time_only;
|
||||||
|
$t->expiration = $date_exp;
|
||||||
|
$t->time = $time;
|
||||||
|
$t->method = "$gateway - $channel";
|
||||||
|
$t->note = $note;
|
||||||
|
$t->routers = $router_name;
|
||||||
|
if ($admin) {
|
||||||
|
$t->admin_id = ($admin['id']) ? $admin['id'] : '0';
|
||||||
|
} else {
|
||||||
|
$t->admin_id = '0';
|
||||||
|
}
|
||||||
|
$t->type = $p['type'];
|
||||||
|
$t->save();
|
||||||
|
|
||||||
|
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
||||||
|
// insert price to fields for invoice next month
|
||||||
|
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
||||||
|
if (!$fl) {
|
||||||
|
$fl = ORM::for_table('tbl_customers_fields')->create();
|
||||||
|
$fl->customer_id = $c['id'];
|
||||||
|
$fl->field_name = 'Invoice';
|
||||||
|
// Calculating Price
|
||||||
|
$sd = new DateTime("$date_only");
|
||||||
|
$ed = new DateTime("$date_exp");
|
||||||
|
$td = $ed->diff($sd);
|
||||||
|
$fd = $td->format("%a");
|
||||||
|
$gi = ($p['price'] / (30 * $p['validity'])) * $fd;
|
||||||
|
if ($gi > $p['price']) {
|
||||||
|
$fl->field_value = $p['price'];
|
||||||
|
} else {
|
||||||
|
$fl->field_value = $gi;
|
||||||
|
}
|
||||||
|
$fl->save();
|
||||||
|
} else {
|
||||||
|
$fl->customer_id = $c['id'];
|
||||||
|
$fl->field_value = $p['price'];
|
||||||
|
$fl->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Message::sendTelegram("#u$c[username] $c[fullname] #buy #$p[type] \n" . $p['name_plan'] .
|
||||||
|
"\nRouter: " . $router_name .
|
||||||
|
"\nGateway: " . $gateway .
|
||||||
|
"\nChannel: " . $channel .
|
||||||
|
"\nExpired: " . Lang::dateAndTimeFormat($date_exp, $time) .
|
||||||
|
"\nPrice: " . Lang::moneyFormat($p['price'] + $add_cost) .
|
||||||
|
"\nNote:\n" . $note);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($bills) && count($bills) > 0) {
|
if (is_array($bills) && count($bills) > 0) {
|
||||||
@ -525,7 +527,7 @@ class Package
|
|||||||
return $t->id();
|
return $t->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function rechargeCustomBalance($customer, $plan, $gateway, $channel, $note = '')
|
public static function rechargeCustomBalance($customer, $plan, $gateway, $channel, $note = '')
|
||||||
{
|
{
|
||||||
global $admin, $config;
|
global $admin, $config;
|
||||||
$plan = ORM::for_table('tbl_payment_gateway')
|
$plan = ORM::for_table('tbl_payment_gateway')
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
<option value="enable" {if $_c['new_version_notify']=='enable' }selected="selected" {/if}>
|
<option value="enable" {if $_c['new_version_notify']=='enable' }selected="selected" {/if}>
|
||||||
{Lang::T('Enabled')}
|
{Lang::T('Enabled')}
|
||||||
</option>
|
</option>
|
||||||
<option value="disable" {if $_c['new_version_notify']=='disable'
|
<option value="disable" {if $_c['new_version_notify']=='disable' }selected="selected" {/if}>
|
||||||
}selected="selected" {/if}>{Lang::T('Disabled')}
|
{Lang::T('Disabled')}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block col-md-4">{Lang::T('This is to notify you when new updates is
|
<p class="help-block col-md-4">{Lang::T('This is to notify you when new updates is
|
||||||
available')}
|
available')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="help-block col-md-4">
|
<p class="help-block col-md-4">
|
||||||
{Lang::T('If enabled, the system will notify Admin when router goes Offline, If admin
|
{Lang::T('If enabled, the system will notify Admin when router goes Offline, If admin
|
||||||
have 10 or more router and many customers, it will get overlapping, you can disabled')}
|
have 10 or more router and many customers, it will get overlapping, you can disabled')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -118,7 +118,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="help-block col-md-4">
|
<p class="help-block col-md-4">
|
||||||
{Lang::T('Hotspot Authentication Method. Make sure you have changed your hotspot login
|
{Lang::T('Hotspot Authentication Method. Make sure you have changed your hotspot login
|
||||||
page.')}<br><a href="https://github.com/agstrxyz/phpnuxbill-login-hotspot"
|
page.')}<br><a href="https://github.com/agstrxyz/phpnuxbill-login-hotspot"
|
||||||
target="_blank">Download
|
target="_blank">Download
|
||||||
phpnuxbill-login-hotspot</a>
|
phpnuxbill-login-hotspot</a>
|
||||||
</p>
|
</p>
|
||||||
@ -139,6 +139,19 @@
|
|||||||
{Lang::T('This will show is Customer currently is online or not')}
|
{Lang::T('This will show is Customer currently is online or not')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label">{Lang::T('Extend Package Expiry')}</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<select name="extend_expiry" id="extend_expiry" class="form-control">
|
||||||
|
<option value="yes" {if $_c['extend_expiry']!='no' }selected="selected" {/if}>
|
||||||
|
{Lang::T('Yes')}</option>
|
||||||
|
<option value="no" {if $_c['extend_expiry']=='no' }selected="selected" {/if}>
|
||||||
|
{Lang::T('No')}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="help-block col-md-4">
|
||||||
|
<small> {Lang::T('If user buy same internet plan, expiry date will extend')}</small></p>
|
||||||
|
</div>
|
||||||
<div class="form-group has-error">
|
<div class="form-group has-error">
|
||||||
<label class="col-md-3 control-label">{Lang::T('Allow Balance custom amount')}</label>
|
<label class="col-md-3 control-label">{Lang::T('Allow Balance custom amount')}</label>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
@ -153,7 +166,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="help-block col-md-4">
|
<p class="help-block col-md-4">
|
||||||
{Lang::T('Allow Customer buy balance with any amount')}
|
{Lang::T('Allow Customer buy balance with any amount')}
|
||||||
<br>*Maybe still have bug
|
<br>*Please report any issue or bugs
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -172,7 +185,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
var sectionTimeoutCheckbox = document.getElementById('enable_session_timeout');
|
var sectionTimeoutCheckbox = document.getElementById('enable_session_timeout');
|
||||||
var timeoutDurationInput = document.getElementById('timeout_duration_input');
|
var timeoutDurationInput = document.getElementById('timeout_duration_input');
|
||||||
var timeoutDurationField = document.getElementById('session_timeout_duration');
|
var timeoutDurationField = document.getElementById('session_timeout_duration');
|
||||||
@ -182,7 +195,7 @@
|
|||||||
timeoutDurationField.required = true;
|
timeoutDurationField.required = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionTimeoutCheckbox.addEventListener('change', function() {
|
sectionTimeoutCheckbox.addEventListener('change', function () {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
timeoutDurationInput.style.display = 'block';
|
timeoutDurationInput.style.display = 'block';
|
||||||
timeoutDurationField.required = true;
|
timeoutDurationField.required = true;
|
||||||
@ -192,9 +205,9 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('form').addEventListener('submit', function(event) {
|
document.querySelector('form').addEventListener('submit', function (event) {
|
||||||
if (sectionTimeoutCheckbox.checked && (!timeoutDurationField.value || isNaN(
|
if (sectionTimeoutCheckbox.checked && (!timeoutDurationField.value || isNaN(
|
||||||
timeoutDurationField.value))) {
|
timeoutDurationField.value))) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
alert('Please enter a valid session timeout duration.');
|
alert('Please enter a valid session timeout duration.');
|
||||||
timeoutDurationField.focus();
|
timeoutDurationField.focus();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user