From 64282249211d2b09edf7a0b6ce93db73ca0de7cd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Mar 2024 20:40:27 +0100 Subject: [PATCH 1/2] =?UTF-8?q?falta=20el=20mensaje=20de=20dejar=20tipolog?= =?UTF-8?q?=C3=ADas=20o=20por=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presupuestos/Cosidotapablanda.php | 79 ++++++++++++++++++- ci4/app/Controllers/Test.php | 26 +++--- ...y.php => PresupuestoManipuladosEntity.php} | 0 ci4/app/Language/en/Presupuestos.php | 2 +- ci4/app/Language/es/Presupuestos.php | 1 + .../PresupuestoDireccionesModel.php | 2 +- .../Presupuestos/PresupuestoLineaModel.php | 13 +++ .../cosidotapablanda/_datosEnvios.php | 2 +- .../_lineasPresupuestoItems.php | 60 ++++---------- .../_presupuestoDireccionesForm.php | 1 + .../viewCosidotapablandaForm.php | 40 +++++++++- 11 files changed, 162 insertions(+), 64 deletions(-) rename ci4/app/Entities/Presupuestos/{PresupuestoManipuladosEntity copy.php => PresupuestoManipuladosEntity.php} (100%) mode change 100755 => 100644 diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 38ddd816..b118a844 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -620,6 +620,27 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $this->respond($data); } + else if ($tipo == 'duplicar'){ + $presupuesto_id = $reqData['presupuesto_id'] ?? -1; + $result = $this->duplicarPresupuesto($presupuesto_id); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + if($result['success']){ + $data = [ + 'id' => $result['id'], + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else{ + $data = [ + 'error' => $result['message'], + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + } + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); $data = [ @@ -685,7 +706,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController } - public function getCompIntData($uso, $datosPedido, $papel_generico, $gramaje, $isColor, $isHq, $cliente_id, $datosTipolog = null, $a_favor_fibra = false) + private function getCompIntData($uso, $datosPedido, $papel_generico, $gramaje, $isColor, $isHq, $cliente_id, $datosTipolog = null, $a_favor_fibra = false) { $tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro'); @@ -740,9 +761,63 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $lineas; } + private function duplicarPresupuesto($id){ + + try{ + + $presupuesto = $this->model->find($id); + $presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado'); + $new_id = $this->model->insert($presupuesto); + + $presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); + foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) { + $acabado->presupuesto_id = $new_id; + $presupuestoAcabadosModel->insert($acabado); + } + + $presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel'); + foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) { + $encuadernacion->presupuesto_id = $new_id; + $presupuestoEncuadernacionesModel->insert($encuadernacion); + } + + $presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel'); + foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) { + $manipulado->presupuesto_id = $new_id; + $presupuestoManipuladosModel->insert($manipulado); + } + + $presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel'); + foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) { + $preimpresion->presupuesto_id = $new_id; + $presupuestoPreimpresionesModel->insert($preimpresion); + } + + $presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); + foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) { + $direccion->presupuesto_id = $new_id; + $presupuestoDireccionesModel->insert($direccion); + } + + $presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id); + + return [ + 'success' => true, + 'id' => $new_id + ]; + + }catch(\Exception $e){ + return [ + 'success' => false, + 'message' => $e->getMessage() + ]; + } + } - public function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $cliente_id, $datosTipolog = null) + + private function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $cliente_id, $datosTipolog = null) { $uso = 'interior'; diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 0938429f..9b7e760b 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -6,6 +6,7 @@ use App\Controllers\BaseController; use App\Models\Configuracion\MaquinasTarifasImpresionModel; use App\Models\Configuracion\PapelGenericoModel; use App\Models\Configuracion\MaquinaModel; +use App\Models\Presupuestos\PresupuestoModel; use App\Services\PresupuestoService; class Test extends BaseController @@ -16,23 +17,18 @@ class Test extends BaseController public function index() { - $json_text = '[{"paginas":"150","paginas_impresion":0,"papel":"3","papel_impresion_id":"45","gramaje":"90.00","maquina_id":"33","row_id":"lp_bnhq"},{"paginas":"150","paginas_impresion":0,"papel":"3","papel_impresion_id":"45","gramaje":"90.00","maquina_id":"97","row_id":"lp_colorhq"},{"paginas":"2","paginas_impresion":0,"papel":"5","papel_impresion_id":"49","gramaje":"270.00","maquina_id":"55","row_id":"lp_cubierta"},{"paginas":"4","paginas_impresion":0,"papel":"1","papel_impresion_id":"91","gramaje":"200.00","maquina_id":"55","row_id":"lp_sobrecubierta"}]'; + $presupuestoModel = model('App\Models\Presupuestos\PresupuestoModel'); + $presupuesto = $presupuestoModel->find(44); + + $presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); + echo '
';
-        var_dump($this->test_get_tirada_alt(
-            tirada: 200,
-            merma: 20,  
-            tipo_impresion_id: 4,
-            json_data: $json_text,
-            cliente_id: 685,
-            ancho: 150,
-            alto: 210,
-            solapas_cubierta: 0,
-            solapas_ancho_cubierta: 0,
-            solapas_sobrecubierta: 0,
-            solapas_ancho_sobrecubierta: 0,
-            lomo: 16.53
-        ));
+        $presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
+        $presupuestoLineaModel->duplicateLineasPresupuesto(48, 75);
         echo '
'; + + + } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity copy.php b/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php old mode 100755 new mode 100644 similarity index 100% rename from ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity copy.php rename to ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 6c0b3f2a..071fcce8 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -154,7 +154,7 @@ return [ 'envios' => 'Shipments', 'cantidad' => 'Quantity', - + 'duplicado' => 'DUPLICATED', 'validation' => [ 'decimal' => 'The {field} field must contain a decimal number.', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index b208a914..6e971e3f 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -246,6 +246,7 @@ return [ 'tiradaMargen' => 'Margen', 'tiradaEnvio' => 'Coste Envío', 'tiradaImpresion' => 'Coste Impresión', + 'duplicado' => 'DUPLICADO', 'validation' => [ diff --git a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php index b70c2a3a..398dc0fa 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php @@ -47,7 +47,7 @@ class PresupuestoDireccionesModel extends \App\Models\GoBaseModel "entregaPieCalle", ]; - protected $returnType = "App\Entities\Clientes\ClienteDireccionesEntity"; + protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity"; public static $labelField = "id"; diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php index 6a93f8f8..dbf15f72 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -411,6 +411,19 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel return $builder; } + public function duplicateLineasPresupuesto($presupuesto_id, $new_presupuesto_id) + { + $lineas = $this->getLineasPresupuesto($presupuesto_id); + $lineas = json_decode(json_encode($lineas), true); + foreach ($lineas as $linea) { + $linea['presupuesto_id'] = $new_presupuesto_id; + unset($linea['id']); + $this->db + ->table($this->table . " t1") + ->insert($linea); + } + } + } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php index 51f6898d..b973d9c5 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php @@ -382,7 +382,7 @@ function load_datos_envios(){ }) .draw(); checkInsertar() - + updateTotales(false, false, true) }); $('#tableOfDireccionesEnvio').bind('draw.dt', update_tiradas_alternativas); }) diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index f1b49fc6..bbfb8b10 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -1254,12 +1254,7 @@ $('#btn_addLinea').on("click", function (e) { }) -// Funcion para actualizar el total de coste de la linea dependiendo -// de los checkboxes que esten seleccionados -function update_total_linea(e){ - - -} + endSection() ?> @@ -1443,7 +1438,7 @@ function calcularPresupuesto_bn(input_data={}, updatedTipologias = false){ datos.a_favor_fibra = $('#lp_bn_aFavorFibra').prop('checked') } - if(updatedTipologias){ + if(updatedTipologias && $('#lp_bn_gotaNegro').length){ datos.gota_negro= $('#lp_bn_gotaNegro').val() datos.gota_color= $('#lp_bn_gotaColor').val() datos.negro= $('#lp_bn_cobNegro').val() @@ -1591,9 +1586,6 @@ function eventos_lp_bn(isInkjet = false){ $('#lp_bn_defecto').bind("click", por_defecto_lp_bn); $('#lp_bn_aFavorFibra').bind("change", change_lp_bn_aFavorFibra); } - - $('#lp_bn_checkPapel').bind("change", {id_linea: 'lp_bn'}, update_total_linea); - $('#lp_bn_checkClicks').bind("change", {id_linea: 'lp_bn'}, update_total_linea); } endSection() ?> @@ -1798,7 +1790,7 @@ function calcularPresupuesto_color(input_data={}, updatedTipologias = false){ : v }; - if(updatedTipologias){ + if(updatedTipologias && $('#lp_color_gotaNegro').length){ datos.gota_negro= $('#lp_color_gotaNegro').val() datos.gota_color= $('#lp_color_gotaColor').val() datos.negro= $('#lp_color_cobNegro').val() @@ -1922,9 +1914,6 @@ function eventos_lp_color(isInkjet = false){ $('#lp_color_defecto').bind("click", por_defecto_lp_color); $('#lp_color_aFavorFibra').bind("change", change_lp_color_aFavorFibra); } - - $('#lp_color_checkPapel').bind("change", {id_linea: 'lp_color'}, update_total_linea); - $('#lp_color_checkClicks').bind("change", {id_linea: 'lp_color'}, update_total_linea); } endSection() ?> @@ -2126,7 +2115,7 @@ function calcularPresupuesto_bnhq(input_data={}, updatedTipologias = false){ : v }; - if(updatedTipologias){ + if(updatedTipologias && $('#lp_bnhq_gotaNegro').length){ datos.gota_negro= $('#lp_bnhq_gotaNegro').val() datos.gota_color= $('#lp_bnhq_gotaColor').val() datos.negro= $('#lp_bnhq_cobNegro').val() @@ -2250,9 +2239,6 @@ function eventos_lp_bnhq(isInkjet = false){ $('#lp_bnhq_defecto').bind("click", por_defecto_lp_bnhq); $('#lp_bnhq_aFavorFibra').bind("change", change_lp_bnhq_aFavorFibra); } - - $('#lp_bnhq_checkPapel').bind("change", {id_linea: 'lp_bnhq'}, update_total_linea); - $('#lp_bnhq_checkClicks').bind("change", {id_linea: 'lp_bnhq'}, update_total_linea); } endSection() ?> @@ -2462,7 +2448,7 @@ function calcularPresupuesto_colorhq(input_data={}, updatedTipologias = false){ : v }; - if(updatedTipologias){ + if(updatedTipologias && $('#lp_colorhq_gotaNegro').length){ datos.gota_negro= $('#lp_colorhq_gotaNegro').val() datos.gota_color= $('#lp_colorhq_gotaColor').val() datos.negro= $('#lp_colorhq_cobNegro').val() @@ -2587,11 +2573,7 @@ function eventos_lp_colorhq(isInkjet = false){ $('.lp-colorhq-tipologia').bind("change", change_lp_colorhq_tipologia); $('#lp_colorhq_defecto').bind("click", por_defecto_lp_colorhq); $('#lp_colorhq_aFavorFibra').bind("change", change_lp_colorhq_aFavorFibra); - } - - $('#lp_colorhq_checkPapel').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea); - $('#lp_colorhq_checkClicks').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea); - + } } endSection() ?> @@ -2927,8 +2909,6 @@ function eventos_lp_rot_bn(){ $('#lp_rot_bn_aFavorFibra').bind("change", change_lp_rot_bn_aFavorFibra); $('.lp-rot-bn-tipologia').bind("change", change_lp_rot_bn_tipologia); $('#lp_rot_bn_defecto').bind("click", por_defecto_lp_rot_bn); - $('#lp_rot_bn_checkPapel').bind("change", {id_linea: 'lp_rot_bn'}, update_total_linea); - $('#lp_rot_bn_checkClicks').bind("change", {id_linea: 'lp_rot_bn'}, update_total_linea); } endSection() ?> @@ -3272,8 +3252,6 @@ function eventos_lp_rot_color(){ $('#lp_rot_color_aFavorFibra').bind("change", change_lp_rot_color_aFavorFibra); $('.lp-rot-color-tipologia').bind("change", change_lp_rot_color_tipologia); $('#lp_rot_color_defecto').bind("click", por_defecto_lp_rot_color); - $('#lp_rot_color_checkPapel').bind("change", {id_linea: 'lp_rot_color'}, update_total_linea); - $('#lp_rot_color_checkClicks').bind("change", {id_linea: 'lp_rot_color'}, update_total_linea); } endSection() ?> @@ -3542,8 +3520,6 @@ function eventos_lp_cubierta(){ $('#lp_cubierta_maquina').bind("change", change_lp_cubierta_maquina); $('#lp_cubierta_paginas').bind("change", change_lp_cubierta_paginas); $('#lp_cubierta_vercalculos').bind("click", {rowId: 'lp_cubierta'}, verCalculosInkjet); - $('#lp_cubierta_checkPapel').bind("change", {id_linea: 'lp_cubierta'}, update_total_linea); - $('#lp_cubierta_checkClicks').bind("change", {id_linea: 'lp_cubierta'}, update_total_linea); } @@ -3805,8 +3781,6 @@ function eventos_lp_sobrecubierta(){ $('#lp_sobrecubierta_maquina').bind("focus", set_lp_sobrecubierta_maquina); $('#lp_sobrecubierta_maquina').bind("change", change_lp_sobrecubierta_maquina); $('#lp_sobrecubierta_vercalculos').bind("click", {rowId: 'lp_sobrecubierta'}, verCalculosInkjet); - $('#lp_sobrecubierta_checkPapel').bind("change", {id_linea: 'lp_sobrecubierta'}, update_total_linea); - $('#lp_sobrecubierta_checkClicks').bind("change", {id_linea: 'lp_sobrecubierta'}, update_total_linea); } @@ -4005,8 +3979,6 @@ function eventos_lp_guardas(isInkjet = false){ $('#lp_guardas_maquina').bind("focus", set_lp_guardas_maquina); $('#lp_guardas_maquina').bind("change", calcularPresupuesto_guardas); $('#lp_guardas_paginas').bind("change", change_lp_guardas_paginas); - $('#lp_guardas_checkPapel').bind("change", {id_linea: 'lp_guardas'}, update_total_linea); - $('#lp_guardas_checkClicks').bind("change", {id_linea: 'lp_guardas'}, update_total_linea); if(isInkjet){ $('#lp_guardas_vercalculos').bind("click", {rowId: 'lp_guardas'}, verCalculosInkjet); @@ -4414,7 +4386,7 @@ async function fill_bbdd_from_lp(presupuesto_id){ // Handle error here console.log(jqXHR) }); - + } function updateLineasPresupuesto(){ @@ -4422,27 +4394,29 @@ function updateLineasPresupuesto(){ $('#tableLineasPresupuesto tbody tr:visible ').each(function(){ if(this.id.endsWith('lp_bn')){ - checkComparadorInt(false, false, true, false); + calcularPresupuesto_bn({}, true); } else if(this.id.endsWith('lp_bnhq')){ - checkComparadorInt(false, true, true, false); + calcularPresupuesto_bnhq({}, true); } else if(this.id.endsWith('lp_color')){ - checkComparadorInt(true, false, true, false); + calcularPresupuesto_color({}, true); } else if(this.id.endsWith('lp_colorhq')){ - checkComparadorInt(true, true, true, false); + calcularPresupuesto_colorhq({}, true); } else if(this.id.endsWith('lp_rot_bn')){ - checkComparadorInt(false, false, false, true) + calcularPresupuesto_rot_bn(false, true, {}) } else if(this.id.endsWith('lp_rot_color')){ - checkComparadorInt(true,false, false, true); + calcularPresupuesto_rot_color(false, true, {}) } else if(this.id.endsWith('_cubierta')){ - checkComparadorCubierta(true) + calcularPresupuesto_cubierta(false, {}) + } + else if(this.id.endsWith('_guardas')){ + calcularPresupuesto_guardas(false, {}) } - }) } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm.php index e8baeae1..ee35fd5f 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm.php @@ -250,6 +250,7 @@ $('#saveDireccionEnvio').on('click', function(){ }) } checkInsertar() + updateTotales(false, false, true) $('#addressForm').modal("hide"); } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 594f467f..48fe8d43 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -43,7 +43,12 @@ /> "btn btn-dark float-start me-sm-3 me-1",'target' => '_blank']) ?> - "btn btn-info float-start me-sm-3 me-1",]) ?> + " + /> "btn btn-secondary float-start",]) ?> @@ -55,6 +60,39 @@ endSection() ?> + + + + +section("additionalInlineJs") ?> + $('#cloneForm').on('click', function(e) { + $.ajax({ + type: 'post', + url: '', + + data: { + tipo: 'duplicar', + presupuesto_id: id, + : v + }, + dataType: 'json', + success:function(response){ + + token=response.; + yeniden(token); + // redirect + new_location = '' + response.id + window.location.href = new_location; + } + }).fail(function (jqXHR, textStatus, error) { + // Handle error here + console.log(jqXHR) + }); + }); + + +endSection() ?> + 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 2/2] =?UTF-8?q?terminado=20con=20un=20mensaje=20de=20alert?= =?UTF-8?q?a=20cuando=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 @@ + + +section('additionalInlineJs') ?> + + +function asyncMessageDialog(title, msg, callback) { + var $messageDialog = $("#modalMessage"); + $messageDialog.modal('show'); + $("#labelTitleMessageDialog").html(title); + $("#labelMsgMessageDialog").html(msg); + $("#okButton").off('click').click(function () { + callback(); + $confirmDialog.modal("hide"); + }); + } + +endSection() ?> + + diff --git a/ci4/app/Views/themes/backend/vuexy/form/login/index.php b/ci4/app/Views/themes/backend/vuexy/form/login/index.php index 0f7dda27..b9f0c32a 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/login/index.php +++ b/ci4/app/Views/themes/backend/vuexy/form/login/index.php @@ -33,7 +33,6 @@

👋

-

diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index bbfb8b10..49105ce8 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -2722,7 +2722,7 @@ function change_lp_rot_bn_aFavorFibra(){ } -function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=false, input_data={}){ +async function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=false, input_data={}){ const dimension = getDimensionLibro(); @@ -2768,7 +2768,7 @@ function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=fals datos.amarillo= $('#lp_rot_bn_cobAmarillo').val() } - $.ajax({ + await $.ajax({ type: "POST", url: "/cosidotapablanda/datatable", data: datos, @@ -2826,11 +2826,12 @@ function change_lp_rot_bn_tipologia(){ ){ calcularPresupuesto_rot_bn(false,true); + } } -function por_defecto_lp_rot_bn(){ +function por_defecto_lp_rot_bn(wait_result = false){ if( parseInt($('#lp_rot_bn_paginas').val())>0 && parseInt($('#lp_rot_bn_papel option:selected').val())>0 && @@ -2838,7 +2839,7 @@ function por_defecto_lp_rot_bn(){ parseInt($('#lp_rot_bn_papelImpresion option:selected').val())>0 ){ - calcularPresupuesto_rot_bn(false); + calcularPresupuesto_rot_bn(false); } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 48fe8d43..1e354ad2 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -57,6 +57,7 @@ + endSection() ?> @@ -65,29 +66,44 @@ section("additionalInlineJs") ?> - $('#cloneForm').on('click', function(e) { - $.ajax({ - type: 'post', - url: '', - - data: { - tipo: 'duplicar', - presupuesto_id: id, - : v - }, - dataType: 'json', - success:function(response){ - - token=response.; - yeniden(token); - // redirect - new_location = '' + response.id - window.location.href = new_location; + $('#cloneForm').on('click', async function(e) { + + // se comprueba que no haya lineas de presupuesto en el que exista la variable gotaNegro + var gotaNegro = false + $("#tableLineasPresupuesto").DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) { + var rowData = this.data(); + if(rowData.hasOwnProperty('gotaNegro')){ + gotaNegro = true + return; } - }).fail(function (jqXHR, textStatus, error) { - // Handle error here - console.log(jqXHR) - }); + }) + + if(gotaNegro){ + asyncMessageDialog('', '', function() { + $.ajax({ + type: 'post', + url: '', + + data: { + tipo: 'duplicar', + presupuesto_id: id, + : v + }, + dataType: 'json', + success:function(response){ + + token=response.; + yeniden(token); + // redirect + new_location = '' + response.id + window.location.href = new_location; + } + }).fail(function (jqXHR, textStatus, error) { + // Handle error here + console.log(jqXHR) + }); + }) + } });