mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadidos ficheros faltantes
This commit is contained in:
199
httpdocs/assets/js/safekat/pages/facturas/facturasList.js
Normal file
199
httpdocs/assets/js/safekat/pages/facturas/facturasList.js
Normal file
@ -0,0 +1,199 @@
|
||||
$(() => {
|
||||
|
||||
$(document).on('click', '.btn-edit', function (e) {
|
||||
window.location.href = '/facturas/edit/' + $(this).attr('data-id');
|
||||
});
|
||||
|
||||
const lastColNr = $('#tableOfFacturas').find("tr:first th").length - 1;
|
||||
|
||||
let datatableColumns = [];
|
||||
if ($('#cliente_id').val() == -1) {
|
||||
datatableColumns = [
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'numero' },
|
||||
{ 'data': 'fecha_factura_at', searchable: false },
|
||||
{ 'data': 'cliente' },
|
||||
{ 'data': 'base', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'total', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'pendiente', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'creditoAsegurado' },
|
||||
{ 'data': 'estado' },
|
||||
{ 'data': 'estado_pago' },
|
||||
{ 'data': 'forma_pago' },
|
||||
{ 'data': 'vencimiento' },
|
||||
{ 'data': 'dias_vencimiento' },
|
||||
{ 'data': 'action' }
|
||||
];
|
||||
} else {
|
||||
datatableColumns = [
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'numero' },
|
||||
{ 'data': 'fecha_factura_at', searchable: false },
|
||||
{ 'data': 'base', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'total', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'pendiente', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'action' }
|
||||
];
|
||||
}
|
||||
|
||||
$('#tableOfFacturas').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
orderCellsTop: true,
|
||||
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||
pageLength: 250,
|
||||
"dom": 'lBrtip',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Exportar Excel Contaplus',
|
||||
action: function (e, dt, button, config) {
|
||||
var searchValue = theTable.search(); // Captura el valor del campo de búsqueda
|
||||
var ajaxParams = theTable.ajax.params(); // Captura otros parámetros de la tabla
|
||||
|
||||
console.log(searchValue);
|
||||
|
||||
/*
|
||||
$.ajax({
|
||||
url: '/ruta/exportarExcel', // URL del servidor para manejar la exportación
|
||||
type: 'POST',
|
||||
data: {
|
||||
search: searchValue,
|
||||
extraParams: ajaxParams
|
||||
},
|
||||
xhrFields: {
|
||||
responseType: 'blob' // Para manejar la descarga del archivo
|
||||
},
|
||||
success: function(blob, status, xhr) {
|
||||
// Crear un enlace temporal para descargar el archivo
|
||||
var link = document.createElement('a');
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
link.href = url;
|
||||
link.download = 'datos_personalizados.xlsx';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Exportar Lineas a Excel',
|
||||
action: function (e, dt, button, config) {
|
||||
var searchValue = theTable.search(); // Captura el valor del campo de búsqueda
|
||||
var ajaxParams = theTable.ajax.params(); // Captura otros parámetros de la tabla
|
||||
|
||||
console.log(searchValue);
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Exportar Girosgit ',
|
||||
action: function (e, dt, button, config) {
|
||||
var searchValue = theTable.search(); // Captura el valor del campo de búsqueda
|
||||
var ajaxParams = theTable.ajax.params(); // Captura otros parámetros de la tabla
|
||||
|
||||
console.log(searchValue);
|
||||
|
||||
}
|
||||
}
|
||||
],
|
||||
order: [[0, 'asc']],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
ajax: {
|
||||
url: '/facturas/datatable',
|
||||
type: 'GET',
|
||||
data: function (d) {
|
||||
d.cliente_id = $('#cliente_id').val();
|
||||
d.fecha_factura = getDate();
|
||||
}
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
},
|
||||
],
|
||||
columns: datatableColumns,
|
||||
});
|
||||
|
||||
$(document).on("keyup", ".factura-filter", (event) => {
|
||||
//console.log(this.datatablePlanningRot.column($(event.currentTarget).attr("name")))
|
||||
let columnName = $(event.currentTarget).attr("name");
|
||||
let columnIndex = $('#tableOfFacturas').DataTable().columns().eq(0).filter(function (index) {
|
||||
return $('#tableOfFacturas').DataTable().column(index).dataSrc() === columnName;
|
||||
})[0];
|
||||
$('#tableOfFacturas').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
|
||||
$(document).on("change", ".factura-filter-select", (event) => {
|
||||
let columnName = $(event.currentTarget).attr("name");
|
||||
let columnIndex = $('#tableOfFacturas').DataTable().columns().eq(0).filter(function (index) {
|
||||
return $('#tableOfFacturas').DataTable().column(index).dataSrc() === columnName;
|
||||
})[0];
|
||||
$('#tableOfFacturas').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw();
|
||||
});
|
||||
|
||||
|
||||
|
||||
let bsRangePickerRange = $('#' + 'fechaFactura');
|
||||
bsRangePickerRange.daterangepicker({
|
||||
ranges: {
|
||||
[window.datepickerLang.hoy]: [moment(), moment()],
|
||||
[window.datepickerLang.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
[window.datepickerLang.ultimos7]: [moment().subtract(6, 'days'), moment()],
|
||||
[window.datepickerLang.ultimos30]: [moment().subtract(29, 'days'), moment()],
|
||||
[window.datepickerLang.esteMes]: [moment().startOf('month'), moment().endOf('month')],
|
||||
[window.datepickerLang.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
},
|
||||
opens: 'right',
|
||||
language: window.datepickerLocale,
|
||||
"locale": {
|
||||
"customRangeLabel": window.datepickerLang.rangoPersonalizado,
|
||||
"format": "YYYY-MM-DD",
|
||||
"separator": " ",
|
||||
"applyLabel": window.datepickerLang.aplicar,
|
||||
"cancelLabel": window.datepickerLang.limpiar,
|
||||
|
||||
},
|
||||
"alwaysShowCalendars": true,
|
||||
autoUpdateInput: false,
|
||||
|
||||
});
|
||||
|
||||
|
||||
function getDate() {
|
||||
|
||||
let picker = bsRangePickerRange.data('daterangepicker');
|
||||
|
||||
if (!picker || !picker.startDate || !picker.endDate || $('#fechaFactura').val() == '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
let startDate = picker.startDate.format('YYYY-MM-DD');
|
||||
let endDate = picker.endDate.format('YYYY-MM-DD');
|
||||
|
||||
return startDate + "|" + endDate;
|
||||
|
||||
}
|
||||
|
||||
bsRangePickerRange.on('apply.daterangepicker', function (ev, picker) {
|
||||
|
||||
$(this).val(picker.startDate.format('DD/MM/YYYY') + ' ' + picker.endDate.format('DD/MM/YYYY'));
|
||||
let table = $('#tableOfFacturas').DataTable();
|
||||
table.column(2).draw();
|
||||
});
|
||||
|
||||
bsRangePickerRange.on('cancel.daterangepicker', function (ev, picker) {
|
||||
$(this).val('');
|
||||
$('#tableOfFacturas').DataTable().column(2).search('').draw();
|
||||
});
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user