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); }
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')); } }
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') {