/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Visadetail::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'id_visa' => $this->id_visa, 'birthday' => $this->birthday, 'expire' => $this->expire, 'arrivaldate' => $this->arrivaldate, 'exitdate' => $this->exitdate]);
     $query->andFilterWhere(['like', 'fullame', $this->fullame])->andFilterWhere(['like', 'nation', $this->nation])->andFilterWhere(['like', 'idpassport', $this->idpassport])->andFilterWhere(['like', 'flightdetail', $this->flightdetail])->andFilterWhere(['like', 'portarrival', $this->portarrival])->andFilterWhere(['like', 'purposevisit', $this->purposevisit]);
     return $dataProvider;
 }
Example #2
0
 public function getVisadetails()
 {
     return $this->hasMany(Visadetail::className(), ['id_visa' => 'id']);
 }
 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']]);
 }
 /**
  * Finds the Visadetail model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Visadetail the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Visadetail::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }