Fix notification

This commit is contained in:
Ibnu Maksum 2024-03-18 11:48:15 +07:00
parent d36f39af8f
commit 130451e1ae
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
5 changed files with 107 additions and 44 deletions

View File

@ -2,6 +2,11 @@
# CHANGELOG # CHANGELOG
## 2024.3.18
- Add Broadcasting SMS by @Focuslinkstech
- Fix Notification with Bills
## 2024.3.16 ## 2024.3.16
- Fix Zero Charging - Fix Zero Charging

View File

@ -116,6 +116,9 @@ class Message
$textInvoice = str_replace('[[phone]]', $config['phone'], $textInvoice); $textInvoice = str_replace('[[phone]]', $config['phone'], $textInvoice);
$textInvoice = str_replace('[[invoice]]', $trx['invoice'], $textInvoice); $textInvoice = str_replace('[[invoice]]', $trx['invoice'], $textInvoice);
$textInvoice = str_replace('[[date]]', Lang::dateAndTimeFormat($trx['recharged_on'], $trx['recharged_time']), $textInvoice); $textInvoice = str_replace('[[date]]', Lang::dateAndTimeFormat($trx['recharged_on'], $trx['recharged_time']), $textInvoice);
if (!empty($trx['note'])) {
$textInvoice = str_replace('[[note]]', $trx['note'], $textInvoice);
}
$gc = explode("-", $trx['method']); $gc = explode("-", $trx['method']);
$textInvoice = str_replace('[[payment_gateway]]', trim($gc[0]), $textInvoice); $textInvoice = str_replace('[[payment_gateway]]', trim($gc[0]), $textInvoice);
$textInvoice = str_replace('[[payment_channel]]', trim($gc[1]), $textInvoice); $textInvoice = str_replace('[[payment_channel]]', trim($gc[1]), $textInvoice);

View File

