Skip to content

Commit

Permalink
Support thermal printer for invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnux committed Jan 16, 2024
1 parent 64f52d6 commit b4bec89
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions system/autoload/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 8 additions & 0 deletions ui/ui/app-settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
<input type="text" class="form-control" id="phone" name="phone" value="{$_c['phone']}">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label"><i class="glyphicon glyphicon-print"></i> Print Max Char</label>
<div class="col-md-6">
<input type="number" required class="form-control" id="printer_cols" placeholder="37" name="printer_cols"
value="{$_c['printer_cols']}">
</div>
<span class="help-block col-md-4">For invoice print using Thermal Printer</span>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Theme</label>
<div class="col-md-6">
Expand Down
45 changes: 21 additions & 24 deletions ui/ui/invoice-print.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,27 @@
<table width="200">
<tr>
<td>
<fieldset>
<center>
<b>{$_c['CompanyName']}</b><br>
{$_c['address']}<br>
{$_c['phone']}<br>
</center>
============================================<br>
INVOICE: <b>{$d['invoice']}</b> - {$_L['Date']} : {$date}<br>
{$_L['Sales']} : {$_admin['fullname']}<br>
============================================<br>
{$_L['Type']} : <b>{$d['type']}</b><br>
{$_L['Plan_Name']} : <b>{$d['plan_name']}</b><br>
{$_L['Plan_Price']} : <b>{Lang::moneyFormat($d['price'])}</b><br>
<br>
{$_L['Username']} : <b>{$d['username']}</b><br>
{$_L['Password']} : **********<br>
{if $in['type'] != 'Balance'}
<br>
{$_L['Created_On']} : <b>{Lang::dateAndTimeFormat($d['recharged_on'],$d['recharged_time'])}</b><br>
{$_L['Expires_On']} : <b>{Lang::dateAndTimeFormat($d['expiration'],$d['time'])}</b><br>
{/if}
============================================<br>
<center>{$_c['note']}</center>
</fieldset>
<pre style="border-style: none; background-color: white;"><b>{Lang::pad($_c['CompanyName'],' ', 2)}</b>
{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)}</pre>
</td>
</tr>
</table>
Expand Down
66 changes: 30 additions & 36 deletions ui/ui/invoice.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,36 @@
<div class="panel panel-hovered panel-primary panel-stacked mb30">
<div class="panel-heading">{$in['invoice']}</div>
<div class="panel-body">
<div class="well">
<fieldset>
<center>
<b>{$_c['CompanyName']}</b><br>
{$_c['address']}<br>
{$_c['phone']}<br>
</center>
====================================================<br>
INVOICE: <b>{$in['invoice']}</b> - {$_L['Date']} : {$date}<br>
{$_L['Sales']} : {$_admin['fullname']}<br>
====================================================<br>
{$_L['Type']} : <b>{$in['type']}</b><br>
{$_L['Plan_Name']} : <b>{$in['plan_name']}</b><br>
{$_L['Plan_Price']} : <b>{Lang::moneyFormat($in['price'])}</b><br>
{$in['method']}<br>
<br>
{$_L['Username']} : <b>{$in['username']}</b><br>
{$_L['Password']} : **********<br>
{if $in['type'] != 'Balance'}
<br>
{$_L['Created_On']} : <b>{Lang::dateAndTimeFormat($in['recharged_on'],$in['recharged_time'])}</b><br>
{$_L['Expires_On']} : <b>{Lang::dateAndTimeFormat($in['expiration'],$in['time'])}</b><br>
{/if}
=====================================================<br>
<center>{$_c['note']}</center>
</fieldset>
</div>
<form class="form-horizontal" method="post" action="{$_url}prepaid/print" target="_blank">
<input type="hidden" name="id" value="{$in['id']}">
<a href="{$_url}prepaid/list" class="btn btn-primary btn-sm"><i
class="ion-reply-all"></i>{$_L['Finish']}</a>
<a href="{$_url}prepaid/view/{$in['id']}/send" class="btn btn-info text-black btn-sm"><i
class="glyphicon glyphicon-envelope"></i> {Lang::T("Resend To Customer")}</a>
<button type="submit" class="btn btn-default btn-sm"><i class="fa fa-print"></i>
{$_L['Click_Here_to_Print']}</button>
</form>
<pre><b>{Lang::pad($_c['CompanyName'],' ', 2)}</b>
{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)}</pre>
<form class="form-horizontal" method="post" action="{$_url}prepaid/print" target="_blank">
<input type="hidden" name="id" value="{$in['id']}">
<a href="{$_url}prepaid/list" class="btn btn-primary btn-sm"><i
class="ion-reply-all"></i>{$_L['Finish']}</a>
<a href="{$_url}prepaid/view/{$in['id']}/send" class="btn btn-info text-black btn-sm"><i
class="glyphicon glyphicon-envelope"></i> {Lang::T("Resend To Customer")}</a>
<button type="submit" class="btn btn-default btn-sm"><i class="fa fa-print"></i>
{$_L['Click_Here_to_Print']}</button>
</form>

</div>
</div>
Expand Down

0 comments on commit b4bec89

Please sign in to comment.