From 9016ecbb984b3e63bf9f86eddee239bdf2dd86a2 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 7 Oct 2024 14:49:43 +0700 Subject: [PATCH] Fix Invoice Print --- system/controllers/plan.php | 4 +- ui/ui/invoice-print.tpl | 163 ++++++++++++++++++++---------------- ui/ui/invoice.tpl | 19 +++-- 3 files changed, 107 insertions(+), 79 deletions(-) diff --git a/system/controllers/plan.php b/system/controllers/plan.php index dc92ba6f..c8b81443 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -228,11 +228,13 @@ switch ($action) { $ui->assign('content', $content); } else { $id = _post('id'); + if(empty($id)) { + $id = $routes['2']; + } $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one(); $ui->assign('in', $d); $ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time'])); } - run_hook('print_invoice'); #HOOK $ui->display('invoice-print.tpl'); break; diff --git a/ui/ui/invoice-print.tpl b/ui/ui/invoice-print.tpl index 5c6b3afd..07b0647d 100644 --- a/ui/ui/invoice-print.tpl +++ b/ui/ui/invoice-print.tpl @@ -16,7 +16,8 @@ .invoice { width: 100%; - max-width: 70mm; /* Maximum width for thermal printing */ + max-width: 70mm; + /* Maximum width for thermal printing */ background: white; border-radius: 8px; padding: 10px; @@ -43,8 +44,10 @@ .details div { margin: 5px 0; - font-weight: bold; /* Bold text for details */ - color: black; /* Ensure text is black */ + font-weight: bold; + /* Bold text for details */ + color: black; + /* Ensure text is black */ } .invoice-info { @@ -57,8 +60,10 @@ .invoice-info td { padding: 5px; text-align: left; - color: black; /* Ensure text is black */ - font-weight: bold; /* Bold text for table content */ + color: black; + /* Ensure text is black */ + font-weight: bold; + /* Bold text for table content */ } .invoice-info th { @@ -68,7 +73,8 @@ .footer { margin-top: 10px; - text-align: left; /* Align footer text to left */ + text-align: left; + /* Align footer text to left */ } @media print { @@ -79,10 +85,14 @@ } .invoice { - width: 70mm; /* Fixed width for thermal printer */ - padding: 5px; /* Reduced padding for print */ - box-shadow: none; /* Remove shadow for clearer print */ - border: none; /* Remove border for print */ + width: 70mm; + /* Fixed width for thermal printer */ + padding: 5px; + /* Reduced padding for print */ + box-shadow: none; + /* Remove shadow for clearer print */ + border: none; + /* Remove border for print */ } .details { @@ -96,19 +106,25 @@ .invoice-info th, .invoice-info td { - padding: 5px; /* Reduced padding */ + padding: 5px; + /* Reduced padding */ text-align: left; - font-weight: bold; /* Bold text for print */ - color: black; /* Ensure text is black */ - border: none; /* Remove borders for print */ + font-weight: bold; + /* Bold text for print */ + color: black; + /* Ensure text is black */ + border: none; + /* Remove borders for print */ } hr { - border: 1px solid #000; /* Darker line for print */ + border: 1px solid #000; + /* Darker line for print */ } .btn { - display: none; /* Hide buttons when printing */ + display: none; + /* Hide buttons when printing */ } } @@ -122,63 +138,68 @@
-
-

{Lang::pad($_c['CompanyName'], ' ', 2)}

-

{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}

-
-
-
{Lang::pad(Lang::T('Invoice'), ' ', 2)}: {$in['invoice']}
-
{Lang::pad(Lang::T('Date'), ' ', 2)}: {$date}
-
{Lang::pad(Lang::T('Sales'), ' ', 2)}: {Lang::pad($_admin['fullname'], ' ', 2)}
-
+ {if $content} +
{$content}
+ {else} +
+

{Lang::pad($_c['CompanyName'], ' ', 2)}

+

{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}

+
+
+
{Lang::pad(Lang::T('Invoice'), ' ', 2)}: {$in['invoice']}
+
{Lang::pad(Lang::T('Date'), ' ', 2)}: {$date}
+
{Lang::pad(Lang::T('Sales'), ' ', 2)}: {Lang::pad($_admin['fullname'], ' ', 2)} +
+
- - - - - - - - - - - - - - - - - - - - - - - - - - {if $in['type'] != 'Balance'} - - - - - - - - - {/if} -
{Lang::pad(Lang::T('Type'), ' ', 2)}{$in['type']}
{Lang::pad(Lang::T('Package Name'), ' ', 2)}{$in['plan_name']}
{Lang::pad(Lang::T('Package Price'), ' ', 2)}{Lang::moneyFormat($in['price'])}
{Lang::pad(Lang::T('Username'), ' ', 2)}{$in['username']}
{Lang::pad(Lang::T('Password'), ' ', 2)}**********
{Lang::pad(Lang::T('Payment Method'), ' ', 2)}{$in['method']}
{Lang::pad(Lang::T('Created On'), ' ', 2)}{Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time'])}
{Lang::pad(Lang::T('Expires On'), ' ', 2)}{Lang::dateAndTimeFormat($in['expiration'], $in['time'])}
+ + + + + + + + + + + + + + + + + + + + + + + + + + {if $in['type'] != 'Balance'} + + + + + + + + + {/if} +
{Lang::pad(Lang::T('Type'), ' ', 2)}{$in['type']}
{Lang::pad(Lang::T('Package Name'), ' ', 2)}{$in['plan_name']}
{Lang::pad(Lang::T('Package Price'), ' ', 2)}{Lang::moneyFormat($in['price'])}
{Lang::pad(Lang::T('Username'), ' ', 2)}{$in['username']}
{Lang::pad(Lang::T('Password'), ' ', 2)}**********
{Lang::pad(Lang::T('Payment Method'), ' ', 2)}{$in['method']}
{Lang::pad(Lang::T('Created On'), ' ', 2)}{Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time'])}
{Lang::pad(Lang::T('Expires On'), ' ', 2)}{Lang::dateAndTimeFormat($in['expiration'], $in['time'])}
-
+
- + + {/if}
@@ -187,4 +208,4 @@ {if isset($xfooter)} {$xfooter} {/if} - + \ No newline at end of file diff --git a/ui/ui/invoice.tpl b/ui/ui/invoice.tpl index 321bedc6..3f208413 100644 --- a/ui/ui/invoice.tpl +++ b/ui/ui/invoice.tpl @@ -12,19 +12,24 @@ {Lang::T('Finish')} - WhatsApp + class="btn btn-primary btn-sm"> + WhatsApp {Lang::T("Resend")} - +
+ + {Lang::T('Print')} HTML + @@ -37,4 +42,4 @@ var s5_taf_parent = window.location; document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML; -{include file="sections/footer.tpl"} +{include file="sections/footer.tpl"} \ No newline at end of file