Example #1
0
 /**
  * Save workflow out of the browser
  * 
  * @param sfWebRequest $request
  * @return <type>
  */
 public function executeSaveWorkflow(sfWebRequest $request) {
     sfLoader::loadHelpers('Url');
     $data = $request->getPostParameters();
     $workflowSaveObj = new SaveWorkflow();
     if($data['workfloweditAcceptWorkflow_decission'] == 1) { // user accepted Workflow
         // workflow contains fields to write, not e.g. not only file-fields
         if(isset($data['field'])) {
             foreach($data['field'] as $field) {
                 switch ($field['type']) {
                 case 'TEXTFIELD':
                     WorkflowSlotFieldTextfieldTable::instance()->updateTextfieldByWorkflowFieldId($field['field_id'],$field['value']);
                     break;
                 case 'CHECKBOX':
                     $value = $field['value'] == 'false' ? 0 : 1;
                     WorkflowSlotFieldCheckboxTable::instance()->updateCheckboxByWorkflowFieldId($field['field_id'],$value);
                     break;
                 case 'NUMBER':
                     WorkflowSlotFieldNumberTable::instance()->updateNumberByWorkflowFieldId($field['field_id'],$field['value']);
                     break;
                 case 'DATE':
                     WorkflowSlotFieldDateTable::instance()->updateDateByWorkflowFieldId($field['field_id'],$field['value']);
                     break;
                 case 'TEXTAREA':
                     WorkflowSlotFieldTextareaTable::instance()->updateTextareaByWorkflowFieldId($field['field_id'],$field['value']);
                     break;
                 case 'RADIOGROUP':
                     $items = $field['item'];
                     foreach($items as $item) {
                         $value = $item['value'] == 'false' ? 0 : 1;
                         WorkflowSlotFieldRadiogroupTable::instance()->updateRadiogroupById($item['id'],$value);
                     }
                     break;
                 case 'CHECKBOXGROUP':
                     $items = $field['item'];
                     foreach($items as $item) {
                         $value = $item['value'] == 'false' ? 0 : 1;
                         WorkflowSlotFieldCheckboxgroupTable::instance()->updateCheckboxgroupById($item['id'],$value);
                     }
                     break;
                 case 'COMBOBOX':
                     $items = $field['item'];
                     foreach($items as $item) {
                         $value = $item['value'] == 'false' ? 0 : 1;
                         WorkflowSlotFieldComboboxTable::instance()->updateComboboxById($item['id'],$value);
                     }
                     break;
                 case 'FILE':
                     break;
                 }
             }
         }
         // calculate next station
         $context = sfContext::getInstance();
         $context->getConfiguration()->loadHelpers('Partial', 'I18N', 'Url', 'Date', 'CalculateDate', 'ColorBuilder', 'Icon', 'EndAction');
         $slots = $data['slot'];
         $workflowSaveObj->setContext($context);
         $workflowSaveObj->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));
         $workflowSaveObj->getNextStation($slots,$this->getUser()->getAttribute('id'),$request->getParameter('versionid'));
     }
     else { // user denies workflow
         $workflowSaveObj->denyWorkflow($data, $request->getParameter('workflowid'), $this->getUser()->getAttribute('id'), $request->getParameter('versionid'));
     }
     $this->renderText('{success:true}');
     return sfView::NONE;
 }
Example #2
0
    /**
     * Skip a station, and calculate next
     *
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeSkipStation(sfWebRequest $request) {
        sfLoader::loadHelpers('Url');
        WorkflowProcessUserTable::instance()->skipStation($request->getParameter('workflowprocessuserid'));
        $context = sfContext::getInstance();
        $context->getConfiguration()->loadHelpers('Partial', 'I18N', 'Url', 'Date', 'CalculateDate', 'ColorBuilder', 'Icon', 'EndAction');
        $saveWf = new SaveWorkflow();
        $saveWf->setContext($context);
        $saveWf->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));

        $checkWorkflow = new CreateNextStation($request->getParameter('versionid'),$request->getParameter('workflowslotid'),$request->getParameter('workflowslotuserid'),$saveWf);


        $detailsObj = new WorkflowDetail();
        $detailsObj->setUser($this->getUser());
        $detailsObj->setCulture($this->getUser()->getCulture());
        $detailsObj->setContext($this->getContext());
        $workflowsettings = WorkflowVersionTable::instance()->getWorkflowVersionById($request->getParameter('versionid'));
        $userData = $detailsObj->buildUserData($workflowsettings, $request->getParameter('versionid'));
       
        
        $this->renderText('{"detailData" : '.json_encode($userData).'}');
        return sfView::NONE;
    }