/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DerivacionReclamoSugerencia::find(); $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->joinWith('eDR'); $query->joinWith('sRS'); $query->andFilterWhere(['DRS_ID' => $this->DRS_ID, 'DRS_FECHA_DERIVACION' => $this->DRS_FECHA_DERIVACION, 'DRS_FECHA_RESPUESTA' => $this->DRS_FECHA_RESPUESTA]); $query->andFilterWhere(['like', 'USU_RUT', $this->USU_RUT])->andFilterWhere(['like', 'DRS_CARGO', $this->DRS_CARGO])->andFilterWhere(['like', 'DRS_UNIDAD', $this->DRS_UNIDAD])->andFilterWhere(['like', 'DRS_RESPUESTA', $this->DRS_RESPUESTA])->andFilterWhere(['like', 'DRS_SERVICIO_NO_CONFORME', $this->DRS_SERVICIO_NO_CONFORME])->andFilterWhere(['like', 'EDR_ESTADO', $this->EDR_ID])->andFilterWhere(['like', 'REC_NUMERO', $this->SRS_ID]); return $dataProvider; }
public function actionDerivate($id) { $model = $this->findModel($id); $derivacion = new DerivacionReclamoSugerencia(); $reclamo = new ReclamoSugerencia(); $reclamo = $reclamo->findOne($model->REC_NUMERO); if ($derivacion->load(Yii::$app->request->post())) { $derivacion->DRS_FECHA_DERIVACION = date('Y-m-d'); $derivacion->SRS_ID = $model->SRS_ID; $derivacion->EDR_ID = 1; $derivacion->save(); //Historial $historial = new HistorialEstados(); $historial->REC_NUMERO = $reclamo->REC_NUMERO; $historial->ERS_ID = $reclamo->ERS_ID; $historial->USU_RUT = $reclamo->USU_RUT; $historial->HES_FECHA_HORA = date('Y-m-d H:i:s'); $historial->HES_COMENTARIO = "El usuario " . $historial->USU_RUT . " ha Derivado la solucitud Nº " . $historial->REC_NUMERO . " a la unidad " . $derivacion->DRS_UNIDAD . " el día " . $historial->HES_FECHA_HORA; $historial->save(); return $this->redirect(['derivacion-reclamo-sugerencia/view', 'id' => $derivacion->DRS_ID]); } else { return $this->render('derivate', ['model' => $model, 'derivacion' => $derivacion]); } }
/** * Finds the DerivacionReclamoSugerencia model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DerivacionReclamoSugerencia the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DerivacionReclamoSugerencia::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }