Enhancements and Fixes

Added Vouchers Printing Per Page option, default is 36 for A4 papers.
Fix voucher printing date showing time and seconds (its annoying), replaced with group by days created, and also added  number of vouchers created on each days to make it more unique and classy
This commit is contained in:
Focuslinkstech 2024-12-30 22:49:46 +01:00
parent b1e145f0dc
commit cfe0a14f31
4 changed files with 93 additions and 66 deletions

View File

@ -595,6 +595,17 @@ switch ($action) {
->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) ->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
->where('tbl_voucher.status', '0') ->where('tbl_voucher.status', '0')
->where_gt('tbl_voucher.id', $from_id); ->where_gt('tbl_voucher.id', $from_id);
} else if ($from_id > 0 && $planid == 0 && $selected_datetime != '') {
$v = ORM::for_table('tbl_plans')
->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
->where('tbl_voucher.status', '0')
->where_raw("DATE(created_at) = ?", [$selected_datetime])
->where_gt('tbl_voucher.id', $from_id)
->limit($limit);
$vc = ORM::for_table('tbl_plans')
->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
->where('tbl_voucher.status', '0')
->where_gt('tbl_voucher.id', $from_id);
} else { } else {
$v = ORM::for_table('tbl_plans') $v = ORM::for_table('tbl_plans')
->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) ->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan'))
@ -617,11 +628,7 @@ switch ($action) {
$v = $v->where_in('generated_by', $sales)->find_many(); $v = $v->where_in('generated_by', $sales)->find_many();
$vc = $vc->where_in('generated_by', $sales)->count(); $vc = $vc->where_in('generated_by', $sales)->count();
} }
if (!empty($selected_datetime)) {
$v = ORM::for_table('tbl_voucher')
->where('created_at', $selected_datetime)
->find_many();
}
$template = file_get_contents("pages/Voucher.html"); $template = file_get_contents("pages/Voucher.html");
$template = str_replace('[[company_name]]', $config['CompanyName'], $template); $template = str_replace('[[company_name]]', $config['CompanyName'], $template);
@ -636,9 +643,14 @@ switch ($action) {
$ui->assign('planid', $planid); $ui->assign('planid', $planid);
$createdate = ORM::for_table('tbl_voucher') $createdate = ORM::for_table('tbl_voucher')
->select_expr('DISTINCT created_at', 'created_datetime') ->select_expr(
"CASE WHEN DATE(created_at) = CURDATE() THEN 'Today' ELSE DATE(created_at) END",
'created_datetime'
)
->where_not_equal('created_at', '0') ->where_not_equal('created_at', '0')
->order_by_desc('created_at') ->select_expr('COUNT(*)', 'voucher_count')
->group_by('created_datetime')
->order_by_desc('created_datetime')
->find_array(); ->find_array();
$ui->assign('createdate', $createdate); $ui->assign('createdate', $createdate);
@ -678,6 +690,7 @@ switch ($action) {
$numbervoucher = _post('numbervoucher'); $numbervoucher = _post('numbervoucher');
$lengthcode = _post('lengthcode'); $lengthcode = _post('lengthcode');
$printNow = _post('print_now', 'no'); $printNow = _post('print_now', 'no');
$voucherPerPage = _post('voucher_per_page', '36');
$msg = ''; $msg = '';
if (empty($type) || empty($plan) || empty($server) || empty($numbervoucher) || empty($lengthcode)) { if (empty($type) || empty($plan) || empty($server) || empty($numbervoucher) || empty($lengthcode)) {
@ -768,7 +781,7 @@ switch ($action) {
$ui->assign('jml', 0); $ui->assign('jml', 0);
$ui->assign('from_id', 0); $ui->assign('from_id', 0);
$ui->assign('vpl', '3'); $ui->assign('vpl', '3');
$ui->assign('pagebreak', '12'); $ui->assign('pagebreak', $voucherPerPage);
$ui->display('print-voucher.tpl'); $ui->display('print-voucher.tpl');
} }

View File

@ -930,5 +930,15 @@
"Send_yours_balance___": "Send yours balance ? ", "Send_yours_balance___": "Send yours balance ? ",
"Cards": "Cards", "Cards": "Cards",
"CRM": "CRM", "CRM": "CRM",
"Coupons": "Coupons" "Coupons": "Coupons",
"Voucher_Cards": "Voucher Cards",
"Create_Date": "Create Date",
"Delete_Selected": "Delete Selected",
"Print_Now": "Print Now",
"Vouchers_Per_Page": "Vouchers Per Page",
"Save_as_template": "Save as template",
"Template_Name": "Template Name",
"Voucher_Code": "Voucher Code",
"Voucher_Package": "Voucher Package",
"Counter": "Counter"
} }

View File

@ -24,7 +24,6 @@
display: block; display: block;
margin: 0 auto; margin: 0 auto;
margin-bottom: 0.5cm; margin-bottom: 0.5cm;
html, html,
body { body {
width: 210mm; width: 210mm;
@ -38,18 +37,15 @@
margin: 0; margin: 0;
box-shadow: 0; box-shadow: 0;
} }
page[size="A4"] { page[size="A4"] {
margin: 0; margin: 0;
size: auto; size: auto;
box-shadow: 0; box-shadow: 0;
} }
.page-break { .page-break {
display: block; display: block;
page-break-before: always; page-break-before: always;
} }
.no-print, .no-print,
.no-print * { .no-print * {
display: none !important; display: none !important;
@ -65,10 +61,10 @@
<tr> <tr>
<td>From ID &gt; <input type="text" name="from_id" style="width:40px" value="{$from_id}"> limit <td>From ID &gt; <input type="text" name="from_id" style="width:40px" value="{$from_id}"> limit
<input type="text" name="limit" style="width:40px" value="{$limit}"></td> <input type="text" name="limit" style="width:40px" value="{$limit}"></td>
<td>Voucher PerLine <input type="text" style="width:40px" name="vpl" value="{$vpl}"> <td>Voucher PerLine <input type="text" style="width:40px" name="vpl" value="{$vpl}"> vouchers
vouchers</td> </td>
<td>PageBreak after <input type="text" style="width:40px" name="pagebreak" value="{$pagebreak}"> <td>PageBreak after <input type="text" style="width:40px" name="pagebreak" value="{$pagebreak}"> vouchers
vouchers</td> </td>
<td>Plans <select id="plan_id" name="planid" style="width:50px"> <td>Plans <select id="plan_id" name="planid" style="width:50px">
<option value="0">--all--</option> <option value="0">--all--</option>
{foreach $plans as $plan} {foreach $plans as $plan}
@ -76,11 +72,11 @@
</option> </option>
{/foreach} {/foreach}
</select></td> </select></td>
<td>Date <select id="selected_datetime" name="selected_datetime" style="width:50px"> <td>Date <select id="selected_datetime" name="selected_datetime" style="width:50px">
<option value="">--all--</option> <option value="">--all--</option>
{foreach $createdate as $date} {foreach $createdate as $date}
<option value="{$date.created_datetime}" {if $date.created_datetime eq $selected_datetime}selected{/if}> <option value="{$date.created_datetime}" {if $date.created_datetime eq $selected_datetime}selected{/if}>
{$date.created_datetime} {$date.created_datetime} ({$date.voucher_count})
</option> </option>
{/foreach} {/foreach}
</select></td> </select></td>
@ -88,47 +84,29 @@
</tr> </tr>
</table> </table>
<hr> <hr>
<center><button type="button" onclick="window.print()" <center><button type="button" onclick="window.print()" class="btn btn-default btn-sm no-print">{Lang::T('Click Here to Print')}</button><br> {Lang::T('Print side by side, it will easy to cut')}<br> show {$v|@count} vouchers from {$vc} vouchers<br> from ID {$v[0]['id']} limit {$limit} vouchers
class="btn btn-default btn-sm no-print">{Lang::T('Click Here to Print')}</button><br>
{Lang::T('Print side by side, it will easy to cut')}<br>
show {$v|@count} vouchers from {$vc} vouchers<br>
from ID {$v[0]['id']} limit {$limit} vouchers
</center> </center>
</form> </form>
<div id="printable" align="center"> <div id="printable" align="center">
<hr> <hr> {$n = 1} {foreach $voucher as $vs} {$jml = $jml + 1} {if $n == 1}
{$n = 1} <table>
{foreach $voucher as $vs} <tr>
{$jml = $jml + 1} {/if}
{if $n == 1} <td>{$vs}</td>
<table> {if $n == $vpl}
<tr> </table>
{/if} {$n = 1} {else} {$n = $n + 1} {/if} {if $jml == $pagebreak} {$jml = 0}
<td>{$vs}</td> <!-- pageBreak -->
{if $n == $vpl} <div class="page-break">
</table> <div class="no-print" style="background-color: #E91E63; color:#FFF;" align="center">-- pageBreak --
{$n = 1} <hr>
{else} </div>
{$n = $n + 1} </div>
{/if} {/if} {/foreach}
{if $jml == $pagebreak}
{$jml = 0}
<!-- pageBreak -->
<div class="page-break">
<div class="no-print" style="background-color: #E91E63; color:#FFF;" align="center">-- pageBreak --
<hr>
</div>
</div>
{/if}
{/foreach}
</div> </div>
</page> </page>
<script src="ui/ui/scripts/jquery.min.js"></script> <script src="ui/ui/scripts/jquery.min.js"></script>
{if isset($xfooter)} {if isset($xfooter)} {$xfooter} {/if}
{$xfooter}
{/if}
<script> <script>
jQuery(document).ready(function() { jQuery(document).ready(function() {
// initiate layout and plugins // initiate layout and plugins

View File

@ -41,16 +41,15 @@
<label class="col-md-2 control-label">{Lang::T('Voucher Format')}</label> <label class="col-md-2 control-label">{Lang::T('Voucher Format')}</label>
<div class="col-md-6"> <div class="col-md-6">
<select name="voucher_format" id="voucher_format" class="form-control"> <select name="voucher_format" id="voucher_format" class="form-control">
<option value="numbers" {if $_c['voucher_format'] == 'numbers'}selected="selected" <option value="numbers" {if $_c['voucher_format']=='numbers' }selected="selected" {/if}>
{/if}>
Numbers Numbers
</option> </option>
<option value="up" {if $_c['voucher_format'] == 'up'}selected="selected" {/if}>UPPERCASE <option value="up" {if $_c['voucher_format']=='up' }selected="selected" {/if}>UPPERCASE
</option> </option>
<option value="low" {if $_c['voucher_format'] == 'low'}selected="selected" {/if}> <option value="low" {if $_c['voucher_format']=='low' }selected="selected" {/if}>
lowercase lowercase
</option> </option>
<option value="rand" {if $_c['voucher_format'] == 'rand'}selected="selected" {/if}> <option value="rand" {if $_c['voucher_format']=='rand' }selected="selected" {/if}>
RaNdoM RaNdoM
</option> </option>
</select> </select>
@ -60,8 +59,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Voucher Prefix')}</label> <label class="col-md-2 control-label">{Lang::T('Voucher Prefix')}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" class="form-control" name="prefix" placeholder="NUX-" <input type="text" class="form-control" name="prefix" placeholder="NUX-" value="{$_c['voucher_prefix']}">
value="{$_c['voucher_prefix']}">
</div> </div>
<p class="help-block col-md-4">NUX-VoUCHeRCOdE</p> <p class="help-block col-md-4">NUX-VoUCHeRCOdE</p>
</div> </div>
@ -76,9 +74,19 @@
<label for="inputSkills" class="col-sm-2 control-label">{Lang::T('Print Now')}</label> <label for="inputSkills" class="col-sm-2 control-label">{Lang::T('Print Now')}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="checkbox" id="print_now" name="print_now" class="iCheck" value="yes"> <input type="checkbox" id="print_now" name="print_now" class="iCheck" value="yes" onclick="showVouchersPerPage()">
</div> </div>
</div> </div>
<div class="form-group" id="printers" style="display:none;">
<label class="col-md-2 control-label">{Lang::T('Vouchers Per Page')}</label>
<div class="col-md-6">
<input type="text" id="voucher-print" class="form-control" name="voucher_per_page" value="36" placeholder="Vouchers Per Page (default 36)">
</div>
<p class="help-block col-md-4">
{Lang::T('Vouchers Per Page')} (default 36)
</p>
</div>
<div class="form-group"> <div class="form-group">
<div class="col-lg-offset-2 col-lg-10"> <div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-success" onclick="return ask(this, 'Continue the Voucher creation process?')" type="submit">{Lang::T('Generate')}</button> <button class="btn btn-success" onclick="return ask(this, 'Continue the Voucher creation process?')" type="submit">{Lang::T('Generate')}</button>
@ -91,4 +99,22 @@
</div> </div>
</div> </div>
<!-- /voucher-add -->
<script>
function showVouchersPerPage() {
var printNow = document.getElementById('print_now');
var printers = document.getElementById('printers');
var voucherPrint = document.getElementById('voucher-print');
voucherPrint.required = false;
if (printNow.checked) {
printers.style.display = 'block';
voucherPrint.required = true;
} else {
printers.style.display = 'none';
}
}
</script>
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}