terminadas modificaciones en tarifas acabado

This commit is contained in:
2024-08-27 14:31:00 +02:00
parent 1e347cc7d6
commit 49314e166d
10 changed files with 177 additions and 29 deletions

View File

@ -45,12 +45,13 @@
<table id="tableOfTarifaacabadolineas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('TarifaAcabadoLineas.proveedor') ?></th>
<th><?= lang('TarifaAcabadoLineas.tiradaMin') ?></th>
<th><?= lang('TarifaAcabadoLineas.precioMax') ?></th>
<th><?= lang('TarifaAcabadoLineas.tiradaMax') ?></th>
<th><?= lang('TarifaAcabadoLineas.precioMin') ?></th>
<th><?= lang('TarifaAcabadoLineas.margen') ?></th>
<th style="min-width:100px"></th>
<th class="noFilter" style="min-width:100px"></th>
</tr>
</thead>
<tbody>
@ -85,7 +86,7 @@
};
editor = new $.fn.dataTable.Editor( {
var editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('tarifaAcabadoLineasDTE') ?>",
headers: {
@ -94,7 +95,11 @@
},
table : "#tableOfTarifaacabadolineas",
idSrc: 'id',
fields: [ {
fields: [
{
name: "proveedor_id",
type: "select",
}, {
name: "tirada_min"
}, {
name: "precio_max"
@ -107,6 +112,9 @@
}, {
"name": "tarifa_acabado_id",
"type": "hidden"
},{
name: "proveedor_nombre",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
@ -117,6 +125,10 @@
]
} );
// Generación de la lista de proveedores (id, nombre) para encuadernación
const suppliersList = <?php echo json_encode($proveedores); ?>;
editor.field( 'proveedor_id' ).update( suppliersList );
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['tarifa_acabado_id'] = id;
@ -141,18 +153,94 @@
});
function searchProviders(){
var values = [];
$('#select_Proveedor').find(':selected').each(function () {
values.push($(this).val());
});
theTable.column(0).search(values).draw();
}
// Setup - add a text input to each footer cell
$('#tableOfTarifaacabadolineas thead tr').clone(true).appendTo('#tableOfTarifaacabadolineas thead');
$('#tableOfTarifaacabadolineas thead tr:eq(1) th').each(function (i) {
if (!$(this).hasClass("noFilter")) {
var title = $(this).text();
title = title.replace(/ /g, "_").replace(/\./g, "_");
if(i==0){
// Agregar un selector en la primera columna
$(this).html(`<select id=select_${title} class="form-control select2" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>`);
// Agregar opciones al selector
var selector = $('select', this);
const suppliersList = <?php echo json_encode($proveedores); ?>;
//selector.append('<option value="">Todos</option>'); // Opción vacía
for (j = 0; j < suppliersList.length; j++) {
selector.append('<option value="' + suppliersList[j].value + '">' + suppliersList[j].label + '</option>');
};
$('#select_' + title).select2({
multiple: true,
placeholder: ""
});
selector.bind('select2:select', searchProviders);
selector.bind('select2:unselect', searchProviders);
$('#select_' + title).val("").trigger('change');
}
else{
$(this).html(`
<div class='d-flex'>
<input name=min_${title} id=min_${title} class="form-control" type='text' min='0' placeholder='Min' style='width: 80px;'/>
<input name=max_${title} id=max_${title} class="form-control ml-1" type='text' min='0' placeholder='Max' style='width: 80px;'/>
</div>
`);
$('input', this).on('change clear', function () {
var minInputValue = parseFloat($(`#min_${title}`).val()) || "";
var maxInputValue = parseFloat($(`#max_${title}`).val()) || "";
if (theTable.column(i).search() !== [minInputValue,maxInputValue]) {
theTable
.column(i)
.search([minInputValue,maxInputValue])
.draw();
}
});
}
}
else {
$(this).html('<span></span>');
}
});
var theTable = $('#tableOfTarifaacabadolineas').DataTable( {
serverSide: true,
orderCellsTop: true,
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
fixedHeader: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
paging: true,
info: false,
stateSave: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('tarifaAcabadoLineasDT') ?>',
@ -164,6 +252,12 @@
async: true,
}),
columns: [
{ 'data': 'proveedor_id',
render: function(data, type, row, meta) {
var value = suppliersList.find(element => element.value === data);
return value['label'];
},
},
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
@ -180,7 +274,6 @@
searchable: false,
targets: [lastColNr]
},
{"orderData": [ 0, 1 ], "targets": 0 },
],
language: {
@ -244,6 +337,7 @@
<?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/fixedheader/fixedHeader.dataTables.min.css") ?>">
<?=$this->endSection() ?>

View File

@ -49,11 +49,11 @@
<th><?= lang('TarifaEncuadernacionTiradas.proveedor') ?></th>
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMin') ?></th>
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMax') ?></th>
<th><?= lang('Tarifaencuadernacion.precioMin') ?></th>
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
<th><?= lang('Tarifaencuadernacion.importeFijo') ?></th>
<th></th>
</tr>
</thead>
</thead>
<tbody>
</tbody>
</table>

View File

@ -75,6 +75,13 @@ if (
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('proveedores.menu')) { ?>
<li class="menu-item">
<a href="<?= route_to("proveedorList") ?>" class="menu-link">
<?= lang("App.menu_proveedores") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('ubicaciones.menu')) { ?>
<li class="menu-item">
<a href="<?= route_to("ubicacionesList") ?>" class="menu-link">