public function actionReorder($id)
 {
     $traveler = $this->loadModel($id);
     if (isset($_POST['position'])) {
         Step::model()->sortSteps($_POST['position']);
         exit("ok");
     }
     $this->render('reorder', array('steps' => $traveler->getStepParent(), 'id' => $id));
 }
 protected function loadStep($stepId)
 {
     //if the project property is null, create it based on input id
     if ($this->step === null) {
         $this->step = Step::model()->findbyPk($stepId);
         if ($this->step === null) {
             throw new CHttpException(404, 'The requested step does not exist.');
         }
     }
     return $this->step;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     throw new CHttpException(404, 'The requested page does not exist.');
     $model = new File();
     $issue = null;
     if (isset($_GET['discrepancyId'])) {
         $discrepancyId = $_GET['discrepancyId'];
         $discrepancy = Nonconformity::model()->findByPk($discrepancyId);
         $step = $discrepancy->step;
         $model->discrepancyId = $discrepancyId;
         $issue = Issue::model()->find("id = {$discrepancy->issueId}");
         $dir = "discrepancy/";
     } elseif (isset($_GET['stepId'])) {
         $stepId = $_GET['stepId'];
         $step = Step::model()->findByPk($stepId);
         $model->stepId = $stepId;
         $dir = "step/";
     } else {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['File'])) {
         $model->attributes = $_POST['File'];
         $upload = CUploadedFile::getInstance($model, 'fileSelected');
         $rnd = rand(0, 99999);
         if (@getimagesize($upload->tempName)) {
             $model->image = 1;
         } else {
             $model->image = 0;
         }
         $fileName = "{$rnd}-{$upload}";
         $model->userId = Yii::app()->user->id;
         $model->fileSelected = $upload;
         $link = $dir . preg_replace("/[^a-zA-Z0-9\\/_|.-]/", "_", $fileName);
         if ($upload->saveAs(Yii::app()->params['dfs'] . "/{$link}")) {
             $model->link = $link;
             $model->save();
             $this->redirect(array('index', 'discrepancyId' => $model->discrepancyId));
         }
     }
     $this->render('create', array('model' => $model, 'step' => $step, 'issue' => $issue, 'discrepancyId' => $discrepancyId));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Step the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Step::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Element('search');
     $model->unsetAttributes();
     // clear any default values
     if (!isset($_GET['stepId'])) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $model->stepId = $_GET['stepId'];
     if (isset($_GET['Element'])) {
         $model->attributes = $_GET['Element'];
     }
     $this->render('admin', array('model' => $model, 'step' => Step::model()->findByPk($model->stepId)));
 }
 public function getStep($id)
 {
     return Step::model()->findByPk($id);
 }
Example #7
0
    ?>
	<div class="row">
            <?php 
    if (isset($parentId)) {
        ?>
                <?php 
        echo $form->hiddenField($model, 'parentId', array('value' => $parentId));
        ?>
            <?php 
    } else {
        ?>
		<?php 
        echo $form->labelEx($model, 'parentId');
        ?>
		<?php 
        echo $form->dropDownList($model, 'parentId', CHtml::listData(Step::model()->getStepParent($travelerId), 'id', 'stepName'), array('prompt' => Yii::t('default', 'None')));
        ?>
		<?php 
        echo $form->error($model, 'parentId');
        ?>
            <?php 
    }
    ?>
	</div>
<?php 
}
?>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'name');
?>
Example #8
0
	public function initSteps(){
		$step1 = Step::model()->findByPk(1);
		$step2 = Step::model()->findByPk(2);
		$step3 = Step::model()->findByPk(3);
		$step4 = Step::model()->findByPk(4);
		$step5 = Step::model()->findByPk(5);

		$step1->stepTitle =  Yii::t('step','0038');
		$step2->stepTitle =  Yii::t('step','0039');
		$step3->stepTitle =  Yii::t('step','0040');
		$step4->stepTitle =  Yii::t('step','0041');
		$step5->stepTitle =  Yii::t('step','0042');

		$step1->stepText =  Yii::t('step','0044');
		$step2->stepText =  Yii::t('step','0045');
		$step3->stepText =  Yii::t('step','0046');
		$step4->stepText =  Yii::t('step','0047');
		$step5->stepText =  Yii::t('step','0048');


		return $arraySteps = array(
			'step1'=>$step1,
			'step2'=>$step2,
			'step3'=>$step3,
			'step4'=>$step4,
			'step5'=>$step5,
		);
	}
Example #9
0
 public function getStepParent()
 {
     return Step::model()->getStepParent($this->id);
 }
Example #10
0
 public function sortSteps($position)
 {
     $i = 1;
     foreach ($position as $id) {
         $step = Step::model()->findByPk($id);
         $step->position = $i;
         $step->save();
         $i++;
     }
 }