diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 84f7f385..9fe3a397 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -50,11 +50,6 @@ $routes->delete('api/user/(:segment)', 'Api::user/delete/$1'); * Route Definitions * -------------------------------------------------------------------- */ -$routes->group('pdfcontroller', ['namespace' => 'App\Controllers\Pdf'], function ($routes) { - $routes->get('', 'PdfController::index', ['as' => 'pdfList']); - $routes->match(['get', 'post'], 'htmltopdf', 'PdfController::htmlToPDF', ['as' => 'toPdf']); -}); - $routes->group('tarifaacabado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->get('', 'Tarifaacabado::index', ['as' => 'tarifaAcabadoList']); $routes->get('index', 'Tarifaacabado::index', ['as' => 'tarifaAcabadoIndex']); @@ -483,6 +478,11 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos }); $routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']); +$routes->group('printpresupuestos', ['namespace' => 'App\Controllers\Pdf'], function ($routes) { + $routes->get('', 'PrintPresupuestos::index', ['as' => 'pdfList']); + $routes->match(['get', 'post'], 'generar', 'PrintPresupuestos::generar', ['as' => 'presupuestoToPdf']); +}); + /* * -------------------------------------------------------------------- * Additional Routing diff --git a/ci4/app/Controllers/Pdf/PdfController.php b/ci4/app/Controllers/Pdf/PrintPresupuestos.php similarity index 80% rename from ci4/app/Controllers/Pdf/PdfController.php rename to ci4/app/Controllers/Pdf/PrintPresupuestos.php index ba3808e0..4469e9dd 100644 --- a/ci4/app/Controllers/Pdf/PdfController.php +++ b/ci4/app/Controllers/Pdf/PrintPresupuestos.php @@ -4,7 +4,7 @@ namespace App\Controllers\Pdf; use App\Controllers\BaseController; -class PdfController extends BaseController +class PrintPresupuestos extends BaseController { function __construct() { @@ -16,12 +16,12 @@ class PdfController extends BaseController //return view('pdf_view'); return view(getenv('theme.path').'pdfs/presupuesto'); } - public function htmlToPDF(){ + public function generar(){ $dompdf = new \Dompdf\Dompdf(['isRemoteEnabled' => true]); //$dompdf->loadHtml(view('pdf_view')); $dompdf->loadHtml(view(getenv('theme.path').'pdfs/presupuesto')); $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); - $dompdf->stream(); + $dompdf->stream('presupuesto-demo.pdf'); } } \ No newline at end of file diff --git a/ci4/app/Language/es/Basic.php b/ci4/app/Language/es/Basic.php index 1dcfd513..2c68ade2 100644 --- a/ci4/app/Language/es/Basic.php +++ b/ci4/app/Language/es/Basic.php @@ -10,6 +10,8 @@ return [ 'Cancel' => 'Cancelar', 'ChangePassword' => 'Cambiar contraseña', 'Close' => 'Cerrar', + 'Print' => 'Imprimir', + 'Clone' => 'Duplicar', 'Dashboard' => 'Panel de control', 'Delete' => 'Borrar', 'Error' => 'Error', diff --git a/ci4/app/Views/pdf_view.php b/ci4/app/Views/pdf_view.php deleted file mode 100644 index 69fc8975..00000000 --- a/ci4/app/Views/pdf_view.php +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - Codeigniter 4 PDF Example - positronx.io - - - - -
-

Generate PDF in Codeigniter from View

-
- - Download PDF - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameProfileCityDateCTC
Airi SatouAccountantTokyo332008/11/28$162,700
Angelica RamosChief Executive Officer (CEO)London472009/10/09$1,200,000
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Bradley GreerSoftware EngineerLondon412012/10/13$132,000
Brenden WagnerSoftware EngineerSan Francisco282011/06/07$206,850
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Bruno NashSoftware EngineerLondon382011/05/03$163,500
Caesar VancePre-Sales SupportNew York212011/12/12$106,450
Cara StevensSales AssistantNew York462011/12/06$145,600
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
-
- - 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 0b877195..d73bfb3f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -17,13 +17,19 @@ + + + +
" /> - "btn btn-secondary float-start",]) ?> + "btn btn-dark float-start me-sm-3 me-1",]) ?> + "btn btn-info float-start me-sm-3 me-1",]) ?> + "btn btn-secondary float-start",]) ?>
@@ -63,6 +69,9 @@ } }); + /******************************* + * Inicialización de los Select2 + *******************************/ $('#incRei').select2({ allowClear: false, }); @@ -94,7 +103,7 @@ $('#compGramajeNegrohq').select2({ allowClear: false, }); - + $('#compPapelColor').select2({ allowClear: false, }); @@ -102,11 +111,15 @@ $('#compPapelColorhq').select2({ allowClear: false, }); - + $('#compGramajeColor').select2({ allowClear: false, }); + $('#compGramajeColorhq').select2({ + allowClear: false, + }); + $('#compPapelCubierta').select2({ allowClear: false, }); @@ -119,14 +132,11 @@ allowClear: false, }); - $('#compPaginasCubierta').select2({ + $('#compCarasCubierta').select2({ allowClear: false, minimumResultsForSearch: Infinity, }); - - - endSection() ?> @@ -136,24 +146,25 @@ section("additionalInlineJs") ?> autosize($('#compCalPaginasColor')); - - - + $('#papelFormatoPersonalizado').on("click",function(){ var checkbox = document.getElementById('papelFormatoPersonalizado'); if(checkbox.checked == true){ document.getElementById("papelFormatoAncho").style.display = "block"; document.getElementById("papelFormatoAlto").style.display = "block"; $('#papelFormatoId').next(".select2-container").hide(); - document.getElementById("label_papelFormatoId").innerHTML = + $('#papelFormatoId').val('').change(); + document.getElementById("label_papelFormatoId").innerHTML = " (" + " x )*"; } else{ + document.getElementById("papelFormatoAncho").value= ""; + document.getElementById("papelFormatoAlto").value= ""; document.getElementById("papelFormatoAncho").style.display = "none"; document.getElementById("papelFormatoAlto").style.display = "none"; $('#papelFormatoId').next(".select2-container").show(); - document.getElementById("label_papelFormatoId").innerHTML = + document.getElementById("label_papelFormatoId").innerHTML = "*"; } }); @@ -164,221 +175,649 @@ var tableCompIntPlana = new DataTable('#tableCompIntPlana',{ scrollX: true, - searching: false, - paging: false, + searching: false, + paging: false, info: false, - ordering: false, + ordering: false, responsive: true, + select: true, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='bn') + return ''; + else if(data=='bnhq') + return ''; + else if(data=='color') + return ''; + else if(data=='colorhq') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'} + ], + columnDefs: [ + { + target: [16,17,18,19,20], + visible: false, + searchable: false + }, + ] }); var tableCompIntRotativa = new DataTable('#tableCompIntRotativa',{ scrollX: true, - searching: false, - paging: false, + searching: false, + paging: false, info: false, - ordering: false, + ordering: false, responsive: true, + select: true, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='rotativa') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'aFavorFibra', + 'render': function(data, type, row, meta){ + if(data=='si') + return ''; + else if(data=='no') + return ''; + } + }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'precioPagNegro' }, + { 'data': 'precioPagColor' }, + { 'data': 'totalTinta' }, + { 'data': 'totalCorte' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'} + ], + columnDefs: [ + { + target: [21,22,23,24,25], + visible: false, + searchable: false + }, + ] }); - var tableCompIntCubierta = new DataTable('#tableCompCubierta',{ + var tableCompCubierta = new DataTable('#tableCompCubierta',{ scrollX: true, - searching: false, - paging: false, + searching: false, + paging: false, info: false, - ordering: false, + ordering: false, responsive: true, + select: true, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='cubierta') + return ''; + else if(data=='sobrecubierta') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'} + ], + columnDefs: [ + { + target: [16,17,18,19,20], + visible: false, + searchable: false + }, + ] }); - var tableCompIntSobrecubierta = new DataTable('#tableCompSobrecubierta',{ + const papelGenericoNegroList = ; + + + var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ scrollX: true, - searching: false, - paging: false, + searching: false, + paging: false, info: false, - ordering: false, + ordering: false, responsive: true, + select: false, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, + }); + $('.comp_negro_items').on('change', function (e) { + + checkComparadorInt(false,false); + }); + + $('.comp_negrohq_items').on('change', function (e) { + + checkComparadorInt(false, true); + }); + + $('.comp_color_items').on('change', function (e) { + + checkComparadorInt(true, false); + }); + + $('.comp_colorhq_items').on('change', function (e) { + checkComparadorInt(true, true); + }); + + async function getLineasIntPlana(is_color, is_hq){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'interior', + color: is_color?1:0, + hq: is_hq?1:0, + paginas: parseInt($(''+ elementos.paginas).val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, + papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), + gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntLineas(is_color); + + if(data.lineas.length >0){ + + fillIntPlana(data, is_color, is_hq); + selectIntLineas(); + $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none') + } + else{ + $('#title_int_plana').html(''); + $('#insertarPlanaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00'); + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + return false; + } + + async function getLineasIntRot(is_hq){ + + const dimension = getDimensionLibro(); + + // Rotativa solo negro o color (no hq) + if ( is_hq==false){ + + if(checkInputsForRotativa()){ + + let datos = { + type: 'interior_rot', + paginas: parseInt($('#paginas').val()), + paginas_negro: parseInt($('#compPaginasNegro').val()), + paginas_color: parseInt($('#compPaginasColor').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + // el papel y el gramaje se coge del negro (siempre estará) + papel_generico_id: $('#compPapelNegro').select2('data')[0].id, + papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), + gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntRot(); + + if(data.lineas.length >0){ + + fillIntRot(data); + selectIntRotLineas(); + $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); + $('#insertarRotativaBtn').removeClass('d-none') + } + else{ + $('#title_int_rot').html(''); + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_rot').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + } + return false; + } + + + $('.comp_cubierta_items').on('change', function (){ + + if ($('#compCarasCubierta').select2('data').length > 0 && + $('#compPapelCubierta').select2('data').length > 0 && + $('#compGramajeCubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'cubierta', + paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: parseInt($('#solapas_ancho').val()), + papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, + papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearCubierta(); + + if(data.lineas.length >0){ + + fillCubierta(data); + selectCubiertaLineas(); + $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); + $('#insertarCubiertaBtn').removeClass('d-none') + + } + 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(); + } + }); + + + $('#tipoImpresion').on("change", function () { + updatePapelesComparador(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + $('#paginas').change(); + + + if (($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color')){ + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && + $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + + } + else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + if($('#tableCompIntPlana').DataTable().rows().count() > 0 && + !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + } + }); + + + function checkComparadorInt(is_color, is_hq) { + + elementos = getIDsComparador(is_color, is_hq) + + if ($(''+ elementos.papel).select2('data').length > 0 && + $(''+ elementos.gramaje).select2('data').length > 0 && + parseInt($(''+ elementos.paginas).val()) > 0 && + checkDatosPedidoForComp()) { + + getLineasIntPlana(is_color, is_hq).then((result) =>{ + getLineasIntRot(is_hq); + }); + } + else{ + clearIntLineas(is_color); + clearIntRot(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + + } + } + $('#compPapelNegro').on('select2:select', function (e){ - $('#compGramajeNegro').val(null).trigger('change'); - $('#compGramajeNegro').prop('disabled', false); - $('#compPapelNegro').find('option[value="0"]').remove(); - $('#compGramajeNegro').select2({ - allowClear: true, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', + if($('#compPapelNegro').select2('data')[0].id=='0'){ + $('#compGramajeNegro').val('').change(); + $('#compGramajeNegro').prop('disabled', true); + } - data: function (params) { - return { - tipo: 'gramaje', - datos: $('#compPapelNegro').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeNegro').val('').change(); + $('#compGramajeNegro').empty().trigger("change"); + $('#compGramajeNegro').prop('disabled', false); + $('#compGramajeNegro').select2({ + allowClear: true, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'bn', + datos: $('#compPapelNegro').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } }); - $('#compPapelNegrohq').on('select2:select', function (e){ - $('#compGramajeNegrohq').val(null).trigger('change'); - $('#compGramajeNegrohq').prop('disabled', false); - $('#compPapelNegrohq').find('option[value="0"]').remove(); - $('#compGramajeNegrohq').select2({ - allowClear: true, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', + if($('#compPapelNegrohq').select2('data')[0].id=='0'){ + $('#compGramajeNegrohq').val('').change(); + $('#compGramajeNegrohq').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeNegrohq').empty().trigger("change"); + $('#compGramajeNegrohq').prop('disabled', false); + $('#compGramajeNegrohq').select2({ + allowClear: true, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', - data: function (params) { - return { - tipo: 'gramaje', - datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); + data: function (params) { + return { + tipo: 'gramaje', + uso: 'bnhq', + datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } }); $('#compPapelColor').on('select2:select', function (e){ - $('#compGramajeColor').val(null).trigger('change'); - $('#compGramajeColor').prop('disabled', false); - $('#compPapelColor').find('option[value="0"]').remove(); - $('#compGramajeColor').select2({ - allowClear: true, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', + if($('#compPapelColor').select2('data')[0].id=='0'){ + $('#compGramajeColor').val('').change(); + $('#compGramajeColor').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeColor').empty().trigger("change"); + $('#compGramajeColor').prop('disabled', false); + $('#compPapelColor').find('option[value="0"]').remove(); + $('#compGramajeColor').select2({ + allowClear: true, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', - data: function (params) { - return { - tipo: 'gramaje', - datos: $('#compPapelColor').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); + data: function (params) { + return { + tipo: 'gramaje', + uso: 'color', + datos: $('#compPapelColor').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } }); $('#compPapelColorhq').on('select2:select', function (e){ - $('#compGramajeColorhq').val(null).trigger('change'); - $('#compGramajeColorhq').prop('disabled', false); - $('#compPapelColorhq').find('option[value="0"]').remove(); - $('#compGramajeColorhq').select2({ - allowClear: true, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', + if($('#compPapelColorhq').select2('data')[0].id=='0'){ + $('#compGramajeColorhq').val('').change(); + $('#compGramajeColorhq').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeColorhq').empty().trigger("change"); + $('#compGramajeColorhq').prop('disabled', false); + $('#compPapelColorhq').find('option[value="0"]').remove(); + $('#compGramajeColorhq').select2({ + allowClear: true, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', - data: function (params) { - return { - tipo: 'gramaje', - datos: $('#compPapelColorhq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); + data: function (params) { + return { + tipo: 'gramaje', + uso: 'colorhq', + datos: $('#compPapelColorhq').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } }); $('#compPapelCubierta').on('select2:select', function (e){ + if($('#compPapelCubierta').select2('data')[0].id=='0'){ + $('#compGramajeCubierta').val('').change(); + $('#compGramajeCubierta').prop('disabled', true); + } + else{ + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + $('#compGramajeCubierta').val('').trigger('change'); + $('#compGramajeCubierta').prop('disabled', false); + $('#compPapelCubierta').find('option[value="0"]').remove(); + $('#compGramajeCubierta').select2({ + allowClear: true, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', - $('#compGramajeCubierta').val(null).trigger('change'); - $('#compGramajeCubierta').prop('disabled', false); - $('#compPapelCubierta').find('option[value="0"]').remove(); - $('#compGramajeCubierta').select2({ - allowClear: true, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - datos: $('#compPapelCubierta').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); + data: function (params) { + return { + tipo: 'gramaje', + uso: 'cubierta', + datos: $('#compPapelCubierta').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } }); - - - endSection() ?> section('css') ?> @@ -386,12 +825,7 @@ - -endSection() ?> -section('additionalExternalJs') ?> - - endSection() ?> @@ -400,4 +834,9 @@ -endSection() ?> \ No newline at end of file + + + + + +endSection() ?>