Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $id = ArrayHelper::getValue($params, 'id');
     if ($id > 0) {
         $query = DtEnquiryDevices::find()->where(['dt_enquiries_id' => $id]);
     } else {
         $query = DtEnquiryDevices::find();
     }
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['dt_enquiries_id' => $this->dt_enquiries_id, 'type_id' => $this->type_id, 'parent_device_id' => $this->parent_device_id, 'id' => $this->id]);
     $query->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Удаление документа Заявка на оборудование и его табличной части
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if (DtEnquiryDevices::deleteAll(['dt_enquiries_id' => $model->id])) {
         if ($model->delete()) {
         } else {
             Yii::$app->session->setFlash('error', 'Ошибка при удалении документа');
         }
     } else {
         Yii::$app->session->setFlash('error', 'Ошибка при удалении строк');
     }
     return $this->redirect(['index']);
 }
 /**
  * Finds the DtEnquiryDevices model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DtEnquiryDevices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DtEnquiryDevices::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрашиваемая страница не найдена.');
     }
 }