Exemplo n.º 1
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Sample('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Echantillon'])) {
         $model->attributes = $_GET['Echantillon'];
     }
     $this->render('admin', array('model' => $model));
 }
Exemplo n.º 2
0
 /**
  * affichage du module de gestion des echantillons de la biobanque
  */
 public function actionEchManage()
 {
     if (Yii::app()->user->isAdmin()) {
         $id = $_SESSION['biobank_id'];
     } else {
         $id = Yii::app()->user->biobank_id;
     }
     $model = $this->loadModel($id);
     $model = new Sample('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
     }
     $this->render('echManage', array('model' => $model, 'biobank_id' => $id));
 }
Exemplo n.º 3
0
 /**
  * affichage de la page de recherche des echantillons
  */
 public function actionSearch()
 {
     $model = new Sample('search');
     $model->unsetAttributes();
     $biobankId = null;
     if (isset($_GET['id']) && isset($_GET['layout']) && $_GET['layout'] == 'vitrine_layout') {
         $biobankId = $_GET['id'];
     }
     $model->biobank_id = $biobankId;
     $user = CommonTools::getConnectedUser();
     if (isset($_GET['Preferences'])) {
         $user->preferences->attributes = $_GET['Preferences'];
         $user->disableBehavior('LoggableBehavior');
         if ($user->validate(array('preferences'))) {
             $user->save(false);
         } else {
             var_dump($user->preferences->errors);
         }
     }
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
         //Used to search terms in model->biobank->collection_id and model->biobank->collection_name
         $arrayOfBiobanks = array();
         if (!empty($_GET['collection_id'])) {
             $criteria = new EMongoCriteria();
             $listWords = explode(",", $_GET['collection_id']);
             $regexId = "";
             foreach ($listWords as $word) {
                 $regexId .= "{$word}|";
             }
             $regexId = substr($regexId, 0, -1);
             $criteria->addCond('collection_id', '==', new MongoRegex("/({$regexId})/i"));
             $criteria->select(array('_id'));
             $biobanks = Biobank::model()->findAll($criteria);
             foreach ($biobanks as $biobank) {
                 $arrayOfBiobanks[(string) $biobank->_id] = (string) $biobank->_id;
             }
         }
         if (!empty($_GET['collection_name'])) {
             $criteria = new EMongoCriteria();
             $listWords = explode(",", $_GET['collection_name']);
             $regexId = "";
             foreach ($listWords as $word) {
                 $regexId .= "{$word}|";
             }
             $regexId = substr($regexId, 0, -1);
             $criteria->addCond('collection_name', '==', new MongoRegex("/({$regexId})/i"));
             $criteria->select(array('_id'));
             $biobanks = Biobank::model()->findAll($criteria);
             foreach ($biobanks as $biobank) {
                 $arrayOfBiobanks[$biobank->_id] = (string) $biobank->_id;
             }
         }
         if (!empty($arrayOfBiobanks)) {
             //     $model->arrayOfBiobanks;
             $model->setArrayOfBiobanks(array_values($arrayOfBiobanks));
         }
         $content = '';
         foreach ($_GET['Sample'] as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $vkey => $vval) {
                     $content = $content . (string) $vkey . '=' . str_replace(';', ',', (string) $vval) . ';';
                 }
             } else {
                 if ($value != null && !empty($value) && (string) $value != '0') {
                     $content = $content . (string) $key . '=' . str_replace(';', ',', (string) $value) . ';';
                 }
             }
         }
         if (Yii::app()->session['SampleForm'] != $_GET['Sample']) {
             $_GET['Echantillon_page'] = null;
             $this->logAdvancedSearch($content);
         }
         Yii::app()->session['SampleForm'] = $_GET['Sample'];
     }
     //form de la recherche intelligente
     $smartForm = new SampleSmartForm();
     if (isset($_POST['SampleSmartForm'])) {
         $model->unsetAttributes();
         $smartForm->attributes = $_POST['SampleSmartForm'];
         if (Yii::app()->session['keywords'] != $smartForm->keywords) {
             $_GET['Echantillon_page'] = null;
             $this->logSmartSearch($smartForm->keywords);
         }
         Yii::app()->session['keywords'] = $smartForm->keywords;
         $model = SmartResearcherTool::search($smartForm->keywords, $biobankId);
     }
     $this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
 }
