From 7318e4bd7c8a8c25dc59193d42016a6db9749414 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Wed, 31 Jul 2024 22:54:20 +0200 Subject: [PATCH] Actualizacion automatica: 2024-07-31 22:54:20 --- .../vuexy/form/pedidos/viewPedidosList.php | 101 +++++++++++++++++- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php index 1a169428..351031c4 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php @@ -23,7 +23,7 @@ - + @@ -57,6 +57,73 @@ `; }; +// Setup - add a text input to each footer cell +$('#tableOfPedidos thead tr').clone(true).appendTo('#tableOfPedidos thead'); +$('#tableOfPedidos thead tr:eq(1) th').each(function (i) { + if (!$(this).hasClass("noFilter")) { + var title = $(this).text(); + if(i==1){ + $(this).html(''); + var bsRangePickerRange = $('#bs-rangepicker-range') + bsRangePickerRange.daterangepicker({ + ranges: { + '': [moment(), moment()], + '': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], + '': [moment().subtract(6, 'days'), moment()], + '': [moment().subtract(29, 'days'), moment()], + '': [moment().startOf('month'), moment().endOf('month')], + '': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] + }, + opens: 'right', + language: 'i18n ?>', + "locale": { + "customRangeLabel": "", + "format": "YYYY-MM-DD", + "separator": " ", + "applyLabel": "", + "cancelLabel": "", + + }, + "alwaysShowCalendars": true, + autoUpdateInput: false, + + }); + + bsRangePickerRange.on('apply.daterangepicker', function(ev, picker) { + $(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD')); + theTable + .column(i) + .search(this.value) + .draw(); + }); + + bsRangePickerRange.on('cancel.daterangepicker', function(ev, picker) { + $(this).val(''); + theTable + .column(i) + .search(this.value) + .draw(); + }); + + } + else{ + $(this).html(''); + + $('input', this).on('change clear', function () { + if (theTable.column(i).search() !== this.value) { + theTable + .column(i) + .search(this.value) + .draw(); + } + }); + } + } + else { + $(this).html(''); + } +}); + theTable = $('#tableOfPedidos').DataTable({ processing: true, serverSide: true, @@ -66,9 +133,9 @@ lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], pageLength: 50, lengthChange: true, - "dom": 'lfBrtip', + "dom": '<"mb-3"l>Brtip', "buttons": [ - 'copy', 'csv', 'excel', 'print', { + 'colvis', 'copy', 'csv', 'excel', 'print', { extend: 'pdfHtml5', orientation: 'landscape', pageSize: 'A4' @@ -143,14 +210,37 @@ theTable.on( 'draw.dt', function () { const boolCols = []; + const dateCols = [1]; + const priceCols = [10]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : ''; }); } + + for (let coln of dateCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + const datestr = cell.innerHTML; + const dateStrLen = datestr.toString().trim().length; + if (dateStrLen > 0) { + let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values + dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one + const d = new Date(...dateTimeParts); // new Date(datestr); + cell.innerHTML = d.toLocaleDateString(); + } + }); + } + + for (let coln of priceCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = parseFloat(cell.innerHTML).toFixed(2); + + }); + } }); + $(document).on('click', '.btn-edit', function(e) { var url = ''; url = url.replace(':id', `${$(this).attr('data-id')}` ); @@ -163,6 +253,8 @@ section('css') ?> "> + "> + endSection() ?> @@ -171,6 +263,9 @@ + + +