From b4bec8964d76498a959372a58689c6b9efa09a9e Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 16 Jan 2024 10:32:59 +0700 Subject: [PATCH] Support thermal printer for invoice --- CHANGELOG.md | 1 + system/autoload/Lang.php | 24 +++++++++++++++ ui/ui/app-settings.tpl | 8 +++++ ui/ui/invoice-print.tpl | 45 +++++++++++++-------------- ui/ui/invoice.tpl | 66 ++++++++++++++++++---------------------- 5 files changed, 84 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 262ab4f4..ca4727e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add yellow color to table for plan not allowed to purchase - Fix Radius pool select - add price to reminder notification +- Support thermal printer for invoice ## 2024.1.15 diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php index 6736c700..38d56e3a 100644 --- a/system/autoload/Lang.php +++ b/system/autoload/Lang.php @@ -99,4 +99,28 @@ public static function randomUpLowCase($text){ } return $result; } + + /** + * $pad_type + * 0 Left + * 1 right + * 2 center + * */ + public static function pad($text, $pad_string = ' ', $pad_type = 0){ + global $config; + $cols = 37; + if($config['printer_cols']){ + $cols = $config['printer_cols']; + } + return str_pad($text, $cols, $pad_string, $pad_type); + } + + public static function pads($textLeft, $textRight, $pad_string = ' '){ + global $config; + $cols = 37; + if($config['printer_cols']){ + $cols = $config['printer_cols']; + } + return $textLeft.str_pad($textRight, $cols-strlen($textLeft), $pad_string, 0); + } } diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index f84b56f5..12854e41 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -53,6 +53,14 @@ +
+ +
+ +
+ For invoice print using Thermal Printer +
diff --git a/ui/ui/invoice-print.tpl b/ui/ui/invoice-print.tpl index 09899735..21b98a93 100644 --- a/ui/ui/invoice-print.tpl +++ b/ui/ui/invoice-print.tpl @@ -21,30 +21,27 @@
-
-
- {$_c['CompanyName']}
- {$_c['address']}
- {$_c['phone']}
-
- ============================================
- INVOICE: {$d['invoice']} - {$_L['Date']} : {$date}
- {$_L['Sales']} : {$_admin['fullname']}
- ============================================
- {$_L['Type']} : {$d['type']}
- {$_L['Plan_Name']} : {$d['plan_name']}
- {$_L['Plan_Price']} : {Lang::moneyFormat($d['price'])}
-
- {$_L['Username']} : {$d['username']}
- {$_L['Password']} : **********
- {if $in['type'] != 'Balance'} -
- {$_L['Created_On']} : {Lang::dateAndTimeFormat($d['recharged_on'],$d['recharged_time'])}
- {$_L['Expires_On']} : {Lang::dateAndTimeFormat($d['expiration'],$d['time'])}
- {/if} - ============================================
-
{$_c['note']}
-
+
{Lang::pad($_c['CompanyName'],' ', 2)}
+{Lang::pad($_c['address'],' ', 2)}
+{Lang::pad($_c['phone'],' ', 2)}
+{Lang::pad("", '=')}
+{Lang::pads("Invoice", $in['invoice'], ' ')}
+{Lang::pads($_L['Date'], $date, ' ')}
+{Lang::pads($_L['Sales'], $_admin['fullname'], ' ')}
+{Lang::pad("", '=')}
+{Lang::pads($_L['Type'], $in['type'], ' ')}
+{Lang::pads($_L['Plan_Name'], $in['plan_name'], ' ')}
+{Lang::pads($_L['Plan_Price'], Lang::moneyFormat($in['price']), ' ')}
+{Lang::pad($in['method'], ' ', 2)}
+
+{Lang::pads($_L['Username'], $in['username'], ' ')}
+{Lang::pads($_L['Password'], '**********', ' ')}
+{if $in['type'] != 'Balance'}
+{Lang::pads($_L['Created_On'], Lang::dateAndTimeFormat($in['recharged_on'],$in['recharged_time']), ' ')}
+{Lang::pads($_L['Expires_On'], Lang::dateAndTimeFormat($in['expiration'],$in['time']), ' ')}
+{/if}
+{Lang::pad("", '=')}
+{Lang::pad($_c['note'],' ', 2)}
diff --git a/ui/ui/invoice.tpl b/ui/ui/invoice.tpl index 0c9fa384..eec58810 100644 --- a/ui/ui/invoice.tpl +++ b/ui/ui/invoice.tpl @@ -5,42 +5,36 @@
{$in['invoice']}
-
-
-
- {$_c['CompanyName']}
- {$_c['address']}
- {$_c['phone']}
-
- ====================================================
- INVOICE: {$in['invoice']} - {$_L['Date']} : {$date}
- {$_L['Sales']} : {$_admin['fullname']}
- ====================================================
- {$_L['Type']} : {$in['type']}
- {$_L['Plan_Name']} : {$in['plan_name']}
- {$_L['Plan_Price']} : {Lang::moneyFormat($in['price'])}
- {$in['method']}
-
- {$_L['Username']} : {$in['username']}
- {$_L['Password']} : **********
- {if $in['type'] != 'Balance'} -
- {$_L['Created_On']} : {Lang::dateAndTimeFormat($in['recharged_on'],$in['recharged_time'])}
- {$_L['Expires_On']} : {Lang::dateAndTimeFormat($in['expiration'],$in['time'])}
- {/if} - =====================================================
-
{$_c['note']}
-
-
-
- - {$_L['Finish']} - {Lang::T("Resend To Customer")} - -
+
{Lang::pad($_c['CompanyName'],' ', 2)}
+{Lang::pad($_c['address'],' ', 2)}
+{Lang::pad($_c['phone'],' ', 2)}
+{Lang::pad("", '=')}
+{Lang::pads("Invoice", $in['invoice'], ' ')}
+{Lang::pads($_L['Date'], $date, ' ')}
+{Lang::pads($_L['Sales'], $_admin['fullname'], ' ')}
+{Lang::pad("", '=')}
+{Lang::pads($_L['Type'], $in['type'], ' ')}
+{Lang::pads($_L['Plan_Name'], $in['plan_name'], ' ')}
+{Lang::pads($_L['Plan_Price'], Lang::moneyFormat($in['price']), ' ')}
+{Lang::pad($in['method'], ' ', 2)}
+
+{Lang::pads($_L['Username'], $in['username'], ' ')}
+{Lang::pads($_L['Password'], '**********', ' ')}
+{if $in['type'] != 'Balance'}
+{Lang::pads($_L['Created_On'], Lang::dateAndTimeFormat($in['recharged_on'],$in['recharged_time']), ' ')}
+{Lang::pads($_L['Expires_On'], Lang::dateAndTimeFormat($in['expiration'],$in['time']), ' ')}
+{/if}
+{Lang::pad("", '=')}
+{Lang::pad($_c['note'],' ', 2)}
+
+ + {$_L['Finish']} + {Lang::T("Resend To Customer")} + +