/**
  * export csv liste des fiches disponibles
  */
 public function actionExportCsv()
 {
     if (isset($_POST['exporter'])) {
         $filter = array();
         if (isset($_POST['filter'])) {
             $filter = $_POST['filter'];
         }
         $filename = date('Ymd_H') . 'h' . date('i') . '_liste_fiches_CBSD_Platform.csv';
         $arAnswers = Answer::model()->resultToArray($_SESSION['models'], $filter);
         $csv = new ECSVExport($arAnswers, true, false, null, null);
         Yii::app()->getRequest()->sendFile($filename, "" . $csv->toCSV(), "text/csv; charset=UTF-8", false);
     }
     $model = new Answer('search');
     $model->unsetAttributes();
     if (isset($_GET['Answer'])) {
         $model->attributes = $_GET['Answer'];
     }
     if (isset($_SESSION['criteria']) && $_SESSION['criteria'] != null && $_SESSION['criteria'] instanceof EMongoCriteria) {
         $criteria = $_SESSION['criteria'];
     } else {
         $criteria = new EMongoCriteria();
     }
     // trier par id_patient et type de fiche dans l'ordre croissant
     $criteria->sort('id_patient', EMongoCriteria::SORT_ASC);
     $criteria->sort('type', EMongoCriteria::SORT_ASC);
     $models = Answer::model()->findAll($criteria);
     $_SESSION['models'] = $models;
     if (count($models) < 1) {
         Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'emptyPatientFormExport'));
         $this->redirect(array("rechercheFiche/admin"));
     }
     $this->render('exportFilter', array('models' => $models));
 }
