From 1315621259cf3b807e1726880c7356e84d4f860d Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 6 Mar 2023 14:50:55 +0700 Subject: [PATCH] check notification --- system/autoload/Package.php | 26 ++++++++++++++++---------- system/controllers/prepaid.php | 26 ++++++++++++++++++-------- system/controllers/voucher.php | 4 ++-- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 53c87a46..19c0b087 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -51,8 +51,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removeHotspotUser($client,$c['username']); - Mikrotik::addHotspotUser($client,$p,$c); + Mikrotik::removeHotspotUser($client, $c['username']); + Mikrotik::addHotspotUser($client, $p, $c); } $b->customer_id = $id_customer; @@ -84,7 +84,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::addHotspotUser($client,$p,$c); + Mikrotik::addHotspotUser($client, $p, $c); } $d = ORM::for_table('tbl_user_recharges')->create(); @@ -115,7 +115,7 @@ class Package $t->type = "Hotspot"; $t->save(); } - sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . + Message::sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . @@ -125,8 +125,8 @@ class Package if ($b) { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::removePpoeUser($client,$c['username']); - Mikrotik::addPpoeUser($client,$p,$c); + Mikrotik::removePpoeUser($client, $c['username']); + Mikrotik::addPpoeUser($client, $p, $c); } $b->customer_id = $id_customer; @@ -158,7 +158,7 @@ class Package } else { if (!$_c['radius_mode']) { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); - Mikrotik::addPpoeUser($client,$p,$c); + Mikrotik::addPpoeUser($client, $p, $c); } $d = ORM::for_table('tbl_user_recharges')->create(); @@ -189,7 +189,7 @@ class Package $t->type = "PPPOE"; $t->save(); } - sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . + Message::sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nGateway: " . $gateway . "\nChannel: " . $channel . @@ -198,7 +198,7 @@ class Package $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); - sendWhatsapp($c['username'], "*$_c[CompanyName]*\n" . + $msg = "*$_c[CompanyName]*\n" . "$_c[address]\n" . "$_c[phone]\n" . "\n\n" . @@ -214,7 +214,13 @@ class Package "$_L[Created_On] :\n*" . date($_c['date_format'], strtotime($in['recharged_on'])) . " $in[time]*\n" . "$_L[Expires_On] :\n*" . date($_c['date_format'], strtotime($in['expiration'])) . " $in[time]*\n" . "\n\n" . - "$_c[note]"); + "$_c[note]"; + + if ($_c['user_notification_payment'] == 'sms') { + Message::sendSMS($c['phonenumber'], $msg); + } else if ($_c['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($c['phonenumber'], $msg); + } return true; } } diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 90fe7b93..4aa267a1 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -169,7 +169,7 @@ switch ($action) { $t->type = "Hotspot"; $t->save(); } - sendTelegram( "$admin[fullname] #Recharge Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] #Recharge Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. "\nRouter: ".$server. "\nPrice: ".$p['price']); } else { @@ -241,7 +241,7 @@ switch ($action) { $t->type = "PPPOE"; $t->save(); } - sendTelegram( "$admin[fullname] #Recharge Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] #Recharge Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. "\nRouter: ".$server. "\nPrice: ".$p['price']); } @@ -249,7 +249,7 @@ switch ($action) { $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); $ui->assign('in', $in); - sendWhatsapp($c['username'], "*$config[CompanyName]*\n". + $msg = "*$config[CompanyName]*\n". "$config[address]\n". "$config[phone]\n". "\n\n". @@ -265,8 +265,13 @@ switch ($action) { "$_L[Created_On] :\n*".date($config['date_format'], strtotime($in['recharged_on']))." $in[time]*\n". "$_L[Expires_On] :\n*".date($config['date_format'], strtotime($in['expiration']))." $in[time]*\n". "\n\n". - "$config[note]"); + "$config[note]"; + if ($_c['user_notification_payment'] == 'sms') { + Message::sendSMS($c['phonenumber'], $msg); + } else if ($_c['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($c['phonenumber'], $msg); + } $ui->assign('date', $date_now); $ui->display('invoice.tpl'); @@ -631,7 +636,7 @@ switch ($action) { $v1->user = $c['username']; $v1->save(); - sendTelegram( "$admin[fullname] #Refill #Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] #Refill #Voucher #Hotspot for #u$c[username]\n".$p['name_plan']. "\nCode: ".$code. "\nRouter: ".$v1['routers']. "\nPrice: ".$p['price']); @@ -709,7 +714,7 @@ switch ($action) { $v1->save(); - sendTelegram( "$admin[fullname] Refill #Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. + Message::sendTelegram( "$admin[fullname] Refill #Voucher #PPPOE for #u$c[username]\n".$p['name_plan']. "\nCode: ".$code. "\nRouter: ".$v1['routers']. "\nPrice: ".$p['price']); @@ -718,7 +723,7 @@ switch ($action) { $ui->assign('in', $in); - sendWhatsapp($c['username'], "*$config[CompanyName]*\n". + $msg = "*$config[CompanyName]*\n". "$config[address]\n". "$config[phone]\n". "\n\n". @@ -734,8 +739,13 @@ switch ($action) { "$_L[Created_On] :\n*".date($config['date_format'], strtotime($in['recharged_on']))." $in[time]*\n". "$_L[Expires_On] :\n*".date($config['date_format'], strtotime($in['expiration']))." $in[time]*\n". "\n\n". - "$config[note]"); + "$config[note]"; + if ($_c['user_notification_payment'] == 'sms') { + Message::sendSMS($c['phonenumber'], $msg); + } else if ($_c['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($c['phonenumber'], $msg); + } $ui->assign('date', $date_now); $ui->display('invoice.tpl'); } else { diff --git a/system/controllers/voucher.php b/system/controllers/voucher.php index 65704807..22ee64dc 100644 --- a/system/controllers/voucher.php +++ b/system/controllers/voucher.php @@ -123,7 +123,7 @@ switch ($action) { $v1->user = $c['username']; $v1->save(); // Telegram to Admin - sendTelegram('#u' . $c['username'] . " Activate #Voucher #Hotspot\n" . $p['name_plan'] . + Message::sendTelegram('#u' . $c['username'] . " Activate #Voucher #Hotspot\n" . $p['name_plan'] . "\nCode: " . $code . "\nRouter: " . $v1['routers'] . "\nPrice: " . $p['price']); @@ -200,7 +200,7 @@ switch ($action) { $v1->user = $c['username']; $v1->save(); // Telegram to Admin - sendTelegram('#u' . $c['username'] . " Activate #Voucher #PPPOE\n" . $p['name_plan'] . + Message::sendTelegram('#u' . $c['username'] . " Activate #Voucher #PPPOE\n" . $p['name_plan'] . "\nCode: " . $code . "\nRouter: " . $v1['routers'] . "\nPrice: " . $p['price']);