Exemplo n.º 4
0
 public function actionSearchSample()
 {
     $id = CommonTools::getBiobankInfo();
     if (Yii::app()->user->isGuest) {
         $this->redirect(array('login', 'id' => $id));
     }
     $model = new Sample('search');
     $model->unsetAttributes();
     $model->biobank_id = $id;
     $prefs = Preferences::model()->findByAttributes(array('id_user' => Yii::app()->user->id));
     if ($prefs == null) {
         $prefs = new Preferences();
         $prefs->id_user = Yii::app()->user->id;
         $prefs->save();
     }
     if (isset($_GET['Preferences'])) {
         $prefs->attributes = $_GET['Preferences'];
         $prefs->save();
     }
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
         $content = '';
         foreach ($_GET['Sample'] as $key => $value) {
             if ($value != null && !empty($value) && (string) $value != '0') {
                 $content = $content . (string) $key . '=' . str_replace(';', ',', (string) $value) . ';';
             }
         }
         if (Yii::app()->session['SampleForm'] != $_GET['Sample']) {
             $_GET['Echantillon_page'] = null;
         }
         Yii::app()->session['SampleForm'] = $_GET['Sample'];
     }
     //form de la recherche intelligente
     $smartForm = new SampleSmartForm();
     if (isset($_POST['SampleSmartForm'])) {
         $model->unsetAttributes();
         $model->biobank_id = $id;
         $smartForm->attributes = $_POST['SampleSmartForm'];
         if (Yii::app()->session['keywords'] != $smartForm->keywords) {
             $_GET['Echantillon_page'] = null;
         }
         Yii::app()->session['keywords'] = $smartForm->keywords;
         $model = SmartResearcherTool::search($smartForm->keywords, $id);
     }
     $this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
 }
Exemplo n.º 5
0
 /**
  * Export des echantillons issus de la recherche en xls
  */
 public function actionExportXls()
 {
     $model = new Sample('search');
     $model->unsetAttributes();
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
     }
     // reprend les critères de la dernière recherche
     $dataprovider = new EMongoDocumentDataProvider('Sample', array('criteria' => $_SESSION['criteria'], 'pagination' => array('pageSize' => CommonTools::XLS_EXPORT_NB)));
     // supprime la pagination pour exporter l'ensemble des echantillons
     //	$echantillons = $dataprovider->data;
     $data = array(1 => array_keys($model->attributeExportedLabels()));
     setlocale(LC_ALL, 'fr_FR.UTF-8');
     $nb = 0;
     foreach ($dataprovider->data as $ech) {
         $line = array();
         foreach (array_keys($model->attributeExportedLabels()) as $attribute) {
             if ($attribute != 'notes') {
                 if ($ech->{$attribute} != null && !empty($ech->{$attribute})) {
                     $line[] = trim(iconv('UTF-8', 'ASCII//TRANSLIT', $ech->{$attribute}));
                     // solution la moins pire qui ne fait pas bugge les accents mais les convertit en caractere generique
                 } else {
                     $line[] = "-";
                 }
             } else {
                 foreach ($ech->{$attribute} as $noteValue) {
                     $line[] = trim(iconv('UTF-8', 'ASCII//TRANSLIT', $noteValue->key . ' : ' . $noteValue->value));
                 }
             }
         }
         $data[] = $line;
     }
     Yii::import('application.extensions.phpexcel.JPhpExcel');
     $xls = new JPhpExcel('UTF-8', true, 'Sample list');
     $xls->addArray($data);
     $xls->generateXML('sample list');
 }