Example #2
0
 public function search($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     //$criteria->conditions['id'] = $this->id;
     $criteria->sort('id', EMongoCriteria::SORT_DESC);
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
 /**
  * export pdf avec mpdf et liste  d'index : Technique HTML to PDF
  */
 public function actionExportPdf()
 {
     $criteria = new EMongoCriteria();
     $criteria->sort('name', EMongoCriteria::SORT_ASC);
     $models = Biobank::model()->findAll($criteria);
     BiobanksPDFExporter::exporter($models);
 }
Example #4
0
 public static function getByBiobank($biobankId, $limit)
 {
     $criteria = new EMongoCriteria();
     $criteria->addCond('biobank_id', '==', $biobankId);
     $criteria->sort('date', EMongoCriteria::SORT_DESC);
     $criteria->limit($limit);
     return BiobankStats::model()->findAll($criteria);
 }
Example #5
0
 public function getDateLastImportByBiobank($biobank_id)
 {
     $criteria = new EMongoCriteria();
     $criteria->biobank_id = $biobank_id;
     $criteria->limit(1);
     $criteria->sort('date_import', EMongoCriteria::SORT_DESC);
     $criteria->select(array('date_import'));
     $result = $this->find($criteria);
     if ($result != null) {
         return $result->date_import;
     }
 }
Example #6
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($caseSensitive = false)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new EMongoCriteria();
     if ($this->nom != null) {
         $criteria->addCond('nom', '==', new MongoRegex('/' . $this->nom . '*/i'));
     }
     if ($this->prenom != null) {
         $criteria->addCond('prenom', '==', new MongoRegex('/' . $this->name . '*/i'));
     }
     //always sort with alphabetical order
     $criteria->sort('nom', EMongoCriteria::SORT_ASC);
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
 public function run($args)
 {
     //upper case for each last name of contact
     $criteria = new EMongoCriteria();
     $criteria->sort('nom', EMongoCriteria::SORT_ASC);
     $users = User::model()->findAll($criteria);
     foreach ($users as $model) {
         $model->cleanAttributesFormat();
         //catch exception on update if problem ( utf8 encoding  for example?)
         try {
             $model->update();
         } catch (Exception $e) {
             echo 'Exception reçue pour le model: ' . $model->_id . " " . $model->nom . " " . $model->prenom, $e->getMessage(), "\n";
         }
     }
 }
Example #8
0
 public function run($args)
 {
     //uppar case for each last name of contact
     $criteria = new EMongoCriteria();
     $criteria->sort('last_name', EMongoCriteria::SORT_ASC);
     $contacts = Contact::model()->findAll($criteria);
     foreach ($contacts as $model) {
         $town = $model->ville;
         $postalCode = $this->getPostalCode($town);
         if ($postalCode != null) {
             try {
                 $model->code_postal = $postalCode;
                 $model->update();
             } catch (Exception $e) {
                 echo 'Exception reçue pour le model: ' . $model->ville, $e->getMessage(), "\n";
             }
         }
     }
 }
 public function run($args)
 {
     //uppar case for each last name of contact
     $criteria = new EMongoCriteria();
     $criteria->sort('last_name', EMongoCriteria::SORT_ASC);
     $contacts = Contact::model()->findAll($criteria);
     foreach ($contacts as $model) {
         //last name to upper case automatically /prevent pb to sort and display
         // echo $model->_id."\n";
         $model->last_name = mb_strtoupper($model->last_name, "UTF-8");
         //convertie first name en lower case et mettant les caracteres en utf-8 ( cas possible de bug sur chaines mixtes)
         $model->first_name = mb_strtolower($model->first_name, "UTF-8");
         //phone without withespace, point a 0> +33
         $model->phone = mb_ereg_replace('/\\s+/', '', $model->phone);
         $model->phone = mb_ereg_replace('/\\./', '', $model->phone);
         //replace first zero and add +33
         $model->phone = mb_ereg_replace('/^0/', '+33', $model->phone);
         //pays = FR
         $model->pays = "FR";
         $model->inactive = 0;
         //catch exception on update if problem ( utf8 encoding  for example?)
         try {
             $model->update();
         } catch (Exception $e) {
             echo 'Exception reçue pour le model: ' . $model->_id . " " . $model->last_name . " " . $model->first_name, $e->getMessage(), "\n";
             //detection de le ncodage si pb d estring
             echo "first name encoding :" . mb_detect_encoding($model->first_name) . "\n";
         }
     }
     //update relation biobank->contact_id if old id contact, si ancien attribut id utilisé alors on mets le nouvel attribut _id
     $criteriaB = new EMongoCriteria();
     $criteriaB->sort('name', EMongoCriteria::SORT_ASC);
     $biobanks = Biobank::model()->findAll($criteriaB);
     foreach ($biobanks as $biobank) {
         $contact = Contact::model()->findByAttributes(array('id' => $biobank->contact_id));
         if ($contact != null) {
             // echo "current value from migration:" . $contact->last_name . " " . $contact->first_name."\n";
             $biobank->contact_id = $contact->_id;
             $biobank->update();
         }
     }
 }
Example #10
0
 public function search($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     if (!empty($this->id)) {
         $criteria->id = $this->id;
     }
     if (!empty($this->name)) {
         $criteria->name = $this->name;
     }
     if (!empty($this->en_name)) {
         $criteria->en_name = $this->en_name;
     }
     if (!empty($this->request_times)) {
         $criteria->request_times = $this->request_times;
     }
     $criteria->sort('id', EMongoCriteria::SORT_DESC);
     //$criteria->last_uid = $this->last_uid;
     //$criteria->update_time = $this->update_time;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #11
0
 public function searchFilter($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     if (isset($_SESSION['id_patient'])) {
         $criteria->id_patient = new MongoRegex($_SESSION['id_patient']);
     }
     if (isset($this->dynamics) && !empty($this->dynamics)) {
         $index = 0;
         $nbCriteria = array();
         foreach ($this->dynamics as $questionId => $answerValue) {
             if ($answerValue != null && !empty($answerValue)) {
                 if ($index != 0) {
                     $nbCriteria = '$criteria' . $index;
                     $nbCriteria = new EMongoCriteria();
                 }
                 if (isset($this->compare[$questionId])) {
                     if ($index == 0) {
                         if ($this->compare[$questionId] == "between") {
                             $answerDate = $this->formatDatePicker($answerValue);
                             $criteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer.date' => array('$gte' => $answerDate['date_from'] . " 00:00:00.000000", '$lte' => $answerDate['date_to'] . " 23:59:59.000000")));
                         } else {
                             $criteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => array(EMongoCriteria::$operators[$this->compare[$questionId]] => (int) $answerValue)));
                         }
                     } else {
                         if ($this->compare[$questionId] == "between") {
                             $answerDate = $this->formatDatePicker($answerValue);
                             $nbCriteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer.date' => array('$gte' => $answerDate['date_from'] . " 00:00:00.000000", '$lte' => $answerDate['date_to'] . " 23:59:59.000000")));
                         } else {
                             $nbCriteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => array(EMongoCriteria::$operators[$this->compare[$questionId]] => (int) $answerValue)));
                         }
                     }
                 } else {
                     $values = !is_array($answerValue) ? split(',', $answerValue) : $answerValue;
                     if ($index == 0) {
                         $criteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => new MongoRegex($this->regexString($values))));
                     } else {
                         $nbCriteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => new MongoRegex($this->regexString($values))));
                     }
                 }
             }
             if ($index != 0) {
                 $criteria->mergeWith($nbCriteria, $this->condition[$questionId]);
             }
             $index++;
         }
     }
     $criteria->sort('id_patient', EMongoCriteria::SORT_ASC);
     $criteria->sort('type', EMongoCriteria::SORT_ASC);
     $criteria->sort('last_updated', EMongoCriteria::SORT_DESC);
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #12
0
<div class="form">
    <?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'biobank_manUploaded-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'text/html', 'accept-charset' => "UTF-8")));
?>

    <?php 
echo $form->errorSummary($biobankIdentifier);
?>
    <div class="row" >



        <?php 
$criteria = new EMongoCriteria();
$criteria->sort('identifier', EMongoCriteria::SORT_ASC);
echo $form->DropDownList($biobankIdentifier, 'identifier', CHtml::listData(Biobank::model()->findAll($criteria), 'identifier', 'identifierAndName'), array('empty' => 'select brif code'));
?>
        <?php 
echo $form->error($biobankIdentifier, 'identifier');
?>
    </div>



    <?php 
$this->endWidget();
?>

</div>
<!-- form -->
Example #13
0
 /**
  * 获取内容列表
  * http://db.admin.mofang.com/api/card/getitems?setid=1&select=name
  */
 public function actionGetItems()
 {
     $return = array('code' => 0, 'data' => array(), 'pages' => array(), 'show_type' => 1);
     //参数接收
     //http://db.dev.mofang.com/api/card/getitems/setid/4/filter/djfl|珍品::/regex/djname|水/order/xyd|1/page/-2/size/20
     $datasetId = isset($_GET['setid']) ? intval($_GET['setid']) : 0;
     //表id			setid = 4
     $select = isset($_GET['select']) ? $_GET['select'] : '';
     //返回字段		select = data.name
     $filter = isset($_GET['filter']) ? $this->paramStr2Arr($_GET['filter']) : '';
     //过滤条件		filter = djfl|珍品::	m_power|[20,1000](多个且关系)[m_power]魔力在20-1000范围内
     $regex = isset($_GET['regex']) ? $this->paramStr2Arr($_GET['regex']) : '';
     //正则匹配		regex = djname|碎片(目前是不限定头尾匹配,后面需要优化)
     $order = isset($_GET['order']) ? $this->paramStr2Arr($_GET['order']) : '';
     //排序			order = xyd|1
     $currPage = isset($_GET['page']) && $_GET['page'] >= 1 ? intval($_GET['page']) : 1;
     //当前页码		page = 1
     $pageSize = isset($_GET['size']) ? intval($_GET['size']) : 0;
     //每页数量		size = 20
     //参数验证
     if (empty($datasetId)) {
         $return['code'] = -9101;
         //接口参数不足
     }
     $cache_data = null;
     $this->checkCache($cache_data);
     //检查缓存
     if (!empty($cache_data)) {
         echo $cache_data;
         return;
     }
     //开始查询
     if (empty($return['code'])) {
         $dsModel = $this->loadModel($datasetId, 'ds');
         $fields = array_keys($dsModel->fields);
         //查询器
         $criteria = new EMongoCriteria();
         $criteria->addCond('dataset_id', '==', $datasetId);
         //指明对象
         if ($select) {
             $select = explode(',', $select);
             foreach ($select as $skey => $sfield) {
                 $select[$skey] = 'data.' . $sfield;
             }
             array_unshift($select, 'id');
             //压入默认字段
             $criteria->select($select);
         }
         //加入过滤条件
         if ($filter) {
             foreach ($filter as $fkey => $fval) {
                 //特殊处理20:1000 数据
                 if (preg_match("/\\d+:\\d+/", $fval)) {
                     $_numberfield = explode(':', $fval);
                     $_minval = intval($_numberfield[0]);
                     $_maxval = intval($_numberfield[1]);
                     // ==
                     if ($_minval == $_maxval) {
                         $criteria->addCond('data.' . $fkey, '==', $_minval);
                         continue;
                     }
                     !empty($_minval) && $criteria->addCond('data.' . $fkey, '>=', $_minval);
                     if ($_minval <= $_maxval) {
                         !empty($_maxval) && $criteria->addCond('data.' . $fkey, '<=', $_maxval);
                     }
                     continue;
                 }
                 if (in_array($fkey, $fields)) {
                     //只查询定义的字段
                     $criteria->addCond('data.' . $fkey, '==', $fval);
                 } else {
                     if (in_array($fkey, array('id'))) {
                         $criteria->addCond($fkey, '==', intval($fval));
                     }
                 }
             }
         }
         //加入正则
         if ($regex) {
             foreach ($regex as $rkey => $rval) {
                 if (in_array($rkey, $fields)) {
                     //只查询定义的字段
                     $rkey = 'data.' . $rkey;
                     $criteria->{$rkey} = new MongoRegex('/' . $rval . '/i');
                 }
             }
         }
         //排序
         if ($order) {
             foreach ($order as $okey => $oval) {
                 if (in_array($okey, $fields)) {
                     //只查询定义的字段
                     $criteria->sort('data.' . $okey, $oval);
                 }
             }
         } else {
             $criteria->sort('id', EMongoCriteria::SORT_ASC);
             //默认id正序
         }
         //构建分页
         $count = CardItem::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = $pageSize;
         $offset = ($currPage - 1) * $pageSize;
         $criteria->limit($pageSize)->offset($offset);
         //查询本页
         $return['data'] = CardItem::model()->findAll($criteria);
         //数据显示方式
         $return['show_type'] = $dsModel->show_type;
         $return['pages'] = array('itemCount' => $count, 'pageSize' => $pageSize, 'currPage' => $currPage);
         foreach ($return['data'] as $rkey => $rval) {
             $arr_info = $return['data'][$rkey]->toArray();
             //清除无用的字段
             unset($arr_info['dataset_id']);
             unset($arr_info['request_times']);
             unset($arr_info['last_uid']);
             unset($arr_info['update_time']);
             unset($arr_info['_id']);
             $return['data'][$rkey] = $arr_info;
         }
         $this->writeCache(CJSON::encode($return));
         //设置缓存
     }
     echo CJSON::encode($return);
 }
