Fix Invoice Print

This commit is contained in:
Ibnu Maksum 2024-10-07 14:49:43 +07:00
parent 277ab87645
commit 9016ecbb98
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
3 changed files with 107 additions and 79 deletions

View File

@ -228,11 +228,13 @@ switch ($action) {
$ui->assign('content', $content); $ui->assign('content', $content);
} else { } else {
$id = _post('id'); $id = _post('id');
if(empty($id)) {
$id = $routes['2'];
}
$d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one(); $d = ORM::for_table('tbl_transactions')->where('id', $id)->find_one();
$ui->assign('in', $d); $ui->assign('in', $d);
$ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time'])); $ui->assign('date', Lang::dateAndTimeFormat($d['recharged_on'], $d['recharged_time']));
} }
run_hook('print_invoice'); #HOOK run_hook('print_invoice'); #HOOK
$ui->display('invoice-print.tpl'); $ui->display('invoice-print.tpl');
break; break;

View File

@ -16,7 +16,8 @@
.invoice { .invoice {
width: 100%; width: 100%;
max-width: 70mm; /* Maximum width for thermal printing */ max-width: 70mm;
/* Maximum width for thermal printing */
background: white; background: white;
border-radius: 8px; border-radius: 8px;
padding: 10px; padding: 10px;
@ -43,8 +44,10 @@
.details div { .details div {
margin: 5px 0; margin: 5px 0;
font-weight: bold; /* Bold text for details */ font-weight: bold;
color: black; /* Ensure text is black */ /* Bold text for details */
color: black;
/* Ensure text is black */
} }
.invoice-info { .invoice-info {
@ -57,8 +60,10 @@
.invoice-info td { .invoice-info td {
padding: 5px; padding: 5px;
text-align: left; text-align: left;
color: black; /* Ensure text is black */ color: black;
font-weight: bold; /* Bold text for table content */ /* Ensure text is black */
font-weight: bold;
/* Bold text for table content */
} }
.invoice-info th { .invoice-info th {
@ -68,7 +73,8 @@
.footer { .footer {
margin-top: 10px; margin-top: 10px;
text-align: left; /* Align footer text to left */ text-align: left;
/* Align footer text to left */
} }
@media print { @media print {
@ -79,10 +85,14 @@
} }
.invoice { .invoice {
width: 70mm; /* Fixed width for thermal printer */ width: 70mm;
padding: 5px; /* Reduced padding for print */ /* Fixed width for thermal printer */
box-shadow: none; /* Remove shadow for clearer print */ padding: 5px;
border: none; /* Remove border for print */ /* Reduced padding for print */
box-shadow: none;
/* Remove shadow for clearer print */
border: none;
/* Remove border for print */
} }
.details { .details {
@ -96,19 +106,25 @@
.invoice-info th, .invoice-info th,
.invoice-info td { .invoice-info td {
padding: 5px; /* Reduced padding */ padding: 5px;
/* Reduced padding */
text-align: left; text-align: left;
font-weight: bold; /* Bold text for print */ font-weight: bold;
color: black; /* Ensure text is black */ /* Bold text for print */
border: none; /* Remove borders for print */ color: black;
/* Ensure text is black */
border: none;
/* Remove borders for print */
} }
hr { hr {
border: 1px solid #000; /* Darker line for print */ border: 1px solid #000;
/* Darker line for print */
} }
.btn { .btn {
display: none; /* Hide buttons when printing */ display: none;
/* Hide buttons when printing */
} }
} }
</style> </style>
@ -122,63 +138,68 @@
<body {if !$nuxprint} onload="printpage()" {/if}> <body {if !$nuxprint} onload="printpage()" {/if}>
<div class="container"> <div class="container">
<div class="invoice"> <div class="invoice">
<div class="header"> {if $content}
<h1>{Lang::pad($_c['CompanyName'], ' ', 2)}</h1> <pre style="border-style: none; background-color: white;">{$content}</pre>
<p>{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}</p> {else}
</div> <div class="header">
<div class="details"> <h1>{Lang::pad($_c['CompanyName'], ' ', 2)}</h1>
<div><strong>{Lang::pad(Lang::T('Invoice'), ' ', 2)}:</strong> {$in['invoice']}</div> <p>{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}</p>
<div><strong>{Lang::pad(Lang::T('Date'), ' ', 2)}:</strong> {$date}</div> </div>
<div><strong>{Lang::pad(Lang::T('Sales'), ' ', 2)}:</strong> {Lang::pad($_admin['fullname'], ' ', 2)}</div> <div class="details">
</div> <div><strong>{Lang::pad(Lang::T('Invoice'), ' ', 2)}:</strong> {$in['invoice']}</div>
<div><strong>{Lang::pad(Lang::T('Date'), ' ', 2)}:</strong> {$date}</div>
<div><strong>{Lang::pad(Lang::T('Sales'), ' ', 2)}:</strong> {Lang::pad($_admin['fullname'], ' ', 2)}
</div>
</div>
<table class="invoice-info"> <table class="invoice-info">
<tr> <tr>
<th>{Lang::pad(Lang::T('Type'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Type'), ' ', 2)}</th>
<td>{$in['type']}</td> <td>{$in['type']}</td>
</tr> </tr>
<tr> <tr>
<th>{Lang::pad(Lang::T('Package Name'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Package Name'), ' ', 2)}</th>
<td>{$in['plan_name']}</td> <td>{$in['plan_name']}</td>
</tr> </tr>
<tr> <tr>
<th>{Lang::pad(Lang::T('Package Price'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Package Price'), ' ', 2)}</th>
<td>{Lang::moneyFormat($in['price'])}</td> <td>{Lang::moneyFormat($in['price'])}</td>
</tr> </tr>
<tr> <tr>
<th>{Lang::pad(Lang::T('Username'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Username'), ' ', 2)}</th>
<td>{$in['username']}</td> <td>{$in['username']}</td>
</tr> </tr>
<tr> <tr>
<th>{Lang::pad(Lang::T('Password'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Password'), ' ', 2)}</th>
<td>**********</td> <td>**********</td>
</tr> </tr>
<tr> <tr>
<th>{Lang::pad(Lang::T('Payment Method'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Payment Method'), ' ', 2)}</th>
<td>{$in['method']}</td> <td>{$in['method']}</td>
</tr> </tr>
{if $in['type'] != 'Balance'} {if $in['type'] != 'Balance'}
<tr> <tr>
<th>{Lang::pad(Lang::T('Created On'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Created On'), ' ', 2)}</th>
<td>{Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time'])}</td> <td>{Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time'])}</td>
</tr> </tr>
<tr> <tr>
<th>{Lang::pad(Lang::T('Expires On'), ' ', 2)}</th> <th>{Lang::pad(Lang::T('Expires On'), ' ', 2)}</th>
<td>{Lang::dateAndTimeFormat($in['expiration'], $in['time'])}</td> <td>{Lang::dateAndTimeFormat($in['expiration'], $in['time'])}</td>
</tr> </tr>
{/if} {/if}
</table> </table>
<hr style="border: 2px solid #0056b3; margin-top: 10px;"> <hr style="border: 2px solid #0056b3; margin-top: 10px;">
<div class="footer"> <div class="footer">
<p>{Lang::pad($_c['note'], ' ', 2)}</p> <p>{Lang::pad($_c['note'], ' ', 2)}</p>
{if $nuxprint} {if $nuxprint}
<a href="{$nuxprint}" class="btn btn-success" name="nux" value="print"> <a href="{$nuxprint}" class="btn btn-success" name="nux" value="print">
<i class="glyphicon glyphicon-print"></i> Nux Print <i class="glyphicon glyphicon-print"></i> Nux Print
</a> </a>
{/if} {/if}
</div> </div>
{/if}
</div> </div>
</div> </div>
@ -187,4 +208,4 @@
{if isset($xfooter)} {$xfooter} {/if} {if isset($xfooter)} {$xfooter} {/if}
</body> </body>
</html> </html>

View File

@ -12,19 +12,24 @@
<a href="{$_url}plan/list" class="btn btn-default btn-sm"><i <a href="{$_url}plan/list" class="btn btn-default btn-sm"><i
class="ion-reply-all"></i>{Lang::T('Finish')}</a> class="ion-reply-all"></i>{Lang::T('Finish')}</a>
<a href="https://api.whatsapp.com/send/?text={$whatsapp}" target="_blank" <a href="https://api.whatsapp.com/send/?text={$whatsapp}" target="_blank"
class="btn btn-primary btn-sm"> class="btn btn-primary btn-sm">
<i class="glyphicon glyphicon-share"></i> WhatsApp</a> <i class="glyphicon glyphicon-share"></i> WhatsApp</a>
<a href="{$_url}plan/view/{$in['id']}/send" class="btn btn-info text-black btn-sm"><i <a href="{$_url}plan/view/{$in['id']}/send" class="btn btn-info text-black btn-sm"><i
class="glyphicon glyphicon-envelope"></i> {Lang::T("Resend")}</a> class="glyphicon glyphicon-envelope"></i> {Lang::T("Resend")}</a>
<button type="submit" class="btn btn-info text-black btn-sm"><i class="glyphicon glyphicon-print"></i> <hr>
{Lang::T('Print')}</button> <a href="{$_url}plan/print/{$in['id']}" target="_print" class="btn btn-info text-black btn-sm"><i
class="glyphicon glyphicon-print"></i>
{Lang::T('Print')} HTML</a>
<button type="submit" class="btn btn-info text-black btn-sm"><i
class="glyphicon glyphicon-print"></i>
{Lang::T('Print')} Text</button>
<a href="nux://print?text={urlencode($invoice)}" <a href="nux://print?text={urlencode($invoice)}"
class="btn btn-success text-black btn-sm hidden-md hidden-lg"> class="btn btn-success text-black btn-sm hidden-md hidden-lg">
<i class="glyphicon glyphicon-phone"></i> <i class="glyphicon glyphicon-phone"></i>
NuxPrint NuxPrint
</a> </a>
<a href="https://github.com/hotspotbilling/android-printer" <a href="https://github.com/hotspotbilling/android-printer"
class="btn btn-success text-black btn-sm hidden-xs hidden-sm" target="_blank"> class="btn btn-success text-black btn-sm hidden-xs hidden-sm" target="_blank">
<i class="glyphicon glyphicon-phone"></i> <i class="glyphicon glyphicon-phone"></i>
NuxPrint NuxPrint
</a> </a>
@ -37,4 +42,4 @@
var s5_taf_parent = window.location; var s5_taf_parent = window.location;
document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML; document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML;
</script> </script>
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}