Add Balance to notification

This commit is contained in:
Ibnu Maksum
2023-09-13 16:23:51 +07:00
parent 309bbc0059
commit 53eb817de4
4 changed files with 20 additions and 13 deletions

View File

@ -56,9 +56,10 @@ class Message
return "$via: $msg";
}
public static function sendBalanceNotification($phone, $name, $balance, $message, $via)
public static function sendBalanceNotification($phone, $name, $balance, $balance_now, $message, $via)
{
$msg = str_replace('[[name]]', "*$name*", $message);
$msg = str_replace('[[current_balance]]', Lang::moneyFormat($balance_now), $msg);
$msg = str_replace('[[balance]]', "*" . Lang::moneyFormat($balance) . "*", $msg);
if (
!empty($phone) && strlen($phone) > 5

View File

@ -5,8 +5,6 @@
**/
use PEAR2\Net\RouterOS;
class Package
{
/**
@ -49,7 +47,9 @@ class Package
$t->type = "Balance";
$t->save();
$balance_before = $c['balance'];
Balance::plus($id_customer, $p['price']);
$balance = $c['balance'] + $p['price'];
$textInvoice = Lang::getNotifText('invoice_balance');
$textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice);
@ -66,6 +66,8 @@ class Package
$textInvoice = str_replace('[[user_name]]', $c['username'], $textInvoice);
$textInvoice = str_replace('[[user_password]]', $c['password'], $textInvoice);
$textInvoice = str_replace('[[footer]]', $_c['note'], $textInvoice);
$textInvoice = str_replace('[[balance_before]]', Lang::moneyFormat($balance_before), $textInvoice);
$textInvoice = str_replace('[[balance]]', Lang::moneyFormat($balance), $textInvoice);
if ($_c['user_notification_payment'] == 'sms') {
Message::sendSMS($c['phonenumber'], $textInvoice);