imsamurai / CakePHP-Audit-Log-Plugin

Records changes made to an object during CRUD operations.
http://imsamurai.github.io/CakePHP-Audit-Log-Plugin
MIT License
2 stars 2 forks source link

Date range filter in listing page won't work for all cases. #14

Open saji89 opened 9 years ago

saji89 commented 9 years ago

The date range filter in the listing page, will not work for all possible values. If both dates given as same, the resultant query will be like: Assume input as:

2014/11/06 to 2014/11/06, the resultant query will be:

SELECT `Audit`.`id`, `Audit`.`event`, `Audit`.`model`, `Audit`.`created`, `Audit`.`user_id`
FROM `database_name`.`audits` AS `Audit`
WHERE `Audit`.`created` BETWEEN '2014-11-06 00:00:00' AND '2014-11-06 00:00:00' ORDER BY `Audit`.`created` desc LIMIT 5 

But for proper working it has to be:

SELECT `Audit`.`id`, `Audit`.`event`, `Audit`.`model`, `Audit`.`created`, `Audit`.`user_id`
FROM `database_name`.`audits` AS `Audit`
WHERE `Audit`.`created` BETWEEN '2014-11-06 00:00:00' AND '2014-11-06 11:59:59' ORDER BY `Audit`.`created` desc LIMIT 5 

Also it'll be nice to specify in README file, the format applicable for date filter.

In PHP format: y/m/d to y/m/d or y/m/d TO y/m/d

e.g: 2014/11/05 TO 2014/11/06

It'll be good to specify single date, in the filter, and it should automatically generate the condition as:

BETWEEN '2014-11-06 00:00:00' AND '2014-11-06 11:59:59' 
saji89 commented 9 years ago

Update:

On closer check, it was understood that the plugin is using https://github.com/dangrossman/bootstrap-daterangepicker for the date range picker.

You could make that clear by specifying it in the README.

imsamurai commented 9 years ago

You can specify time 2014-11-06 12:01:01 - 2014-11-06 13:02:21. As for one date - i'll implement this