mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2025-08-03 17:54:41 +02:00
fix: validate date format in voucher filtering and update created_at condition, it give error in mysql
This commit is contained in:
parent
5bc0ddaf52
commit
a32005e1f0
1 changed files with 7 additions and 3 deletions
|
@ -722,10 +722,13 @@ switch ($action) {
|
|||
$vc = $vc->where_gt('tbl_voucher.id', $from_id);
|
||||
}
|
||||
|
||||
// Group filters (date or batch)
|
||||
if (!empty($group)) {
|
||||
if ($group == 'datetime' && !empty($selected_datetime)) {
|
||||
$dateFilter = date('Y-m-d', strtotime($selected_datetime));
|
||||
$timestamp = strtotime($selected_datetime);
|
||||
if ($timestamp === false) {
|
||||
throw new Exception("Invalid date format provided.");
|
||||
}
|
||||
$dateFilter = date('Y-m-d', $timestamp);
|
||||
$v = $v->where_raw("DATE(tbl_voucher.created_at) = ?", [$dateFilter]);
|
||||
$vc = $vc->where_raw("DATE(tbl_voucher.created_at) = ?", [$dateFilter]);
|
||||
} elseif ($group == 'batch' && !empty($batch)) {
|
||||
|
@ -784,7 +787,7 @@ switch ($action) {
|
|||
"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', '0000-00-00 00:00:00')
|
||||
->select_expr('COUNT(*)', 'voucher_count')
|
||||
->group_by('created_datetime')
|
||||
->order_by_desc('created_datetime')
|
||||
|
@ -792,6 +795,7 @@ switch ($action) {
|
|||
|
||||
$batches = ORM::for_table('tbl_voucher')
|
||||
->select('batch_name')
|
||||
->select('created_at')
|
||||
->distinct()
|
||||
->where_not_equal('batch_name', '')
|
||||
->order_by_desc('created_at')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue