From bd7ab73e7571b028c423da594c9aa780a5287f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= <“jaimejimenezortega@gmail.com”> Date: Sat, 9 Mar 2024 18:48:35 +0100 Subject: [PATCH] =?UTF-8?q?terminado=20con=20un=20mensaje=20de=20alerta=20?= =?UTF-8?q?cuando=20se=20duplican=20y=20tienen=20tipolog=C3=ADas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presupuestos/Cosidotapablanda.php | 63 +++++++++++++++++++ ci4/app/Language/en/Presupuestos.php | 2 + ci4/app/Language/es/Presupuestos.php | 2 + .../Presupuestos/PresupuestoLineaModel.php | 2 + ci4/app/Services/PresupuestoService.php | 2 + .../_commonPartialsBs/_modalMessageDialog.php | 36 +++++++++++ .../themes/backend/vuexy/form/login/index.php | 1 - .../_lineasPresupuestoItems.php | 9 +-- .../viewCosidotapablandaForm.php | 60 +++++++++++------- 9 files changed, 150 insertions(+), 27 deletions(-) create mode 100644 ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index b118a844..41f5c28d 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -383,6 +383,69 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController } // end function edit(...) + /** + * Delete the designated resource object from the model. + * + * @param int $id + * + * @return array an array + */ + public function delete($id = null) + { + if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) { + $objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc)); + } else { + $objName = lang('Basic.global.record'); + } + + if (!$this->soft_delete){ + + if (!$this->model->delete($id)) { + return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + } + } + else{ + $datetime = (new \CodeIgniter\I18n\Time("now")); + $rawResult = $this->model->where('id',$id) + ->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'), + 'is_deleted' => $this->delete_flag]) + ->update(); + if (!$rawResult) { + return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + } + + } + + // Se borran las lineas de presupuesto + $model = new PresupuestoLineaModel(); + $model->where("presupuesto_id", $id)->delete(); + + // Se borran las direcciones de presupuesto + $model = new PresupuestoDireccionesModel(); + $model->where("presupuesto_id", $id)->delete(); + + // Se borran los servicios de acabado + $model = new PresupuestoAcabadosModel(); + $model->where("presupuesto_id", $id)->delete(); + + // Se borran los servicios de preimpresion + $model = new PresupuestoPreimpresionesModel(); + $model->where("presupuesto_id", $id)->delete(); + + // Se borran los servicios de encuadernacion + $model = new PresupuestoEncuadernacionesModel(); + $model->where("presupuesto_id", $id)->delete(); + + // Se borran los servicios de manipulado + $model = new PresupuestoManipuladosModel(); + $model->where("presupuesto_id", $id)->delete(); + + // $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented + $message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]); + $response = $this->respondDeleted(['id' => $id, 'msg' => $message]); + return $response; + } + public function datatable() { diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 071fcce8..eba24c4a 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -156,6 +156,8 @@ return [ 'cantidad' => 'Quantity', 'duplicado' => 'DUPLICATED', + 'duplicarConTipologias' => 'The budget contains budget lines with typology data. The budget will be duplicated with the same typologies', + 'validation' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'integer' => 'The {field} field must contain an integer.', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 6e971e3f..2231446b 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -247,6 +247,8 @@ return [ 'tiradaEnvio' => 'Coste Envío', 'tiradaImpresion' => 'Coste Impresión', 'duplicado' => 'DUPLICADO', + + 'duplicarConTipologias' => 'El presupuesto contiene lineas de presupuesto con datos de tipologías. Se va a duplicar el presupuesto con las mismas tipologías', 'validation' => [ diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php index dbf15f72..a27d5d2a 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -424,6 +424,8 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel } } + + } diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index c85fc822..e2b865e4 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -196,12 +196,14 @@ class PresupuestoService extends BaseService $resultado_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo) ? 'color' : $tipo); if($resultado_tarifa == null){ + /* $info = [ 'maquina_id' => $maquina->maquina_id, 'uso' => $uso, 'tipo' => is_array($tipo) ? 'color' : $tipo ]; log_message("error","No se ha encontrado tarifa para la maquina {maquina_id} y el uso {uso} y el tipo {tipo}", $info); + */ return []; } else{ diff --git a/ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php b/ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php new file mode 100644 index 00000000..1594aa27 --- /dev/null +++ b/ci4/app/Views/themes/_commonPartialsBs/_modalMessageDialog.php @@ -0,0 +1,36 @@ +
= lang("App.login_subtitle") ?>