From b3fd1d5a3e2913a66e3f2593a7841cab57421335 Mon Sep 17 00:00:00 2001 From: gerandonk Date: Fri, 20 Dec 2024 16:48:06 +0700 Subject: [PATCH] add voucher date created and print by date add voucher date created and print by date --- install/phpnuxbill.sql | 1 + system/controllers/plan.php | 15 +++++++++++++++ system/updates.json | 3 +++ ui/ui/print-voucher.tpl | 8 ++++++++ ui/ui/voucher.tpl | 2 ++ 5 files changed, 29 insertions(+) diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index a76642a9..9b887850 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -213,6 +213,7 @@ CREATE TABLE `tbl_voucher` ( `code` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `user` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `status` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `used_date` DATETIME NULL DEFAULT NULL, `generated_by` int NOT NULL DEFAULT '0' COMMENT 'id admin' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; diff --git a/system/controllers/plan.php b/system/controllers/plan.php index 91a84631..ab738245 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -552,6 +552,7 @@ switch ($action) { $pagebreak = _post('pagebreak'); $limit = _post('limit'); $vpl = _post('vpl'); + $selected_datetime = _post('selected_datetime'); if (empty($vpl)) { $vpl = 3; } @@ -616,6 +617,11 @@ 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); @@ -628,6 +634,14 @@ switch ($action) { $ui->assign('plans', $plans); $ui->assign('limit', $limit); $ui->assign('planid', $planid); + + $createdate = ORM::for_table('tbl_voucher') + ->select_expr('DISTINCT created_at', 'created_datetime') + ->where_not_equal('created_at', '0') + ->order_by_desc('created_at') + ->find_array(); + + $ui->assign('createdate', $createdate); $voucher = []; $n = 1; @@ -644,6 +658,7 @@ switch ($action) { $ui->assign('voucher', $voucher); $ui->assign('vc', $vc); + $ui->assign('selected_datetime', $selected_datetime); //for counting pagebreak $ui->assign('jml', 0); diff --git a/system/updates.json b/system/updates.json index eb2526bb..63a1c5a2 100644 --- a/system/updates.json +++ b/system/updates.json @@ -181,5 +181,8 @@ ], "2024.12.16": [ "CREATE TABLE `tbl_coupons` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `code` VARCHAR(50) NOT NULL UNIQUE, `type` ENUM('fixed', 'percent') NOT NULL, `value` DECIMAL(10,2) NOT NULL, `description` TEXT NOT NULL, `max_usage` INT NOT NULL DEFAULT 1,`usage_count` INT NOT NULL DEFAULT 0,`status` ENUM('active', 'inactive') NOT NULL, `min_order_amount` DECIMAL(10,2) NOT NULL, `max_discount_amount` DECIMAL(10,2) NOT NULL, `start_date` DATE NOT NULL,`end_date` DATE NOT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);" + ], + "2024.12.20": [ + "ALTER TABLE `tbl_voucher` ADD `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `status`;" ] } \ No newline at end of file diff --git a/ui/ui/print-voucher.tpl b/ui/ui/print-voucher.tpl index 04d47443..fb8ea612 100644 --- a/ui/ui/print-voucher.tpl +++ b/ui/ui/print-voucher.tpl @@ -75,6 +75,14 @@ {/foreach} + + Date diff --git a/ui/ui/voucher.tpl b/ui/ui/voucher.tpl index f11c552e..65e32f0a 100644 --- a/ui/ui/voucher.tpl +++ b/ui/ui/voucher.tpl @@ -97,6 +97,7 @@ {Lang::T('Code Voucher')} {Lang::T('Status Voucher')} {Lang::T('Customer')} + {Lang::T('Create Date')} {Lang::T('Used Date')} {Lang::T('Generated By')} {Lang::T('Manage')} @@ -119,6 +120,7 @@ {if $ds['user'] eq '0'} - {else}{$ds['user']} {/if} + {if $ds['created_at']}{Lang::dateTimeFormat($ds['created_at'])}{/if} {if $ds['used_date']}{Lang::dateTimeFormat($ds['used_date'])}{/if} {if $ds['generated_by']}