public function run()
 {
     DB::table('workflow')->delete();
     $flow = new Workflow();
     $flow->id = '1';
     $flow->workFlowName = 'Small Value Procurement (Below P50,000)';
     $flow->totalDays = '45';
     $flow->save();
     $flow = new Workflow();
     $flow->id = '2';
     $flow->workFlowName = 'Small Value Procurement (Above P50,000 Below P500,000)';
     $flow->totalDays = '120';
     $flow->save();
     $flow = new Workflow();
     $flow->id = '3';
     $flow->workFlowName = 'Bidding (Above P500,000)';
     $flow->totalDays = '200';
     $flow->save();
     $flow = new Workflow();
     $flow->id = '4';
     $flow->workFlowName = 'Pakyaw';
     $flow->totalDays = '200';
     $flow->save();
     $flow = new Workflow();
     $flow->id = '5';
     $flow->workFlowName = 'Direct Contracting';
     $flow->totalDays = '200';
     $flow->save();
 }
Esempio n. 2
0
 public static function newWorkflow($type)
 {
     $wf = new Workflow();
     $wf->ui_type = $type;
     $wf->save();
     return $wf;
 }
Esempio n. 3
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aRole !== null) {
             if ($this->aRole->isModified() || $this->aRole->isNew()) {
                 $affectedRows += $this->aRole->save($con);
             }
             $this->setRole($this->aRole);
         }
         if ($this->aWorkflow !== null) {
             if ($this->aWorkflow->isModified() || $this->aWorkflow->isNew()) {
                 $affectedRows += $this->aWorkflow->save($con);
             }
             $this->setWorkflow($this->aWorkflow);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = WorkflowRolePeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = WorkflowRolePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += WorkflowRolePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 4
0
 public function actionCreate()
 {
     $workflowModel = new Workflow();
     $workflowModel->lastUpdated = time();
     $stages = array();
     if (isset($_POST['Workflow'], $_POST['WorkflowStages'])) {
         $workflowModel->attributes = $_POST['Workflow'];
         if (isset($_POST['colors']) && is_array($_POST['colors'])) {
             // remove empty strings
             $_POST['colors'] = array_filter($_POST['colors'], function ($a) {
                 return $a !== '';
             });
             $workflowModel->colors = $_POST['colors'];
         }
         if ($workflowModel->save()) {
             $validStages = true;
             for ($i = 0; $i < count($_POST['WorkflowStages']); $i++) {
                 $stages[$i] = new WorkflowStage();
                 $stages[$i]->workflowId = $workflowModel->id;
                 $stages[$i]->attributes = $_POST['WorkflowStages'][$i + 1];
                 $stages[$i]->stageNumber = $i + 1;
                 $stages[$i]->roles = $_POST['WorkflowStages'][$i + 1]['roles'];
                 if (empty($stages[$i]->roles) || in_array('', $stages[$i]->roles)) {
                     $stages[$i]->roles = array();
                 }
                 if (!$stages[$i]->validate()) {
                     $validStages = false;
                 }
             }
             if ($validStages) {
                 foreach ($stages as &$stage) {
                     $stage->save();
                     foreach ($stage->roles as $roleId) {
                         Yii::app()->db->createCommand()->insert('x2_role_to_workflow', array('stageId' => $stage->id, 'roleId' => $roleId, 'workflowId' => $workflowModel->id));
                     }
                 }
                 if ($workflowModel->save()) {
                     $this->redirect(array('view', 'id' => $workflowModel->id));
                 }
             }
         }
     }
     $this->render('create', array('model' => $workflowModel));
 }
 public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $file = $folder . basename($_FILES['uploadfile']['name']);
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
         $row = 0;
         if (($handle = fopen($file, "r")) !== FALSE) {
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if ($row > 0) {
                     $model = Workflow::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Workflow();
                     }
                     $model->workflowid = (int) $data[0];
                     $model->wfname = $data[1];
                     $model->wfdesc = $data[2];
                     $model->wfminstat = $data[3];
                     $model->wfmaxstat = $data[4];
                     $model->recordstatus = (int) $data[5];
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         }
                     } catch (Exception $e) {
                         $this->messages = $this->messages . $e->getMessage();
                     }
                 }
                 $row++;
             }
         } else {
             $this->messages = $this->messages . ' memory or harddisk full';
         }
         fclose($handle);
     } else {
         $this->messages = $this->messages . ' check your directory permission';
     }
     if ($this->messages == '') {
         $this->messages = 'success';
     }
     echo $this->messages;
 }
Esempio n. 6
0
<?php

$workflowID = $_POST['workflowID'];
if ($workflowID != '') {
    $workflow = new Workflow(new NamedArguments(array('primaryKey' => $workflowID)));
} else {
    $workflow = new Workflow();
}
$workflow->workflowName = '';
$workflow->resourceFormatIDValue = $_POST['resourceFormatID'];
$workflow->resourceTypeIDValue = $_POST['resourceTypeID'];
$workflow->acquisitionTypeIDValue = $_POST['acquisitionTypeID'];
try {
    $workflow->save();
    $workflowID = $workflow->primaryKey;
    //first remove all step records, then we'll add them back
    $workflow->removeSteps();
    $stepNameArray = array();
    $stepNameArray = explode(':::', $_POST['stepNames']);
    $userGroupArray = array();
    $userGroupArray = explode(':::', $_POST['userGroups']);
    $priorStepArray = array();
    $priorStepArray = explode(':::', $_POST['priorSteps']);
    $seqOrderArray = array();
    $seqOrderArray = explode(':::', $_POST['seqOrders']);
    $stepIDArray = array();
    $stepIDPriorArray = array();
    foreach ($stepNameArray as $key => $value) {
        if (trim($value)) {
            $step = new Step();
            $step->workflowID = $workflowID;
Esempio n. 7
0
 public function actionCreate()
 {
     $workflowModel = new Workflow();
     $workflowModel->lastUpdated = time();
     $stages = array();
     $workflowAttr = filter_input(INPUT_POST, 'Workflow', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
     $workflowStages = filter_input(INPUT_POST, 'WorkflowStages', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
     if (!empty($workflowAttr) && !empty($workflowStages)) {
         $workflowModel->attributes = $workflowAttr;
         $colors = filter_input(INPUT_POST, 'colors', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
         if (!empty($colors)) {
             $colors = array_filter($colors, function ($a) {
                 return $a !== '';
             });
             $workflowModel->colors = $colors;
         }
         if ($workflowModel->save()) {
             $validStages = true;
             for ($i = 0; $i < count($workflowStages); $i++) {
                 $stages[$i] = new WorkflowStage();
                 $stages[$i]->workflowId = $workflowModel->id;
                 $stages[$i]->attributes = $workflowStages[$i + 1];
                 $stages[$i]->stageNumber = $i + 1;
                 $stages[$i]->roles = $workflowStages[$i + 1]['roles'];
                 if (empty($stages[$i]->roles) || in_array('', $stages[$i]->roles)) {
                     $stages[$i]->roles = array();
                 }
                 if (!$stages[$i]->validate()) {
                     $validStages = false;
                 }
             }
             if ($validStages) {
                 foreach ($stages as &$stage) {
                     $stage->save();
                     foreach ($stage->roles as $roleId) {
                         Yii::app()->db->createCommand()->insert('x2_role_to_workflow', array('stageId' => $stage->id, 'roleId' => $roleId, 'workflowId' => $workflowModel->id));
                     }
                 }
                 if ($workflowModel->save()) {
                     $this->redirect(array('view', 'id' => $workflowModel->id));
                 }
             }
         }
     }
     $this->render('create', array('model' => $workflowModel));
 }