示例#1
0
 /**
  * Create an array containing where keys are statusIds in the form workflowId/statusId
  * and the value is the status label.
  * Note that by default this method never inserts the status of the model passed as argument.
  * see {@link SWHelper::nextStatuslistData} for argument options
  *
  * @param CModel the data model attaching a simpleWorkflow behavior
  * @param array $statusList array of string where each value is the statusId
  * @param array $options the list data that can be used in dropDownList and listBox
  */
 public static function statusListData($model, $statusList, $options = array())
 {
     $nodeList = array();
     $w = $model->swGetWorkflowSource();
     foreach ($statusList as $key => $statusId) {
         $nodeList[] = $w->getNodeDefinition($statusId);
     }
     $options['includeCurrent'] = isset($options['includeCurrent']) ? $options['includeCurrent'] : false;
     return SWHelper::_createListData($model, $nodeList, $options);
 }
示例#2
0
 public function actionStatus($flightBookerId, $status = 0)
 {
     //$this->loadModel();
     //die();
     /** @var FlightBookerComponent $flightBookerComponent  */
     $flightBookerComponent = Yii::app()->flightBooker;
     $flightBookerComponent->setFlightBookerFromId($flightBookerId);
     //echo "FlightBookerId ".$flightBookerComponent->getFlightBookerId()."\n";
     //if($newState)
     //{
     //    $flightBookerComponent->status($newState);
     //    echo "changed\n";
     //}
     if ($this and is_string($status)) {
         $flightBookerComponent->getCurrent()->status = $status;
         $flightBookerComponent->getCurrent()->save();
     }
     echo 'You current status now: ' . $flightBookerComponent->getCurrent()->swGetStatus();
     echo '<br>Your booker id = ' . Yii::app()->user->getState('flightBookerId');
     echo '<br><br>';
     $items = SWHelper::nextStatuslistData($flightBookerComponent->getCurrent(), false);
     if (count($items) > 0) {
         echo 'Next possible statuses:';
         echo '<ul>';
     }
     foreach ($items as $item => $name) {
         echo '<li>' . CHtml::link($name, array('booker/status', 'status' => $name, 'flightBookerId' => $flightBookerId)) . '</li>';
     }
     if (count($items) > 0) {
         echo '</ul>';
     }
     if ($flightBookerComponent->getCurrent()->swIsFinalStatus()) {
         echo 'It is final state<br>';
         Yii::app()->user->setState('flightBookerId', null);
         echo CHtml::link('Start again', array('booker/flight'));
     }
 }
 public function test_04()
 {
     $m = new Model01();
     $ar = SWHelper::nextStatuslistData($m, array('exclude' => 'workflow1/S2,workflow1/S3'));
     $this->assertTrue(is_array($ar));
     $this->assertEquals(count($ar), 1);
     $this->assertTrue(isset($ar['workflow1/S1']));
     $this->assertEquals($ar['workflow1/S1'], 'status S1');
     // exclude status as comma separated list with no workflow id and additional spaces
     $ar = SWHelper::nextStatuslistData($m, array('exclude' => 'S2,    S3'));
     $this->assertTrue(is_array($ar));
     $this->assertEquals(count($ar), 1);
     $this->assertTrue(isset($ar['workflow1/S1']));
     $this->assertEquals($ar['workflow1/S1'], 'status S1');
     $ar = SWHelper::allStatuslistData($m);
     $this->assertEquals(count($ar), 5);
     $ar = SWHelper::allStatuslistData($m, array('includeCurrent' => false));
     $this->assertEquals(count($ar), 4);
     $this->assertTrue(isset($ar['workflow1/S1']) == false);
     $ar = SWHelper::allStatuslistData($m, array('exclude' => array('S1', 'S2', 'S3', 'S4', 'S5')));
     $this->assertEquals(count($ar), 0);
 }
示例#4
0
    echo $form->textField($wr, 'file_link', array('id' => 'zip-filename', 'readonly' => 'readonly'));
    ?>
				<?php 
    echo $form->error($wr, 'file_link');
    ?>
			</div>
			<?php 
}
// approve
?>
			
			<br/>
			
			<div class="row status_buttons">
				<?php 
foreach (SWHelper::nextStatuslistData($wr, false) as $k => $v) {
    if ($v === $action) {
        echo CHtml::submitButton(Yii::t('waterrequest', ucfirst($v)), array('id' => $v . '-button', 'name' => $v . '-button'));
        break;
    }
}
?>
			</div>
		
		<?php 
$this->endWidget();
?>

	</div>
<?php 
if ($action == 'approve') {
示例#5
0
 /**
  * Finds simple workflow status label
  * @param string status id
  * @return string label
  */
 public function getLabelByStatus($status)
 {
     $status = $this->swDbStatus($status);
     $nodes = SWHelper::allStatuslistData($this);
     return isset($nodes[$status]) ? $nodes[$status] : null;
 }