public function actionAdmin()
 {
     $model = new Droits('search');
     $model->unsetAttributes();
     if (isset($_GET['Droits'])) {
         $model->setAttributes($_GET['Droits']);
     }
     $criteria = new EMongoCriteria();
     $criteriaClinique = new EMongoCriteria($criteria);
     $criteriaClinique->type = "clinique";
     $criteriaClinique->profil('!=', "administrateur");
     $dataProviderClinique = new EMongoDocumentDataProvider('Droits');
     $dataProviderClinique->setCriteria($criteriaClinique);
     $criteriaNeuropath = new EMongoCriteria($criteria);
     $criteriaNeuropath->type = "neuropathologique";
     $criteriaNeuropath->profil('!=', "administrateur");
     $dataProviderNeuropath = new EMongoDocumentDataProvider('Droits');
     $dataProviderNeuropath->setCriteria($criteriaNeuropath);
     $criteriaGene = new EMongoCriteria($criteria);
     $criteriaGene->type = "genetique";
     $criteriaGene->profil('!=', "administrateur");
     $dataProviderGene = new EMongoDocumentDataProvider('Droits');
     $dataProviderGene->setCriteria($criteriaGene);
     $this->render('admin', array('model' => $model, 'dataProviderClinique' => $dataProviderClinique, 'dataProviderNeuropath' => $dataProviderNeuropath, 'dataProviderGene' => $dataProviderGene));
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     /*$model = new AdminEventModel('search');
     		$model->unsetAttributes();
     
     		if(isset($_GET['AdminEventModel'])) {
                 $model->setAttributes($_GET['AdminEventModel']);
             }*/
     /*$this->render('admin', array(
     			'model'=>$model
     		));*/
     $model = new AdminEventModel('search');
     if (isset($_GET['AdminEventModel'])) {
         $model->setAttributes($_GET['AdminEventModel']);
     }
     $dataProvider = new EMongoDocumentDataProvider('AdminEventModel');
     $c = array();
     if (isset($_GET['AdminEventModel'])) {
         $name = $_GET['AdminEventModel']['name'];
         $description = $_GET['AdminEventModel']['description'];
         $status = $_GET['AdminEventModel']['status'];
         $reset = $_GET['AdminEventModel']['reset'];
         $group_id = $_GET['AdminEventModel']['group_id'];
         if ($status != '' && is_numeric($status)) {
             $c['conditions']['status'] = array('==' => (int) $status);
         }
         if (is_numeric($reset)) {
             $c['conditions']['reset'] = array('==' => (int) $reset);
         }
         if (!empty($group_id)) {
             $c['conditions']['group_id'] = array('==' => $group_id);
         }
         if (!empty($name)) {
             $c['conditions']['name'] = array('==' => new MongoRegex('/[' . $name . '].*/i'));
         }
         if (!empty($description)) {
             $c['conditions']['description'] = array('==' => new MongoRegex('/[' . $description . '].*/i'));
         }
     }
     $c['sort'] = array('_id' => EMongoCriteria::SORT_DESC);
     $dataProvider->setCriteria($c);
     $paging = new CPagination();
     $paging->pageSize = 20;
     $dataProvider->setPagination($paging);
     $this->render('admin', array('dataProvider' => $dataProvider, 'model' => $model));
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     //test
     /*$chk = UserEventModel::checkIsLogAfterTime('84942111185',778042,'5551b17f0379950c0900002b');
       var_dump($chk);
       exit;*/
     $model = new AdminUserEventModel('search');
     if (isset($_GET['AdminUserEventModel'])) {
         $model->setAttributes($_GET['AdminUserEventModel']);
     }
     $dataProvider = new EMongoDocumentDataProvider('AdminUserEventModel');
     $c = array();
     if (isset($_GET['AdminUserEventModel'])) {
         //$model->setAttributes($_GET['AdminUserEventModel']);
         $method = $_GET['AdminUserEventModel']['method'];
         $user_id = $_GET['AdminUserEventModel']['user_id'];
         $user_phone = $_GET['AdminUserEventModel']['user_phone'];
         $user_phone = Formatter::formatPhone($user_phone);
         $event_id = $_GET['AdminUserEventModel']['event_id'];
         $point = $_GET['AdminUserEventModel']['point'];
         if ($method != '') {
             $c['conditions']['method'] = array('==' => $method);
         }
         if (!empty($user_id)) {
             $c['conditions']['user_id'] = array('==' => (int) $user_id);
         }
         if (!empty($user_phone)) {
             $c['conditions']['user_phone'] = array('==' => $user_phone);
         }
         if (!empty($event_id)) {
             $c['conditions']['event_id'] = array('==' => $event_id);
         }
         if (!empty($point)) {
             $c['conditions']['point'] = array('==' => (int) $point);
         }
     }
     $c['sort'] = array('_id' => EMongoCriteria::SORT_DESC);
     $dataProvider->setCriteria($c);
     $paging = new CPagination();
     $paging->pageSize = 30;
     $dataProvider->setPagination($paging);
     $this->render('admin', array('dataProvider' => $dataProvider, 'model' => $model));
 }
 public function actionAffichepatient()
 {
     $model = new PatientForm();
     $patient = (object) null;
     if (isset($_SESSION['datapatient'])) {
         $patient = $_SESSION['datapatient'];
         $model->copyPatient($patient);
     }
     if (isset($_POST['PatientForm'])) {
         $actionForm = $_POST['PatientForm']['action'];
         $model = new PatientForm();
         $model->attributes = $_POST['PatientForm'];
         if ($_POST['PatientForm']['prenom'] == "" || $_POST['PatientForm']['nom_naissance'] == "" || $_POST['PatientForm']['date_naissance'] == "") {
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'missingFields'));
             $this->redirect(array('site/patient'));
         }
         if ($model->dateFormat($model->date_naissance) == false) {
             Yii::app()->user->setFlash('error', Yii::t('common', 'unvalidDate'));
             $this->redirect(array('site/patient'));
         }
         $patient->id = null;
         $patient->source = null;
         //à identifier en fonction de l'app
         $patient->sourceId = null;
         $patient->birthName = $model->nom_naissance;
         if ($model->nom != "") {
             $patient->useName = $model->nom;
         } else {
             $patient->useName = null;
         }
         $patient->firstName = $model->prenom;
         $patient->birthDate = $model->date_naissance;
         if ($model->sexe != "") {
             $patient->sex = $model->sexe;
         } else {
             $patient->sex = null;
         }
         if ($actionForm == 'create') {
             $patient->source = $model->source == "1" ? "1" : "2";
             $patientest = CommonTools::wsGetPatient($patient);
             if ($patientest == 'NoPatient') {
                 $patient = CommonTools::wsAddPatient($patient);
             } else {
                 $patient = $patientTest;
             }
         } else {
             $patient = CommonTools::wsGetPatient($patient);
         }
     }
     switch ($patient) {
         case "NoPatient":
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'noPatient'));
             Yii::app()->user->setState('patientModel', $model);
             $model->scenario = 'create';
             $this->render('patient_bis', array('model' => $model, 'actionForm' => 'create'));
             exit;
             break;
         case "PatientNotSaved":
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'patientNotSaved'));
             Yii::app()->user->setState('patientModel', $model);
             $model->scenario = 'create';
             $this->render('patient_bis', array('model' => $model, 'actionForm' => 'create'));
             exit;
             break;
         case "ManyPatient":
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'manyPatient'));
             Yii::app()->user->setState('patientModel', $model);
             $this->render('patient_bis', array('model' => $model, 'actionForm' => 'search'));
             exit;
             break;
         default:
     }
     if ($model->validate() && isset($patient->id)) {
         $model->id = $patient->id;
         $criteria = new EMongoCriteria();
         $criteria->id_patient = (string) $model->id;
         $criteriaCliniques = new EMongoCriteria($criteria);
         if (Yii::app()->user->getState('activeProfil') == "clinicien") {
             $criteriaCliniques->login = Yii::app()->user->id;
         }
         $criteriaCliniques->type = "clinique";
         $criteriaNeuropathologiques = new EMongoCriteria($criteria);
         $criteriaNeuropathologiques->type = "neuropathologique";
         $neuropath = Answer::model()->findAll($criteriaNeuropathologiques);
         $criteriaGenetiques = new EMongoCriteria($criteria);
         $criteriaGenetiques->type = "genetique";
         $genetique = Answer::model()->findAll($criteriaGenetiques);
         $dataProviderCliniques = new EMongoDocumentDataProvider('Answer');
         $dataProviderCliniques->setId('dpCli');
         $dataProviderNeuropathologiques = new EMongoDocumentDataProvider('Answer');
         $dataProviderCliniques->setId('dpNeuPa');
         $dataProviderGenetiques = new EMongoDocumentDataProvider('Answer');
         $dataProviderCliniques->setId('dpGen');
         $dataProviderCliniques->setCriteria($criteriaCliniques);
         $dataProviderNeuropathologiques->setCriteria($criteriaNeuropathologiques);
         $dataProviderGenetiques->setCriteria($criteriaGenetiques);
         $questionnaire = Questionnaire::model()->findAll();
         $_SESSION['datapatient'] = $patient;
         if (isset($_SESSION['datapatient'])) {
             $this->render('affichepatient', array('model' => $model, 'dataProviderCliniques' => $dataProviderCliniques, 'dataProviderNeuropathologiques' => $dataProviderNeuropathologiques, 'dataProviderGenetiques' => $dataProviderGenetiques, 'questionnaire' => $questionnaire, 'patient' => $patient, 'neuropath' => $neuropath, 'genetique' => $genetique));
         } elseif (isset($_POST['PatientForm'])) {
             $this->render('affichepatient', array('model' => $model, 'dataProviderCliniques' => $dataProviderCliniques, 'dataProviderNeuropathologiques' => $dataProviderNeuropathologiques, 'dataProviderGenetiques' => $dataProviderGenetiques, 'patient' => $patient));
         } else {
             $this->redirect(array('site/patient'));
         }
     } else {
         $this->redirect(array('site/patient'));
     }
 }