Skip to content
Snippets Groups Projects
Commit b6f685c0 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #1848 from greezybacon/issue/901

search: Fix search on create date
parents 05787723 4d26f29f
No related branches found
No related tags found
No related merge requests found
...@@ -391,6 +391,7 @@ var scp_prep = function() { ...@@ -391,6 +391,7 @@ var scp_prep = function() {
var fObj = $(this); var fObj = $(this);
var elem = $('#advanced-search'); var elem = $('#advanced-search');
$('#result-count').html(''); $('#result-count').html('');
fixupDatePickers.call(this);
$.ajax({ $.ajax({
url: "ajax.php/tickets/search", url: "ajax.php/tickets/search",
data: fObj.serialize(), data: fObj.serialize(),
...@@ -447,18 +448,21 @@ var scp_prep = function() { ...@@ -447,18 +448,21 @@ var scp_prep = function() {
$(document).ready(scp_prep); $(document).ready(scp_prep);
$(document).on('pjax:end', scp_prep); $(document).on('pjax:end', scp_prep);
$(document).on('submit', 'form', function() { var fixupDatePickers = function() {
// Reformat dates // Reformat dates
$('.dp', $(this)).each(function(i, e) { $('.dp', $(this)).each(function(i, e) {
var $e = $(e), var $e = $(e),
d = $e.datepicker('getDate'); d = $e.datepicker('getDate');
if (!d) return; if (!d || $e.data('fixed')) return;
var day = ('0'+d.getDate()).substr(-2), var day = ('0'+d.getDate()).substr(-2),
month = ('0'+(d.getMonth()+1)).substr(-2), month = ('0'+(d.getMonth()+1)).substr(-2),
year = d.getFullYear(); year = d.getFullYear();
$e.val(year+'-'+month+'-'+day); $e.val(year+'-'+month+'-'+day);
$e.data('fixed', true);
$e.on('change', function() { $(this).data('fixed', false); });
}); });
}); };
$(document).on('submit', 'form', fixupDatePickers);
/************ global inits *****************/ /************ global inits *****************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment