From f9b12cbcdd1e4afcc17ae0c81f5ce39aa63a765a Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sat, 19 Oct 2024 07:29:47 +0000 Subject: [PATCH] feat:errores presupuesto --- .../Configuracion/ConfigErrores.php | 9 ++++---- .../Models/Presupuestos/ErrorPresupuesto.php | 5 ++-- .../viewErrorPresupuestoForm.php | 23 ++++++++++++------- .../error_presupuesto/errorPresupuestoForm.js | 21 +++++++++++------ 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/ci4/app/Controllers/Configuracion/ConfigErrores.php b/ci4/app/Controllers/Configuracion/ConfigErrores.php index 6346507d..31160e2f 100644 --- a/ci4/app/Controllers/Configuracion/ConfigErrores.php +++ b/ci4/app/Controllers/Configuracion/ConfigErrores.php @@ -23,8 +23,6 @@ class ConfigErrores extends BaseResourceController public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) { - - parent::initController($request, $response, $logger); $this->errorPresupuestoModel = model(ErrorPresupuestoModel::class); } @@ -32,11 +30,13 @@ class ConfigErrores extends BaseResourceController public function index() { - return view(static::$viewPath . $this->indexRoute, $this->viewData); } public function viewForm(int $error_presupuesto_id) { + $this->errorPresupuestoModel->update($error_presupuesto_id, [ + "last_user_id" => auth()->user()->id + ]); return view(static::$viewPath . 'viewErrorPresupuestoForm', ["error_presupuesto_id" => $error_presupuesto_id]); } public function store() @@ -60,10 +60,9 @@ class ConfigErrores extends BaseResourceController public function datatable() { - $query = $this->errorPresupuestoModel->getQueryDatatable(); return DataTable::of($query) ->add("action", fn($q) => $q->id) ->toJson(true); } -} \ No newline at end of file +} diff --git a/ci4/app/Models/Presupuestos/ErrorPresupuesto.php b/ci4/app/Models/Presupuestos/ErrorPresupuesto.php index 0c4fa122..318ea171 100644 --- a/ci4/app/Models/Presupuestos/ErrorPresupuesto.php +++ b/ci4/app/Models/Presupuestos/ErrorPresupuesto.php @@ -62,7 +62,7 @@ class ErrorPresupuesto extends Model "presupuesto_id" => $presupuesto_id, "presupuesto_user_id" => $presupuesto_user_id, "error" => $error, - "datos" => json_encode($datos) + "datos_presupuesto" => json_encode($datos) ]); } public function updateComment(int $error_presupuesto_id, string $comment): bool @@ -81,7 +81,8 @@ class ErrorPresupuesto extends Model "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_errores.datos_presupuesto", + "presupuesto_errores.error", "presupuesto_errores.visto", "presupuesto_errores.comment", 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 8f57bb37..9b30380b 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 @@ -25,7 +25,7 @@
-
+ + +
+
-
- - -
+ + +
+
+
diff --git a/httpdocs/assets/js/safekat/pages/configuracion/error_presupuesto/errorPresupuestoForm.js b/httpdocs/assets/js/safekat/pages/configuracion/error_presupuesto/errorPresupuestoForm.js index bbf0510c..c3997179 100644 --- a/httpdocs/assets/js/safekat/pages/configuracion/error_presupuesto/errorPresupuestoForm.js +++ b/httpdocs/assets/js/safekat/pages/configuracion/error_presupuesto/errorPresupuestoForm.js @@ -11,7 +11,11 @@ class ErrorPresupuestoForm { this.inputDatos = this.item.find("#datos-presupuesto") this.inputComments = this.item.find("#comments-presupuesto") this.errorPresupuestoId = this.item.find("#error-presupuesto-id").attr("value") - this.updateBtnIcon = this.item.find("#update-button-icon") + this.updateBtnIcon = this.item.find(".button-update-comment") + this.checkVisto = this.item.find("#error-presupuesto-visto") + this.loader = this.item.find("#update-button-loader") + this.btnIcon = this.item.find("#update-button-icon") + } init() { this.item.on("click",".button-update-comment",this.handlePostErrorPresupuesto.bind(this)) @@ -32,10 +36,15 @@ class ErrorPresupuestoForm { this.inputPresupuestoUserId.val(data.data.presupuestoUser) this.inputDatos.val(data.data.datos) this.inputComments.val(data.data.comment) - this.updateBtnIcon.removeClass() - this.updateBtnIcon.addClass("ti ti-md ti-send") + this.updateBtnIcon.prop("disabled",false) + this.checkVisto.prop("checked",parseInt(data.data.visto) == 1 ? true : false) + this.setLoader(false) } + setLoader(state = true){ + this.loader.prop("hidden",!state) + this.btnIcon.prop("hidden",state) + } handleGetErrorPresupuestoError(){} handlePostErrorPresupuesto() { @@ -43,8 +52,8 @@ class ErrorPresupuestoForm { { "comments" : this.inputComments.val() } - this.updateBtnIcon.removeClass() - this.updateBtnIcon.addClass("spinner-border spinner-border-lg text-secondary") + this.updateBtnIcon.prop("disabled",true) + this.setLoader() const ajax = new Ajax( `/configuracion/errores-presupuesto/edit/${this.errorPresupuestoId}`, data, @@ -55,8 +64,6 @@ class ErrorPresupuestoForm { ajax.post() } handlePostErrorPresupuestoSuccess(){ - this.updateBtnIcon.removeClass() - this.updateBtnIcon.addClass("ti ti-md ti-check") this.handleGetErrorPresupuesto() }