Commit e8afa6489e4782bf423b4a62557b1f38bded69e9

Authored by nbm
1 parent 4fbbe830

Add a criteria to be able to search on workflow state, and to be able to

view workflow state of documents in the browse window.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3922 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 43 additions and 1 deletions
lib/browse/Criteria.inc
@@ -456,6 +456,45 @@ class ContentCriterion extends BrowseCriterion { @@ -456,6 +456,45 @@ class ContentCriterion extends BrowseCriterion {
456 } 456 }
457 } 457 }
458 458
  459 +class WorkflowStateCriterion extends BrowseCriterion {
  460 + function documentDisplay ($oDocument) {
  461 + $oState =& KTWorkflowState::getByDocument($oDocument);
  462 + if ($oState) {
  463 + $oWorkflow = KTWorkflow::get($oState->getWorkflowId());
  464 + return $oWorkflow->getName() . " - " . $oState->getName();
  465 + }
  466 + return "Not in workflow";
  467 + }
  468 +
  469 + function getName() {
  470 + return "state";
  471 + }
  472 +
  473 + function searchSQL ($aRequest) {
  474 + $p = array();
  475 + $p[0] = "WD.state_id = ?";
  476 + $p[1] = $aRequest[$this->getWidgetBase()];
  477 + return $p;
  478 + }
  479 +
  480 + function searchJoinSQL () {
  481 + global $default;
  482 + return "INNER JOIN $default->workflow_documents_table AS WD ON D.id = WD.document_id";
  483 + }
  484 +
  485 + function searchWidget ($aRequest) {
  486 + $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n";
  487 + $aStates = KTWorkflowState::getList("ORDER BY workflow_id");
  488 + $sRet .= "<option value=\"-1\">None</option>\n";
  489 + foreach ($aStates as $oState) {
  490 + $oWorkflow =& KTWorkflow::get($oState->getWorkflowId());
  491 + $sRet .= "<option value=\"" . $oState->getId() . "\">" . $oWorkflow->getName() . " - " . $oState->getName() . "</option>\n";
  492 + }
  493 + $sRet .= "</select>\n";
  494 + return $sRet;
  495 + }
  496 +}
  497 +
459 class Criteria { 498 class Criteria {
460 function &_getBaseCriterionByNumber($iID) { 499 function &_getBaseCriterionByNumber($iID) {
461 global $default; 500 global $default;
@@ -487,6 +526,9 @@ class Criteria { @@ -487,6 +526,9 @@ class Criteria {
487 case -9: 526 case -9:
488 $oCriterion =& new ContentCriterion(_("Document Contents"), 'content', 'content', -9); 527 $oCriterion =& new ContentCriterion(_("Document Contents"), 'content', 'content', -9);
489 break; 528 break;
  529 + case -10:
  530 + $oCriterion =& new WorkflowStateCriterion(_("Workflow state"), 'state', 'state', -10);
  531 + break;
490 } 532 }
491 return $oCriterion; 533 return $oCriterion;
492 } 534 }
@@ -497,7 +539,7 @@ class Criteria { @@ -497,7 +539,7 @@ class Criteria {
497 return; 539 return;
498 } 540 }
499 $aBaseCriteria = array(); 541 $aBaseCriteria = array();
500 - $aIDs = range(-1, -9); 542 + $aIDs = range(-1, -10);
501 foreach ($aIDs as $iID) { 543 foreach ($aIDs as $iID) {
502 $oCriterion =& Criteria::_getBaseCriterionByNumber($iID); 544 $oCriterion =& Criteria::_getBaseCriterionByNumber($iID);
503 $aBaseCriteria[$iID] =& $oCriterion; 545 $aBaseCriteria[$iID] =& $oCriterion;