예제 #1
0
 /**
  * @internal param $frameworkId
  * @return string
  */
 public function actionGetSurveillanceSummary()
 {
     $surveillanceCriteria = new CDbCriteria();
     $surveillanceCriteria->condition = 'frameworkId=' . $this->frameworkId;
     $surveillanceRs = FrameworkFields::model()->with('data', 'options')->findAll($surveillanceCriteria);
     $surveillanceFields = ['hazardName' => 'Hazard Name', 'survObj' => 'Surveillance objective', 'geographicalArea' => 'Geographical area', 'stateOfDisease' => 'Hazard situation', 'legalReq' => 'Legal Requirements'];
     //		$evaDetails[] = ['Evaluation Name', $model['evaluationName']];
     //		print_r($surveillanceRs); die;
     //		var_dump(DForm::isJson('68')); die;
     $surveillanceSummary = [];
     $surveillanceSummary[] = ['Surveillance system name', Yii::app()->session['surDesign']['name']];
     foreach ($surveillanceRs as $surveillanceFieldKey => $surveillanceField) {
         if (isset($surveillanceFields[$surveillanceField->inputName])) {
             $surveillanceFieldKey++;
             $surveillanceKey = $surveillanceFields[$surveillanceField->inputName];
             $surveillanceSummary[$surveillanceFieldKey] = [$surveillanceKey, isset($surveillanceField->data[0]) ? $surveillanceField->data[0]['value'] : ''];
             //print_r($surveillanceField->data[0]);
             if (isset($surveillanceField->options[0]) && isset($surveillanceField->data[0])) {
                 //die('pop');
                 foreach ($surveillanceField->options as $option) {
                     $dataValue = $surveillanceField->data[0]['value'];
                     if (DForm::isJson($surveillanceField->data[0]['value'])) {
                         $dataValue = json_decode($surveillanceField->data[0]['value'])[0];
                     }
                     //echo $dataValue;
                     if ($dataValue == $option->optionId) {
                         $surveillanceSummary[$surveillanceFieldKey] = [$surveillanceKey, $option->label];
                         break;
                     }
                 }
             }
         }
     }
     //die;
     $surveillanceComponents = CHtml::link('add surveillance components', ['design/addMultipleComponents']);
     // Get surveillance components
     $rsComponents = ComponentHead::model()->findAll('frameworkId=:framework', [':framework' => $this->frameworkId]);
     if (isset($rsComponents[0])) {
         $surveillanceComponents = '';
         foreach ($rsComponents as $component) {
             $surveillanceComponents .= $component->componentName . ', ';
         }
         $surveillanceComponents = rtrim($surveillanceComponents, ', ');
     }
     $surveillanceSummary[] = ['Surveillance components', $surveillanceComponents];
     //print_r($surveillanceSummary); die;
     echo json_encode(["aaData" => array_values($surveillanceSummary)], JSON_UNESCAPED_SLASHES);
     return;
 }
예제 #2
0
 /**
  * actionDuplicateComponent
  * @access public
  * @return void
  */
 public function actionDuplicateComponent()
 {
     Yii::log("actionDuplicateComponent called", "trace", self::LOG_CAT);
     if (isset($_POST["oldComponentId"]) && $_POST['newComponentName']) {
         $component = new ComponentHead();
         $componentDetails = new ComponentDetails();
         $record = ComponentHead::model()->with("compDetails")->findByPk($_POST['oldComponentId']);
         $component->componentName = $_POST['newComponentName'];
         $component->frameworkId = isset($_POST['oldComponentId']) ? $_POST['oldComponentId'] : Yii::app()->session['surDesign']['id'];
         //save the componentHead values
         $component->save();
         $componentId = $component->componentId;
         // fetch the old component details data and save as new components
         foreach ($record->compDetails as $val) {
             $details = $val->attributes;
             $componentDetails->setIsNewRecord(true);
             $componentDetails->componentDetailId = null;
             $componentDetails->componentId = $componentId;
             $componentDetails->subFormId = $details['subFormId'];
             $componentDetails->value = $details['value'];
             $componentDetails->save();
             //echo $key . "=>" . $val ."<br>";
             //print_r($details['subFormId']);
         }
         echo Yii::t("translation", "Component successfully duplicated");
     } else {
         Yii::log("Error duplicating component id:" . $_POST['oldComponentId'], "warning", self::LOG_CAT);
         echo Yii::t("translation", "A problem occurred when duplicating the component ");
     }
     return;
 }