Example #14
0
 /**
  * Support mongo models interface.
  *
  * @param \EMongoDocument $model
  * @param string|array $where
  * @throws ApiException, NotFoundApiException
  */
 private function mongoGet($model, $where = null)
 {
     $criteria = new \EMongoCriteria();
     if ($id = \Yii::app()->request->getParam(self::ID, false)) {
         $this->data = $model->findByPk($id);
     } else {
         if ($ids = \Yii::app()->request->getParam(self::IDS, false)) {
             // something
         } else {
             $params = $this->getPaginationParams();
             $criteria->offset($params['offset']);
             $criteria->limit($params['limit']);
             if ($order = \Yii::app()->request->getParam(self::ORDER, false)) {
                 $params = explode(' ', $order);
                 $criteria->sort($params[0], $params[1] == 'desc' ? \EMongoCriteria::SORT_DESC : \EMongoCriteria::SORT_ASC);
             }
             if ($where) {
                 if (is_array($where)) {
                     foreach ($where as $cond) {
                         $params = explode(' ', $cond);
                         if ($params[1] == 'in') {
                             $params[2] = $this->manageInCondition($params[2]);
                         }
                         $criteria->addCond($params[0], $params[1], is_numeric($params[2]) ? (int) $params[2] : $params[2]);
                     }
                 } else {
                     $params = explode(' ', $where);
                     if ($params[1] == 'in') {
                         $params[2] = $this->manageInCondition($params[2]);
                     }
                     $criteria->addCond($params[0], $params[1], is_numeric($params[2]) ? (int) $params[2] : $params[2]);
                 }
             }
             $this->data = $model->findAll($criteria);
             if ($this->data == null) {
                 throw new NotFoundApiException();
             }
         }
     }
 }
