Commit db0eae29faef516e537425d9a519d6acd585c72b
1 parent
26ee9de4
Render negative numbers with underscore instead of dash to allow easier
manipulation in javascript. Implement searching for date created, offering between A and B, after A, and before B syntax. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3143 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
51 additions
and
15 deletions
lib/browse/Criteria.inc
| ... | ... | @@ -152,7 +152,11 @@ class BrowseCriterion { |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function searchWidget ($aRequest) { |
| 155 | - return "<input type=\"text\" size=\"50\" name=\"bmd" . $this->getID() . "\" />"; | |
| 155 | + return "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" />"; | |
| 156 | + } | |
| 157 | + | |
| 158 | + function getWidgetBase () { | |
| 159 | + return "bmd" . strtr($this->getID(), '-', '_'); | |
| 156 | 160 | } |
| 157 | 161 | |
| 158 | 162 | function getSearchTable() { |
| ... | ... | @@ -161,9 +165,9 @@ class BrowseCriterion { |
| 161 | 165 | |
| 162 | 166 | function searchSQL ($aRequest) { |
| 163 | 167 | if ($this->bString) { |
| 164 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest['bmd' . $this->getID()]) . "%'", array()); | |
| 168 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest[$this->getWidgetBase()]) . "%'", array()); | |
| 165 | 169 | } else { |
| 166 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest['bmd' . $this->getID()])); | |
| 170 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest[$this->getWidgetBase()])); | |
| 167 | 171 | } |
| 168 | 172 | } |
| 169 | 173 | } |
| ... | ... | @@ -242,7 +246,7 @@ class CreatorCriterion extends BrowseCriterion { |
| 242 | 246 | return $this->documentDisplay($oFolder); |
| 243 | 247 | } |
| 244 | 248 | function searchWidget ($aRequest) { |
| 245 | - $sRet = "<select size=\"1\" name=\"bmd" . $this->getID() . "\">\n"; | |
| 249 | + $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | |
| 246 | 250 | $aUsers = User::getList();/*ok*/ |
| 247 | 251 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| 248 | 252 | foreach ($aUsers as $oUser) { |
| ... | ... | @@ -254,20 +258,52 @@ class CreatorCriterion extends BrowseCriterion { |
| 254 | 258 | } |
| 255 | 259 | |
| 256 | 260 | class DateCreatedCriterion extends BrowseCriterion { |
| 257 | - var $aLookup = array( | |
| 258 | - "table" => "document_transactions", | |
| 259 | - "field" => "datetime", | |
| 260 | - "joinColumn" => "document_id", | |
| 261 | - "whereClause" => "transaction_id=1", | |
| 262 | - ); | |
| 263 | - | |
| 264 | 261 | function documentDisplay ($oDocument) { |
| 265 | - $aDocumentTransaction = DocumentTransaction::getList(array("transaction_id = 1 AND document_id = ?", $oDocument->getID()));/*ok*/ | |
| 266 | - return $aDocumentTransaction[0]->dDateTime; | |
| 262 | + return $oDocument->getCreatedDateTime(); | |
| 267 | 263 | } |
| 268 | 264 | function getName() { |
| 269 | 265 | return "datecreated"; |
| 270 | 266 | } |
| 267 | + function searchWidget ($aRequest) { | |
| 268 | + global $default; | |
| 269 | + $sStartWidget = $this->getWidgetBase() . "_start"; | |
| 270 | + $sEndWidget = $this->getWidgetBase() . "_end"; | |
| 271 | + $sToRender = "<input type=\"text\" size=\"10\" name=\"" . $sStartWidget . "\" />"; | |
| 272 | + $sToRender .= " <a href=\"javascript:show_calendar('MainForm." . $sStartWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; | |
| 273 | + $sToRender .= "<input type=\"text\" size=\"10\" name=\"" . $sEndWidget . "\" />"; | |
| 274 | + $sToRender .= " <a href=\"javascript:show_calendar('MainForm." . $sEndWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; | |
| 275 | + return $sToRender; | |
| 276 | + } | |
| 277 | + function searchSQL ($aRequest) { | |
| 278 | + $sStartWidget = $this->getWidgetBase() . "_start"; | |
| 279 | + $sEndWidget = $this->getWidgetBase() . "_end"; | |
| 280 | + // XXX: DateTimeFixup: Should be more intelligent with handling | |
| 281 | + // end date - should be end of day on that day. | |
| 282 | + if (!array_key_exists($this->getWidgetBase() . "_start", $aRequest)) { | |
| 283 | + $sStart = null; | |
| 284 | + } else { | |
| 285 | + $sStart = $aRequest[$this->getWidgetBase() . "_start"]; | |
| 286 | + } | |
| 287 | + if (!array_key_exists($this->getWidgetBase() . "_end", $aRequest)) { | |
| 288 | + $sEnd = null; | |
| 289 | + } else { | |
| 290 | + $sEnd = $aRequest[$this->getWidgetBase() . "_end"]; | |
| 291 | + } | |
| 292 | + if ($sStart && $sEnd) { | |
| 293 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " BETWEEN ? AND ?", array($sStart, $sEnd)); | |
| 294 | + } | |
| 295 | + if ($sStart) { | |
| 296 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " > ?", array($sStart)); | |
| 297 | + } | |
| 298 | + if ($sEnd) { | |
| 299 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " < ?", array($sEnd)); | |
| 300 | + } | |
| 301 | + var_dump($aRequest); | |
| 302 | + var_dump($sStart); | |
| 303 | + var_dump($sEnd); | |
| 304 | + return array('Huh = ?', array(1)); | |
| 305 | + } | |
| 306 | + | |
| 271 | 307 | } |
| 272 | 308 | |
| 273 | 309 | class DocumentTypeCriterion extends BrowseCriterion { |
| ... | ... | @@ -284,7 +320,7 @@ class DocumentTypeCriterion extends BrowseCriterion { |
| 284 | 320 | return " "; |
| 285 | 321 | } |
| 286 | 322 | function searchWidget ($aRequest) { |
| 287 | - $sRet = "<select size=\"1\" name=\"bmd" . $this->getID() . "\">\n"; | |
| 323 | + $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | |
| 288 | 324 | $aUsers = DocumentType::getList();/*ok*/ |
| 289 | 325 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| 290 | 326 | foreach ($aUsers as $oUser) { |
| ... | ... | @@ -350,7 +386,7 @@ class Criteria { |
| 350 | 386 | $oCriterion =& new CreatorCriterion(_("Creator"), 'creator_id', 'creator_id', -3); |
| 351 | 387 | break; |
| 352 | 388 | case -4: |
| 353 | - $oCriterion =& new DateCreatedCriterion(_("Date Created"), 'id', 'id', -4); | |
| 389 | + $oCriterion =& new DateCreatedCriterion(_("Date Created"), 'created', 'created', -4); | |
| 354 | 390 | break; |
| 355 | 391 | case -5: |
| 356 | 392 | $oCriterion =& new DocumentTypeCriterion(_("Document Type"), 'document_type_id', 'document_type_id', -5); | ... | ... |