From 177522ce4945e0ab0cdb2c66b60f9d8f1207e714 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2024 20:00:44 +0100 Subject: [PATCH] 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));