Example #15
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($caseSensitive = false)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new EMongoCriteria();
     if ($this->identifier != null) {
         $criteria->addCond('identifier', '==', new MongoRegex('/' . $this->identifier . '/i'));
     }
     if ($this->name != null) {
         $criteria->addCond('name', '==', new MongoRegex('/' . $this->name . '/i'));
     }
     if ($this->collection_name != null && $this->collection_name != "") {
         $listWords = explode(" ", $this->collection_name);
         $regex = "";
         foreach ($listWords as $word) {
             $regex .= "{$word}|";
         }
         $regex = substr($regex, 0, -1);
         $criteria->addCond('collection_name', '==', new MongoRegex("/({$regex})/i"));
     }
     if ($this->collection_id != null && $this->collection_id != "") {
         $listWords = explode(" ", $this->collection_id);
         $regexId = "";
         foreach ($listWords as $word) {
             $regexId .= "{$word}|";
         }
         $regexId = substr($regexId, 0, -1);
         $criteria->addCond('collection_id', '==', new MongoRegex("/({$regexId})/i"));
     }
     if ($this->diagnosis_available != null && $this->diagnosis_available != "") {
         $listWords = explode(" ", $this->diagnosis_available);
         $regexId = "";
         foreach ($listWords as $word) {
             $regexId .= "{$word}|";
         }
         $regexId = substr($regexId, 0, -1);
         $criteria->addCond('diagnosis_available', '==', new MongoRegex("/({$regexId})/i"));
     }
     if ($this->keywords_MeSH != null && $this->keywords_MeSH != "") {
         $listWords = explode(" ", $this->keywords_MeSH);
         $regexId = "";
         foreach ($listWords as $word) {
             $regexId .= "{$word}|";
         }
         $regexId = substr($regexId, 0, -1);
         $criteria->addCond('keywords_MeSH', '==', new MongoRegex("/({$regexId})/i"));
     }
     if ($this->contact_id != null && $this->contact_id != "") {
         $criteria->contact_id = $this->contact_id;
     }
     if (isset($this->address) && $this->address->city != null) {
         $criteria->addCond('address.city', '==', new MongoRegex('/' . $this->address->city . '/i'));
     }
     //always sort with alphabetical order on name
     $criteria->sort('name', EMongoCriteria::SORT_ASC);
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #16
0
 /**
  * 在文件夹中查找文件
  * @param $url string 文件夹所在路径(yii格式,如:application.data.game)
  * @param $ext string 扩展名过滤(默认为不过滤)
  * @return array 所有文件的列表
  */
 public function findDir($url, $ext = false, $order = false)
 {
     $rs = array();
     //初始化结果集
     $dir = yiiBase::getPathOfAlias($url);
     //文件夹路径
     $expire_time = $this->expire * 24 * 3600;
     //过期时间
     $expire_warn = floor($this->expire * 24 * 3600 * 2 / 3);
     //警告时间
     //数据库查询
     $criteria = new EMongoCriteria();
     $criteria->filename = new MongoRegex('#^' . $dir . '.*\\.' . $ext . '$#i');
     //按目录前缀查询
     $criteria->sort('metadata.addTime', EMongoCriteria::SORT_DESC);
     $files = File::model()->findAll($criteria);
     foreach ($files as $fv) {
         //标记快失效的备份文件
         if ($fv->metadata['addTime'] < time() - $expire_warn) {
             //还剩下1/3的时间时给予提示
             $fv->metadata['name'] = '<span style="color:#faa" title="文件将在' . date('Y-m-d H:i:s', $fv->metadata['addTime'] + $expire_time) . '失效!">' . $fv->metadata['name'] . ' [Fast Expire]</span>';
         }
         $rs[$fv->_id . ''] = array('id' => $fv->_id . '', 'name' => $fv->metadata['name'], 'edittime' => date('Y-m-d H:i:s', $fv->metadata['addTime']), 'size' => $fv->getSize() / 1000);
     }
     /*文件夹扫描
     		 * if (is_dir($dir)) {
     		    if ($dh = opendir($dir)) {
     				$i = 0;
     		        while (($file = readdir($dh)) !== false) {
     		        	if(!is_dir($dir.'/'.$file) && !in_array($file, array('.', '..', '.svn'))){
     		        		$source_name = $file;
     		        		//$file = $this->toAppCharset($file);
     		        		$finfo = pathinfo($file);
     		        		if($ext===false || (isset($finfo['extension']) && $finfo['extension']==$ext)){
     		        			$edit_time = filemtime($dir.'/'.$source_name);
     		        			$rs[$file] = array(
     		        				'id'=>$finfo['filename'],			//名称
     		        				'name'=>$file,						//全名
     		        				'edittime'=>date('Y-m-d H:i:s', $edit_time),	//修改时间
     		        				'size'=>filesize($dir.'/'.$source_name)/1000,	//文件大小
     		        			);
     		        		}
     		        	}
     					$i++;
     		        }
     		    	closedir($dh);
     		    	krsort($rs);
     		    }
     		}*/
     return $rs;
 }
Example #17
0
 /**
  * get an array of contacts used by dropDownLIst.
  * The first line is blank to allow empty case.
  */
 public function getArrayContacts()
 {
     $res = array();
     $criteria = new EMongoCriteria();
     $criteria->sort('last_name', EMongoCriteria::SORT_ASC);
     $contacts = $this->findAll($criteria);
     foreach ($contacts as $row) {
         $res[(string) $row->_id] = $row->last_name . " " . $row->first_name;
     }
     return $res;
 }
Example #18
0
 /**
  * 获取表查询的范围条件
  * @return unknown_type
  */
 public function getScopeDsCriteria()
 {
     $criteria = new EMongoCriteria();
     if ($this->get_login_user('scopeInfo', 'ds') != 'all') {
         $criteria->addCond('id', 'in', $this->get_login_user('scopeInfo', 'ds'));
     }
     $criteria->sort('id', EMongoCriteria::SORT_ASC);
     return $criteria;
 }