balance notification
This commit is contained in:
parent
75cbe2b1ec
commit
15b9744b18
@ -49,4 +49,13 @@ class Lang
|
||||
public static function arrayCount($arr){
|
||||
return count($arr);
|
||||
}
|
||||
|
||||
public static function getNotifText($key){
|
||||
global $_notifmsg, $_notifmsg_default;
|
||||
if(isset($_notifmsg[$key])){
|
||||
return $_notifmsg[$key];
|
||||
}else{
|
||||
return $_notifmsg_default[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,4 +56,20 @@ class Message
|
||||
return "$via: $msg";
|
||||
}
|
||||
|
||||
public static function sendBalanceNotification($phone, $name, $balance, $message, $via)
|
||||
{
|
||||
$msg = str_replace('[[name]]', "*$name*", $message);
|
||||
$msg = str_replace('[[balance]]', "*" . Lang::moneyFormat($balance) . "*", $msg);
|
||||
if (
|
||||
!empty($phone) && strlen($phone) > 5
|
||||
&& !empty($message) && in_array($via, ['sms', 'wa'])
|
||||
) {
|
||||
if ($via == 'sms') {
|
||||
Message::sendSMS($phone, $msg);
|
||||
} else if ($via == 'wa') {
|
||||
Message::sendWhatsapp($phone, $msg);
|
||||
}
|
||||
}
|
||||
return "$via: $msg";
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class Package
|
||||
|
||||
Balance::plus($id_customer, $p['price']);
|
||||
|
||||
$textInvoice = $_notifmsg['invoice_balance'];
|
||||
$textInvoice = Lang::getNotifText('invoice_balance');
|
||||
$textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice);
|
||||
$textInvoice = str_replace('[[address]]', $_c['address'], $textInvoice);
|
||||
$textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice);
|
||||
@ -165,7 +165,7 @@ class Package
|
||||
"\nRouter: " . $router_name .
|
||||
"\nGateway: " . $gateway .
|
||||
"\nChannel: " . $channel .
|
||||
"\nPrice: " . $p['price']);
|
||||
"\nPrice: " . Lang::moneyFormat($p['price']));
|
||||
} else {
|
||||
|
||||
if ($b) {
|
||||
@ -241,12 +241,12 @@ class Package
|
||||
"\nRouter: " . $router_name .
|
||||
"\nGateway: " . $gateway .
|
||||
"\nChannel: " . $channel .
|
||||
"\nPrice: " . $p['price']);
|
||||
"\nPrice: " . Lang::moneyFormat($p['price']));
|
||||
}
|
||||
|
||||
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
||||
|
||||
$textInvoice = $_notifmsg['invoice_paid'];
|
||||
$textInvoice = Lang::getNotifText('invoice_paid');
|
||||
$textInvoice = str_replace('[[company_name]]', $_c['CompanyName'], $textInvoice);
|
||||
$textInvoice = str_replace('[[address]]', $_c['address'], $textInvoice);
|
||||
$textInvoice = str_replace('[[phone]]', $_c['phone'], $textInvoice);
|
||||
|
@ -131,9 +131,8 @@ include "autoload/Hookers.php";
|
||||
// notification message
|
||||
if(file_exists("system/uploads/notifications.json")){
|
||||
$_notifmsg =json_decode(file_get_contents('system/uploads/notifications.json'), true);
|
||||
}else{
|
||||
$_notifmsg = json_decode(file_get_contents('system/uploads/notifications.default.json'), true);
|
||||
}
|
||||
$_notifmsg_default = json_decode(file_get_contents('system/uploads/notifications.default.json'), true);
|
||||
|
||||
//register all plugin
|
||||
foreach (glob("system/plugin/*.php") as $filename) {
|
||||
|
@ -28,7 +28,7 @@ if (_post('send') == 'balance') {
|
||||
if ($user['username'] == $target['username']) {
|
||||
r2(U . 'home', 'd', Lang::T('Cannot send to yourself'));
|
||||
}
|
||||
if(Balance::transfer($user['id'], $username, $balance)){
|
||||
if (Balance::transfer($user['id'], $username, $balance)) {
|
||||
//sender
|
||||
$d = ORM::for_table('tbl_payment_gateway')->create();
|
||||
$d->username = $user['username'];
|
||||
@ -46,6 +46,7 @@ if (_post('send') == 'balance') {
|
||||
$d->pg_url_payment = 'balance';
|
||||
$d->status = 2;
|
||||
$d->save();
|
||||
Message::sendBalanceNotification($user['phonenumber'], $target['fullname'] . ' (' . $target['username'] . ')', $balance, Lang::getNotifText('balance_send'), $config['user_notification_reminder']);
|
||||
//receiver
|
||||
$d = ORM::for_table('tbl_payment_gateway')->create();
|
||||
$d->username = $target['username'];
|
||||
@ -63,9 +64,11 @@ if (_post('send') == 'balance') {
|
||||
$d->pg_url_payment = 'balance';
|
||||
$d->status = 2;
|
||||
$d->save();
|
||||
Message::sendBalanceNotification($target['phonenumber'], $user['fullname'] . ' (' . $user['username'] . ')', $balance, Lang::getNotifText('balance_received'), $config['user_notification_reminder']);
|
||||
Message::sendTelegram("#u$user[username] send balance to #u$target[username] \n" . Lang::moneyFormat($balance));
|
||||
r2(U . 'home', 's', Lang::T('Sending balance success'));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
r2(U . 'home', 'd', 'Failed, balance is not available');
|
||||
}
|
||||
}
|
||||
|
@ -502,6 +502,7 @@ switch ($action) {
|
||||
}else{
|
||||
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.default.json'), true));
|
||||
}
|
||||
$ui->assign('_default', json_decode(file_get_contents('system/uploads/notifications.default.json'), true));
|
||||
$ui->display('app-notifications.tpl');
|
||||
break;
|
||||
case 'notifications-post':
|
||||
|
@ -19,11 +19,10 @@ ORM::configure('logging', true);
|
||||
include "autoload/Hookers.php";
|
||||
|
||||
// notification message
|
||||
if (file_exists("uploads/notifications.json")) {
|
||||
$_notifmsg = json_decode(file_get_contents('uploads/notifications.json'), true);
|
||||
} else {
|
||||
$_notifmsg = json_decode(file_get_contents('uploads/notifications.default.json'), true);
|
||||
if(file_exists("system/uploads/notifications.json")){
|
||||
$_notifmsg =json_decode(file_get_contents('system/uploads/notifications.json'), true);
|
||||
}
|
||||
$_notifmsg_default = json_decode(file_get_contents('system/uploads/notifications.default.json'), true);
|
||||
|
||||
//register all plugin
|
||||
foreach (glob("plugin/*.php") as $filename) {
|
||||
@ -64,10 +63,10 @@ $_c = $config;
|
||||
|
||||
date_default_timezone_set($config['timezone']);
|
||||
|
||||
$textExpired = $_notifmsg['expired'];
|
||||
$textExpired = Lang::getNotifText('expired');
|
||||
|
||||
$d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->where('expiration', date("Y-m-d"))->find_many();
|
||||
|
||||
echo "Found ".count($d)." user(s)\n";
|
||||
run_hook('cronjob'); #HOOK
|
||||
|
||||
foreach ($d as $ds) {
|
||||
|
@ -22,11 +22,10 @@ ORM::configure('logging', true);
|
||||
include "autoload/Hookers.php";
|
||||
|
||||
// notification message
|
||||
if(file_exists("uploads/notifications.json")){
|
||||
$_notifmsg =json_decode(file_get_contents('uploads/notifications.json'), true);
|
||||
}else{
|
||||
$_notifmsg = json_decode(file_get_contents('uploads/notifications.default.json'), true);
|
||||
if(file_exists("system/uploads/notifications.json")){
|
||||
$_notifmsg =json_decode(file_get_contents('system/uploads/notifications.json'), true);
|
||||
}
|
||||
$_notifmsg_default = json_decode(file_get_contents('system/uploads/notifications.default.json'), true);
|
||||
|
||||
//register all plugin
|
||||
foreach (glob("plugin/*.php") as $filename) {
|
||||
@ -74,17 +73,17 @@ run_hook('cronjob_reminder'); #HOOK
|
||||
$day7 = date('Y-m-d', strtotime("+7 day"));
|
||||
$day3 = date('Y-m-d', strtotime("+3 day"));
|
||||
$day1 = date('Y-m-d', strtotime("+1 day"));
|
||||
print_r([$day1,$day3,$day7]);
|
||||
print_r([$day1, $day3, $day7]);
|
||||
foreach ($d as $ds) {
|
||||
if(in_array($ds['expiration'],[$day1,$day3,$day7])){
|
||||
if (in_array($ds['expiration'], [$day1, $day3, $day7])) {
|
||||
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
|
||||
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
|
||||
if($ds['expiration']==$day7){
|
||||
echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $_notifmsg['reminder_7_day'], $config['user_notification_reminder'])."\n";
|
||||
}else if($ds['expiration']==$day3){
|
||||
echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $_notifmsg['reminder_3_day'], $config['user_notification_reminder'])."\n";
|
||||
}else if($ds['expiration']==$day1){
|
||||
echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], $_notifmsg['reminder_1_day'], $config['user_notification_reminder'])."\n";
|
||||
if ($ds['expiration'] == $day7) {
|
||||
echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], Lang::getNotifText('reminder_7_day'), $config['user_notification_reminder']) . "\n";
|
||||
} else if ($ds['expiration'] == $day3) {
|
||||
echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], Lang::getNotifText('reminder_3_day'), $config['user_notification_reminder']) . "\n";
|
||||
} else if ($ds['expiration'] == $day1) {
|
||||
echo Message::sendPackageNotification($c['phonenumber'], $c['fullname'], $u['namebp'], Lang::getNotifText('reminder_1_day'), $config['user_notification_reminder']) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -380,3 +380,5 @@ $_L['Sending_balance_success'] = 'Sending balance success';
|
||||
$_L['From'] = 'From';
|
||||
$_L['To'] = 'To';
|
||||
$_L['insufficient_balance'] = 'insufficient balance';
|
||||
$_L['Send_Balance'] = 'Send Balance';
|
||||
$_L['Received_Balance'] = 'Received Balance';
|
||||
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"expired": "Hello [[name]], your internet package [[package]] has been expired.",
|
||||
"balance_send": "You sent [[balance]] to [[name]].",
|
||||
"balance_received": "You have received [[balance]] from [[name]].",
|
||||
"reminder_7_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 7 days.",
|
||||
"reminder_3_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 3 days.",
|
||||
"reminder_1_day": "Hello *[[name]]*,\r\n your internet package *[[package]]* will be expired tomorrow.",
|
||||
|
@ -113,6 +113,32 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Send Balance')}</label>
|
||||
<div class="col-md-6">
|
||||
<textarea class="form-control" id="balance_send" name="balance_send"
|
||||
rows="3">{if $_json['balance_send']}{Lang::htmlspecialchars($_json['balance_send'])}{else}{Lang::htmlspecialchars($_default['balance_send'])}{/if}</textarea>
|
||||
</div>
|
||||
<p class="col-md-4 help-block">
|
||||
<b>[[name]]</b> Receiver name.<br>
|
||||
<b>[[balance]]</b> how much balance have been send.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Received Balance')}</label>
|
||||
<div class="col-md-6">
|
||||
<textarea class="form-control" id="balance_received" name="balance_received"
|
||||
rows="3">{if $_json['balance_received']}{Lang::htmlspecialchars($_json['balance_received'])}{else}{Lang::htmlspecialchars($_default['balance_received'])}{/if}</textarea>
|
||||
</div>
|
||||
<p class="col-md-4 help-block">
|
||||
<b>[[name]]</b> Sender name.<br>
|
||||
<b>[[balance]]</b> how much balance have been received.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
Loading…
x
Reference in New Issue
Block a user