From 40acf85725d6c523d75d5baaf35c4613b009e3a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2024 17:02:07 +0100 Subject: [PATCH 01/12] arreglados bug en el tamanio, al guardar cuando hay tamanio personalizado en en update tarifas enc horas --- .../Presupuestos/Cosidotapablanda.php | 8 +++++ .../PresupuestoEncuadernacionesModel.php | 2 +- .../cosidotapablanda/_datosLibroItems.php | 36 +++++++++++-------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index a822c826..10ebbea4 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -100,6 +100,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController // JJO $sanitizedData['user_created_id'] = $session->id_user; + if ($sanitizedData['papel_formato_id'] == null) { + $sanitizedData['papel_formato_id'] = 0; + } + $noException = true; if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -218,6 +222,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $sanitizedData['papel_formato_personalizado'] = false; } + if ($this->request->getPost('papel_formato_id') == null) { + $sanitizedData['papel_formato_id'] = 0; + } + $noException = true; if($sanitizedData['papel_formato_id'] == null && $sanitizedData['papel_formato_ancho'] == null && $sanitizedData['papel_formato_alto'] == null){ diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index 4aa222ac..7d6d6ca3 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -253,7 +253,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel array_push($ret_array, (object)[ - 'tarifa_id'=> $tarifa['tarifa_id'], + 'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id, 'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre, 'precio_unidad'=> $result_data[0], 'total'=> $result_data[1], diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 4b80201e..a1f4cc08 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -73,13 +73,13 @@
- papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control" value="papel_formato_ancho) ?>"> + papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control formato_libro" value="papel_formato_ancho) ?>">
- papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control" value="papel_formato_alto) ?>"> + papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control formato_libro" value="papel_formato_alto) ?>">
@@ -359,7 +359,7 @@ $('#papelFormatoPersonalizado').on("click",function(){ document.getElementById("papelFormatoAncho").style.display = "block"; document.getElementById("papelFormatoAlto").style.display = "block"; $('#papelFormatoId').next(".select2-container").hide(); - $('#papelFormatoId').val('').change(); + $('#papelFormatoId').val(0).change(); document.getElementById("label_papelFormatoId").innerHTML = " (" + " x )*"; @@ -404,23 +404,31 @@ $('#papelFormatoPersonalizado').on("click",function(){ }); -$('#papelFormatoId').on('select2:select', function (e){ +$('#papelFormatoId').on('select2:select', event_change_formato) +$('.formato_libro').on('change', event_change_formato) + +function event_change_formato(){ ancho_libro = getDimensionLibro().ancho; alto_libro = getDimensionLibro().alto; + + checkPaginasPresupuesto() + updateLineasPresupuesto() + // Si es negro o color + if ($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color') { + $('#compPaginasNegro').trigger('change') + } + // Si es negrohq o colorhq + if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq') { + $('#compPaginasNegrohq').trigger('change'); + } + update_servicios(false) -}) +} -$('#papelFormatoAncho').on('change', function (e){ - ancho_libro = getDimensionLibro().ancho; - alto_libro = getDimensionLibro().alto; -}) - -$('#papelFormatoAlto').on('change', function (e){ - ancho_libro = getDimensionLibro().ancho; - alto_libro = getDimensionLibro().alto; -}) $("#solapas").on("click", function () { From 2d5bd6a78ceca0b737654cbaa842a81e6699d177 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2024 17:09:56 +0100 Subject: [PATCH 02/12] cambiada la busqueda para la dimension en tarifa enc. Ahora se tiene en cuenta si es apaisado --- ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php index c4eb90e9..7dc92afe 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -137,6 +137,10 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel public function getTarifaPresupuestoEncuadernacion($tarifa_id, $paginas, $tirada, $ancho, $alto, $proveedor_id=-1){ + // para los apaisados + $dim_h = $ancho<$alto?$ancho:$alto; + $dim_v = $ancho<$alto?$alto:$ancho; + $builder = $this->db ->table($this->table . " t1") ->select( @@ -159,10 +163,10 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel $builder->where('t2.tirada_max >=', $tirada); $builder->where('t3.paginas_libro_min <=', $paginas); $builder->where('t3.paginas_libro_max >=', $paginas); - $builder->where('t4.ancho_min <=', $ancho); - $builder->where('t4.ancho_max >=', $ancho); - $builder->where('t4.alto_min <=', $alto); - $builder->where('t4.alto_max >=', $alto); + $builder->where('t4.ancho_min <=', $dim_h); + $builder->where('t4.ancho_max >', $dim_h); + $builder->where('t4.alto_min <=', $dim_v); + $builder->where('t4.alto_max >=', $dim_v); if($proveedor_id != -1){ $builder->where('t2.proveedor_id', $proveedor_id); From 177522ce4945e0ab0cdb2c66b60f9d8f1207e714 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2024 20:00:44 +0100 Subject: [PATCH 03/12] trabaando en comparador sobre cubierta --- ci4/app/Controllers/Test.php | 9 +- .../Configuracion/PapelGenericoModel.php | 10 - .../_datosPresupuestoClienteItems.php | 179 +++++++++++++++++- .../_lineasPresupuestoItems.php | 18 +- .../cosidotapablanda/comparador.js | 51 ++++- 5 files changed, 248 insertions(+), 19 deletions(-) diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 7fcf3f0d..d2f45369 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -18,7 +18,7 @@ class Test extends BaseController public function index() { echo '
';
-        \var_dump($this->get_precio_tarifa(18,300,10,150,210,-1,30));
+        ($this->getPapelesSobrecubierta());
         echo '
'; /* @@ -179,6 +179,13 @@ class Test extends BaseController var_dump($data); } + public function getPapelesSobrecubierta(){ + $model = model('App\Models\Configuracion\PapelGenericoModel'); + $data = $model->getPapelForComparador('colorhq', false, true, false); + + var_dump($data); + } + public function getPapelesGuardas(){ $model = model('App\Models\Configuracion\PapelGenericoModel'); $data = $model->getPapelForComparador('color', false, false, false, true); diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index cc1b37c7..e9a0a536 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -127,21 +127,11 @@ class PapelGenericoModel extends \App\Models\GoBaseModel $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); } - else{ - if(!$is_guardas){ - $builder->where("t2.cubierta", 0); - } - } if($is_sobrecubierta==true){ $builder->where("t2.sobrecubierta", 1); $builder->where("t5.uso", 'sobrecubierta'); } - else{ - if(!$is_guardas){ - $builder->where("t2.sobrecubierta", 0); - } - } if($is_cubierta==false && $is_sobrecubierta==false){ $builder->where("t5.uso", 'interior'); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php index c0f2e6fb..b86f4d5e 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php @@ -215,6 +215,41 @@ + +
+
+

+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
@@ -441,7 +476,7 @@ - : + : 0.00 @@ -682,9 +717,19 @@ allowClear: false, }); + $('#compPapelSobrecubierta').select2({ + allowClear: false, + }); + + $('#compGramajeSobrecubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + $('#encuadernacion').select2({ allowClear: false, }); + $('#compCarasCubierta').select2({ @@ -711,6 +756,19 @@ computarPaginasColor($('#compPosPaginasColor').val()); } + $('#compSobrecubierta').on('change', function(){ + if ($('#compSobrecubierta').val()==1){ + value = false + } + else{ + value = 'disabled' + $('#compPapelSobrecubierta').val(0) + $('#compGramajeSobrecubierta').val('') + } + $('#compPapelSobrecubierta').prop('disabled', value); + $('#compGramajeSobrecubierta').prop('disabled', value); + }) + function init_lineas_comparador(){ var comp_data = @@ -1292,6 +1350,82 @@ } } + $('.comp_sobrecubierta_items').on('change', function (){ + + checkComparadorSobrecubierta() + }); + + + function checkComparadorSobrecubierta(actualizarLinea = false){ + + if ($('#compSobrecubierta option:selected').val() == 1 && + $('#compPapelSobrecubierta').select2('data').length > 0 && + $('#compGramajeSobrecubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + tipo_impresion_id: , + type: 'sobrecubierta', + paginas: 4, + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + lomo: getLomoLineasPresupuesto(), + lomo_cubierta: getLomoCubiertaLineasPresupuesto(), + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: parseInt($('#solapas_ancho').val()), + papel_generico_id: $('#compPapelSobrecubierta').select2('data')[0].id, + papel_generico: $('#compPapelSobrecubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeSobrecubierta').select2('data')[0].text.trim() , + cliente_id: $('#clienteId').find(":selected").val(), + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + console.log(data) + + clearSobrecubierta(); + + if(data.lineas.length >0){ + + fillCubierta(data); + selectCubiertaLineas(); + $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); + $('#insertarCubiertaBtn').removeClass('d-none') + if(actualizarLinea){ + var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + fill_lp_cubierta(row, true); + } + } + } + else{ + $('#title_cubierta').html(''); + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearCubierta(); + } + } + $('.comp_negro_items').on('change', function (e) { @@ -1649,6 +1783,49 @@ } }); + $('#compPapelSobrecubierta').on('select2:select', function (e){ + if($('#compPapelSobrecubierta').select2('data')[0].id=='0'){ + $('#compGramajeSobrecubierta').val('').change(); + $('#compGramajeSobrecubierta').prop('disabled', true); + } + else{ + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + $('#compGramajeSobrecubierta').empty().trigger("change"); + $('#compGramajeSobrecubierta').val('').trigger('change'); + $('#compGramajeSobrecubierta').prop('disabled', false); + $('#compPapelSobrecubierta').find('option[value="0"]').remove(); + $('#compGramajeSobrecubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'sobrecubierta', + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + datos: $('#compPapelSobrecubierta').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + function checkDatosPedidoForComp() { 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 bedee5a9..5bc7158f 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 @@ -3491,7 +3491,23 @@ function getLomoLineasPresupuesto(){ try{ tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { var rowData = this.data(); - lomoTotal += parseFloat(rowData.lomo) + if(rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta') + lomoTotal += parseFloat(rowData.lomo) + }) + } + catch(error){ + lomoTotal = 0 + } + return lomoTotal +} + +function getLomoCubiertaLineasPresupuesto(){ + let lomoTotal = 0 + try{ + tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { + var rowData = this.data(); + if(rowData.row_id == 'lp_cubierta') + return parseFloat(rowData.lomo) }) } catch(error){ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 23aa03a6..a608cece 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -329,10 +329,29 @@ function clearIntLineas(is_color) { function clearCubierta() { - $('#tableCompCubierta').DataTable().clear().draw(); - $('#insertarCubiertaBtn').css('display', 'none'); + var tabla = $('#tableCompCubierta').DataTable(); + tabla + .rows(function (idx, data, node) { + return data['tipo'] === 'cubierta'; + }) + .remove() + .draw(); + if(tabla.rows().count()==0) + $('#insertarCubiertaBtn').css('display', 'none'); } +function clearSobrecubierta() { + + var tabla = $('#tableCompCubierta').DataTable(); + tabla + .rows(function (idx, data, node) { + return data['tipo'] === 'sobrecubierta'; + }) + .remove() + .draw(); + if(tabla.rows().count()==0) + $('#insertarCubiertaBtn').css('display', 'none'); +} function clearGuardas() { @@ -397,13 +416,33 @@ function selectCubiertaLineas() { $("#tableCompCubierta").DataTable().rows('.selected').deselect(); - let value_total = 0.00; + cubierta_selected = false; + sobrecubierta_selected = false; if ($("#tableCompCubierta").DataTable().rows().count() > 0) { - $("#tableCompCubierta").DataTable().row(0).nodes().to$().toggleClass('selected'); - value_total = parseFloat($("#tableCompCubierta").DataTable().rows(0).data()[0]['total']) - }; + $("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { + if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') { + $("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); + cubierta_selected = true; + } + if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') { + $("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); + sobrecubierta_selected = true; + } + }); + } + + var table = $("#tableCompCubierta").DataTable(); + var rows = table.rows('.selected').indexes(); + var data = table.rows(rows).data(); + + var value_total = 0.00; + + for (let i = 0; i < data.length; i++) { + + value_total += parseFloat(data[i]['total']) + } $('#total_comp_cubierta').html(value_total.toFixed(2)); From b7bfaac05cde762b56f1ae59e924c23067d27df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= <“jaimejimenezortega@gmail.com”> Date: Tue, 20 Feb 2024 21:35:09 +0100 Subject: [PATCH 04/12] falta las lineas de sobrecubierta --- .idea/modules.xml | 0 .idea/phpunit.xml | 0 .idea/safekat.iml | 0 .../Presupuestos/Cosidotapablanda.php | 11 +- ci4/app/Controllers/Test.php | 95 ++++++++++- .../Clientes/ClientePreciosEntity.php | 0 .../Presupuestos/PresupuestoEntity.php | 4 + ci4/app/Language/es/Presupuestos.php | 4 +- .../Models/Clientes/ClientePreciosModel.php | 0 .../Models/Presupuestos/PresupuestoModel.php | 2 + .../cliente/convert2templateModal.php | 0 .../cosidotapablanda/_datosLibroItems.php | 152 ++++++++++++------ .../_datosPresupuestoClienteItems.php | 92 +++++++---- .../_lineasPresupuestoItems.php | 2 +- .../cosidotapablanda/comparador.js | 28 ++++ .../img/safekat/presupuestos/icon_guardas.png | Bin .../safekat/presupuestos/icon_inkjet_bn.png | Bin .../presupuestos/icon_inkjet_color.png | Bin sk-commit.bat | 0 sk-new-branch.bat | 0 20 files changed, 304 insertions(+), 86 deletions(-) mode change 100644 => 100755 .idea/modules.xml mode change 100644 => 100755 .idea/phpunit.xml mode change 100644 => 100755 .idea/safekat.iml mode change 100644 => 100755 ci4/app/Entities/Clientes/ClientePreciosEntity.php mode change 100644 => 100755 ci4/app/Models/Clientes/ClientePreciosModel.php mode change 100644 => 100755 ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/convert2templateModal.php mode change 100644 => 100755 httpdocs/themes/vuexy/img/safekat/presupuestos/icon_guardas.png mode change 100644 => 100755 httpdocs/themes/vuexy/img/safekat/presupuestos/icon_inkjet_bn.png mode change 100644 => 100755 httpdocs/themes/vuexy/img/safekat/presupuestos/icon_inkjet_color.png mode change 100644 => 100755 sk-commit.bat mode change 100644 => 100755 sk-new-branch.bat diff --git a/.idea/modules.xml b/.idea/modules.xml old mode 100644 new mode 100755 diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml old mode 100644 new mode 100755 diff --git a/.idea/safekat.iml b/.idea/safekat.iml old mode 100644 new mode 100755 diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 10ebbea4..74158c71 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -226,6 +226,13 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $sanitizedData['papel_formato_id'] = 0; } + if ($this->request->getPost('solapas') == null) { + $sanitizedData['solapas'] = 0; + } + if ($this->request->getPost('solapas_sobrecubierta') == null) { + $sanitizedData['solapas'] = 0; + } + $noException = true; if($sanitizedData['papel_formato_id'] == null && $sanitizedData['papel_formato_ancho'] == null && $sanitizedData['papel_formato_alto'] == null){ @@ -795,8 +802,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa); } - if(array_key_exists('error', $linea)) + if(array_key_exists('error', $linea)){ + //array_push($lineas, $linea); for debug continue; + } if($maquina->is_inkjet){ // calculo de tintas diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index d2f45369..335538aa 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -18,7 +18,7 @@ class Test extends BaseController public function index() { echo '
';
-        ($this->getPapelesSobrecubierta());
+        ($this->testLineasSobrecubierta());
         echo '
'; /* @@ -521,6 +521,99 @@ class Test extends BaseController echo ''; + } + + public static function testLineasSobrecubierta() + { + $uso = 'sobrecubierta'; + $tipo = 'colorhq'; + + $datosPedido = (object)array( + 'paginas' => 240, + 'tirada' => 100, + 'merma' => 10, + 'merma_portada' => 10, + 'ancho' => 150, + 'alto' => 210, + 'isCosido' => true, + 'solapas' => false, + ); + + $opciones_papel = array( + 'sobrecubierta' => 1, + 'rotativa' => 0, + ); + + + // Se obtienen los papeles disponibles + $papelimpresionmodel = new \App\Models\Configuracion\PapelImpresionModel(); + $papeles = $papelimpresionmodel->getIdPapelesImpresionForPresupuesto( + papel_generico_id: 1, // Blanco offset + gramaje: 200, + options: $opciones_papel + ); + + echo '
';
+        var_dump($papeles);
+        echo '
'; + + $lineas = array(); + // Para cada papel, se obtienen las maquinas disponibles + foreach ($papeles as $papel) { + + $maquinamodel = new \App\Models\Configuracion\MaquinaModel(); + $maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto( + is_rotativa: 0, + tarifa_tipo: $tipo, + uso_tarifa: 'sobrecubierta', + tirada: $datosPedido->tirada + $datosPedido->merma, + papel_impresion_id: $papel->id, + ); + + echo '
';
+            echo '-------------------------------';
+            echo '
'; + + echo '
';
+            var_dump($maquinas);
+            echo '
'; + + // Se recorren las máquinas y se calcula el coste de linea por cada una + foreach ($maquinas as $maquina) { + + echo '
';
+                echo '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$';
+                echo '
'; + + $tarifamodel = new \App\Models\Configuracion\MaquinasTarifasImpresionModel(); + $tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo); + + echo '
';
+                var_dump($tarifa);
+                echo '
'; + + if(!is_float($tarifa)){ + continue; + } + $linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa); + $linea['fields']['maquina'] = $maquina->maquina; + $linea['fields']['maquina_id'] = $maquina->maquina_id; + $linea['fields']['papel_impresion'] = $papel->nombre; + $linea['fields']['papel_impresion_id'] = $papel->id; + $linea['fields']['paginas'] = $datosPedido->paginas; + $linea['fields']['gramaje'] = 100; + $linea['fields']['papel_generico_id'] = 3; + $linea['fields']['papel_generico'] = 'Blanco offset'; + + array_push($lineas, $linea); + } + } + + echo '
';
+        var_dump($lineas);
+        echo '
'; + + } } \ No newline at end of file diff --git a/ci4/app/Entities/Clientes/ClientePreciosEntity.php b/ci4/app/Entities/Clientes/ClientePreciosEntity.php old mode 100644 new mode 100755 diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index bf6bffd0..59b236ce 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -39,6 +39,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "tirada" => null, "solapas" => false, "solapas_ancho" => 0.0, + "solapas_sobrecubierta" => false, + "solapas_ancho_sobrecubierta" => 0.0, "cosido" => false, "sobrecubiertas" => false, "sobrecubiertas_ancho" => 0.0, @@ -107,6 +109,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "tirada" => "int", "solapas" => "boolean", "solapas_ancho" => "float", + "solapas_sobrecubierta" => "boolean", + "solapas_ancho_sobrecubierta" => "float", "cosido" => "boolean", "sobrecubiertas" => "boolean", "sobrecubiertas_ancho" => "float", diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 29acfd76..d298884b 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -95,7 +95,9 @@ return [ 'sobrecubierta' => 'Sobrecubierta', 'encuadernacion' => 'Encuadernación', 'solapasCubierta' => 'Solapas cubierta', - 'solapasAnchoCubierta' => 'Ancho solapas cubierta', + 'solapasSobrecubierta' => 'Solapas sobrecub.', + 'solapasAnchoCubierta' => 'Ancho solapas cub.', + 'solapasAnchoSobrecubierta' => 'Ancho solapas sobrecub.', 'sinImpresion' => 'Sin impresion', '1cara' => '1 cara', '2caras' => '2 caras', diff --git a/ci4/app/Models/Clientes/ClientePreciosModel.php b/ci4/app/Models/Clientes/ClientePreciosModel.php old mode 100644 new mode 100755 diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 8f8f6acc..b2778b09 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -60,6 +60,8 @@ class PresupuestoModel extends \App\Models\GoBaseModel "tirada", "solapas", "solapas_ancho", + "solapas_sobrecubierta", + "solapas_ancho_sobrecubierta", "cosido", "sobrecubiertas", "sobrecubiertas_ancho", diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/convert2templateModal.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/convert2templateModal.php old mode 100644 new mode 100755 diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index a1f4cc08..e652d5e2 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -15,8 +15,7 @@
- -
+
@@ -24,37 +23,21 @@
- - - -
- -
- -
- solapas == true ? 'checked' : ''; ?>> - -
- -
- -
- -
- +
-
+
+
-
+
@@ -72,30 +55,24 @@
-
+
papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control formato_libro" value="papel_formato_ancho) ?>">
-
+
papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control formato_libro" value="papel_formato_alto) ?>">
- -
- papel_formato_personalizado == true ? 'checked' : ''; ?>> - -
-
-
+
@@ -104,7 +81,7 @@
-
+
@@ -114,29 +91,81 @@
+ + +
- - - -
- - - solapas == true): ?> -
- - @@ -81,6 +82,7 @@ const papelGenericoCubiertaList = ; const papelGenericoRotativaNegroList = ; const papelGenericoRotativaColorList = ; + const papelGenericoGuardasList = ; @@ -545,6 +547,9 @@ var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ return select; } + else{ + return ''; + } } }, {data: 'papel', @@ -947,6 +952,9 @@ function clear_cubierta(){ clear_lp_cubierta(true); } +function clear_sobrecubierta(){ + clear_lp_sobrecubierta(true); +} $('.insertarLinea').on("click", function (e) { @@ -995,7 +1003,15 @@ $('.insertarLinea').on("click", function (e) { var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); for(row of rows){ - fill_lp_cubierta(row, true); + if(row.tipo == 'cubierta') + fill_lp_cubierta(row, true); + } + + clear_sobrecubierta(); + + for(row of rows){ + if(row.tipo == 'sobrecubierta') + fill_lp_sobrecubierta(row, true); } } @@ -1168,6 +1184,25 @@ $('#btn_addLinea').on("click", function (e) { eventos_lp_cubierta() break + case 'lp_sobrecubierta': + var hayLinea = false + for(let number=0;number', 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({tipo_maquina: 'toner'}, 'lp_sobrecubierta', 'lp-sobrecubierta'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_sobrecubierta() + break + case 'lp_guardas': var hayLinea = false for(let number=0;number + + + +async function set_lp_sobrecubierta_gramaje(){ + + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_sobrecubierta(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'sobrecubierta', + datos: $('#lp_sobrecubierta_papel option:selected').val() , + tipoLinea: "colorhq", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('
+ + + +
+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
- -
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php index 24fb87d6..f07290fc 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php @@ -26,7 +26,6 @@
-
+
+
+ +
+
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php index 0ab800ae..dba9776b 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php @@ -20,6 +20,8 @@ + + @@ -91,12 +93,14 @@ { 'data': 'precio_min' }, { 'data': 'importe_fijo' }, { 'data': 'mostrar_en_presupuesto' }, + { 'data': 'acabado_cubierta' }, + { 'data': 'acabado_sobrecubierta' }, { 'data': actionBtns } ] }); theTable.on( 'draw.dt', function () { - const boolCols = [3]; + const boolCols = [3, 4, 5]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : ''; From 02003d2b4209b397e5a31aa0e3333c3b8433c263 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Wed, 21 Feb 2024 14:17:31 +0100 Subject: [PATCH 07/12] =?UTF-8?q?A=C3=B1adida=20previsualizacion=20de=20so?= =?UTF-8?q?brecubierta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deployment.xml | 9 +- .idea/webServers.xml | 7 ++ ci4/app/Language/es/Presupuestos.php | 2 + .../cosidotapablanda/_previewItems.php | 100 +++++++++++++++++- .../presupuestos/cosidotapablanda/previews.js | 3 + 5 files changed, 119 insertions(+), 2 deletions(-) diff --git a/.idea/deployment.xml b/.idea/deployment.xml index 554465e5..35307b35 100755 --- a/.idea/deployment.xml +++ b/.idea/deployment.xml @@ -1,8 +1,15 @@ - + diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 1b16ed49..d8625da1 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -198,11 +198,13 @@ return [ 'previewMaquina' => 'Máquina', 'previewConfiguracionGuardas' => 'Configuración de guardas', 'previewConfiguracionCubierta' => 'Configuración de cubierta', + 'previewConfiguracionSobrecubierta' => 'Configuración de sobrecubierta', 'previewEsquemaCubierta' => 'Esquema de cubierta', 'previewConfiguracionEsquemaCubierta' => 'Configuración esquema de cubierta', 'previewMaquinaPlana' => 'Configuración del papel: Plana', 'previewMaquinaRotativa' => 'Configuración del papel: Rotativa', 'previewCubierta' => 'Configuración del papel: Cubierta', + 'previewSobrecubierta' => 'Configuración del papel: Sobrecubierta', 'previewPapelGenerico' => 'Papel Genérico', 'previewPapelCompra' => 'Papel de Compra', 'previewAreaImpresion' => 'Área de Impresión', diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php index bd808c25..2598ebf7 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php @@ -121,7 +121,18 @@ - +
@@ -814,6 +825,87 @@
+
+
+
+
+ + + +
+ + +
+
+
+
TBD
+ +
+
TBD
+ +
+
TBD
+ +
+
TBDxTBD
+ +
+
TBDxTBD
+ +
+
TBDxTBD
+ +
+
TBD
+ +
+
TBD
+
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
@@ -883,6 +975,12 @@ $('#tab-pv-esquema-cubierta').on( "click", function() { } ); +$('#tab-pv-sobrecubierta').on( "click", function() { + +previewInteriorPlana('sobrecubierta', , ); + +} ); + endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js index c5f36f06..ad0af66a 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js @@ -523,6 +523,7 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) { case 'rot_bn': case 'rot_color': case 'guardas': + case 'sobrecubierta': if (lineaPresupuestoId.indexOf(lpName) >= 0) { rowData = this.data(); } @@ -632,6 +633,7 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) { case 'color': case 'colorhq': case 'guardas': + case 'sobrecubierta': // Conditional assignements depending on rotation of the printing shape if (pvObj.orientacionFormas == 'v') { let auxReg = pvObj.altoForma; @@ -675,6 +677,7 @@ function getVisibleTabs() { case 'rot_bn': case 'rot_color': case 'guardas': + case 'sobrecubierta': $("#tab-pv-" + tabName).show(); break; From ae133e8bea3e4aaf12104f8dc7cbcbb4b7a05674 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Wed, 21 Feb 2024 15:25:25 +0100 Subject: [PATCH 08/12] Implementada suma de solapas_sobrecubierta --- .../form/presupuestos/cosidotapablanda/_previewItems.php | 2 +- .../vuexy/form/presupuestos/cosidotapablanda/previews.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php index 2598ebf7..10529606 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php @@ -977,7 +977,7 @@ $('#tab-pv-esquema-cubierta').on( "click", function() { $('#tab-pv-sobrecubierta').on( "click", function() { -previewInteriorPlana('sobrecubierta', , ); + previewInteriorPlana('sobrecubierta', , ); } ); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js index ad0af66a..b63d3746 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js @@ -593,6 +593,7 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) { // Custom overwrites switch (pvObj.idIndex) { case 'cubierta': + case 'sobrecubierta': if(_isTapaDura){ let anchoPliegue = parseFloat(6); // mm let altoPliegue = parseFloat(7); // mm @@ -604,6 +605,12 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) { pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + (2 * sangre) + pvObj.lomoLibro); pvObj.altoForma += (2 * sangre); } + + if(pvObj.idIndex == "sobrecubierta"){ + pvObj.anchoForma += 2 * parseFloat($('#solapas_ancho_sobrecubierta').val()); + $(pvName + '_solapas').text(parseFloat($('#solapas_ancho_sobrecubierta').val())); + } + // Update labels $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); break; @@ -633,7 +640,6 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) { case 'color': case 'colorhq': case 'guardas': - case 'sobrecubierta': // Conditional assignements depending on rotation of the printing shape if (pvObj.orientacionFormas == 'v') { let auxReg = pvObj.altoForma; From 417bc74e1f8ba949b145d8b587f45b7c0ba67b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= <“jaimejimenezortega@gmail.com”> Date: Wed, 21 Feb 2024 21:58:58 +0100 Subject: [PATCH 09/12] =?UTF-8?q?ya=20funciona=20a=C3=B1adir=20los=20servi?= =?UTF-8?q?cios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presupuestos/Cosidotapablanda.php | 7 +- .../Presupuestos/Presupuestoacabados.php | 7 +- ci4/app/Controllers/Test.php | 6 +- .../PresupuestoAcabadosEntity.php | 4 ++ .../Presupuestos/PresupuestoAcabadosModel.php | 36 ++++++++-- ci4/app/Services/PresupuestoService.php | 31 +++++--- .../cosidotapablanda/_datosLibroItems.php | 13 ++-- .../_datosPresupuestoClienteItems.php | 3 +- .../cosidotapablanda/_datosServiciosItems.php | 71 ++++++++++++++++--- .../_lineasPresupuestoItems.php | 21 ++++-- 10 files changed, 150 insertions(+), 49 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 9687e780..0fc99f1a 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -571,11 +571,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $datosPedido->solapas_ancho = $reqData['solapas_ancho']; $datosPedido->lomo = $reqData['lomo']; - if($type=='sobrecubierta') - $datosPedido->lomo_cubierta = $reqData['lomo_cubierta']; - - $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($tipo_impresion_id, $datosPedido); - $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($tipo_impresion_id, $datosPedido); + $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($type, $tipo_impresion_id, $datosPedido); + $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($type, $tipo_impresion_id, $datosPedido); // Cubierta y sobrecubierta siempre color HQ $resourceData = $this->getCompIntData($type, $datosPedido, $papel_generico, $gramaje, $isColor, 1, $cliente_id); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php index 7cd46225..a449aaf9 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php @@ -42,15 +42,14 @@ class Presupuestoacabados extends \App\Controllers\GoBaseResourceController endif; $postData = $this->request->getJSON(); - $tarifas = array_column($postData->datos, 'tarifa_id'); - if(count($tarifas)>0){ - $this->model->deleteServiciosNotInArray($requestedId, $tarifas); + if(count($postData->datos)>0){ + $this->model->deleteServiciosNotInArray($requestedId, $postData->datos); } else{ $this->model->deleteAllServicios($requestedId); } - if(count($tarifas)>0){ + if(count($postData->datos)>0){ $this->model->updateTarifas($requestedId, $postData->datos); } diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 335538aa..581eca3b 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -18,7 +18,11 @@ class Test extends BaseController public function index() { echo '
';
-        ($this->testLineasSobrecubierta());
+        $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
+        $tarifas = [
+            (object)['tarifa_id'=>1, "cubierta"=>0, "sobrecubierta"=>0]
+        ];
+        var_dump($model->deleteServiciosNotInArray(44, $tarifas));
         echo '
'; /* diff --git a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php index 89c30ac9..71c10315 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php @@ -12,6 +12,8 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity "precio_unidad" => null, "precio_total" => null, "margen" => null, + "cubierta" => null, + "sobrecubierta" => null, "created_at" => null, "updated_at" => null, ]; @@ -21,5 +23,7 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity "precio_unidad" => "float", "precio_total" => "float", "margen" => "float", + "cubierta" => "int", + "sobrecubierta" => "int", ]; } diff --git a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php index 3bf50737..6923f0a1 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php @@ -19,7 +19,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel 2 => "t1.precio_total" ]; - protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad", "margen"]; + protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad", "margen", "cubierta", "sobrecubierta"]; protected $returnType = "App\Entities\Presupuestos\PresupuestoAcabadosEntity"; protected $useTimestamps = true; @@ -98,13 +98,33 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->delete(); } - public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){ + public function deleteServiciosNotInArray($presupuesto_id, $tarifas){ + + $builder = $this->db + ->table($this->table . " t1"); + $builder->select("*"); + $builder->where('presupuesto_id', $presupuesto_id); + $results = $builder->get()->getResultObject(); + + $ids_for_delete = []; + foreach($results as $result){ + $found = false; + foreach($tarifas as $tarifa){ + if($tarifa->tarifa_id == $result->tarifa_acabado_id && + $tarifa->cubierta == $result->cubierta && + $tarifa->sobrecubierta == $result->sobrecubierta) + $found = true; + } + if(!$found){ + array_push($ids_for_delete, $result->id); + } + } $builder = $this->db ->table($this->table . " t1"); $builder->where('presupuesto_id', $presupuesto_id); - foreach($tarifas_id as $id){ - $builder->where('tarifa_acabado_id !=', $id); + foreach($ids_for_delete as $id){ + $builder->orWhere('id', $id); } $builder->delete(); } @@ -118,6 +138,8 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel $builder->select("id"); $builder->where('presupuesto_id', $presupuesto_id); $builder->where('tarifa_acabado_id', $tarifa->tarifa_id); + $builder->where('cubierta', $tarifa->cubierta); + $builder->where('sobrecubierta', $tarifa->sobrecubierta); $result = $builder->get()->getResultObject(); if(count($result)>0){ $this->db @@ -127,6 +149,8 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) ->set('margen', $tarifa->margen) + ->set('cubierta', $tarifa->cubierta) + ->set('sobrecubierta', $tarifa->sobrecubierta) ->update(); @@ -139,6 +163,8 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) ->set('margen', $tarifa->margen) + ->set('cubierta', $tarifa->cubierta) + ->set('sobrecubierta', $tarifa->sobrecubierta) ->insert(); } } @@ -157,7 +183,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad, - t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre" + t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta" ); $builder->where('t1.presupuesto_id', $presupuesto_id); diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index aa81ef9a..83c7f2c6 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -541,8 +541,9 @@ class PresupuestoService extends BaseService /** * Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo. + * El $uso tiene que ser "cubierta" o "sobrecubierta" */ - public static function getAnchoTotalExteriores($tipo_impresion_id, $datosPedido=null) + public static function getAnchoTotalExteriores($uso="cubierta", $tipo_impresion_id, $datosPedido=null) { $ancho_total = 0; @@ -550,8 +551,7 @@ class PresupuestoService extends BaseService // Tapa blanda (cosido y fresado) if($tipo_impresion_id == 2 || $tipo_impresion_id == 4){ $ancho_total = floatval($datosPedido->ancho)*2 + floatval($datosPedido->lomo); - $ancho_total += property_exists($datosPedido, 'lomo_cubierta')?$datosPedido->lomo_cubierta:0; - + // añadimos ancho de las solapas // si se añaden solapas hay que sumar 3mm de los dobleces if ($datosPedido->solapas) { @@ -563,9 +563,14 @@ class PresupuestoService extends BaseService // Tapa dura cosido y fresado else if($tipo_impresion_id == 1 || $tipo_impresion_id == 3){ $ancho_total = floatval($datosPedido->ancho)*2 + floatval($datosPedido->lomo); - $ancho_total += property_exists($datosPedido, 'lomo_cubierta')?$datosPedido->lomo_cubierta:0; - // Se añaden 20mm de sangre por cada lado + 2 * 0.6mm de portada y contraportada -> total 41.2 - $ancho_total += (1.2+2*self::SANGRE_FORMAS_CUBIERTA); + // si es cubierta + // Se añaden 20mm de sangre por cada lado + 2 * 6mm de vuelo portada y contraportada -> total 52 + if($uso=="cubierta") + $ancho_total += (12+2*self::SANGRE_FORMAS_CUBIERTA); + // si es sobrecubierta + // Se añaden 5mm de sangre por cada lado + 2 * 6mm de vuelo portada y contraportada -> total 52 + else + $ancho_total += (12+2*self::SANGRE_FORMAS); } else{ // En cualquier otro caso se le suma 5mm de sangre por cada lado @@ -576,9 +581,9 @@ class PresupuestoService extends BaseService } /** - * Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo. + * Devuelve el alto de la cubierta/sobrecubierta */ - public static function getAltoTotalExteriores($tipo_impresion_id, $datosPedido=null) + public static function getAltoTotalExteriores($uso="cubierta", $tipo_impresion_id, $datosPedido=null) { $alto_total = 0; @@ -586,8 +591,14 @@ class PresupuestoService extends BaseService $alto_total = floatval($datosPedido->alto); // Tapa dura (cosido y fresado) if($tipo_impresion_id == 1 || $tipo_impresion_id == 3){ - // Se añaden 20mm de sangre por cada lado + 0.7mm extra que sobresale -> total 40.7 - $alto_total += (0.7+2*self::SANGRE_FORMAS_CUBIERTA); + // Se añaden 20mm de sangre por cada lado + 7mm extra que sobresale -> total 47 + if($uso=="cubierta") + $alto_total += (7+2*self::SANGRE_FORMAS_CUBIERTA); + // si es sobrecubierta + // Se añaden 5mm de sangre por cada lado + 7mm de vuelo -> total 52 + else + $alto_total += (7+2*self::SANGRE_FORMAS); + } // En cualquier otro caso se le suma 5mm de sangre por cada lado else{ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index e0acc12a..543a1f26 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -180,10 +180,10 @@
-