public function actionExport()
 {
     $builder = $this->buildQuery(true);
     $query = $builder['query'];
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     ExcelView::widget(['dataProvider' => $dataProvider, 'fullExportType' => 'xlsx', 'grid_mode' => 'export', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'station_name', 'header' => 'Tên trạm'], ['attribute' => 'message', 'header' => 'Nội dung'], ['attribute' => 'warning_date', 'header' => 'Thời gian']]]);
 }
 public function actionExport($id)
 {
     $model = Visa::find()->where(['id' => $id])->one();
     $visaRelation = Visadetail::find()->where(['id_visa' => $model->id]);
     $provider = new \yii\data\ActiveDataProvider(['query' => $visaRelation]);
     /*$searchModel = new VisaSearch();
       $dataProvider = $searchModel->search(Yii::$app->request->queryParams);*/
     ExcelView::widget(['dataProvider' => $provider, 'fullExportType' => 'xlsx', 'filename' => 'Visa', 'fullExportConfig' => ['xlsx' => ['filename' => 'Visa']], 'grid_mode' => 'export', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'id_visa', 'fullname', 'nation', 'idpassport', 'birthday', 'expire', 'flightdetail', 'arrivaldate', 'exitdate', 'portarrival', 'purposevisit']]);
 }
 public function actionExport()
 {
     $searchModel = new PesertaSearch();
     $id = Yii::$app->request->get('id_event');
     // $query = new Query;
     // $query = $query->from('absensi')->innerJoin('peserta','id_peserta = peserta.id', $id);
     $dataProvider = $searchModel->searchByEvent($id);
     ExcelView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'fullExportType' => 'xlsx', 'grid_mode' => 'export', 'columns' => [['class' => 'yii\\grid\\serialColumn'], 'id', 'nama', 'universitas', 'jurusan']]);
     // }
 }
 public function actionExport()
 {
     $searchModel = new SearchMagazin();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     ExcelView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'fullExportType' => 'xlsx', 'grid_mode' => 'export', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'email', 'level', 'create_at']]);
 }
 public function actionExport()
 {
     $searchModel = null;
     $dataProvider = null;
     if (false !== strpos(Yii::$app->request->post('export_filename'), 'User List')) {
         $searchModel = new MstAccountSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         $gridColumns = [['class' => 'yii\\grid\\SerialColumn'], 'username', ['attribute' => 'password', 'value' => function ($model) {
             if ($model->password === md5(Yii::$app->params["DEFAULT_PASSWORD"])) {
                 return "DEFAULT";
             } else {
                 return '********';
             }
         }], ['attribute' => 'assignment', 'label' => 'Current Location'], ['attribute' => 'start_date', 'label' => 'Current Start Date'], ['attribute' => 'end_date', 'label' => 'Current End Date'], ['attribute' => 'next_assignment', 'label' => 'Next Location'], ['attribute' => 'next_start_date', 'label' => 'Next Start Date'], ['attribute' => 'end_date', 'label' => 'Next End Date']];
     }
     if (false !== strpos(Yii::$app->request->post('export_filename'), 'Transaction Details List')) {
         $params = ['status' => [Yii::$app->params['STATUS_PROCESS'], Yii::$app->params['STATUS_CLOSED'], Yii::$app->params['STATUS_REJECTED']]];
         $searchModel = new TrxTransactionDetailsSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $params);
         $gridColumns = [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'updater_id', 'label' => 'User Name', 'value' => function ($model) {
             $account = Yii::$app->modelFinder->findAccountModel($model->updater_id);
             if ($account) {
                 return $account->first_name . ' ' . $account->last_name;
             }
         }], ['attribute' => 'updated_date', 'label' => 'Date'], ['attribute' => 'transaction_id', 'label' => 'Transaction'], ['attribute' => 'customer_code', 'label' => 'Customer', 'value' => function ($model) {
             $customer = Yii::$app->modelFinder->findCustomerModel($model->customer_code);
             if ($customer) {
                 return $customer->name;
             }
         }], ['attribute' => 'pallet_no', 'label' => 'Pallet No'], ['attribute' => 'status', 'label' => 'Status']];
     }
     if (false !== strpos(Yii::$app->request->post('export_filename'), 'Transaction History')) {
         $params = ['status' => [Yii::$app->params['STATUS_PROCESS'], Yii::$app->params['STATUS_CLOSED']]];
         $searchModel = new TrxTransactionsSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $params);
         $gridColumns = [['attribute' => 'created_date', 'label' => 'DATE'], ['attribute' => 'id', 'label' => 'BRDS NO.'], ['attribute' => 'sap_no', 'label' => 'SAP NO.'], ['attribute' => 'customer_code', 'label' => 'CUSTOMER', 'value' => function ($model) {
             $customer = Yii::$app->modelFinder->findCustomerModel($model->customer_code);
             if ($customer) {
                 return $customer->name;
             }
         }], ['attribute' => 'pallet_count', 'label' => 'NO. OF PALLET'], ['attribute' => 'weight', 'label' => 'TOTAL WT.'], ['attribute' => 'status', 'label' => 'STATUS']];
     }
     if ($searchModel && $dataProvider) {
         ExcelView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'fullExportType' => 'csv', 'grid_mode' => 'export', 'columns' => $gridColumns]);
     }
 }
 /**
  * exports Excel document of the $yaer-$month grid
  * @param type $year int
  * @param type $month int
  */
 public function actionExcel($year, $month)
 {
     $searchModel = new ReportsSearch();
     $dataProvider = $searchModel->search($year, $month, Yii::$app->request->queryParams);
     ExcelView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'fullExportType' => 'xlsx', 'grid_mode' => 'export', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'user_id', 'revenue', 'expense_on_goods', 'other_expenses', 'salary', 'day_type', 'date', 'created_at', 'updated_at']]);
 }