/**
  * export csv des echantillons.
  */
 public function actionExportCsv()
 {
     set_time_limit(60);
     $model = new Echantillon('search');
     $model->unsetAttributes();
     $criteria = $_SESSION['criteria'];
     $criteria->limit = 30000;
     if (isset($_GET['Echantillon'])) {
         $model->attributes = $_GET['Echantillon'];
     }
     $dataProvider = new CActiveDataProvider('Echantillon', array('criteria' => $criteria, 'pagination' => false));
     $filename = 'samples_list.csv';
     $csv = new ECSVExport($dataProvider);
     $toExclude = array();
     $toExport = $model->attributeExportedLabels();
     foreach ($model->attributeLabels() as $attribute => $value) {
         if (!isset($toExport[$attribute])) {
             $toExclude[] = $attribute;
         }
     }
     $csv->setHeaders($toExport);
     $csv->setExclude($toExclude);
     //	$csv->exportCurrentPageOnly ();
     Yii::app()->getRequest()->sendFile($filename, $csv->toCSV(), "text/csv", false);
 }
Exemplo n.º 2
0
 public function actionExportCsv()
 {
     $model = new Contact('search');
     $model->unsetAttributes();
     if (isset($_GET['Contact'])) {
         $model->attributes = $_GET['Contact'];
     }
     if (isset($_SESSION['criteria']) && $_SESSION['criteria'] != null && $_SESSION['criteria'] instanceof EMongoCriteria) {
         $criteria = $_SESSION['criteria'];
     } else {
         $criteria = new EMongoCriteria();
     }
     $models = Contact::model()->findAll($criteria);
     $listAttributes = array();
     foreach ($models as $model) {
         //récuperation de la liste totale des attributs
         foreach ($model->attributes as $attributeName => $attributeValue) {
             $listAttributes[$attributeName] = $attributeName;
         }
     }
     $dataProvider = array();
     //creation du dataprovider
     foreach ($models as $model) {
         $datas = array();
         foreach ($listAttributes as $attribute) {
             if (isset($model->{$attribute})) {
                 if (!is_object($model->{$attribute})) {
                     $datas[$attribute] = $model->{$attribute};
                 }
             } else {
                 $datas[$attribute] = "";
             }
         }
         //create full adress
         $datas['fullAddress'] = $model->fullAddress;
         //create biobank
         $datas['fullAddress'] = $model->biobankName;
         $dataProvider[] = $datas;
     }
     $filename = 'biobanks_list.csv';
     $csv = new ECSVExport($dataProvider);
     $toExclude = array();
     $toExport = $model->attributeExportedLabels();
     foreach ($model->attributes as $attribute => $value) {
         if (!isset($toExport[$attribute])) {
             $toExclude[] = $attribute;
         }
     }
     $csv->setExclude($toExclude);
     // $csv->exportCurrentPageOnly();
     Yii::app()->getRequest()->sendFile($filename, $csv->toCSV(), "text/csv", false);
 }
Exemplo n.º 3
0
 /**
  * export csv des echantillons.
  */
 public function actionExportCsv()
 {
     $model = new Sample('search');
     $model->unsetAttributes();
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
     }
     // reprend les critères de la dernière recherche
     if (isset($_SESSION['criteria']) && $_SESSION['criteria'] != null && $_SESSION['criteria'] instanceof EMongoCriteria) {
         $criteria = $_SESSION['criteria'];
     } else {
         $criteria = new EMongoCriteria();
     }
     $criteria->limit(200);
     $models = Sample::model()->findAll($criteria);
     $dataProvider = array();
     $listAttributes = array();
     foreach ($models as $model) {
         //récuperation de la liste totale des attributs
         foreach ($model->attributes as $attributeName => $attributeValue) {
             $listAttributes[$attributeName] = $attributeName;
         }
     }
     foreach ($models as $model) {
         $datas = array();
         foreach ($listAttributes as $attribute) {
             if (isset($model->{$attribute})) {
                 if (is_array($model->{$attribute})) {
                     if ($attribute == 'notes') {
                         $datas[$attribute] = $model->getShortNotes();
                     }
                 } else {
                     if (!is_object($model->{$attribute})) {
                         $datas[$attribute] = $model->{$attribute};
                     }
                 }
             } else {
                 $datas[$attribute] = "";
             }
         }
         $dataProvider[] = $datas;
     }
     $filename = 'samples_list.csv';
     $csv = new ECSVExport($dataProvider);
     $toExclude = array();
     $toExport = $model->attributeExportedLabels();
     foreach ($listAttributes as $attribute) {
         if (!isset($toExport[$attribute])) {
             $toExclude[] = $attribute;
         }
     }
     $csv->setExclude($toExclude);
     // $csv->exportCurrentPageOnly();
     Yii::app()->getRequest()->sendFile($filename, $csv->toCSV(), "text/csv", false);
 }