コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 /**
  * 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));
 }
コード例 #3
0
ファイル: ExportController.php プロジェクト: humantech/ppma
 /**
  *
  * @return void
  */
 public function actionCsv()
 {
     Yii::import('ext.ECSVExport');
     $data = array();
     foreach (Entry::model()->findAllByAttributes(array('userId' => Yii::app()->user->id)) as $model) {
         /* @var Entry $model */
         $data[] = array('name' => $model->name, 'url' => $model->url, 'comment' => $model->comment, 'tags' => $model->tagList, 'username' => $model->username, 'password' => $model->password);
     }
     $csv = new ECSVExport($data);
     Yii::app()->request->sendFile(sprintf('ppma-export-%s', date('YmdHis')), $csv->toCSV(), 'text/csv', false);
 }
コード例 #4
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);
 }
コード例 #5
0
 public function actionExport()
 {
     Yii::import('ext.ECSVExport');
     $criteria = new CDbCriteria(array('condition' => 'id <> 1'));
     $output = array();
     $users = User::model()->findAll($criteria);
     if ($users) {
         foreach ($users as $row) {
             $output[] = array('Username' => $row->username, 'First Name' => $row->first_name, 'Last Name' => $row->last_name, 'Email' => $row->email, 'Registered At' => $row->created_at);
         }
     }
     $csv = new ECSVExport($output);
     $content = $csv->toCSV();
     Yii::app()->getRequest()->sendFile('users-list.csv', $content, "text/csv", false);
     Yii::app()->end();
 }
コード例 #6
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);
 }
コード例 #7
0
ファイル: PaymentController.php プロジェクト: KaranSofat/yii
 public function actionExport()
 {
     $re = Booking::model()->findAll();
     //echo "<pre>";print_r($re);
     foreach ($re as $res) {
         $detail = $res['cleaningDetail'];
         $trans = $res['trans_id'];
         $price = $res['price'];
         $serName = $res->serviceType['service_name'];
         $cAdd = $res->customerAddress['address'];
         $company = $res->service['company_name'];
         $val[] = array('Copmany Name' => $company, 'Customer Address' => $cAdd, 'Service Name' => $serName, 'price' => $price, 'TransId' => $trans, 'Detail' => $detail);
     }
     //echo "<pre>";print_r($val);die;
     $filename = "payment.csv";
     $csv = new ECSVExport($val);
     $content = $csv->toCSV();
     Yii::app()->getRequest()->sendFile($filename, $content, "text/csv", false);
     exit;
 }
コード例 #8
0
 public function actionExportAll()
 {
     Yii::import('ext.ECSVExport.ECSVExport');
     $dateToday = date("Y-m-d");
     $filename = 'all-leads-submitted-' . $dateToday;
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: private", false);
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"{$filename}.csv\";");
     header("Content-Transfer-Encoding: binary");
     /*find all lead and export*/
     // $csv = new ECSVExport(MainLeadModel::model()->findAllByAttributes(array('user_id'=>$userModel->id)));
     $tempFileContainer = tempnam(sys_get_temp_dir(), "asd");
     $cmd = Yii::app()->db->createCommand("SELECT * FROM tbl_gin");
     $csv = new ECSVExport($cmd);
     $csv->setOutputFile($tempFileContainer);
     $csv->toCSV();
     echo file_get_contents($tempFileContainer);
 }
コード例 #9
0
ファイル: PartController.php プロジェクト: ever4vr/maestro
 /**
  * Save as CSV
  * TODO create filters for query
  * - hide/show column names?
  * - dynamically build SELECT statement?
  * TODO investigate potential bug in CSV extension
  * - may not correctly handle nulls other than in last (right-most) column
  */
 public function actionSaveAsCSV()
 {
     $csvname = "parts.csv";
     $path = Yii::app()->basePath;
     $filename = $path . "/runtime/" . $csvname;
     $cmd = Yii::app()->db->createCommand("SELECT PNPartNumber, type_id, status_id, PNRevision, PNTitle, PNDetail FROM maestro.tbl_part");
     $csv = new ECSVExport($cmd);
     $csv->setHeader('PNPartNumber', 'PartNumber');
     $csv->setHeader('type_id', 'Type');
     $csv->setHeader('status_id', 'Status');
     $csv->setHeader('PNRevision', 'Revision');
     $csv->setHeader('PNTitle', 'Title');
     $csv->setHeader('PNDetail', 'Detail');
     $csv->setOutputFile($filename);
     $output = $csv->toCSV();
     Yii::app()->getRequest()->sendFile($csvname, file_get_contents($filename));
 }
コード例 #10
0
ファイル: CustomerController.php プロジェクト: KaranSofat/yii
 public function actionExport()
 {
     $re = CustomerUser::model()->findAll();
     //echo "<pre>";print_r($re);die;
     foreach ($re as $res) {
         $name = $res['cname'] . " " . $res['clname'];
         $email = $res['email'];
         $country = $res['country'];
         $phone = $res['phone'];
         $zip = $res['zipcode'];
         $customer[] = array('Name' => $name, 'Email Address' => $email, 'Country' => $country, 'Phone' => $phone, 'Zip' => $zip);
     }
     //die;	//echo "<pre>";print_r($val);die;
     $filename = "customer.csv";
     $csv = new ECSVExport($customer);
     $content = $csv->toCSV();
     Yii::app()->getRequest()->sendFile($filename, $content, "text/csv", false);
     exit;
 }
コード例 #11
0
ファイル: CompanyController.php プロジェクト: KaranSofat/yii
 public function actionExport()
 {
     $re = ServiceUser::model()->with('priceAdmins')->findAll();
     // echo "<pre>";print_r($re);die;
     foreach ($re as $res) {
         $compName = $res['company_name'];
         $email = $res['email'];
         $city = $res['city'];
         $phone = $res['phone'];
         $zip = $res['zipcode'];
         $company[] = array('Company Name' => $compName, 'Email Address' => $email, 'City' => $city, 'Phone' => $phone, 'Zip' => $zip);
     }
     //die;	//echo "<pre>";print_r($val);die;
     $filename = "company.csv";
     $csv = new ECSVExport($company);
     $content = $csv->toCSV();
     Yii::app()->getRequest()->sendFile($filename, $content, "text/csv", false);
     exit;
 }
コード例 #12
0
ファイル: StudentController.php プロジェクト: nguyenvanvu/slu
 public function actionExportAttendedStudent()
 {
     Yii::import('ext.ECSVExport');
     $model = new RsStudent();
     $sql_status = $model->sql_status();
     $sql = $sql_status['sql'];
     $list_student = $model->data_query($sql);
     $data_csv = array();
     foreach ($list_student as $values) {
         $faculty = Yii::app()->params['faculty_values'][$values["faculty"]];
         $status = Yii::app()->params['status'][$values["status"]];
         $item_csv = array("名大ID" => $values["student_code"], "名前" => $values["first_name"] . ' ' . $values["last_name"], "フリガナ" => $values["first_kana"] . ' ' . $values["last_kana"], "所属" => $faculty, "学籍・教員番号" => $values["professor_code"], "状況" => $status);
         array_push($data_csv, $item_csv);
     }
     $csv = new ECSVExport($data_csv);
     //$output = $csv->toCSV();
     //$output = mb_convert_encoding($csv->toCSV(),"SJIS", "UTF-8");
     $output = mb_convert_encoding($csv->toCSV(), "SJIS-win", "UTF-8");
     $filename = "認定者一覧.csv";
     Yii::app()->getRequest()->sendFile($filename, $output, "text/csv", false);
 }