Compare commits

...

10 Commits

Author SHA1 Message Date
6f5d49cd2f Show Paid 2024-03-15 10:56:08 +07:00
850581d328 Fix instalment finished 2024-03-15 10:48:17 +07:00
1d0d3f13ab 2024.3.14 2024-03-15 10:43:49 +07:00
c82b6b6acf Change Attribute to Bill Only 2024-03-15 10:38:05 +07:00
532fbf7337 Active plan on user page 2024-03-15 09:46:01 +07:00
c4afd6da7f Additional Cost at Cron 2024-03-15 09:29:15 +07:00
a812e3a3e0 Merge pull request #128 from gerandonk/Development
postpaid always zero for first time recharge and invoice atribute for…
2024-03-15 09:24:02 +07:00
a15510e62a postpaid always zero for first time recharge and invoice atribute for next month
for postpaid customer invoice reminder and order get from invoice attribute
2024-03-15 04:07:30 +07:00
78d1634470 Send plan to friend will pay for Additional Cost 2024-03-14 14:55:49 +07:00
cc8d810d45 Additional Cost Customer side 2024-03-14 14:42:20 +07:00
19 changed files with 409 additions and 260 deletions

View File

@ -2,6 +2,11 @@
# CHANGELOG
## 2024.3.15
- Fix Customer View to list active Plan
- Additional Bill using Customer Attributes
## 2024.3.14
- Add Note to Invoices

View File

