Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Policies::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 15]]);
     $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, 'date_created' => $this->date_created, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'insurance_company' => $this->insurance_company]);
     $query->andFilterWhere(['ilike', 'registration_number', $this->registration_number])->andFilterWhere(['ilike', 'policy_holder_name', $this->policy_holder_name])->andFilterWhere(['ilike', 'policy_holder_phone', $this->policy_holder_phone])->andFilterWhere(['ilike', 'policy_number', $this->policy_number])->andFilterWhere(['like', 'sticker_reference', $this->sticker_reference]);
     unset($_SESSION['exportData']);
     $_SESSION['exportData'] = $dataProvider;
     return $dataProvider;
 }
 /**
  * Finds the Policies model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Policies the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Policies::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPolicies()
 {
     return $this->hasMany(Policies::className(), ['insurance_company' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPolicies()
 {
     return $this->hasOne(Policies::className(), ['sticker_reference' => 'print_code']);
 }