コード例 #1
0
 public function createFicheNeuropath()
 {
     $index = 0;
     $criteria = new EMongoCriteria();
     $criteria->login = "******";
     $user = User::model()->find($criteria);
     $neuropath = Neuropath::model()->findAll();
     if ($neuropath != null) {
         foreach ($neuropath as $neuro) {
             $answer = new Answer();
             $answer->creator = "Bernard TE";
             $answer->id = "neuropath_filemaker_form";
             $answer->type = "neuropathologique";
             $answer->login = new MongoId($user->_id);
             $answer->questionnaireMongoId = new MongoId();
             $answer->name = "Import Neuropath";
             $answer->last_modified = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
             $answer->description = "Données neuropathologiques de la base FileMaker";
             $answer->last_updated = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
             $answerGroup = new AnswerGroup();
             $answerGroup->id = "onglet";
             $answerGroup->title = "Données neuropathologiques FileMaker";
             $answerGroup->title_fr = $answerGroup->title;
             foreach ($neuro as $k => $v) {
                 if ($k != "_id") {
                     if ($k == "id_cbsd") {
                         $answer->id_patient = (string) $v;
                     } else {
                         $answerQuestion = new AnswerQuestion();
                         $answerQuestion->id = $k;
                         $answerQuestion->label = $k;
                         $answerQuestion->label_fr = $k;
                         if (is_numeric($v)) {
                             $answerQuestion->type = "number";
                         } elseif (CommonTools::isDate($v)) {
                             $answerQuestion->type = "date";
                         } else {
                             $answerQuestion->type = "input";
                         }
                         $answerQuestion->style = "";
                         if ($answerQuestion->type == "date") {
                             $answerQuestion->answer = DateTime::createFromFormat('d/m/Y', date('d/m/Y', strtotime($v)));
                         } else {
                             $answerQuestion->answer = $v;
                         }
                         $answerGroup->answers[] = $answerQuestion;
                     }
                 }
             }
             $answer->answers_group[] = $answerGroup;
             $answer->save();
         }
     }
 }
コード例 #2
0
 /**
  * Write queries (search filter)
  */
 public function actionWriteQueries()
 {
     $operators = array("equals" => "=", "noteq" => "<>", "less" => "<", "greater" => ">", "lesseq" => "<=", "greatereq" => ">=", "between" => "comprise entre", '$and' => Yii::t('common', 'and'), '$or' => Yii::t('common', 'or'));
     $mainQuestions = array();
     $questions = array();
     $condition = array();
     $compare = array();
     $dynamics = array();
     $html = "";
     $htmlQueries = "";
     if (isset($_POST['Answer']) && !empty($_POST['Answer'])) {
         echo count($_POST['Answer']) == 1 && $_POST['Answer']['last_updated'] == "" ? "<h4 align=\"center\">" . Yii::t('common', 'noFilterSelected') . "</h4>" : "<h4 align=\"center\">" . Yii::t('common', 'query') . "</h4>";
         foreach ($_POST['Answer'] as $label => $answer) {
             if ($label == "last_updated" && $answer == "") {
             } elseif ($label != "condition" && $label != "compare" && $label != "dynamics") {
                 if (!is_array($answer)) {
                     $mainQuestions[$label] = $answer;
                 } else {
                     $mainQuestions[$label] = implode(', ', $answer);
                 }
             } else {
                 foreach ($answer as $key => $value) {
                     if ($label == "condition") {
                         $condition[$key] = $value;
                     }
                     if ($label == "compare") {
                         $compare[$key] = $value;
                     }
                     if ($label == "dynamics") {
                         $dynamics[$key] = $value;
                     }
                     if (!isset($compare[$key])) {
                         $compare[$key] = "";
                     }
                 }
                 foreach ($dynamics as $k => $v) {
                     if (gettype($v) == "array") {
                         $dynamics[$k] = implode(', ', $v);
                     } elseif (CommonTools::isDate($v)) {
                         $dynamics[$k] = str_replace('-', strtolower(Yii::t('common', 'and')), $dynamics[$k]);
                     }
                 }
             }
         }
         $questions = array_merge_recursive($condition, $compare, $dynamics);
         $html .= "<ul>";
         foreach ($mainQuestions as $label => $answer) {
             $html .= "<li>" . Answer::model()->attributeLabels()[$label] . " = " . $answer . "</li>";
         }
         foreach ($questions as $key => $value) {
             $html .= $operators[$questions[$key][0]];
             $html .= "<li>" . Answer::model()->getLabelQuestionById($key);
             foreach ($value as $label => $answer) {
                 if ($label != 0) {
                     if ($label == 1) {
                         $html .= $answer != "" ? " " . $operators[$answer] : " = ";
                     }
                     if ($label == 2) {
                         $html .= " " . $answer . "</li>";
                     }
                 }
             }
         }
         $html .= "</ul>";
         $htmlQueries .= $html;
         $htmlQueries .= CHtml::form(Yii::app()->createUrl("answer/exportQueries"), "POST");
         $htmlQueries .= CHtml::hiddenField('exportQueries', $html);
         $htmlQueries .= CHtml::submitButton(Yii::t('common', 'exportQuery'), array('class' => 'btn btn-default', 'style' => 'margin:auto;display:block;'));
         $htmlQueries .= CHtml::endForm();
         echo $htmlQueries;
     }
 }