From afd75d757e9cc4dc1078d44e534dfc6d71faba13 Mon Sep 17 00:00:00 2001
From: Ibnu Maksum <ibnumaksum@gmail.com>
Date: Fri, 5 Apr 2024 09:34:29 +0700
Subject: [PATCH] add full name in invoice

---
 system/autoload/Package.php  | 8 ++++++++
 system/controllers/order.php | 3 ++-
 system/lan/indonesia.json    | 4 +++-
 ui/ui/user-orderView.tpl     | 4 ++++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/system/autoload/Package.php b/system/autoload/Package.php
index 6d906ff4..a9bdd1a1 100644
--- a/system/autoload/Package.php
+++ b/system/autoload/Package.php
@@ -690,6 +690,8 @@ class Package
         } else {
             $admin['fullname'] = 'Customer';
         }
+        $cust = ORM::for_table('tbl_customers')->where('username', $in['username'])->findOne();
+
         $note = '';
         //print
         $invoice = Lang::pad($config['CompanyName'], ' ', 2) . "\n";
@@ -724,6 +726,9 @@ class Package
             $invoice .= Lang::pad($note, ' ', 2) . "\n";
         }
         $invoice .= Lang::pad("", '=') . "\n";
+        if($cust){
+            $invoice .= Lang::pads(Lang::T('Full Name'), $cust['fullname'], ' ') . "\n";
+        }
         $invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
         $invoice .= Lang::pads(Lang::T('Password'), '**********', ' ') . "\n";
         if ($in['type'] != 'Balance') {
@@ -765,6 +770,9 @@ class Package
             $invoice .= Lang::pad($note, ' ', 2) . "\n";
         }
         $invoice .= Lang::pad("", '=') . "\n";
+        if($cust){
+            $invoice .= Lang::pads(Lang::T('Full Name'), $cust['fullname'], ' ') . "\n";
+        }
         $invoice .= Lang::pads(Lang::T('Username'), $in['username'], ' ') . "\n";
         $invoice .= Lang::pads(Lang::T('Password'), '**********', ' ') . "\n";
         if ($in['type'] != 'Balance') {
diff --git a/system/controllers/order.php b/system/controllers/order.php
index c8ca1fcd..0607297a 100644
--- a/system/controllers/order.php
+++ b/system/controllers/order.php
@@ -127,6 +127,7 @@ switch ($action) {
         if (empty($trx)) {
             r2(U . "order/package", 'e', Lang::T("Transaction Not found"));
         }
+
         $router = Mikrotik::info($trx['routers']);
         $plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']);
         $bandw = ORM::for_table('tbl_bandwidth')->find_one($plan['id_bw']);
@@ -220,7 +221,7 @@ switch ($action) {
             if ($active && $active['plan_id'] != $plan['id']) {
                 r2(U . "order/package", 'e', Lang::T("Target has active plan, different with current plant.") . " [ <b>$active[namebp]</b> ]");
             }
-            if (Package::rechargeUser($target['id'], $router_name, $plan['id'], $user['fullname'], 'Balance')) {
+            if (Package::rechargeUser($target['id'], $router_name, $plan['id'], $user['username'], 'Balance')) {
                 // if success, then get the balance
                 Balance::min($user['id'], $plan['price']);
                 //sender
diff --git a/system/lan/indonesia.json b/system/lan/indonesia.json
index e1dfdb51..21094081 100644
--- a/system/lan/indonesia.json
+++ b/system/lan/indonesia.json
@@ -420,5 +420,7 @@
     "Resend": "Kirim ulang",
     "Login": "Masuk",
     "success": "Sukses",
-    "Click_Here": "Klik disini"
+    "Click_Here": "Klik disini",
+    "Your_friend_do_not_have_active_package": "Teman Anda tidak memiliki paket aktif",
+    "If_your_friend_have_Additional_Cost__you_will_pay_for_that_too": "Jika teman Anda memiliki Biaya Tambahan, Anda juga akan membayarnya"
 }
\ No newline at end of file
diff --git a/ui/ui/user-orderView.tpl b/ui/ui/user-orderView.tpl
index 41954048..01979a27 100644
--- a/ui/ui/user-orderView.tpl
+++ b/ui/ui/user-orderView.tpl
@@ -41,6 +41,10 @@
                                 <td>{Lang::T('Balance')}</td>
                                 <td>{Lang::moneyFormat($trx['price'])}</td>
                             </tr>
+                            <tr>
+                                <td>{Lang::T('Balance')}</td>
+                                <td>{$trx['note']}</td>
+                            </tr>
                         </tbody>
                     </table>
                 {else}