예제 #1
0
 public static function getComponentData($componentsOnly = false)
 {
     $componentListArray = [];
     $formDetailsArray = [];
     // get list of surveillance designs
     $componentList = ComponentHead::model()->with("compDetails")->findAll(['condition' => 'frameworkId=:frameworkId', 'params' => [':frameworkId' => Yii::app()->session['surDesign']['id']]]);
     $formDetails = SurFormDetails::model()->findAll(['condition' => 'showOnComponentList=:showOnList', 'params' => [':showOnList' => true]]);
     $selectOptions = CHtml::listData(Options::model()->findAll(['condition' => 'componentId IS NOT NULL']), 'optionId', 'label');
     //print_r($selectOptions); die;
     // format dataTable data
     $count = 0;
     foreach ($componentList as $com) {
         $componentListArray[$count] = ['componentId' => $com->componentId, 'frameworkId' => $com->frameworkId, 'name' => $com->componentName, 'targetSpecies' => '', 'targetSector' => '', 'dataColPoint' => '', 'diseaseType' => '', 'sampleType' => '', 'studyType' => ''];
         foreach ($formDetails as $formInput) {
             $formDetailsArray[$formInput->inputName] = $formInput->label;
             foreach ($com->compDetails as $data) {
                 //$subDetails[$data->inputName] = $data->value;
                 if ($formInput->subFormId == $data->subFormId) {
                     $componentListArray[$count][$formInput->inputName] = $data->value;
                     if ($formInput->inputType == "dropdownlist" && isset($selectOptions[$data->value])) {
                         $componentListArray[$count][$formInput->inputName] = $selectOptions[$data->value];
                     }
                 }
             }
         }
         $count++;
     }
     return $componentsOnly ? $componentListArray : ['componentListArray' => $componentListArray, 'formDetailsArray' => $formDetailsArray];
 }
예제 #2
0
 /**
  * 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 SurFormDetails the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SurFormDetails::model()->findByPk($id);
     if ($model === null) {
         Yii::app()->user->setFlash('error', Yii::t("translation", "The form element does not exist"));
         $this->redirect(array('surformdetails/index'));
     }
     return $model;
 }