@ -37,7 +37,6 @@ function _autoloader($class)
}
spl_autoload_register('_autoloader');
if (!file_exists($root_path . 'config.php')) {
$root_path .= '..' . DIRECTORY_SEPARATOR;
if (!file_exists($root_path . 'config.php')) {

View File

@ -32,29 +32,21 @@ class Package
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
// Additional cost
$add_cost = 0;
$add_rem = User::getAttribute("Additional Remaining", $id_customer);
// if empty then it doesnt have cycle, if zero then it finish
if ($add_rem != 0) {
$add_cost = User::getAttribute("Additional Cost", $id_customer);
if (empty($add_cost)) {
$add_cost = 0;
}
}
if ($add_cost > 0 && $router_name != 'balance') {
$bills = User::getAttributes("Bill", $id_customer);
foreach ($bills as $k => $v) {
$note .= $k . " : " . Lang::moneyFormat($v) . "\n";
}
}
// Zero cost recharge
if (isset($zero) && $zero == 1) {
$p['price'] = 0;
$add_cost = 0;
}else{
// Additional cost
list($bills, $add_cost) = User::getBills($id_customer);
if ($add_cost > 0 && $router_name != 'balance') {
foreach ($bills as $k => $v) {
$note .= $k . " : " . Lang::moneyFormat($v) . "\n";
}
}
}
if (!$p['enabled']) {
if (!isset($admin) || !isset($admin['id']) || empty($admin['id'])) {
r2(U . 'home', 'e', Lang::T('Plan Not found'));
@ -246,7 +238,17 @@ class Package
$t->invoice = "INV-" . Package::_raid();
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'] + $add_cost;
if ($p['validity_unit'] == 'Period') {
// Postpaid price from field
$add_inv = User::getAttribute("Invoice", $id_customer);
if (empty ($add_inv) or $add_inv == 0) {
$t->price = $p['price'] + $add_cost;
} else {
$t->price = $add_inv + $add_cost;
}
} else {
$t->price = $p['price'] + $add_cost;
}
$t->recharged_on = $date_only;
$t->recharged_time = $time_only;
$t->expiration = $date_exp;
@ -263,7 +265,7 @@ class Package
$t->save();
if ($p['validity_unit'] == 'Period') {
// insert to fields
// 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();
@ -319,18 +321,9 @@ class Package
$t->invoice = "INV-" . Package::_raid();
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
// Calculating Price
$sd = new DateTime("$date_only");
$ed = new DateTime("$date_exp");
$td = $ed->diff($sd);
$fd = $td->format("%a");
$gi = ($p['price'] / 30) * $fd;
if ($gi > $p['price']) {
$t->price = $p['price'] + $add_cost;
} else {
$t->price = $gi + $add_cost;
}
if ($p['validity_unit'] == 'Period') {
// Postpaid price always zero for first time
$t->price = 0 + $add_cost;
} else {
$t->price = $p['price'] + $add_cost;
}
@ -350,12 +343,18 @@ class Package
$t->save();
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
// insert to fields
// 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) * $fd;
if ($gi > $p['price']) {
$fl->field_value = $p['price'];
} else {
@ -433,7 +432,17 @@ class Package
$t->invoice = "INV-" . Package::_raid();
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'] + $add_cost;
if ($p['validity_unit'] == 'Period') {
// Postpaid price from field
$add_inv = User::getAttribute("Invoice", $id_customer);
if (empty ($add_inv) or $add_inv == 0) {
$t->price = $p['price'] + $add_cost;
} else {
$t->price = $add_inv + $add_cost;
}
} else {
$t->price = $p['price'] + $add_cost;
}
$t->recharged_on = $date_only;
$t->recharged_time = $time_only;
$t->expiration = $date_exp;
@ -450,7 +459,7 @@ class Package
$t->save();
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
// insert to fields
// 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();
@ -505,18 +514,9 @@ class Package
$t->invoice = "INV-" . Package::_raid();
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
// Calculating Price
$sd = new DateTime("$date_only");
$ed = new DateTime("$date_exp");
$td = $ed->diff($sd);
$fd = $td->format("%a");
$gi = ($p['price'] / 30) * $fd;
if ($gi > $p['price']) {
$t->price = $p['price'] + $add_cost;
} else {
$t->price = $gi + $add_cost;
}
if ($p['validity_unit'] == 'Period') {
// Postpaid price always zero for first time
$t->price = 0 + $add_cost;
} else {
$t->price = $p['price'] + $add_cost;
}
@ -536,12 +536,18 @@ class Package
$t->save();
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
// insert to fields
// 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) * $fd;
if ($gi > $p['price']) {
$fl->field_value = $p['price'];
} else {
@ -562,8 +568,8 @@ class Package
"\nPrice: " . Lang::moneyFormat($p['price']));
}
}
if ($add_rem > 0) {
User::setAttribute('Additional Remaining', ($add_rem - 1), $id_customer);
if (count($bills) > 0) {
User::billsPaid($bills, $id_customer);
}
run_hook("recharge_user_finish");
Message::sendInvoice($c, $t);
@ -671,6 +677,8 @@ class Package
$_admin = Admin::_info($in['admin_id']);
// if admin not deleted
if ($_admin) $admin = $_admin;
}else{
$admin['fullname'] = 'Customer';
}
//print
$invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";

View File

@ -26,6 +26,60 @@ class User
return 0;
}
public static function getBills($id = 0)
{
if (!$id) {
$id = User::getID();
if (!$id) {
return [];
}
}
$addcost = 0;
$bills = [];
$attrs = User::getAttributes('Bill', $id);
foreach ($attrs as $k => $v) {
// if has : then its an installment
if (strpos($v, ":") === false) {
// Not installment
$bills[$k] = $v;
$addcost += $v;
} else {
// installment
list($cost, $rem) = explode(":", $v);
// :0 installment is done
if (!empty($rem)) {
$bills[$k] = $cost;
$addcost += $cost;
}
}
}
return [$bills, $addcost];
}
public static function billsPaid($bills, $id = 0)
{
if (!$id) {
$id = User::getID();
if (!$id) {
return [];
}
}
foreach ($bills as $k => $v) {
// if has : then its an installment
$v = User::getAttribute($k, $id);
if (strpos($v, ":") === false) {
// Not installment, no need decrement
} else {
// installment
list($cost, $rem) = explode(":", $v);
// :0 installment is done
if ($rem != 0) {
User::setAttribute($k, "$cost:".($rem - 1), $id);
}
}
}
}
public static function setAttribute($name, $value, $id = 0)
{
if (!$id) {
@ -35,7 +89,7 @@ class User
}
}
$f = ORM::for_table('tbl_customers_fields')->where('field_name', $name)->where('customer_id', $id)->find_one();
if(!$f){
if (!$f) {
$f = ORM::for_table('tbl_customers_fields')->create();
$f->customer_id = $id;
$f->field_name = $name;
@ -45,7 +99,7 @@ class User
if ($result) {
return $result;
}
}else{
} else {
$f->field_value = $value;
$f->save();
return $f['id'];

View File

@ -97,20 +97,14 @@ switch ($action) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
$id_customer = $routes['2'];
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
$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';
$channel = $admin['fullname'];
$cust = User::_info($id_customer);
$plan = ORM::for_table('tbl_plans')->find_one($b['plan_id']);
$add_cost = 0;
$add_rem = User::getAttribute("Additional Remaining", $id_customer);
if($add_rem != 0){
$add_cost = User::getAttribute("Additional Cost", $id_customer);
if (empty($add_cost)) {
$add_cost = 0;
}
}
list($bills, $add_cost) = User::getBills($id_customer);
if ($using == 'balance' && $config['enable_balance'] == 'yes') {
if (!$cust) {
r2(U . 'prepaid/recharge', 'e', Lang::T('Customer not found'));
@ -127,10 +121,8 @@ switch ($action) {
$zero = 1;
$gateway = 'Recharge Zero';
}
$bills = User::getAttributes("Bill", $id_customer);
$ui->assign('bills', $bills);
$ui->assign('add_cost', $add_cost);
$ui->assign('add_rem', $add_rem);
$ui->assign('cust', $cust);
$ui->assign('gateway', $gateway);
$ui->assign('channel', $channel);
@ -138,16 +130,19 @@ switch ($action) {
$ui->assign('using', 'cash');
$ui->assign('plan', $plan);
$ui->display('recharge-confirm.tpl');
}else{
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
}
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
break;
case 'deactivate':
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'];
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
$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'])->where('enabled', '1')->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->find_one();
if ($p) {
if ($p['is_radius']) {
Radius::customerDeactivate($b['username']);
@ -175,27 +170,28 @@ switch ($action) {
break;
case 'sync':
$id_customer = $routes['2'];
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->find_one();
if ($b) {
$c = ORM::for_table('tbl_customers')->find_one($id_customer);
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->where('enabled', '1')->find_one();
if ($p) {
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, $p['expiration'] . ' ' . $p['time']);
r2(U . 'customers/view/' . $id_customer, 's', 'Success sync customer to Radius');
} else {
$mikrotik = Mikrotik::info($b['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if ($b['type'] == 'Hotspot') {
Mikrotik::addHotspotUser($client, $p, $c);
} else if ($b['type'] == 'PPPOE') {
Mikrotik::addPpoeUser($client, $p, $c);
$bs = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('status', 'on')->findMany();
if ($bs) {
$routers = [];
foreach ($bs as $b) {
$c = ORM::for_table('tbl_customers')->find_one($id_customer);
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->where('enabled', '1')->find_one();
if ($p) {
$routers[] = $b['routers'];
if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, $p['expiration'] . ' ' . $p['time']);
} else {
$mikrotik = Mikrotik::info($b['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if ($b['type'] == 'Hotspot') {
Mikrotik::addHotspotUser($client, $p, $c);
} else if ($b['type'] == 'PPPOE') {
Mikrotik::addPpoeUser($client, $p, $c);
}
}
r2(U . 'customers/view/' . $id_customer, 's', 'Success sync customer to Mikrotik');
}
} else {
r2(U . 'customers/view/' . $id_customer, 'e', 'Customer plan is inactive');
}
r2(U . 'customers/view/' . $id_customer, 's', 'Sync success to '.implode(", ",$routers));
}
r2(U . 'customers/view/' . $id_customer, 'e', 'Cannot find active plan');
break;
@ -216,7 +212,10 @@ switch ($action) {
->find_many();
$v = $routes['3'];
if (empty($v) || $v == 'order') {
if(empty($v)){
$v = 'activation';
}
if ($v == 'order') {
$v = 'order';
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'), ['username' => $customer['username']]);
$order = ORM::for_table('tbl_payment_gateway')
@ -238,8 +237,7 @@ switch ($action) {
$ui->assign('paginator', $paginator);
$ui->assign('activation', $activation);
}
$package = ORM::for_table('tbl_user_recharges')->where('username', $customer['username'])->find_one();
$ui->assign('package', $package);
$ui->assign('packages', User::_billing($customer['id']));
$ui->assign('v', $v);
$ui->assign('d', $customer);
$ui->assign('customFields', $customFields);

View File

@ -124,16 +124,16 @@ switch ($action) {
$trx = ORM::for_table('tbl_payment_gateway')
->where('username', $user['username'])
->find_one($trxid);
if ('midtrans' == $trx['gateway']) {
//Hapus invoice link
}
}
if (empty($trx)) {
r2(U . "order/package", 'e', Lang::T("Transaction Not found"));
}
$router = ORM::for_table('tbl_routers')->find_one($trx['routers_id']);
$router = Mikrotik::info($trx['routers']);
$plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']);
$bandw = ORM::for_table('tbl_bandwidth')->find_one($plan['id_bw']);
list($bills, $add_cost) = User::getBills($id_customer);
$ui->assign('bills', $bills);
$ui->assign('add_cost', $add_cost);
$ui->assign('trx', $trx);
$ui->assign('router', $router);
$ui->assign('plan', $plan);
@ -157,11 +157,12 @@ switch ($action) {
} else {
$router_name = $plan['routers'];
}
list($bills, $add_cost) = User::getBills($id_customer);
if ($plan && $plan['enabled'] && $user['balance'] >= $plan['price']) {
if (Package::rechargeUser($user['id'], $router_name, $plan['id'], 'Customer', 'Balance')) {
// if success, then get the balance
Balance::min($user['id'], $plan['price']);
r2(U . "home", 's', Lang::T("Success to buy package"));
Balance::min($user['id'], $plan['price'] + $add_cost);
r2(U . "voucher/invoice/", 's', Lang::T("Success to buy package"));
} else {
r2(U . "order/package", 'e', Lang::T("Failed to buy package"));
Message::sendTelegram("Buy Package with Balance Failed\n\n#u$c[username] #buy \n" . $plan['name_plan'] .
@ -192,6 +193,12 @@ switch ($action) {
}
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)) {
$ui->assign('bills', $bills);
$ui->assign('add_cost', $add_cost);
$plan['price'] += $add_cost;
}
if (!$target) {
r2(U . 'home', 'd', Lang::T('Username not found'));
}
@ -267,13 +274,13 @@ switch ($action) {
r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address"));
}
$pgs = array_values(explode(',', $config['payment_gateway']));
if(count($pgs)==0){
if (count($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.."));
}
if(count($pgs)>1){
$ui->assign('pgs',$pgs );
if (count($pgs) > 1) {
$ui->assign('pgs', $pgs);
//$ui->assign('pgs', $pgs);
$ui->assign('route2', $routes[2]);
$ui->assign('route3', $routes[3]);
@ -281,12 +288,12 @@ switch ($action) {
//$ui->assign('plan', $plan);
$ui->display('user-selectGateway.tpl');
break;
}else{
if(empty($pgs[0])){
} else {
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.."));
}else{
} else {
$_POST['gateway'] = $pgs[0];
}
}
@ -333,6 +340,10 @@ switch ($action) {
}
}
}
$add_cost = 0;
if ($router['name'] != 'balance') {
list($bills, $add_cost) = User::getBills($id_customer);
}
if (empty($id)) {
$d = ORM::for_table('tbl_payment_gateway')->create();
$d->username = $user['username'];
@ -341,7 +352,18 @@ switch ($action) {
$d->plan_name = $plan['name_plan'];
$d->routers_id = $router['id'];
$d->routers = $router['name'];
$d->price = $plan['price'];
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');
$d->status = 1;
$d->save();
@ -353,7 +375,18 @@ switch ($action) {
$d->plan_name = $plan['name_plan'];
$d->routers_id = $router['id'];
$d->routers = $router['name'];
$d->price = $plan['price'];
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');
$d->status = 1;
$d->save();

View File

@ -115,14 +115,7 @@ switch ($action) {
$channel = $admin['fullname'];
$cust = User::_info($id_customer);
$plan = ORM::for_table('tbl_plans')->find_one($planId);
$add_cost = 0;
$add_rem = User::getAttribute("Additional Remaining", $id_customer);
if($add_rem != 0){
$add_cost = User::getAttribute("Additional Cost", $id_customer);
if (empty($add_cost)) {
$add_cost = 0;
}
}
list($bills, $add_cost) = User::getBills($id_customer);
if ($using == 'balance' && $config['enable_balance'] == 'yes') {
if (!$cust) {
r2(U . 'prepaid/recharge', 'e', Lang::T('Customer not found'));
@ -139,10 +132,8 @@ switch ($action) {
$zero = 1;
$gateway = 'Recharge Zero';
}
$bills = User::getAttributes("Bill", $id_customer);
$ui->assign('bills', $bills);
$ui->assign('add_cost', $add_cost);
$ui->assign('add_rem', $add_rem);
$ui->assign('cust', $cust);
$ui->assign('gateway', $gateway);
$ui->assign('channel', $channel);
@ -173,14 +164,7 @@ switch ($action) {
$gateway = 'Recharge';
$channel = $admin['fullname'];
$cust = User::_info($id_customer);
$add_cost = 0;
$add_rem = User::getAttribute("Additional Remaining", $id_customer);
if($add_rem != 0){
$add_cost = User::getAttribute("Additional Cost", $id_customer);
if (empty($add_cost)) {
$add_cost = 0;
}
}
list($bills, $add_cost) = User::getBills($id_customer);
if ($using == 'balance' && $config['enable_balance'] == 'yes') {
$plan = ORM::for_table('tbl_plans')->find_one($planId);
if (!$cust) {

View File

@ -51,9 +51,17 @@ switch ($action) {
break;
case 'invoice':
$id = $routes[2];
$in = ORM::for_table('tbl_transactions')->where('username', $user['username'])->where('id', $id)->find_one();
Package::createInvoice($in);
$ui->display('invoice-customer.tpl');
if(empty($id)){
$in = ORM::for_table('tbl_transactions')->where('username', $user['username'])->order_by_desc('id')->find_one();
}else{
$in = ORM::for_table('tbl_transactions')->where('username', $user['username'])->where('id', $id)->find_one();
}
if($in){
Package::createInvoice($in);
$ui->display('invoice-customer.tpl');
}else{
r2(U . 'voucher/list-activated', 'e', Lang::T('Not Found'));
}
default:
$ui->display('a404.tpl');
}

View File

@ -46,21 +46,27 @@ foreach ($d as $ds) {
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if (!empty($p['pool_expired'])) {
Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']);
// }if (!empty($p['list_expired'])) {
// $ip = Mikrotik::getIpHotspotUser($client, $ds['username']);
// Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']);
// }if (!empty($p['list_expired'])) {
// $ip = Mikrotik::getIpHotspotUser($client, $ds['username']);
// Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']);
} else {
Mikrotik::removeHotspotUser($client, $c['username']);
}
Mikrotik::removeHotspotActiveUser($client, $c['username']);
}
echo Message::sendPackageNotification($c, $u['namebp'], $price, $textExpired, $config['user_notification_expired'])."\n";
echo Message::sendPackageNotification($c, $u['namebp'], $price, $textExpired, $config['user_notification_expired']) . "\n";
//update database user dengan status off
$u->status = 'off';
$u->save();
// autorenewal from deposit
if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
list($bills, $add_cost) = User::getBills($ds['customer_id']);
if ($add_cost > 0) {
if (!empty($add_cost)) {
$p['price'] += $add_cost;
}
}
if ($p && $p['enabled'] && $c['balance'] >= $p['price']) {
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
// if success, then get the balance
@ -109,13 +115,19 @@ foreach ($d as $ds) {
}
Mikrotik::removePpoeActive($client, $c['username']);
}
echo Message::sendPackageNotification($c, $u['namebp'], $price, $textExpired, $config['user_notification_expired'])."\n";
echo Message::sendPackageNotification($c, $u['namebp'], $price, $textExpired, $config['user_notification_expired']) . "\n";
$u->status = 'off';
$u->save();
// autorenewal from deposit
if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
list($bills, $add_cost) = User::getBills($ds['customer_id']);
if ($add_cost > 0) {
if (!empty($add_cost)) {
$p['price'] += $add_cost;
}
}
if ($p && $p['enabled'] && $c['balance'] >= $p['price']) {
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
// if success, then get the balance

View File

@ -38,7 +38,24 @@ foreach ($d as $ds) {
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
$price = Lang::moneyFormat($p['price']);
list($bills, $add_cost) = User::getBills($ds['customer_id']);
if ($add_cost > 0) {
if (!empty($add_cost)) {
$p['price'] += $add_cost;
}
}
if ($p['validity_unit'] == 'Period') {
// Postpaid price from field
$add_inv = User::getAttribute("Invoice", $ds['customer_id']);
if (empty ($add_inv) or $add_inv == 0) {
$price = Lang::moneyFormat($p['price']);
} else {
$price = Lang::moneyFormat($add_inv);
}
} else {
$price = Lang::moneyFormat($p['price']);
}
//$price = Lang::moneyFormat($p['price']);
if ($ds['expiration'] == $day7) {
echo Message::sendPackageNotification($c, $p['name_plan'], $price, Lang::getNotifText('reminder_7_day'), $config['user_notification_reminder']) . "\n";
} else if ($ds['expiration'] == $day3) {

View File

@ -487,5 +487,11 @@
"Current_Cycle": "Current Cycle",
"Additional_Cost": "Additional Cost",
"Remaining": "Remaining",
"": ""
"": "",
"Not_Found": "Not Found",
"Cash": "Cash",
"Payment_not_found": "Payment not found",
"If_your_friend_have_Additional_Cost__you_will_pay_for_that_too": "If your friend have Additional Cost, you will pay for that too",
"Cache_cleared_successfully_": "Cache cleared successfully!",
"Paid": "Paid"
}

View File

@ -1,8 +0,0 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -30,20 +30,26 @@
onclick="this.select()">
</li>
{if $d['pppoe_password'] != ''}
<li class="list-group-item">
<b>PPPOE {Lang::T('Password')}</b> <input type="password" value="{$d['pppoe_password']}"
style=" border: 0px; text-align: right;" class="pull-right"
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'"
onclick="this.select()">
</li>
<li class="list-group-item">
<b>PPPOE {Lang::T('Password')}</b> <input type="password" value="{$d['pppoe_password']}"
style=" border: 0px; text-align: right;" class="pull-right"
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'"
onclick="this.select()">
</li>
{/if}
<!--Customers Attributes view start -->
{if $customFields}
{foreach $customFields as $customField}
<li class="list-group-item">
<b>{$customField.field_name}</b> <span class="pull-right">{$customField.field_value}</span>
</li>
{/foreach}
{foreach $customFields as $customField}
<li class="list-group-item">
<b>{$customField.field_name}</b> <span class="pull-right">
{if strpos($customField.field_value, ':0') === false}
{$customField.field_value}
{else}
<b>{Lang::T('Paid')}</b>
{/if}
</span>
</li>
{/foreach}
{/if}
<!--Customers Attributes view end -->
<li class="list-group-item">
@ -54,7 +60,8 @@
</li>
<li class="list-group-item">
<b>{Lang::T('Auto Renewal')}</b> <span class="pull-right">{if
$d['auto_renewal']}yes{else}no{/if}</span>
$d['auto_renewal']}yes{else}no
{/if}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Created On')}</b> <span
@ -78,22 +85,26 @@
</div>
</div>
</div>
{if $package}
<div class="box box-{if $package['status']=='on'}success{else}danger{/if}">
<div class="box-body box-profile">
<h4 class="text-center">{$package['type']} - {$package['namebp']}</h4>
<ul class="list-group list-group-unbordered">
{foreach $packages as $package}
<div class="box box-{if $package['status']=='on'}success{else}danger{/if}">
<div class="box-body box-profile">
<h4 class="text-center">{$package['type']} - {$package['namebp']}</h4>
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
{Lang::T('Active')} <span class="pull-right">{if
$package['status']=='on'}yes{else}no
{/if}</span>
</li>
<li class="list-group-item">
{Lang::T('Active')} <span class="pull-right">{if
$package['status']=='on'}yes{else}no{/if}</span>
{Lang::T('Type')} <span class="pull-right">
{if $package['prepaid'] eq yes}Prepaid{else}<b>Postpaid</b>{/if}</span>
</li>
<li class="list-group-item">
{Lang::T('Created On')} <span
class="pull-right">{Lang::dateAndTimeFormat($package['recharged_on'],$package['recharged_time'])}</span>
</li>
<li class="list-group-item">
{Lang::T('Expires On')} <span
class="pull-right">{Lang::dateAndTimeFormat($package['expiration'],
{Lang::T('Expires On')} <span class="pull-right">{Lang::dateAndTimeFormat($package['expiration'],
$package['time'])}</span>
</li>
<li class="list-group-item">
@ -102,28 +113,28 @@
</ul>
<div class="row">
<div class="col-xs-4">
<a href="{$_url}customers/deactivate/{$d['id']}" id="{$d['id']}"
<a href="{$_url}customers/deactivate/{$d['id']}/{$package['plan_id']}" id="{$d['id']}"
class="btn btn-danger btn-block btn-sm"
onclick="return confirm('This will deactivate Customer Plan, and make it expired')">{Lang::T('Deactivate')}</a>
</div>
<div class="col-xs-4">
<a href="{$_url}customers/recharge/{$d['id']}"
onclick="return confirm('This will extend Customer plan, same as recharge')"
<div class="col-xs-8">
<a href="{$_url}customers/recharge/{$d['id']}/{$package['plan_id']}"
class="btn btn-success btn-sm btn-block">{Lang::T('Recharge')}</a>
</div>
<div class="col-xs-4">
<a href="{$_url}customers/sync/{$d['id']}"
onclick="return confirm('This will sync Customer to Mikrotik?')"
class="btn btn-primary btn-sm btn-block">{Lang::T('Sync')}</a>
</div>
</div>
</div>
</div>
{else}
<a href="{$_url}prepaid/recharge/{$d['id']}"
class="btn btn-success btn-sm btn-block mt-1">{Lang::T('Recharge')}</a><br>
{/if}
<a href="{$_url}customers/list" class="btn btn-primary btn-sm btn-block mt-1">{Lang::T('Back')}</a><br>
{/foreach}
<div class="row">
<div class="col-xs-4">
<a href="{$_url}customers/list" class="btn btn-primary btn-sm btn-block">{Lang::T('Back')}</a>
</div>
<div class="col-xs-8">
<a href="{$_url}customers/sync/{$d['id']}"
onclick="return confirm('This will sync Customer to Mikrotik?')"
class="btn btn-info btn-sm btn-block">{Lang::T('Sync')}</a>
</div>
</div>
</div>
<div class="col-sm-8 col-md-8">
<ul class="nav nav-tabs">
@ -135,68 +146,68 @@
<div class="table-responsive" style="background-color: white;">
<table id="datatable" class="table table-bordered table-striped">
{if Lang::arrayCount($activation)}
<thead>
<tr>
<th>{Lang::T('Invoice')}</th>
<th>{Lang::T('Username')}</th>
<th>{Lang::T('Plan Name')}</th>
<th>{Lang::T('Plan Price')}</th>
<th>{Lang::T('Type')}</th>
<th>{Lang::T('Created On')}</th>
<th>{Lang::T('Expires On')}</th>
<th>{Lang::T('Method')}</th>
</tr>
</thead>
<tbody>
{foreach $activation as $ds}
<tr onclick="window.location.href = '{$_url}prepaid/view/{$ds['id']}'" style="cursor:pointer;">
<td>{$ds['invoice']}</td>
<td>{$ds['username']}</td>
<td>{$ds['plan_name']}</td>
<td>{Lang::moneyFormat($ds['price'])}</td>
<td>{$ds['type']}</td>
<td class="text-success">{Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])}
</td>
<td class="text-danger">{Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])}</td>
<td>{$ds['method']}</td>
</tr>
{/foreach}
</tbody>
<thead>
<tr>
<th>{Lang::T('Invoice')}</th>
<th>{Lang::T('Username')}</th>
<th>{Lang::T('Plan Name')}</th>
<th>{Lang::T('Plan Price')}</th>
<th>{Lang::T('Type')}</th>
<th>{Lang::T('Created On')}</th>
<th>{Lang::T('Expires On')}</th>
<th>{Lang::T('Method')}</th>
</tr>
</thead>
<tbody>
{foreach $activation as $ds}
<tr onclick="window.location.href = '{$_url}prepaid/view/{$ds['id']}'" style="cursor:pointer;">
<td>{$ds['invoice']}</td>
<td>{$ds['username']}</td>
<td>{$ds['plan_name']}</td>
<td>{Lang::moneyFormat($ds['price'])}</td>
<td>{$ds['type']}</td>
<td class="text-success">{Lang::dateAndTimeFormat($ds['recharged_on'],$ds['recharged_time'])}
</td>
<td class="text-danger">{Lang::dateAndTimeFormat($ds['expiration'],$ds['time'])}</td>
<td>{$ds['method']}</td>
</tr>
{/foreach}
</tbody>
{/if}
{if Lang::arrayCount($order)}
<thead>
<tr>
<th>{Lang::T('Plan Name')}</th>
<th>{Lang::T('Gateway')}</th>
<th>{Lang::T('Routers')}</th>
<th>{Lang::T('Type')}</th>
<th>{Lang::T('Plan Price')}</th>
<th>{Lang::T('Created On')}</th>
<th>{Lang::T('Expires On')}</th>
<th>{Lang::T('Date Done')}</th>
<th>{Lang::T('Method')}</th>
</tr>
</thead>
<tbody>
{foreach $order as $ds}
<tr>
<td>{$ds['plan_name']}</td>
<td>{$ds['gateway']}</td>
<td>{$ds['routers']}</td>
<td>{$ds['payment_channel']}</td>
<td>{Lang::moneyFormat($ds['price'])}</td>
<td class="text-primary">{Lang::dateTimeFormat($ds['created_date'])}</td>
<td class="text-danger">{Lang::dateTimeFormat($ds['expired_date'])}</td>
<td class="text-success">{if $ds['status']!=1}{Lang::dateTimeFormat($ds['paid_date'])}{/if}</td>
<td>{if $ds['status']==1}{Lang::T('UNPAID')}
{elseif $ds['status']==2}{Lang::T('PAID')}
{elseif $ds['status']==3}{$_L['FAILED']}
{elseif $ds['status']==4}{Lang::T('CANCELED')}
{elseif $ds['status']==5}{Lang::T('UNKNOWN')}
{/if}</td>
</tr>
{/foreach}
</tbody>
<thead>
<tr>
<th>{Lang::T('Plan Name')}</th>
<th>{Lang::T('Gateway')}</th>
<th>{Lang::T('Routers')}</th>
<th>{Lang::T('Type')}</th>
<th>{Lang::T('Plan Price')}</th>
<th>{Lang::T('Created On')}</th>
<th>{Lang::T('Expires On')}</th>
<th>{Lang::T('Date Done')}</th>
<th>{Lang::T('Method')}</th>
</tr>
</thead>
<tbody>
{foreach $order as $ds}
<tr>
<td>{$ds['plan_name']}</td>
<td>{$ds['gateway']}</td>
<td>{$ds['routers']}</td>
<td>{$ds['payment_channel']}</td>
<td>{Lang::moneyFormat($ds['price'])}</td>
<td class="text-primary">{Lang::dateTimeFormat($ds['created_date'])}</td>
<td class="text-danger">{Lang::dateTimeFormat($ds['expired_date'])}</td>
<td class="text-success">{if $ds['status']!=1}{Lang::dateTimeFormat($ds['paid_date'])}{/if}</td>
<td>{if $ds['status']==1}{Lang::T('UNPAID')}
{elseif $ds['status']==2}{Lang::T('PAID')}
{elseif $ds['status']==3}{$_L['FAILED']}
{elseif $ds['status']==4}{Lang::T('CANCELED')}
{elseif $ds['status']==5}{Lang::T('UNKNOWN')}
{/if}</td>
</tr>
{/foreach}
</tbody>
{/if}
</table>
</div>

View File

@ -55,7 +55,7 @@
</ul>
<center><b>{Lang::T('Total')}</b></center>
<ul class="list-group list-group-unbordered">
{if $add_rem != 0 and $using neq 'zero' and $add_cost>0}
{if $using neq 'zero' and $add_cost>0}
{foreach $bills as $k => $v}
<li class="list-group-item">
<b>{$k}</b> <span class="pull-right">{Lang::moneyFormat($v)}</span>
@ -65,11 +65,6 @@
<b>{Lang::T('Additional Cost')}</b> <span
class="pull-right">{Lang::moneyFormat($add_cost)}</span>
</li>
{if $add_rem != ''}
<li class="list-group-item">
<b>{Lang::T('Remaining')}</b> <span class="pull-right">{$add_rem}</span>
</li>
{/if}
<li class="list-group-item">
<b>{Lang::T('Total')}</b> <small>({Lang::T('Plan Price')} +{Lang::T('Additional Cost')})</small><span class="pull-right"
style="font-size: large; font-weight:bolder; font-family: 'Courier New', Courier, monospace; ">{Lang::moneyFormat($plan['price']+$add_cost)}</span>

View File

@ -54,17 +54,18 @@
<li>Make sure your hosting not blocking port to external</li>
<li>Make sure your Mikrotik accessible from PHPNuxBill</li>
</ul>
If you just update PHPNuxBill from upload files, try click Update Database
</div>
<div class="box-footer">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<a href="./update.php?step=4" class="btn btn-info btn-sm btn-block">Update Database</a>
<a href="{$_url}community#update" class="btn btn-success btn-sm btn-block">Update
<a href="./update.php?step=4" style="color: black;" class="btn btn-info btn-sm btn-block">Update Database</a>
<a href="{$_url}community#update" style="color: black;" class="btn btn-success btn-sm btn-block">Update
PHPNuxBill</a>
</div>
<br>
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<a href="https://github.com/hotspotbilling/phpnuxbill/discussions" target="_blank"
class="btn btn-success btn-sm btn-block">Ask Github Community</a>
class="btn btn-success btn-sm btn-block" style="color: black;">Ask Github Community</a>
<a href="https://t.me/phpnuxbill" target="_blank"
class="btn btn-primary btn-sm btn-block">Ask Telegram Community</a>
</div>

View File

@ -113,8 +113,8 @@
<li>{if $_c['radius_plan']==''}Radius Plan{else}{$_c['radius_plan']}{/if}</li>
<li>{if $_c['pppoe_plan']==''}PPPOE Plan{else}{$_c['pppoe_plan']}{/if}</li>
</ol>
<div class="row">
{if Lang::arrayCount($radius_pppoe)>0}
{if Lang::arrayCount($radius_pppoe)>0}
<div class="row">
{foreach $radius_pppoe as $plan}
<div class="col col-md-4">
<div class="box box-primary">
@ -157,13 +157,14 @@
</div>
</div>
{/foreach}
{/if}
{if Lang::arrayCount($radius_hotspot)>0}
<ol class="breadcrumb">
<li>{if $_c['radius_plan']==''}Radius Plan{else}{$_c['radius_plan']}{/if}</li>
<li>{if $_c['hotspot_plan']==''}Hotspot Plan{else}{$_c['hotspot_plan']}{/if}</li>
</ol>
</div>
{/if}
{if Lang::arrayCount($radius_hotspot)>0}
<ol class="breadcrumb">
<li>{if $_c['radius_plan']==''}Radius Plan{else}{$_c['radius_plan']}{/if}</li>
<li>{if $_c['hotspot_plan']==''}Hotspot Plan{else}{$_c['hotspot_plan']}{/if}</li>
</ol>
<div class="row">
{foreach $radius_hotspot as $plan}
<div class="col col-md-4">
<div class="box box-primary">
@ -206,8 +207,8 @@
</div>
</div>
{/foreach}
{/if}
</div>
</div>
{/if}
{/if}
{/if}
{foreach $routers as $router}

View File

@ -6,7 +6,7 @@
<div
class="panel mb20 {if $trx['status']==1}panel-warning{elseif $trx['status']==2}panel-success{elseif $trx['status']==3}panel-danger{elseif $trx['status']==4}panel-danger{else}panel-primary{/if} panel-hovered">
<div class="panel-footer">Transaction #{$trx['id']}</div>
{if $trx['routers']!='balance'}
{if !in_array($trx['routers'],['balance','radius'])}
<div class="panel-body">
<div class="panel panel-primary panel-hovered">
<div class="panel-heading">{$router['name']}</div>
@ -30,8 +30,8 @@
{date('H:i', strtotime($trx['paid_date']))} </td>
</tr>
<tr>
{if $trx['plan_name'] == 'Receive Balance'}
<td>{Lang::T('From')}</td>
{if $trx['plan_name'] == 'Receive Balance'}
<td>{Lang::T('From')}</td>
{else}
<td>{Lang::T('To')}</td>
{/if}
@ -67,9 +67,21 @@
<td>{Lang::T('Plan Name')}</td>
<td>{$plan['name_plan']}</td>
</tr>
{if $add_cost>0}
{foreach $bills as $k => $v}
<tr>
<td>{$k}</td>
<td>{Lang::moneyFormat($v)}</td>
</tr>
{/foreach}
<tr>
<td>{Lang::T('Additional Cost')}</td>
<td>{Lang::moneyFormat($add_cost)}</td>
</tr>
{/if}
<tr>
<td>{Lang::T('Plan Price')}</td>
<td>{Lang::moneyFormat($plan['price'])}</td>
<td>{Lang::T('Plan Price')}{if $add_cost>0}<small> + {Lang::T('Additional Cost')}{/if}</small></td>
<td style="font-size: large; font-weight:bolder; font-family: 'Courier New', Courier, monospace; ">{Lang::moneyFormat($trx['price'])}</td>
</tr>
<tr>
<td>{Lang::T('Type')}</td>

View File

@ -12,9 +12,21 @@
<td>{Lang::T('Type')}</td>
<td>{$plan['type']}</td>
</tr>
{if $add_cost>0}
{foreach $bills as $k => $v}
<tr>
<td>{$k}</td>
<td>{Lang::moneyFormat($v)}</td>
</tr>
{/foreach}
<tr>
<td>{Lang::T('Additional Cost')}</td>
<td>{Lang::moneyFormat($add_cost)}</td>
</tr>
{/if}
<tr>
<td>{Lang::T('Price')}</td>
<td>{Lang::moneyFormat($plan['price'])}</td>
<td>{Lang::T('Price')}{if $add_cost>0}<small> + {Lang::T('Additional Cost')}{/if}</td>
<td style="font-size: large; font-weight:bolder; font-family: 'Courier New', Courier, monospace; ">{Lang::moneyFormat($plan['price'])}</td>
</tr>
<tr>
<td>{Lang::T('Validity')}</td>
@ -35,6 +47,7 @@
value="plan"><i class="glyphicon glyphicon-send"></i></button>
</div>
</div>
<p class="help-block text-center">{Lang::T('If your friend have Additional Cost, you will pay for that too')}</p>
</form>
</div>
</div>

View File

@ -1,3 +1,3 @@
{
"version": "2024.3.14"
"version": "2024.3.15"
}