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,6 +138,9 @@
<body {if !$nuxprint} onload="printpage()" {/if}> <body {if !$nuxprint} onload="printpage()" {/if}>
<div class="container"> <div class="container">
<div class="invoice"> <div class="invoice">
{if $content}
<pre style="border-style: none; background-color: white;">{$content}</pre>
{else}
<div class="header"> <div class="header">
<h1>{Lang::pad($_c['CompanyName'], ' ', 2)}</h1> <h1>{Lang::pad($_c['CompanyName'], ' ', 2)}</h1>
<p>{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}</p> <p>{Lang::pad($_c['address'], ' ', 2)} | {Lang::pad($_c['phone'], ' ', 2)}</p>
@ -129,7 +148,8 @@
<div class="details"> <div class="details">
<div><strong>{Lang::pad(Lang::T('Invoice'), ' ', 2)}:</strong> {$in['invoice']}</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('Date'), ' ', 2)}:</strong> {$date}</div>
<div><strong>{Lang::pad(Lang::T('Sales'), ' ', 2)}:</strong> {Lang::pad($_admin['fullname'], ' ', 2)}</div> <div><strong>{Lang::pad(Lang::T('Sales'), ' ', 2)}:</strong> {Lang::pad($_admin['fullname'], ' ', 2)}
</div>
</div> </div>
<table class="invoice-info"> <table class="invoice-info">
@ -179,6 +199,7 @@
</a> </a>
{/if} {/if}
</div> </div>
{/if}
</div> </div>
</div> </div>

View File

@ -16,8 +16,13 @@
<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>