/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SolucionReclamoSugerencia::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('eSR'); $query->andFilterWhere(['SRS_ID' => $this->SRS_ID, 'SRS_VISTO_BUENO' => $this->SRS_VISTO_BUENO, 'SRS_FECHA_RESPUESTA' => $this->SRS_FECHA_RESPUESTA, 'SRS_FECHA_ENVIO' => $this->SRS_FECHA_ENVIO]); $query->andFilterWhere(['like', 'USU_RUT', $this->USU_RUT])->andFilterWhere(['like', 'REC_NUMERO', $this->REC_NUMERO])->andFilterWhere(['like', 'SRS_COMENTARIO', $this->SRS_COMENTARIO])->andFilterWhere(['like', 'SRS_ANTECEDENTES', $this->SRS_ANTECEDENTES])->andFilterWhere(['like', 'SRS_RESULTADOS', $this->SRS_RESULTADOS])->andFilterWhere(['like', 'ESR_ESTADO', $this->ESR_ID]); return $dataProvider; }
/** * Finds the SolucionReclamoSugerencia model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SolucionReclamoSugerencia the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SolucionReclamoSugerencia::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionEvaluate($id) { $model = $this->findModel($id); $solucion = new SolucionReclamoSugerencia(); if (Yii::$app->request->isAjax && $solucion->load($_POST)) { Yii::$app->response->format = 'json'; return \yii\widgets\ActiveForm::validate($model); } if ($solucion->load(Yii::$app->request->post())) { $solucion->ESR_ID = 1; $solucion->REC_NUMERO = $model->REC_NUMERO; $solucion->SRS_FECHA_ENVIO = date('Y-m-d'); //Aprobar o rechazar el Reclamo o Sugerencia $historial = new HistorialEstados(); if ($solucion->SRS_VISTO_BUENO == 'Autorizado') { $model->ERS_ID = 2; $motivo = $model->REC_MOTIVO; $model->REC_MOTIVO = $motivo; $model->save(); $solucion->save(); //insertar en el historial la aprobacion $historial->REC_NUMERO = $model->REC_NUMERO; $historial->ERS_ID = $model->ERS_ID; $historial->USU_RUT = $solucion->USU_RUT; $historial->HES_FECHA_HORA = date('Y-m-d H:i:s'); $historial->HES_COMENTARIO = "El usuario " . $historial->USU_RUT . " ha Aprobado el Reclamo Nº " . $historial->REC_NUMERO . " el día " . $historial->HES_FECHA_HORA; $historial->save(); } else { $model->ERS_ID = 3; $motivo = $model->REC_MOTIVO; $model->REC_MOTIVO = $motivo; $model->save(); $solucion->save(); //insertar en e historial el rechazo $historial->REC_NUMERO = $model->REC_NUMERO; $historial->ERS_ID = $model->ERS_ID; $historial->USU_RUT = $solucion->USU_RUT; $historial->HES_FECHA_HORA = date('Y-m-d H:i:s'); $historial->HES_COMENTARIO = "El usuario " . $historial->USU_RUT . " ha Rechazado el Reclamo Nº " . $historial->REC_NUMERO . " el día " . $historial->HES_FECHA_HORA; $historial->save(); } // $solucion->save(); return $this->redirect(['/solucion-reclamo-sugerencia/view', 'id' => $solucion->SRS_ID]); } else { if ($model->ERS_ID != 1) { //soucion parche return $this->redirect(['/solucion-reclamo-sugerencia/index']); } else { return $this->render('evaluate', ['model' => $model, 'solucion' => $solucion]); } } }