/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Documents::find();
     $query->joinWith(['from', 'to']);
     $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, 'Document' => $this->Document, 'Company' => $this->Company, 'Type' => $this->Type])->andFilterWhere(['like', 'WarehousesFrom.Warehouse', $this->From])->andFilterWhere(['like', 'WarehousesTo.Warehouse', $this->To])->andFilterWhere(['like', 'Date', $this->Date]);
     $query->andFilterWhere(['like', 'Comment', $this->Comment]);
     return $dataProvider;
 }
Exemple #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDocuments()
 {
     return $this->hasMany(Documents::className(), ['Company' => 'ID']);
 }
 /**
  * Finds the Documents model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Documents the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Documents::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDocument()
 {
     return $this->hasOne(Documents::className(), ['ID' => 'Document']);
 }