@ -37,7 +37,7 @@ class Package
// Zero cost recharge // Zero cost recharge
if (isset($zero) && $zero == 1) { if (isset($zero) && $zero == 1) {
$p['price'] = 0; $p['price'] = 0;
}else{ } else {
// Additional cost // Additional cost
list($bills, $add_cost) = User::getBills($id_customer); list($bills, $add_cost) = User::getBills($id_customer);
if ($add_cost > 0 && $router_name != 'balance') { if ($add_cost > 0 && $router_name != 'balance') {
@ -240,13 +240,13 @@ class Package
$t->username = $c['username']; $t->username = $c['username'];
$t->plan_name = $p['name_plan']; $t->plan_name = $p['name_plan'];
if ($p['validity_unit'] == 'Period') { if ($p['validity_unit'] == 'Period') {
// Postpaid price from field // Postpaid price from field
$add_inv = User::getAttribute("Invoice", $id_customer); $add_inv = User::getAttribute("Invoice", $id_customer);
if (empty ($add_inv) or $add_inv == 0) { if (empty($add_inv) or $add_inv == 0) {
$t->price = $p['price'] + $add_cost; $t->price = $p['price'] + $add_cost;
} else { } else {
$t->price = $add_inv + $add_cost; $t->price = $add_inv + $add_cost;
} }
} else { } else {
$t->price = $p['price'] + $add_cost; $t->price = $p['price'] + $add_cost;
} }
@ -286,7 +286,8 @@ class Package
"\nRouter: " . $router_name . "\nRouter: " . $router_name .
"\nGateway: " . $gateway . "\nGateway: " . $gateway .
"\nChannel: " . $channel . "\nChannel: " . $channel .
"\nPrice: " . Lang::moneyFormat($p['price'])); "\nPrice: " . Lang::moneyFormat($p['price']) .
"\nNote:\n" . $note);
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
@ -323,7 +324,7 @@ class Package
$t->username = $c['username']; $t->username = $c['username'];
$t->plan_name = $p['name_plan']; $t->plan_name = $p['name_plan'];
if ($p['validity_unit'] == 'Period') { if ($p['validity_unit'] == 'Period') {
// Postpaid price always zero for first time // Postpaid price always zero for first time
$t->price = 0 + $add_cost; $t->price = 0 + $add_cost;
} else { } else {
$t->price = $p['price'] + $add_cost; $t->price = $p['price'] + $add_cost;
@ -350,12 +351,12 @@ class Package
$fl = ORM::for_table('tbl_customers_fields')->create(); $fl = ORM::for_table('tbl_customers_fields')->create();
$fl->customer_id = $c['id']; $fl->customer_id = $c['id'];
$fl->field_name = 'Invoice'; $fl->field_name = 'Invoice';
// Calculating Price // Calculating Price
$sd = new DateTime("$date_only"); $sd = new DateTime("$date_only");
$ed = new DateTime("$date_exp"); $ed = new DateTime("$date_exp");
$td = $ed->diff($sd); $td = $ed->diff($sd);
$fd = $td->format("%a"); $fd = $td->format("%a");
$gi = ($p['price'] / 30) * $fd; $gi = ($p['price'] / 30) * $fd;
if ($gi > $p['price']) { if ($gi > $p['price']) {
$fl->field_value = $p['price']; $fl->field_value = $p['price'];
} else { } else {
@ -373,7 +374,8 @@ class Package
"\nRouter: " . $router_name . "\nRouter: " . $router_name .
"\nGateway: " . $gateway . "\nGateway: " . $gateway .
"\nChannel: " . $channel . "\nChannel: " . $channel .
"\nPrice: " . Lang::moneyFormat($p['price'])); "\nPrice: " . Lang::moneyFormat($p['price']) .
"\nNote:\n" . $note);
} }
} else { } else {
@ -434,13 +436,13 @@ class Package
$t->username = $c['username']; $t->username = $c['username'];
$t->plan_name = $p['name_plan']; $t->plan_name = $p['name_plan'];
if ($p['validity_unit'] == 'Period') { if ($p['validity_unit'] == 'Period') {
// Postpaid price from field // Postpaid price from field
$add_inv = User::getAttribute("Invoice", $id_customer); $add_inv = User::getAttribute("Invoice", $id_customer);
if (empty ($add_inv) or $add_inv == 0) { if (empty($add_inv) or $add_inv == 0) {
$t->price = $p['price'] + $add_cost; $t->price = $p['price'] + $add_cost;
} else { } else {
$t->price = $add_inv + $add_cost; $t->price = $add_inv + $add_cost;
} }
} else { } else {
$t->price = $p['price'] + $add_cost; $t->price = $p['price'] + $add_cost;
} }
@ -479,7 +481,8 @@ class Package
"\nRouter: " . $router_name . "\nRouter: " . $router_name .
"\nGateway: " . $gateway . "\nGateway: " . $gateway .
"\nChannel: " . $channel . "\nChannel: " . $channel .
"\nPrice: " . Lang::moneyFormat($p['price'])); "\nPrice: " . Lang::moneyFormat($p['price']) .
"\nNote:\n" . $note);
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
@ -516,7 +519,7 @@ class Package
$t->username = $c['username']; $t->username = $c['username'];
$t->plan_name = $p['name_plan']; $t->plan_name = $p['name_plan'];
if ($p['validity_unit'] == 'Period') { if ($p['validity_unit'] == 'Period') {
// Postpaid price always zero for first time // Postpaid price always zero for first time
$t->price = 0 + $add_cost; $t->price = 0 + $add_cost;
} else { } else {
$t->price = $p['price'] + $add_cost; $t->price = $p['price'] + $add_cost;
@ -543,12 +546,12 @@ class Package
$fl = ORM::for_table('tbl_customers_fields')->create(); $fl = ORM::for_table('tbl_customers_fields')->create();
$fl->customer_id = $c['id']; $fl->customer_id = $c['id'];
$fl->field_name = 'Invoice'; $fl->field_name = 'Invoice';
// Calculating Price // Calculating Price
$sd = new DateTime("$date_only"); $sd = new DateTime("$date_only");
$ed = new DateTime("$date_exp"); $ed = new DateTime("$date_exp");
$td = $ed->diff($sd); $td = $ed->diff($sd);
$fd = $td->format("%a"); $fd = $td->format("%a");
$gi = ($p['price'] / 30) * $fd; $gi = ($p['price'] / 30) * $fd;
if ($gi > $p['price']) { if ($gi > $p['price']) {
$fl->field_value = $p['price']; $fl->field_value = $p['price'];
} else { } else {
@ -566,7 +569,8 @@ class Package
"\nRouter: " . $router_name . "\nRouter: " . $router_name .
"\nGateway: " . $gateway . "\nGateway: " . $gateway .
"\nChannel: " . $channel . "\nChannel: " . $channel .
"\nPrice: " . Lang::moneyFormat($p['price'])); "\nPrice: " . Lang::moneyFormat($p['price']) .
"\nNote:\n" . $note);
} }
} }
if (is_array($bills) && count($bills) > 0) { if (is_array($bills) && count($bills) > 0) {
@ -678,9 +682,10 @@ class Package
$_admin = Admin::_info($in['admin_id']); $_admin = Admin::_info($in['admin_id']);
// if admin not deleted // if admin not deleted
if ($_admin) $admin = $_admin; if ($_admin) $admin = $_admin;
}else{ } else {
$admin['fullname'] = 'Customer'; $admin['fullname'] = 'Customer';
} }
$note = '';
//print //print
$invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n"; $invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";
$invoice .= Lang::pad($config['address'], ' ', 2) . "\n"; $invoice .= Lang::pad($config['address'], ' ', 2) . "\n";
@ -692,11 +697,26 @@ class Package
$invoice .= Lang::pad("", '=') . "\n"; $invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n"; $invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n"; $invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($in['price']), ' ') . "\n"; if (!empty($in['note'])) {
$invoice .= Lang::pad($in['method'], ' ', 2) . "\n"; $in['note'] = str_replace("\r", "", $in['note']);
if(!empty($in['note'])){ $tmp = explode("\n", $in['note']);
foreach ($tmp as $t) {
if (strpos($t, " : ") === false) {
if (!empty($t)) {
$note .= "$t\n";
}
} else {
$tmp2 = explode(" : ", $t);
$invoice .= Lang::pads($tmp2[0], $tmp2[1], ' ') . "\n";
}
}
}
$invoice .= Lang::pads(Lang::T('Total'), Lang::moneyFormat($in['price']), ' ') . "\n";
$method = explode("-", $in['method']);
$invoice .= Lang::pads($method[0], $method[1], ' ') . "\n";
if (!empty($note)) {
$invoice .= Lang::pad("", '=') . "\n"; $invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($in['note'], ' ', 2); $invoice .= Lang::pad($note, ' ', 2) . "\n";
} }
$invoice .= Lang::pad("", '=') . "\n"; $invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n"; $invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
@ -720,11 +740,24 @@ class Package
$invoice .= Lang::pad("", '=') . "\n"; $invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n"; $invoice .= Lang::pads(Lang::T('Type'), $in['type'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n"; $invoice .= Lang::pads(Lang::T('Plan Name'), $in['plan_name'], ' ') . "\n";
$invoice .= Lang::pads(Lang::T('Plan Price'), Lang::moneyFormat($in['price']), ' ') . "\n"; if (!empty($in['note'])) {
$invoice .= Lang::pad($in['method'], ' ', 2) . "\n";
if(!empty($in['note'])){
$invoice .= Lang::pad("", '=') . "\n"; $invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($in['note'], ' ', 2); foreach ($tmp as $t) {
if (strpos($t, " : ") === false) {
if (!empty($t)) {
$invoice .= Lang::pad($t, ' ', 2) . "\n";
}
} else {
$tmp2 = explode(" : ", $t);
$invoice .= Lang::pads($tmp2[0], $tmp2[1], ' ') . "\n";
}
}
}
$invoice .= Lang::pads(Lang::T('Total'), Lang::moneyFormat($in['price']), ' ') . "\n";
$invoice .= Lang::pads($method[0], $method[1], ' ') . "\n";
if (!empty($note)) {
$invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pad($note, ' ', 2) . "\n";
} }
$invoice .= Lang::pad("", '=') . "\n"; $invoice .= Lang::pad("", '=') . "\n";
$invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n"; $invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";

