From 381d14a6f6d37b05663cb003cf71fd23dccf26bd Mon Sep 17 00:00:00 2001 From: abijah Date: Sat, 8 Jan 2011 00:56:15 +0000 Subject: [PATCH] Modified the grid search to support standard date formats, with a bit of a kludge by applying it to fields that end with _date or stamp. git-svn-id: file:///svn-source/pmgr/branches/v0.3_work/site@1002 97e9348a-65ac-dc4b-aefc-98561f571b83 --- app_controller.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app_controller.php b/app_controller.php index fd73846..c081397 100644 --- a/app_controller.php +++ b/app_controller.php @@ -948,13 +948,22 @@ class AppController extends Controller { 'value' => $params['filtValue']); } + // Translate a user specified date into the SQL date format + foreach ($searches AS &$search) { + if (preg_match('/(_date|stamp)$/', $search['field']) && + preg_match('%(\d{1,2})[-/](\d{1,2})[-/](\d{2,4})%', $search['value'], $matches)) { + $search['value'] = sprintf('%04d%02d%02d', $matches[3], $matches[2], $matches[1]); + } + } + unset($search); + $ops = array('eq' => array('op' => null, 'pre' => '', 'post' => ''), 'ne' => array('op' => '<>', 'pre' => '', 'post' => ''), 'lt' => array('op' => '<', 'pre' => '', 'post' => ''), 'le' => array('op' => '<=', 'pre' => '', 'post' => ''), 'gt' => array('op' => '>', 'pre' => '', 'post' => ''), 'ge' => array('op' => '>=', 'pre' => '', 'post' => ''), - 'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'), + 'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'), 'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'), 'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''), 'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'), @@ -1157,7 +1166,7 @@ class AppController extends Controller { } function gridDataOutputSummary(&$params, &$model, $pagination) { - if ($params['debug']) + if ($params['debug']) echo " \n"; echo " {$pagination['page']}\n"; echo " {$pagination['total']}\n";