Ali Samie Posted January 16, 2023 Share Posted January 16, 2023 In prestashop back office we have order listing with the option to filter by date which is limited to a single day. Is it possible to add time limit like hour:minute:seconds? Link to comment Share on other sites More sharing options...
Ali Samie Posted January 17, 2023 Author Share Posted January 17, 2023 For example, in cart rules controller there is a js file like this: admin/themes/default/template/controllers/cart_rules/form.js here you can find $('.datepicker').datetimepicker this means that with jquery, you can make a datepicker with hour and minute and seconds anywhere else that you see a datepicker you can change it to datetimepicker and then you have time picker but for modern controllers there is another issue. I can not change it easy as it is with symfony and ... hate this change in PS Link to comment Share on other sites More sharing options...
Ali Samie Posted January 17, 2023 Author Share Posted January 17, 2023 I changed this for helper list, and now all legacy admin controllers will be like this Link to comment Share on other sites More sharing options...
ps8modules Posted January 17, 2023 Share Posted January 17, 2023 Hi. Add custom javascript loading to your module and controller. You can then put in it when and where the datetimepicker will be loaded. E.g: Module: public function hookActionAdminControllerSetMedia($params) { if ($this->context->controller->controller_name == 'AdminModules' && Tools::getValue('configure') == $this->name){ $this->context->controller->addJqueryUI('ui.datepicker'); $this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/admin/js/admin.js'); } } JavaScript: $('.datepicker').datetimepicker(); Link to comment Share on other sites More sharing options...
Ali Samie Posted January 17, 2023 Author Share Posted January 17, 2023 2 hours ago, prestashopfree.com said: Hi. Add custom javascript loading to your module and controller. You can then put in it when and where the datetimepicker will be loaded. E.g: Module: public function hookActionAdminControllerSetMedia($params) { if ($this->context->controller->controller_name == 'AdminModules' && Tools::getValue('configure') == $this->name){ $this->context->controller->addJqueryUI('ui.datepicker'); $this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/admin/js/admin.js'); } } JavaScript: $('.datepicker').datetimepicker(); thanks for the answer, yes that is the workaround for this scenario but it needs a little more configuration i will post it soon Link to comment Share on other sites More sharing options...
Ali Samie Posted January 17, 2023 Author Share Posted January 17, 2023 I added this to the view of modern controllers with this js file in a custom module: // adds hour, minute and seconds to the time picker in any listing page you see in modern controllers $(document).ready(function () { $('.datepicker input').each(function (i,e) { $(e).data("DateTimePicker").format('YYYY-MM-DD HH:mm:ss') $(e).data("DateTimePicker").sideBySide() if($(e).attr('value')){ $(e).data("DateTimePicker").date($(e).attr('value')) } }) }) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now