diff --git a/ci4/app/Controllers/Configuracion/ConfigErrores.php b/ci4/app/Controllers/Configuracion/ConfigErrores.php index 31160e2f..a47eb8b0 100644 --- a/ci4/app/Controllers/Configuracion/ConfigErrores.php +++ b/ci4/app/Controllers/Configuracion/ConfigErrores.php @@ -35,7 +35,8 @@ class ConfigErrores extends BaseResourceController public function viewForm(int $error_presupuesto_id) { $this->errorPresupuestoModel->update($error_presupuesto_id, [ - "last_user_id" => auth()->user()->id + "last_user_id" => auth()->user()->id, + "visto" => true, ]); return view(static::$viewPath . 'viewErrorPresupuestoForm', ["error_presupuesto_id" => $error_presupuesto_id]); } @@ -47,9 +48,12 @@ class ConfigErrores extends BaseResourceController } public function get_error_presupuesto(int $error_presupuesto_id) { - $data = $this->errorPresupuestoModel->getQueryDatatable() - ->where("presupuesto_errores.id", $error_presupuesto_id)->get()->getResultObject()[0]; - return $this->response->setJSON(["data" => $data]); + $data = $this->errorPresupuestoModel->getErrorPresupuestoForm($error_presupuesto_id); + if(isset($data[0])){ + return $this->response->setJSON(["data" => $data[0]]); + }else{ + return $this->response->setJSON(["data" => []]); + } } public function update_error_presupuesto(int $error_presupuesto_id) { diff --git a/ci4/app/Models/Presupuestos/ErrorPresupuesto.php b/ci4/app/Models/Presupuestos/ErrorPresupuesto.php index 318ea171..add5a233 100644 --- a/ci4/app/Models/Presupuestos/ErrorPresupuesto.php +++ b/ci4/app/Models/Presupuestos/ErrorPresupuesto.php @@ -72,6 +72,25 @@ class ErrorPresupuesto extends Model ]); return $updated; } + public function getErrorPresupuestoForm(int $error_presupuesto_id) : array + { + $query = $this->builder() + ->select([ + "presupuesto_errores.id", + "CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser", + "CONCAT(t2.first_name,' ',t2.last_name) as lastUser", + "presupuesto_errores.created_at", + "presupuesto_errores.datos_presupuesto", + "presupuesto_errores.error", + "presupuesto_errores.visto", + "presupuesto_errores.comment" + ]) + ->join("users t1", "t1.id = presupuesto_errores.presupuesto_user_id", "left") + ->join("users t2", "t2.id = presupuesto_errores.last_user_id", "left") + ->where("presupuesto_errores.deleted_at", null) + ->where("presupuesto_errores.id",$error_presupuesto_id); + return $query->get()->getResultObject(); + } public function getQueryDatatable(): BaseBuilder { $query = $this->builder() diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php index 9b30380b..b0f2a90d 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/error_presupuesto/viewErrorPresupuestoForm.php @@ -46,7 +46,7 @@