public function actionUpdate($id) { $model = Transfers::findOne($id); if (!$model) { Yii::$app->getSession()->setFlash('error', 'Запись не существует'); return $this->redirect(Yii::$app->request->referrer); } if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->updated_at = date('Y-m-d H:i:s'); // if ($model->ship_date != $model->getOldAttribute('ship_date')) { if (!$model->getOldAttribute('express')) { $model->moved = Transfers::MOVED; $model->moved_count++; } else { Yii::$app->getSession()->setFlash('error', 'Нельзя переносить срочные перемещения'); return $this->redirect(['/transfers/update', 'id' => $id]); } } // $model->save(); Yii::$app->getSession()->setFlash('success', 'Изменения сохранены'); return $this->redirect(['/transfers/update', 'id' => $id]); } $log = EventLogs::find()->where(['model' => Transfers::className()])->andWhere(['record_id' => $id])->orderBy(['timestamp' => SORT_DESC])->all(); return $this->render('form', ['model' => $model, 'title' => 'Редактировать', 'log' => $log]); }
public function search($params) { $query = EventLogs::find()->joinWith('managers'); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['timestamp' => SORT_DESC]]]); // load the search form data and validate if (!($this->load($params) && $this->validate())) { return $dataProvider; } // adjust the query by adding the filters $query->andFilterWhere(['like', 'timestamp', $this->timestamp])->andFilterWhere(['like', 'managers.managerName', $this->managerId])->andFilterWhere(['like', 'table', $this->table])->andFilterWhere(['=', 'action', $this->action])->andFilterWhere(['like', 'data', $this->data])->andFilterWhere(['like', 'recordId', $this->recordId]); return $dataProvider; }