From cfe0a14f3177911dbd1a35de84ebafcab7a52bd0 Mon Sep 17 00:00:00 2001
From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com>
Date: Mon, 30 Dec 2024 22:49:46 +0100
Subject: [PATCH] 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
---
system/controllers/plan.php | 29 +++++++++++----
system/lan/english.json | 12 +++++-
ui/ui/print-voucher.tpl | 74 +++++++++++++------------------------
ui/ui/voucher-add.tpl | 44 +++++++++++++++++-----
4 files changed, 93 insertions(+), 66 deletions(-)
diff --git a/system/controllers/plan.php b/system/controllers/plan.php
index d10bf624..53c1a93d 100644
--- a/system/controllers/plan.php
+++ b/system/controllers/plan.php
@@ -595,6 +595,17 @@ switch ($action) {
->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 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 {
$v = ORM::for_table('tbl_plans')
->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();
$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 = str_replace('[[company_name]]', $config['CompanyName'], $template);
@@ -636,9 +643,14 @@ switch ($action) {
$ui->assign('planid', $planid);
$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')
- ->order_by_desc('created_at')
+ ->select_expr('COUNT(*)', 'voucher_count')
+ ->group_by('created_datetime')
+ ->order_by_desc('created_datetime')
->find_array();
$ui->assign('createdate', $createdate);
@@ -678,6 +690,7 @@ switch ($action) {
$numbervoucher = _post('numbervoucher');
$lengthcode = _post('lengthcode');
$printNow = _post('print_now', 'no');
+ $voucherPerPage = _post('voucher_per_page', '36');
$msg = '';
if (empty($type) || empty($plan) || empty($server) || empty($numbervoucher) || empty($lengthcode)) {
@@ -768,7 +781,7 @@ switch ($action) {
$ui->assign('jml', 0);
$ui->assign('from_id', 0);
$ui->assign('vpl', '3');
- $ui->assign('pagebreak', '12');
+ $ui->assign('pagebreak', $voucherPerPage);
$ui->display('print-voucher.tpl');
}
diff --git a/system/lan/english.json b/system/lan/english.json
index b8e4bba2..f5892a3d 100644
--- a/system/lan/english.json
+++ b/system/lan/english.json
@@ -930,5 +930,15 @@
"Send_yours_balance___": "Send yours balance ? ",
"Cards": "Cards",
"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"
}
\ No newline at end of file
diff --git a/ui/ui/print-voucher.tpl b/ui/ui/print-voucher.tpl
index fb8ea612..c090fa07 100644
--- a/ui/ui/print-voucher.tpl
+++ b/ui/ui/print-voucher.tpl
@@ -9,14 +9,14 @@
.ukuran {
size: A4;
}
-
+
body,
td,
th {
font-size: 12px;
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
}
-
+
page[size="A4"] {
background: white;
width: 21cm;
@@ -24,32 +24,28 @@
display: block;
margin: 0 auto;
margin-bottom: 0.5cm;
-
html,
body {
width: 210mm;
height: 297mm;
}
}
-
+
@media print {
body {
size: auto;
margin: 0;
box-shadow: 0;
}
-
page[size="A4"] {
margin: 0;
size: auto;
box-shadow: 0;
}
-
.page-break {
display: block;
page-break-before: always;
}
-
.no-print,
.no-print * {
display: none !important;
@@ -65,10 +61,10 @@
From ID > limit
- Voucher PerLine
- vouchers
- PageBreak after
- vouchers
+ Voucher PerLine vouchers
+
+ PageBreak after vouchers
+
Plans
--all--
{foreach $plans as $plan}
@@ -76,11 +72,11 @@
{/foreach}
- Date
+ Date
--all--
{foreach $createdate as $date}
- {$date.created_datetime}
+ {$date.created_datetime} ({$date.voucher_count})
{/foreach}
@@ -88,47 +84,29 @@
- {Lang::T('Click Here to Print')}
- {Lang::T('Print side by side, it will easy to cut')}
- show {$v|@count} vouchers from {$vc} vouchers
- from ID {$v[0]['id']} limit {$limit} vouchers
+ {Lang::T('Click Here to Print')} {Lang::T('Print side by side, it will easy to cut')} show {$v|@count} vouchers from {$vc} vouchers from ID {$v[0]['id']} limit {$limit} vouchers
-
- {$n = 1}
- {foreach $voucher as $vs}
- {$jml = $jml + 1}
- {if $n == 1}
-
-
- {/if}
- {$vs}
- {if $n == $vpl}
-
- {$n = 1}
- {else}
- {$n = $n + 1}
- {/if}
-
-
- {if $jml == $pagebreak}
- {$jml = 0}
-
-
- {/if}
- {/foreach}
+
{$n = 1} {foreach $voucher as $vs} {$jml = $jml + 1} {if $n == 1}
+
+
+ {/if}
+ {$vs}
+ {if $n == $vpl}
+
+ {$n = 1} {else} {$n = $n + 1} {/if} {if $jml == $pagebreak} {$jml = 0}
+
+
+ {/if} {/foreach}
- {if isset($xfooter)}
- {$xfooter}
- {/if}
+ {if isset($xfooter)} {$xfooter} {/if}
+
+{include file="sections/footer.tpl"}
\ No newline at end of file