/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['EvaAttributesMatrix'])) { $model->attributes = $_POST['EvaAttributesMatrix']; if ($model->save()) { $this->redirect(['index']); } } $dropDownData = []; $survObjCriteria = new CDbCriteria(); $survObjCriteria->with = ['options']; $survObjCriteria->select = 'inputName'; $survObjCriteria->condition = "inputName='survObj' AND options.frameworkFieldId=t.id"; $rsSurveillanceObjective = FrameworkFields::model()->find($survObjCriteria); $dropDownData['objectives'] = CHtml::listData($rsSurveillanceObjective->options, 'optionId', 'label'); $rsQuestionGrp = EvaQuestionGroups::model()->find(['select' => 'questions']); $questionsArray = array_keys((array) json_decode($rsQuestionGrp->questions)); $dropDownData['groups'] = array_combine($questionsArray, range(1, count($questionsArray))); //print_r($dropDownData['groups']); die; $dropDownData['attributes'] = CHtml::listData(EvaAttributes::model()->findAll(), 'attributeId', 'name'); $this->menu = [['label' => 'Add Attribute Relevance', 'url' => $this->createUrl('create')], ['label' => 'List Attribute Relevance', 'url' => $this->createUrl('index')]]; $this->render('update', ['model' => $model, 'dropDownData' => $dropDownData]); }
/** * actionEvaSummary */ public function actionEvaSummary() { $this->setPageTitle('Evaluation Summary'); $evaDetails = $this->getEvaDetails(); $evaAssMethods = ModelToArray::convertModelToArray(EvaAssessmentMethods::model()->with('evaluationAttributes', 'evaAttrAssMethods')->findAll('evaluationId=:evaId', [':evaId' => $this->evaContextId])); //print_r($evaAssMethods); die; $econEvaMethods = []; $evaAttributes = []; $rsEvaHeader = ModelToArray::convertModelToArray(EvaluationHeader::model()->findByPk($this->evaContextId, ['select' => 'econEvaMethods, evaAttributes'])); if (isset($rsEvaHeader['econEvaMethods'])) { $selectedEconEvaMethods = json_decode($rsEvaHeader['econEvaMethods']); $econEvaMethodsCriteria = new CDbCriteria(); $econEvaMethodsCriteria->addInCondition('t.id', $selectedEconEvaMethods); $econEvaMethodsCriteria->with = 'econMethodGroup'; $econEvaMethods = ModelToArray::convertModelToArray(EconomicMethods::model()->findAll($econEvaMethodsCriteria)); } if (isset($rsEvaHeader['evaAttributes'])) { $selectedEvaAttributes = json_decode($rsEvaHeader['evaAttributes'], true); $evaAttributesCriteria = new CDbCriteria(); $evaAttributesCriteria->addInCondition('attributeId', $selectedEvaAttributes); $evaAttributesCriteria->with = 'attributeTypes'; $evaAttributes = ModelToArray::convertModelToArray(EvaAttributes::model()->findAll($evaAttributesCriteria)); } $this->docName = 'evaSummary'; if (isset($_POST['pageId'])) { SystemController::savePage('evaSummary'); } $page = SystemController::getPageContent($this->docName); //print_r(json_encode($evaAttributes)); die; $this->render('evaSummary', ['evaDetails' => $evaDetails, 'evaAssMethods' => $evaAssMethods, 'econEvaMethods' => $econEvaMethods, 'evaAttributes' => $evaAttributes, 'page' => $page]); }
/** * actionSelectAttribute * @param $id mixed * @access public * @return array */ public static function actionSelectAttribute($id = null) { Yii::log("actionSelectAttribute called", "trace", self::LOG_CAT); //$model = new NewDesign; $attributesArray = array(); $dataArray = array(); $attributeData = EvaAttributes::model()->findAll(); // create array options for attribute dropdown foreach ($attributeData as $data) { $dataArray['attributeList'][$data->attributeId] = $data->name; $attributesArray[$data->attributeId] = $data->name; } if (isset($attributesArray[$id])) { Yii::app()->session->add('performanceAttribute', array('id' => $id, 'name' => $attributesArray[$id])); Yii::app()->user->setFlash('success', "Attribute successfully selected"); Yii::app()->request->redirect(Yii::app()->request->getUrlReferrer()); } return $attributesArray; }
$rsQuestionGrp = EvaQuestionGroups::model()->find(['select' => 'questions']); $questionsArray = array_keys((array) json_decode($rsQuestionGrp->questions)); $groups = array_combine($questionsArray, range(1, count($questionsArray))); $groups[6] = 'Risk based'; //Group 6 ?> <?php echo CHtml::activeDropDownList($model, "[{$index}]evaQuestionGroup", $groups, ['empty' => 'Select one']); ?> <?php echo CHtml::error($model, "[{$index}]evaQuestionGroup"); ?> </td> <td> <?php $attributes = CHtml::listData(EvaAttributes::model()->findAll(), 'attributeId', 'name'); ?> <?php echo CHtml::activeDropDownList($model, "[{$index}]attributeId", $attributes, ['empty' => 'Select one']); ?> <?php echo CHtml::error($model, "[{$index}]attributeId"); ?> </td> <td> <?php echo CHtml::activeDropDownList($model, "[{$index}]relevance", ['Do not include', 'Low', 'Medium', 'High'], ['empty' => 'Select one']); ?> <?php echo CHtml::error($model, "[{$index}]relevance"); ?>
/** * @return array */ public static function getEvaAttributes() { return CHtml::listData(EvaAttributes::model()->findAll(['select' => 'attributeId, name']), 'attributeId', 'name'); }