Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $_1cid)
 {
     if (Yii::$app->user->can('admin')) {
         $query = Acts::find();
     } else {
         $query = Acts::find()->where(['users_user_1c_id' => $_1cid]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('usersUser');
     $query->andFilterWhere(['id' => $this->id, 'begdate' => $this->begdate, 'enddate' => $this->enddate, 'customers_customer_1c_id' => $this->customers_customer_1c_id]);
     $query->andFilterWhere(['like', 'num', $this->num])->andFilterWhere(['like', 'begenddate', $this->begenddate])->andFilterWhere(['like', 'user.fullname', $this->users_user_1c_id])->andFilterWhere(['like', 'typedoc', $this->typedoc]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Finds the Acts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Acts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Acts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }