Пример #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
 /**
  * actionAddRelation
  * @access public
  * @return void
  */
 public function actionAddRelation()
 {
     Yii::log("actionaddRelation AttributeController called", "trace", self::LOG_CAT);
     $formRelationModel = new AttributeFormRelation();
     $attributeModel = new EvaAttributes();
     $surFormDetailsModel = new SurFormDetails();
     if (isset($_POST['AttributeFormRelation'])) {
         $formRelationModel->attributes = $_POST['AttributeFormRelation'];
         if ($formRelationModel->validate()) {
             $formRelationModel->save();
             Yii::app()->user->setFlash('success', "Relation successfully created.");
             $this->redirect(array('attribute/listRelations'));
         }
     }
     // QUERY FOR ALL ATTRIBUTES
     $queryAttributes = $attributeModel->findAll(array('select' => 'attributeId, name'));
     // QUERY FOR ALL SURFORM DETAILS
     $querySurformDetails = $surFormDetailsModel->findAll(array('select' => 'subFormId, inputName'));
     $attributesArray = array();
     $surformDetailsArray = array();
     // Pack data to send to view
     foreach ($queryAttributes as $key => $value) {
         $attributesArray[$value['attributeId']] = $value['name'];
     }
     foreach ($querySurformDetails as $key => $value) {
         $surformDetailsArray[$value['subFormId']] = $value['inputName'];
     }
     $this->render('addRelation', array('attributeModel' => $attributeModel, 'formRelationModel' => $formRelationModel, 'surFormDetailsModel' => $surFormDetailsModel, 'attributesArray' => $attributesArray, 'surformDetailsArray' => $surformDetailsArray));
 }
Пример #3
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;
 }