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);
} 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;

View File

@ -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 */
}
}
</style>
@ -122,63 +138,68 @@
<body {if !$nuxprint} onload="printpage()" {/if}>
<div class="container">
<div class="invoice">
<div class="header">
<h1>{Lang::pad($_c['CompanyName'], ' ', 2)}</h1>
<p>{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}</p>
</div>
<div class="details">
<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>
{if $content}
<pre style="border-style: none; background-color: white;">{$content}</pre>
{else}
<div class="header">
<h1>{Lang::pad($_c['CompanyName'], ' ', 2)}</h1>
<p>{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}</p>
</div>
<div class="details">
<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">
<tr>
<th>{Lang::pad(Lang::T('Type'), ' ', 2)}</th>
<td>{$in['type']}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Package Name'), ' ', 2)}</th>
<td>{$in['plan_name']}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Package Price'), ' ', 2)}</th>
<td>{Lang::moneyFormat($in['price'])}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Username'), ' ', 2)}</th>
<td>{$in['username']}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Password'), ' ', 2)}</th>
<td>**********</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Payment Method'), ' ', 2)}</th>
<td>{$in['method']}</td>
</tr>
{if $in['type'] != 'Balance'}
<tr>
<th>{Lang::pad(Lang::T('Created On'), ' ', 2)}</th>
<td>{Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time'])}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Expires On'), ' ', 2)}</th>
<td>{Lang::dateAndTimeFormat($in['expiration'], $in['time'])}</td>
</tr>
{/if}
</table>
<table class="invoice-info">
<tr>
<th>{Lang::pad(Lang::T('Type'), ' ', 2)}</th>
<td>{$in['type']}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Package Name'), ' ', 2)}</th>
<td>{$in['plan_name']}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Package Price'), ' ', 2)}</th>
<td>{Lang::moneyFormat($in['price'])}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Username'), ' ', 2)}</th>
<td>{$in['username']}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Password'), ' ', 2)}</th>
<td>**********</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Payment Method'), ' ', 2)}</th>
<td>{$in['method']}</td>
</tr>
{if $in['type'] != 'Balance'}
<tr>
<th>{Lang::pad(Lang::T('Created On'), ' ', 2)}</th>
<td>{Lang::dateAndTimeFormat($in['recharged_on'], $in['recharged_time'])}</td>
</tr>
<tr>
<th>{Lang::pad(Lang::T('Expires On'), ' ', 2)}</th>
<td>{Lang::dateAndTimeFormat($in['expiration'], $in['time'])}</td>
</tr>
{/if}
</table>
<hr style="border: 2px solid #0056b3; margin-top: 10px;">
<hr style="border: 2px solid #0056b3; margin-top: 10px;">
<div class="footer">
<p>{Lang::pad($_c['note'], ' ', 2)}</p>
{if $nuxprint}
<a href="{$nuxprint}" class="btn btn-success" name="nux" value="print">
<i class="glyphicon glyphicon-print"></i> Nux Print
</a>
{/if}
</div>
<div class="footer">
<p>{Lang::pad($_c['note'], ' ', 2)}</p>
{if $nuxprint}
<a href="{$nuxprint}" class="btn btn-success" name="nux" value="print">
<i class="glyphicon glyphicon-print"></i> Nux Print
</a>
{/if}
</div>
{/if}
</div>
</div>
@ -187,4 +208,4 @@
{if isset($xfooter)} {$xfooter} {/if}
</body>
</html>
</html>

View File

@ -12,19 +12,24 @@
<a href="{$_url}plan/list" class="btn btn-default btn-sm"><i
class="ion-reply-all"></i>{Lang::T('Finish')}</a>
<a href="https://api.whatsapp.com/send/?text={$whatsapp}" target="_blank"
class="btn btn-primary btn-sm">
<i class="glyphicon glyphicon-share"></i> WhatsApp</a>
class="btn btn-primary btn-sm">
<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
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>
{Lang::T('Print')}</button>
<hr>
<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)}"
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>
NuxPrint
</a>
<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>
NuxPrint
</a>
@ -37,4 +42,4 @@
var s5_taf_parent = window.location;
document.getElementById('content').innerHTML = document.getElementById('formcontent').innerHTML;
</script>
{include file="sections/footer.tpl"}
{include file="sections/footer.tpl"}