diff --git a/.gitignore b/.gitignore
index 3ee86c36..a1d15e77 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,4 +38,5 @@ system/lan/**
!system/lan/spanish.json
!system/lan/turkish.json
!system/lan/english.json
-!system/lan/country.json
\ No newline at end of file
+!system/lan/country.json
+*.zip
diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql
index 6b811b39..24439d2d 100644
--- a/install/phpnuxbill.sql
+++ b/install/phpnuxbill.sql
@@ -29,6 +29,7 @@ CREATE TABLE `tbl_customers` (
`coordinates` VARCHAR(50) NOT NULL DEFAULT '6.465422, 3.406448' COMMENT 'Latitude and Longitude coordinates',
`balance` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT 'For Money Deposit',
`service_type` ENUM('Hotspot','PPPoE','Others') DEFAULT 'Others' COMMENT 'For selecting user type',
+ `account_type` ENUM('Business', 'Personal') DEFAULT 'Personal' COMMENT 'For selecting account type',
`auto_renewal` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Auto renewall using balance',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_login` datetime DEFAULT NULL
@@ -80,26 +81,27 @@ CREATE TABLE `tbl_payment_gateway` (
DROP TABLE IF EXISTS `tbl_plans`;
CREATE TABLE `tbl_plans` (
- `id` int(10) NOT NULL,
- `name_plan` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
- `id_bw` int(10) NOT NULL,
- `price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
- `type` enum('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
- `typebp` enum('Unlimited','Limited') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
- `limit_type` enum('Time_Limit','Data_Limit','Both_Limit') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
- `time_limit` int(10) UNSIGNED DEFAULT NULL,
- `time_unit` enum('Mins','Hrs') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
- `data_limit` int(10) UNSIGNED DEFAULT NULL,
- `data_unit` enum('MB','GB') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
- `validity` int(10) NOT NULL,
- `validity_unit` enum('Mins','Hrs','Days','Months','Period') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
- `shared_users` int(10) DEFAULT NULL,
- `routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
- `is_radius` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 is radius',
- `pool` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
- `pool_expired` varchar(40) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
- `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled\r\n',
- `allow_purchase` enum('yes','no') DEFAULT 'yes' COMMENT 'allow to show package in buy package page'
+ `id` int(10) NOT NULL,
+ `name_plan` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `id_bw` int(10) NOT NULL,
+ `price` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `type` enum('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `typebp` enum('Unlimited','Limited') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `limit_type` enum('Time_Limit','Data_Limit','Both_Limit') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `time_limit` int(10) UNSIGNED DEFAULT NULL,
+ `time_unit` enum('Mins','Hrs') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `data_limit` int(10) UNSIGNED DEFAULT NULL,
+ `data_unit` enum('MB','GB') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `validity` int(10) NOT NULL,
+ `validity_unit` enum('Mins','Hrs','Days','Months','Period') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `shared_users` int(10) DEFAULT NULL,
+ `routers` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `is_radius` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1 is radius',
+ `pool` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `pool_expired` varchar(40) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 disabled',
+ `allow_purchase` enum('yes','no') DEFAULT 'yes' COMMENT 'allow to show package in buy package page',
+ `plan_type` ENUM('Business', 'Personal') DEFAULT 'Personal' COMMENT 'For switching plan according to user type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
DROP TABLE IF EXISTS `tbl_pool`;
@@ -318,4 +320,4 @@ ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `
ALTER TABLE `tbl_transactions` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;
ALTER TABLE `tbl_user_recharges` ADD `admin_id` INT NOT NULL DEFAULT '1' AFTER `type`;
ALTER TABLE `tbl_plans` CHANGE `allow_purchase` `prepaid` ENUM('yes','no') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'yes' COMMENT 'is prepaid';
-ALTER TABLE `tbl_transactions` ADD `note` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'for note' AFTER `type`;
\ No newline at end of file
+ALTER TABLE `tbl_transactions` ADD `note` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'for note' AFTER `type`;
diff --git a/phpnuxbill.zip b/phpnuxbill.zip
new file mode 100644
index 00000000..eab17410
Binary files /dev/null and b/phpnuxbill.zip differ
diff --git a/system/controllers/customers.php b/system/controllers/customers.php
index 151ace8a..7baecae0 100644
--- a/system/controllers/customers.php
+++ b/system/controllers/customers.php
@@ -12,7 +12,7 @@ $ui->assign('_system_menu', 'customers');
$action = $routes['1'];
$ui->assign('_admin', $admin);
-if (empty($action)) {
+if (empty ($action)) {
$action = 'list';
}
@@ -96,8 +96,8 @@ switch ($action) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
- $id_customer = $routes['2'];
- $plan_id = $routes['3'];
+ $id_customer = $routes['2'];
+ $plan_id = $routes['3'];
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('plan_id', $plan_id)->find_one();
if ($b) {
$gateway = 'Recharge';
@@ -138,8 +138,8 @@ switch ($action) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
- $id_customer = $routes['2'];
- $plan_id = $routes['3'];
+ $id_customer = $routes['2'];
+ $plan_id = $routes['3'];
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('plan_id', $plan_id)->find_one();
if ($b) {
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->find_one();
@@ -169,7 +169,7 @@ switch ($action) {
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
break;
case 'sync':
- $id_customer = $routes['2'];
+ $id_customer = $routes['2'];
$bs = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->findMany();
if ($bs) {
$routers = [];
@@ -198,7 +198,7 @@ switch ($action) {
case 'viewu':
$customer = ORM::for_table('tbl_customers')->where('username', $routes['2'])->find_one();
case 'view':
- $id = $routes['2'];
+ $id = $routes['2'];
run_hook('view_customer'); #HOOK
if (!$customer) {
$customer = ORM::for_table('tbl_customers')->find_one($id);
@@ -210,9 +210,9 @@ switch ($action) {
$customFields = ORM::for_table('tbl_customers_fields')
->where('customer_id', $customer['id'])
->find_many();
-
- $v = $routes['3'];
- if (empty($v)) {
+
+ $v = $routes['3'];
+ if (empty ($v)) {
$v = 'activation';
}
if ($v == 'order') {
@@ -250,7 +250,7 @@ switch ($action) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
- $id = $routes['2'];
+ $id = $routes['2'];
run_hook('edit_customer'); #HOOK
$d = ORM::for_table('tbl_customers')->find_one($id);
// Fetch the Customers Attributes values from the tbl_customers_fields table
@@ -270,7 +270,7 @@ switch ($action) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
- $id = $routes['2'];
+ $id = $routes['2'];
run_hook('delete_customer'); #HOOK
$d = ORM::for_table('tbl_customers')->find_one($id);
if ($d) {
@@ -309,7 +309,8 @@ switch ($action) {
} catch (Throwable $e) {
}
try {
- if ($c) $c->delete();
+ if ($c)
+ $c->delete();
} catch (Exception $e) {
} catch (Throwable $e) {
}
@@ -328,6 +329,7 @@ switch ($action) {
$address = _post('address');
$phonenumber = _post('phonenumber');
$service_type = _post('service_type');
+ $account_type = _post('account_type');
$coordinates = _post('coordinates');
//post Customers Attributes
$custom_field_names = (array) $_POST['custom_field_name'];
@@ -356,6 +358,7 @@ switch ($action) {
$d->password = $password;
$d->pppoe_password = $pppoe_password;
$d->email = $email;
+ $d->account_type = $account_type;
$d->fullname = $fullname;
$d->address = $address;
$d->created_by = $admin['id'];
@@ -367,13 +370,13 @@ switch ($action) {
// Retrieve the customer ID of the newly created customer
$customerId = $d->id();
// Save Customers Attributes details
- if (!empty($custom_field_names) && !empty($custom_field_values)) {
+ if (!empty ($custom_field_names) && !empty ($custom_field_values)) {
$totalFields = min(count($custom_field_names), count($custom_field_values));
for ($i = 0; $i < $totalFields; $i++) {
$name = $custom_field_names[$i];
$value = $custom_field_values[$i];
- if (!empty($name)) {
+ if (!empty ($name)) {
$customField = ORM::for_table('tbl_customers_fields')->create();
$customField->customer_id = $customerId;
$customField->field_name = $name;
@@ -391,6 +394,7 @@ switch ($action) {
case 'edit-post':
$username = Lang::phoneFormat(_post('username'));
$fullname = _post('fullname');
+ $account_type = _post('account_type');
$password = _post('password');
$pppoe_password = _post('pppoe_password');
$email = _post('email');
@@ -425,8 +429,8 @@ switch ($action) {
}
$oldusername = $d['username'];
- $oldPppoePassword = $d['password'];
- $oldPassPassword = $d['pppoe_password'];
+ $oldPppoePassword = $d['password'];
+ $oldPassPassword = $d['pppoe_password'];
$userDiff = false;
$pppoeDiff = false;
$passDiff = false;
@@ -454,6 +458,7 @@ switch ($action) {
$d->pppoe_password = $pppoe_password;
$d->fullname = $fullname;
$d->email = $email;
+ $d->account_type = $account_type;
$d->address = $address;
$d->phonenumber = $phonenumber;
$d->service_type = $service_type;
@@ -464,7 +469,7 @@ switch ($action) {
// Update Customers Attributes values in tbl_customers_fields table
foreach ($customFields as $customField) {
$fieldName = $customField['field_name'];
- if (isset($_POST['custom_fields'][$fieldName])) {
+ if (isset ($_POST['custom_fields'][$fieldName])) {
$customFieldValue = $_POST['custom_fields'][$fieldName];
$customField->set('field_value', $customFieldValue);
$customField->save();
@@ -472,7 +477,7 @@ switch ($action) {
}
// Add new Customers Attributess
- if (isset($_POST['custom_field_name']) && isset($_POST['custom_field_value'])) {
+ if (isset ($_POST['custom_field_name']) && isset ($_POST['custom_field_value'])) {
$newCustomFieldNames = $_POST['custom_field_name'];
$newCustomFieldValues = $_POST['custom_field_value'];
@@ -495,7 +500,7 @@ switch ($action) {
}
// Delete Customers Attributess
- if (isset($_POST['delete_custom_fields'])) {
+ if (isset ($_POST['delete_custom_fields'])) {
$fieldsToDelete = $_POST['delete_custom_fields'];
foreach ($fieldsToDelete as $fieldName) {
// Delete the Customers Attributes with the given field name
@@ -525,7 +530,7 @@ switch ($action) {
Mikrotik::removeHotspotActiveUser($client, $d['username']);
} else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
- if (!empty($d['pppoe_password'])) {
+ if (!empty ($d['pppoe_password'])) {
Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);
} else {
Mikrotik::setPpoeUser($client, $c['username'], $password);
diff --git a/system/controllers/order.php b/system/controllers/order.php
index 9df265f2..e11e7879 100644
--- a/system/controllers/order.php
+++ b/system/controllers/order.php
@@ -47,26 +47,27 @@ switch ($action) {
}
$ui->assign('_title', 'Order Plan');
$ui->assign('_system_menu', 'package');
- if (!empty($_SESSION['nux-router'])) {
+ if (!empty ($_SESSION['nux-router'])) {
+ $account_type = $user['account_type'];
if ($_SESSION['nux-router'] == 'radius') {
- $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
- $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
+ $radius_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
+ $radius_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
} else {
$routers = ORM::for_table('tbl_routers')->where('id', $_SESSION['nux-router'])->find_many();
$rs = [];
foreach ($routers as $r) {
$rs[] = $r['name'];
}
- $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
- $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
+ $plans_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
+ $plans_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
}
} else {
- $radius_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
- $radius_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
+ $radius_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
+ $radius_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
$routers = ORM::for_table('tbl_routers')->find_many();
- $plans_pppoe = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
- $plans_hotspot = ORM::for_table('tbl_plans')->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
+ $plans_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
+ $plans_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
}
$ui->assign('routers', $routers);
$ui->assign('radius_pppoe', $radius_pppoe);
@@ -84,7 +85,7 @@ switch ($action) {
run_hook('custome
r_find_unpaid'); #HOOK
if ($d) {
- if (empty($d['pg_url_payment'])) {
+ if (empty ($d['pg_url_payment'])) {
r2(U . "order/buy/" . $trx['routers_id'] . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment"));
} else {
r2(U . "order/view/" . $d['id'] . '/check/', 's', Lang::T("You have unpaid transaction"));
@@ -100,11 +101,11 @@ switch ($action) {
->find_one($trxid);
run_hook('customer_view_payment'); #HOOK
// jika tidak ditemukan, berarti punya orang lain
- if (empty($trx)) {
+ if (empty ($trx)) {
r2(U . "order/package", 'w', Lang::T("Payment not found"));
}
// jika url kosong, balikin ke buy
- if (empty($trx['pg_url_payment'])) {
+ if (empty ($trx['pg_url_payment'])) {
r2(U . "order/buy/" . (($trx['routers_id'] == 0) ? $trx['routers'] : $trx['routers_id']) . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment"));
}
if ($routes['3'] == 'check') {
@@ -125,7 +126,7 @@ switch ($action) {
->where('username', $user['username'])
->find_one($trxid);
}
- if (empty($trx)) {
+ if (empty ($trx)) {
r2(U . "order/package", 'e', Lang::T("Transaction Not found"));
}
$router = Mikrotik::info($trx['routers']);
@@ -146,7 +147,7 @@ switch ($action) {
r2(U . "order/package", 'e', Lang::T("Balance not enabled"));
}
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']);
- if (empty($plan)) {
+ if (empty ($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found"));
}
if (!$plan['enabled']) {
@@ -180,7 +181,7 @@ switch ($action) {
$ui->assign('_title', Lang::T('Buy for friend'));
$ui->assign('_system_menu', 'package');
$plan = ORM::for_table('tbl_plans')->find_one($routes['3']);
- if (empty($plan)) {
+ if (empty ($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found"));
}
if (!$plan['enabled']) {
@@ -191,10 +192,10 @@ switch ($action) {
} else {
$router_name = $plan['routers'];
}
- if (isset($_POST['send']) && $_POST['send'] == 'plan') {
+ if (isset ($_POST['send']) && $_POST['send'] == 'plan') {
$target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one();
list($bills, $add_cost) = User::getBills($target['id']);
- if (!empty($add_cost)) {
+ if (!empty ($add_cost)) {
$ui->assign('bills', $bills);
$ui->assign('add_cost', $add_cost);
$plan['price'] += $add_cost;
@@ -289,7 +290,7 @@ switch ($action) {
$ui->display('user-selectGateway.tpl');
break;
} else {
- if (empty($pgs[0])) {
+ if (empty ($pgs[0])) {
sendTelegram("Payment Gateway not set, please set it in Settings");
_log(Lang::T("Payment Gateway not set, please set it in Settings"));
r2(U . "home", 'e', Lang::T("Failed to create Transaction.."));
@@ -299,12 +300,12 @@ switch ($action) {
}
case 'buy':
$gateway = _post('gateway');
- if (empty($gateway) && !empty($_SESSION['gateway'])) {
+ if (empty ($gateway) && !empty ($_SESSION['gateway'])) {
$gateway = $_SESSION['gateway'];
- } else if (!empty($gateway)) {
+ } else if (!empty ($gateway)) {
$_SESSION['gateway'] = $gateway;
}
- if (empty($gateway)) {
+ if (empty ($gateway)) {
r2(U . 'order/gateway/' . $routes[2] . '/' . $routes[3], 'w', Lang::T("Please select Payment Gateway"));
}
run_hook('customer_buy_plan'); #HOOK
@@ -321,7 +322,7 @@ switch ($action) {
$router['name'] = 'balance';
}
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']);
- if (empty($router) || empty($plan)) {
+ if (empty ($router) || empty ($plan)) {
r2(U . "order/package", 'e', Lang::T("Plan Not found"));
}
$d = ORM::for_table('tbl_payment_gateway')
@@ -344,7 +345,7 @@ switch ($action) {
if ($router['name'] != 'balance') {
list($bills, $add_cost) = User::getBills($id_customer);
}
- if (empty($id)) {
+ if (empty ($id)) {
$d = ORM::for_table('tbl_payment_gateway')->create();
$d->username = $user['username'];
$d->gateway = $gateway;
@@ -352,16 +353,16 @@ switch ($action) {
$d->plan_name = $plan['name_plan'];
$d->routers_id = $router['id'];
$d->routers = $router['name'];
- if ($plan['validity_unit'] == 'Period') {
- // Postpaid price from field
- $add_inv = User::getAttribute("Invoice", $id_customer);
- if (empty ($add_inv) or $add_inv == 0) {
- $d->price = ($plan['price'] + $add_cost);
- } else {
- $d->price = ($add_inv + $add_cost);
- }
- } else {
+ if ($plan['validity_unit'] == 'Period') {
+ // Postpaid price from field
+ $add_inv = User::getAttribute("Invoice", $id_customer);
+ if (empty ($add_inv) or $add_inv == 0) {
$d->price = ($plan['price'] + $add_cost);
+ } else {
+ $d->price = ($add_inv + $add_cost);
+ }
+ } else {
+ $d->price = ($plan['price'] + $add_cost);
}
//$d->price = ($plan['price'] + $add_cost);
$d->created_date = date('Y-m-d H:i:s');
@@ -375,16 +376,16 @@ switch ($action) {
$d->plan_name = $plan['name_plan'];
$d->routers_id = $router['id'];
$d->routers = $router['name'];
- if ($plan['validity_unit'] == 'Period') {
- // Postpaid price from field
- $add_inv = User::getAttribute("Invoice", $id_customer);
- if (empty ($add_inv) or $add_inv == 0) {
- $d->price = ($plan['price'] + $add_cost);
- } else {
- $d->price = ($add_inv + $add_cost);
- }
- } else {
+ if ($plan['validity_unit'] == 'Period') {
+ // Postpaid price from field
+ $add_inv = User::getAttribute("Invoice", $id_customer);
+ if (empty ($add_inv) or $add_inv == 0) {
$d->price = ($plan['price'] + $add_cost);
+ } else {
+ $d->price = ($add_inv + $add_cost);
+ }
+ } else {
+ $d->price = ($plan['price'] + $add_cost);
}
//$d->price = ($plan['price'] + $add_cost);
$d->created_date = date('Y-m-d H:i:s');
diff --git a/system/controllers/services.php b/system/controllers/services.php
index d0fb3b41..ab025528 100644
--- a/system/controllers/services.php
+++ b/system/controllers/services.php
@@ -12,7 +12,7 @@ $action = $routes['1'];
$ui->assign('_admin', $admin);
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
- _alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
+ _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
use PEAR2\Net\RouterOS;
@@ -60,7 +60,7 @@ switch ($action) {
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
Mikrotik::addHotspotPlan($client, $plan['name_plan'], $plan['shared_users'], $rate);
$log .= "DONE : $plan[name_plan], $plan[shared_users], $rate
";
- if (!empty($plan['pool_expired'])) {
+ if (!empty ($plan['pool_expired'])) {
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired']);
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]
";
}
@@ -105,7 +105,7 @@ switch ($action) {
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
Mikrotik::addPpoePlan($client, $plan['name_plan'], $plan['pool'], $rate);
$log .= "DONE : $plan[name_plan], $plan[pool], $rate
";
- if (!empty($plan['pool_expired'])) {
+ if (!empty ($plan['pool_expired'])) {
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired'], '512K/512K');
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]
";
}
@@ -142,7 +142,7 @@ switch ($action) {
break;
case 'edit':
- $id = $routes['2'];
+ $id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
$ui->assign('d', $d);
@@ -158,7 +158,7 @@ switch ($action) {
break;
case 'delete':
- $id = $routes['2'];
+ $id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
@@ -185,6 +185,7 @@ switch ($action) {
case 'add-post':
$name = _post('name');
+ $plan_type = _post('plan_type'); //Personal / Business
$radius = _post('radius');
$typebp = _post('typebp');
$limit_type = _post('limit_type');
@@ -213,7 +214,7 @@ switch ($action) {
if ($name == '' or $id_bw == '' or $price == '' or $validity == '') {
$msg .= Lang::T('All field is required') . '
';
}
- if (empty($radius)) {
+ if (empty ($radius)) {
if ($routers == '') {
$msg .= Lang::T('All field is required') . '
';
}
@@ -251,6 +252,7 @@ switch ($action) {
$d->price = $price;
$d->type = 'Hotspot';
$d->typebp = $typebp;
+ $d->plan_type = $plan_type;
$d->limit_type = $limit_type;
$d->time_limit = $time_limit;
$d->time_unit = $time_unit;
@@ -259,7 +261,7 @@ switch ($action) {
$d->validity = $validity;
$d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers;
- if (!empty($radius)) {
+ if (!empty ($radius)) {
$d->is_radius = 1;
$d->routers = '';
} else {
@@ -279,7 +281,7 @@ switch ($action) {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
- if (!empty($pool_expired)) {
+ if (!empty ($pool_expired)) {
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired);
}
}
@@ -295,6 +297,7 @@ switch ($action) {
case 'edit-post':
$id = _post('id');
$name = _post('name');
+ $plan_type = _post('plan_type');
$id_bw = _post('id_bw');
$typebp = _post('typebp');
$price = _post('price');
@@ -354,7 +357,7 @@ switch ($action) {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate);
- if (!empty($pool_expired)) {
+ if (!empty ($pool_expired)) {
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired);
}
}
@@ -367,6 +370,7 @@ switch ($action) {
$d->time_limit = $time_limit;
$d->time_unit = $time_unit;
$d->data_limit = $data_limit;
+ $d->plan_type = $plan_type;
$d->data_unit = $data_unit;
$d->validity = $validity;
$d->validity_unit = $validity_unit;
@@ -414,7 +418,7 @@ switch ($action) {
case 'pppoe-edit':
$ui->assign('_title', Lang::T('PPPOE Plans'));
- $id = $routes['2'];
+ $id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
$ui->assign('d', $d);
@@ -435,7 +439,7 @@ switch ($action) {
break;
case 'pppoe-delete':
- $id = $routes['2'];
+ $id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
@@ -461,6 +465,7 @@ switch ($action) {
case 'pppoe-add-post':
$name = _post('name_plan');
+ $plan_type = _post('plan_type');
$radius = _post('radius');
$id_bw = _post('id_bw');
$price = _post('price');
@@ -484,7 +489,7 @@ switch ($action) {
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $pool == '') {
$msg .= Lang::T('All field is required') . '
';
}
- if (empty($radius)) {
+ if (empty ($radius)) {
if ($routers == '') {
$msg .= Lang::T('All field is required') . '
';
}
@@ -520,10 +525,11 @@ switch ($action) {
$d->name_plan = $name;
$d->id_bw = $id_bw;
$d->price = $price;
+ $d->plan_type = $plan_type;
$d->validity = $validity;
$d->validity_unit = $validity_unit;
$d->pool = $pool;
- if (!empty($radius)) {
+ if (!empty ($radius)) {
$d->is_radius = 1;
$d->routers = '';
} else {
@@ -543,7 +549,7 @@ switch ($action) {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoePlan($client, $name, $pool, $rate);
- if (!empty($pool_expired)) {
+ if (!empty ($pool_expired)) {
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K');
}
}
@@ -556,6 +562,7 @@ switch ($action) {
case 'edit-pppoe-post':
$id = _post('id');
+ $plan_type = _post('plan_type');
$name = _post('name_plan');
$id_bw = _post('id_bw');
$price = _post('price');
@@ -611,7 +618,7 @@ switch ($action) {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPpoePlan($client, $name, $pool, $rate);
- if (!empty($pool_expired)) {
+ if (!empty ($pool_expired)) {
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K');
}
}
@@ -619,6 +626,7 @@ switch ($action) {
$d->name_plan = $name;
$d->id_bw = $id_bw;
$d->price = $price;
+ $d->plan_type = $plan_type;
$d->validity = $validity;
$d->validity_unit = $validity_unit;
$d->routers = $routers;
@@ -657,14 +665,14 @@ switch ($action) {
break;
case 'balance-edit':
$ui->assign('_title', Lang::T('Balance Plans'));
- $id = $routes['2'];
+ $id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
$ui->assign('d', $d);
run_hook('view_edit_balance'); #HOOK
$ui->display('balance-edit.tpl');
break;
case 'balance-delete':
- $id = $routes['2'];
+ $id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
diff --git a/ui/ui/customers-add.tpl b/ui/ui/customers-add.tpl
index 0ff75696..ed37dfcb 100644
--- a/ui/ui/customers-add.tpl
+++ b/ui/ui/customers-add.tpl
@@ -95,6 +95,16 @@
+