public function actionAnswer($id) { $model = $this->findModel($id); $solucion = new SolucionReclamoSugerencia(); $solucion = $solucion->findOne($model->SRS_ID); //validacion con ajax if (Yii::$app->request->isAjax && $model->load($_POST)) { Yii::$app->response->format = 'json'; return \yii\widgets\ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { $historial = new HistorialEstados(); //proceso para traer el reclamo correspondiente $reclamo = new ReclamoSugerencia(); //revisar estas querys que no estan trabajando como corresponde $query = new Query(); $query->select('REC_NUMERO')->from('RECLAMO_SUGERENCIA')->where('REC_NUMERO=:numero', [':numero' => $solucion->REC_NUMERO])->limit('1'); $query = $query->one(); $reclamo = $reclamo->findOne($query); //end proceso $model->DRS_FECHA_RESPUESTA = date('Y-m-d'); $model->EDR_ID = 2; $model->save(); //historial $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 Respondido a la derivación de la solicitud Nº " . $historial->REC_NUMERO . " el día " . $historial->HES_FECHA_HORA; $historial->save(); //end historial return $this->redirect(['view', 'id' => $model->DRS_ID]); } else { return $this->render('answer', ['model' => $model, 'solucion' => $solucion]); } }
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]); } }
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]); } } }