View File

@ -490,5 +490,27 @@
"Payment_not_found": "Payment not found", "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", "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!", "Cache_cleared_successfully_": "Cache cleared successfully!",
"Paid": "Paid" "Paid": "Paid",
"Send_Message": "Send Message",
"Send_SMS_WA_Message": "Send SMS\/WA Message",
"Send_Bulk_SMS_WA_Message": "Send Bulk SMS\/WA Message",
"Send_Personal_Message": "Send Personal Message",
"Send_Via": "Send Via",
"Compose_your_message___": "Compose your message...",
"Use_placeholders_": "Use placeholders:",
"__name__": "[[name]]",
"Customer_Name": "Customer Name",
"__user_name__": "[[user_name]]",
"Customer_Username": "Customer Username",
"__phone__": "[[phone]]",
"Customer_Phone": "Customer Phone",
"__company_name__": "[[company_name]]",
"Your_Company_Name": "Your Company Name",
"Message_Sent_Successfully": "Message Sent Successfully",
"Send_Bulk_Message": "Send Bulk Message",
"Group": "Group",
"All_Customers": "All Customers",
"New_Customers": "New Customers",
"Expired_Customers": "Expired Customers",
"Active_Customers": "Active Customers"
} }

View File

@ -1,3 +1,3 @@
{ {
"version": "2024.3.16" "version": "2024.3.18"
} }