From d95e4d1d844a290d9f6782336908d261acb7782e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Fri, 20 Oct 2023 13:57:12 +0700 Subject: [PATCH] resend invoice --- system/autoload/Message.php | 26 ++++++++++++++++++++++++++ system/autoload/Package.php | 24 +----------------------- system/controllers/order.php | 3 ++- system/controllers/prepaid.php | 12 ++++++++---- ui/ui/invoice.tpl | 12 ++++++------ 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/system/autoload/Message.php b/system/autoload/Message.php index 2a7465e4..aab67ed2 100644 --- a/system/autoload/Message.php +++ b/system/autoload/Message.php @@ -75,4 +75,30 @@ class Message } return "$via: $msg"; } + + public static function sendInvoice($cust, $trx){ + global $config; + $textInvoice = Lang::getNotifText('invoice_paid'); + $textInvoice = str_replace('[[company_name]]', $config['CompanyName'], $textInvoice); + $textInvoice = str_replace('[[address]]', $config['address'], $textInvoice); + $textInvoice = str_replace('[[phone]]', $config['phone'], $textInvoice); + $textInvoice = str_replace('[[invoice]]', $trx['invoice'], $textInvoice); + $textInvoice = str_replace('[[date]]', Lang::dateAndTimeFormat($trx['recharged_on'], $trx['recharged_time']), $textInvoice); + $textInvoice = str_replace('[[payment_gateway]]', $config['gateway'], $textInvoice); + $textInvoice = str_replace('[[payment_channel]]', $config['channel'], $textInvoice); + $textInvoice = str_replace('[[type]]', $trx['type'], $textInvoice); + $textInvoice = str_replace('[[plan_name]]', $trx['plan_name'], $textInvoice); + $textInvoice = str_replace('[[plan_price]]', Lang::moneyFormat($trx['price']), $textInvoice); + $textInvoice = str_replace('[[name]]', $cust['fullname'], $textInvoice); + $textInvoice = str_replace('[[user_name]]', $trx['username'], $textInvoice); + $textInvoice = str_replace('[[user_password]]', $cust['password'], $textInvoice); + $textInvoice = str_replace('[[expired_date]]', Lang::dateAndTimeFormat($trx['expiration'], $trx['time']), $textInvoice); + $textInvoice = str_replace('[[footer]]', $config['note'], $textInvoice); + + if ($config['user_notification_payment'] == 'sms') { + Message::sendSMS($cust['phonenumber'], $textInvoice); + } else if ($config['user_notification_payment'] == 'wa') { + Message::sendWhatsapp($cust['phonenumber'], $textInvoice); + } + } } diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 45a0b205..df986a7d 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -317,29 +317,7 @@ class Package } $in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one(); - - $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); - $textInvoice = str_replace('[[invoice]]', $in['invoice'], $textInvoice); - $textInvoice = str_replace('[[date]]', Lang::dateTimeFormat($date_now), $textInvoice); - $textInvoice = str_replace('[[payment_gateway]]', $_c['gateway'], $textInvoice); - $textInvoice = str_replace('[[payment_channel]]', $_c['channel'], $textInvoice); - $textInvoice = str_replace('[[type]]', $in['type'], $textInvoice); - $textInvoice = str_replace('[[plan_name]]', $in['plan_name'], $textInvoice); - $textInvoice = str_replace('[[plan_price]]', Lang::moneyFormat($in['price']), $textInvoice); - $textInvoice = str_replace('[[name]]', $c['fullname'], $textInvoice); - $textInvoice = str_replace('[[user_name]]', $in['username'], $textInvoice); - $textInvoice = str_replace('[[user_password]]', $c['password'], $textInvoice); - $textInvoice = str_replace('[[expired_date]]', Lang::dateAndTimeFormat($in['expiration'], $in['time']), $textInvoice); - $textInvoice = str_replace('[[footer]]', $_c['note'], $textInvoice); - - if ($_c['user_notification_payment'] == 'sms') { - Message::sendSMS($c['phonenumber'], $textInvoice); - } else if ($_c['user_notification_payment'] == 'wa') { - Message::sendWhatsapp($c['phonenumber'], $textInvoice); - } + Message::sendInvoice($c, $in); return true; } diff --git a/system/controllers/order.php b/system/controllers/order.php index 5c47d0b2..ec7d084d 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -81,7 +81,8 @@ switch ($action) { ->where('username', $user['username']) ->where('status', 1) ->find_one(); - run_hook('customer_find_unpaid'); #HOOK + run_hook('custome + r_find_unpaid'); #HOOK if ($d) { if (empty($d['pg_url_payment'])) { r2(U . "order/buy/" . $trx['routers_id'] . '/' . $trx['plan_id'], 'w', Lang::T("Checking payment")); diff --git a/system/controllers/prepaid.php b/system/controllers/prepaid.php index 24f8619c..08de07e5 100644 --- a/system/controllers/prepaid.php +++ b/system/controllers/prepaid.php @@ -142,11 +142,15 @@ switch ($action) { $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one(); $ui->assign('in', $d); - if(!empty($routes['3'])){ - - r2(U . 'prepaid/view/'.$id, 'e', "Success send to customer"); + if(!empty($routes['3']) && $routes['3']=='send'){ + $c = ORM::for_table('tbl_customers')->where('username', $d['username'])->find_one(); + if($c){ + Message::sendInvoice($c, $d); + r2(U . 'prepaid/view/'.$id, 's', "Success send to customer"); + } + r2(U . 'prepaid/view/'.$id, 'd', "Customer not found"); } - + $ui->assign('_title', 'View Invoice'); $ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'],$d['recharged_time'])); $ui->display('invoice.tpl'); break; diff --git a/ui/ui/invoice.tpl b/ui/ui/invoice.tpl index 0228c9d9..0c9fa384 100644 --- a/ui/ui/invoice.tpl +++ b/ui/ui/invoice.tpl @@ -1,9 +1,9 @@ {include file="sections/header.tpl"}
-
+
-
PRINT INVOICE
+
{$in['invoice']}