Exemplo n.º 1
0
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt('workflow'));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/workflow/documentWorkflow');
     $oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
     $oWorkflow = KTWorkflowUtil::getWorkflowForDocument($oDocument);
     $oWorkflowState = KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
     $oUser =& User::get($_SESSION['userID']);
     // If the document is checked out - set transitions and workflows to empty and set checkedout to true
     $bIsCheckedOut = $this->oDocument->getIsCheckedOut();
     if ($bIsCheckedOut) {
         $aTransitions = array();
         $aWorkflows = array();
         $transition_fields = array();
         $bHasPerm = FALSE;
     } else {
         $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($oDocument, $oUser);
         $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1 ');
         $bHasPerm = false;
         if (KTPermissionUtil::userHasPermissionOnItem($oUser, 'ktcore.permissions.workflow', $oDocument)) {
             $bHasPerm = true;
         }
         $fieldErrors = null;
         $transition_fields = array();
         if ($aTransitions) {
             $aVocab = array();
             foreach ($aTransitions as $oTransition) {
                 if (is_null($oTransition) || PEAR::isError($oTransition)) {
                     continue;
                 }
                 $aVocab[$oTransition->getId()] = $oTransition->showDescription();
             }
             $fieldOptions = array('vocab' => $aVocab);
             $transition_fields[] = new KTLookupWidget(_kt('Transition to perform'), _kt('The transition listed will cause the document to change from its current state to the listed destination state.'), 'fTransitionId', null, $this->oPage, true, null, $fieldErrors, $fieldOptions);
             $transition_fields[] = new KTTextWidget(_kt('Reason for transition'), _kt('Describe why this document qualifies to be changed from its current state to the destination state of the transition chosen.'), 'fComments', '', $this->oPage, true, null, null, array('cols' => 80, 'rows' => 4));
         }
     }
     // Add an electronic signature
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to modify the document workflow');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.modify_workflow', 'document', 'start_workflow_form', 'submit', {$this->oDocument->iId});";
         $heading2 = _kt('You are attempting to transition the document workflow');
         $submit2['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading2}', 'ktcore.transactions.transition_workflow', 'document', 'transition_wf_form', 'submit', {$this->oDocument->iId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
         $submit2['onclick'] = '';
     }
     $aTemplateData = array('oDocument' => $oDocument, 'oWorkflow' => $oWorkflow, 'oState' => $oWorkflowState, 'aTransitions' => $aTransitions, 'aWorkflows' => $aWorkflows, 'transition_fields' => $transition_fields, 'bHasPerm' => $bHasPerm, 'bIsCheckedOut' => $bIsCheckedOut, 'submit' => $submit, 'submit2' => $submit2);
     return $oTemplate->render($aTemplateData);
 }
Exemplo n.º 2
0
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("Configure Workflows for Folder"));
     $this->oPage->setTitle(_kt("Configure Workflows for Folder"));
     $oTemplate =& $this->oValidator->validateTemplate('ktstandard/workflow/folderconfigure');
     $fields = array();
     $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1');
     $aVocab = array();
     $aVocab[] = _kt('No automatic workflow.');
     foreach ($aWorkflows as $oWorkflow) {
         $aVocab[$oWorkflow->getId()] = $oWorkflow->getName();
     }
     $fieldOptions = array("vocab" => $aVocab);
     // grab the value.
     $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('folder_workflow_map');
     $sQuery .= ' WHERE `folder_id` = ?';
     $aParams = array($this->oFolder->getId());
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'workflow_id');
     if (PEAR::isError($res)) {
         $res = null;
     }
     $fields[] = new KTLookupWidget(_kt('Automatic Workflow'), _kt('If you specify an automatic workflow, new documents will automatically enter that workflow\'s starting state.  Setting this to "No Automatic Workflow" will mean that users can choose the appropriate workflow.'), 'fWorkflowId', $res, $this->oPage, true, null, $fieldErrors, $fieldOptions);
     $oTemplate->setData(array('context' => &$this, 'folder_id' => $this->oFolder->getId(), 'fields' => $fields));
     return $oTemplate->render();
 }
Exemplo n.º 3
0
 function do_main()
 {
     $oTemplate = $this->oValidator->validateTemplate('ktcore/workflow/admin/list');
     $aWorkflows = KTWorkflow::getList();
     $oTemplate->setData(array('context' => $this, 'workflows' => $aWorkflows));
     return $oTemplate->render();
 }
Exemplo n.º 4
0
 function do_update()
 {
     $types_mapping = (array) KTUtil::arrayGet($_REQUEST, 'fDocumentTypeAssignment');
     $aWorkflows = KTWorkflow::getList();
     $aTypes = DocumentType::getList();
     $sQuery = 'DELETE FROM ' . KTUtil::getTableName('type_workflow_map');
     $aParams = array();
     DBUtil::runQuery(array($sQuery, $aParams));
     $aOptions = array('noid' => true);
     $sTable = KTUtil::getTableName('type_workflow_map');
     foreach ($aTypes as $oType) {
         $t = $types_mapping[$oType->getId()];
         if ($t == null) {
             $t = null;
         }
         $res = DBUtil::autoInsert($sTable, array('document_type_id' => $oType->getId(), 'workflow_id' => $t), $aOptions);
     }
     $this->successRedirectToMain(_kt('Type mapping updated.'));
 }