From 7b42d497e0facf366b2b066b12b174b3ffd33143 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 13 Jul 2023 13:41:12 +0200 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20la=20comprobaci=C3=B3n=20de=20qu?= =?UTF-8?q?e=20no=20se=20solape=20el=20alto=20en=20maquinas=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Language/en/MaquinasPorDefecto.php | 2 ++ ci4/app/Language/es/MaquinasPorDefecto.php | 2 ++ .../Configuracion/MaquinasDefectoModel.php | 28 ++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ci4/app/Language/en/MaquinasPorDefecto.php b/ci4/app/Language/en/MaquinasPorDefecto.php index 524b38d2..61b3ddae 100644 --- a/ci4/app/Language/en/MaquinasPorDefecto.php +++ b/ci4/app/Language/en/MaquinasPorDefecto.php @@ -32,8 +32,10 @@ return [ 'userUpdatedId' => 'User Updated ID', 'validation' => [ 'error_ancho_overlap' => 'The range [Min Width, Max Width] is overlapped with another one for the selected type.', + 'error_alto_overlap' => 'The range [Min Height, Max Height] is overlapped with another one for the selected type.', 'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.', 'error_ancho_range' => 'The field Min Width must be lower than the field Max Width', + 'error_alto_range' => 'The field Min Height must be lower than the field Max Height', 'error_tirada_range' => 'The field Min Printing must be lower than the field Max Printing', 'alto_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', diff --git a/ci4/app/Language/es/MaquinasPorDefecto.php b/ci4/app/Language/es/MaquinasPorDefecto.php index fc9a9bf8..08d02125 100644 --- a/ci4/app/Language/es/MaquinasPorDefecto.php +++ b/ci4/app/Language/es/MaquinasPorDefecto.php @@ -32,8 +32,10 @@ return [ 'userUpdatedId' => 'User Updated ID', 'validation' => [ 'error_ancho_overlap' => 'El rango [Ancho Min, Ancho Max] se solapa con otro existente para el tipo seleccionado.', + 'error_alto_overlap' => 'El rango [Alto Min, Alto Max] se solapa con otro existente para el tipo seleccionado.', 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', 'error_ancho_range' => 'El campo Ancho Min debe ser menor que el campo Ancho Max', + 'error_alto_range' => 'El campo Alto Min debe ser menor que el campo Alto Max', 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'alto_max' => [ 'decimal' => 'El campo {field} debe contener un nĂºmero decimal.', diff --git a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php index 64d39383..f17287dd 100644 --- a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php +++ b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php @@ -191,15 +191,19 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel return lang('MaquinasPorDefecto.validation.error_tirada_range'); } - $anchos = $this->db + if(floatval($data["alto_min"])>= floatval($data["alto_max"])){ + return lang('MaquinasPorDefecto.validation.error_alto_range'); + } + + $rows = $this->db ->table($this->table) - ->select("id, ancho_min, ancho_max") + ->select("id, ancho_min, ancho_max, alto_min, alto_max, tirada_min, tirada_max") ->where("is_deleted", 0) ->where("tipo", $data["tipo"]) ->get()->getResultObject(); - foreach ($anchos as $row) { + foreach ($rows as $row) { if (!is_null($id)){ if($row->id == $id){ continue; @@ -209,20 +213,9 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel $row->ancho_min, $row->ancho_max)){ return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); } - } - - $tiradas = $this->db - ->table($this->table) - ->select("id, tirada_min, tirada_max") - ->where("is_deleted", 0) - ->where("tipo", $data["tipo"]) - ->get()->getResultObject(); - - foreach ($tiradas as $row) { - if (!is_null($id)){ - if($row->id == $id){ - continue; - } + if($this->check_overlap(floatval($data["alto_min"]), floatval($data["alto_max"]), + $row->alto_min, $row->alto_max)){ + return lang('MaquinasPorDefecto.validation.error_alto_overlap'); } if($this->check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), $row->tirada_min, $row->tirada_max)){ @@ -230,6 +223,7 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel } } + return ""; }