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();
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
145
httpdocs/assets/js/safekat/pages/pedidos/pedidos.js
Normal file
145
httpdocs/assets/js/safekat/pages/pedidos/pedidos.js
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
import Ajax from "../../components/ajax.js"
|
||||||
|
|
||||||
|
class Pedidos {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
this.total_ejemplares = 0;
|
||||||
|
this.total_facturado = 0;
|
||||||
|
|
||||||
|
this.tableFacturas = $('#tableOfFacturas').DataTable();
|
||||||
|
this.tablePedidos = $('#tableOfLineasPedido').DataTable();
|
||||||
|
this.btnAddFactura = $('#add-factura');
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
if (this.btnAddFactura) {
|
||||||
|
this.tableFacturas.on('draw', function () {
|
||||||
|
this.total_facturado = 0;
|
||||||
|
for (let i = 0; i < this.tableFacturas.rows().count(); i++) {
|
||||||
|
this.total_facturado += parseFloat(this.tableFacturas.row(i).data().ejemplares);
|
||||||
|
}
|
||||||
|
this.checkAddFactura();
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this.tablePedidos.on('draw', function () {
|
||||||
|
this.total_ejemplares = 0;
|
||||||
|
for (let i = 0; i < this.tablePedidos.rows().count(); i++) {
|
||||||
|
this.total_ejemplares += parseInt(this.tablePedidos.row(i).data().unidades);
|
||||||
|
}
|
||||||
|
this.checkAddFactura();
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this.btnAddFactura.on('click', this.addFacturaAction.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addFacturaAction() {
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Seleccione serie de facturación',
|
||||||
|
html: `<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<select id="select-serie" class="form-control select2bs serie-facturacion-select" style="width: 100%;"></select>
|
||||||
|
</div>
|
||||||
|
</div>`,
|
||||||
|
showCancelButton: true,
|
||||||
|
cancelButtonText: 'Cancelar',
|
||||||
|
showDenyButton: false,
|
||||||
|
confirmButtonText: 'Ok',
|
||||||
|
showDenyButton: false,
|
||||||
|
buttonsStyling: false,
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary',
|
||||||
|
cancelButton: 'btn btn-danger'
|
||||||
|
},
|
||||||
|
didOpen: function () {
|
||||||
|
$('.serie-facturacion-select').select2({
|
||||||
|
allowClear: false,
|
||||||
|
minimumResultsForSearch: -1,
|
||||||
|
//dropdownParent: $('#swal2-html-container'),
|
||||||
|
ajax: {
|
||||||
|
url: '/configuracion/series-facturas/menuitemsFacturas',
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
|
||||||
|
data: function (params) {
|
||||||
|
return {
|
||||||
|
id: 'id',
|
||||||
|
text: 'nombre',
|
||||||
|
searchTerm: params.term,
|
||||||
|
|
||||||
|
};
|
||||||
|
},
|
||||||
|
delay: 60,
|
||||||
|
processResults: function (response) {
|
||||||
|
return {
|
||||||
|
results: response.menu
|
||||||
|
};
|
||||||
|
},
|
||||||
|
cache: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
preConfirm: () => {
|
||||||
|
return $('#select-serie').val();
|
||||||
|
}
|
||||||
|
}).then(result => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
if (result.value != null && result.value != '' && result.value != 0) {
|
||||||
|
let id = window.location.pathname.split('/').pop();
|
||||||
|
const ajax = new Ajax(`/pedidos/insertfactura`,
|
||||||
|
{
|
||||||
|
pedido_id: id,
|
||||||
|
serie_id: result.value,
|
||||||
|
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
() => {
|
||||||
|
this.tableFacturas.clearPipeline().draw();
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log("Error:", error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
ajax.post();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
checkAddFactura() {
|
||||||
|
|
||||||
|
if (this.total_facturado == this.total_ejemplares) {
|
||||||
|
this.btnAddFactura.addClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.btnAddFactura.removeClass('d-none');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
/*
|
||||||
|
const dropdown = document.querySelector(".dropdown-language");
|
||||||
|
const activeItem = dropdown.querySelector(".dropdown-menu .dropdown-item");
|
||||||
|
let locale = 'es';
|
||||||
|
if (activeItem) {
|
||||||
|
locale = activeItem.getAttribute("data-language");
|
||||||
|
}
|
||||||
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Presupuestos', 'PresupuestosDirecciones'] }, {},
|
||||||
|
function (translations) {
|
||||||
|
window.language = JSON.parse(translations);
|
||||||
|
new PresupuestoAdminEdit().init();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log("Error getting translations:", error);
|
||||||
|
}
|
||||||
|
).post();*/
|
||||||
|
|
||||||
|
new Pedidos().init();
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Pedidos;
|
||||||
9
httpdocs/themes/vuexy/css/pedidos.css
Normal file
9
httpdocs/themes/vuexy/css/pedidos.css
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.swal2-container {
|
||||||
|
overflow-y: visible !important;
|
||||||
|
}
|
||||||
|
.swal2-html-container {
|
||||||
|
overflow: visible !important;
|
||||||
|
}
|
||||||
|
.select2-dropdown {
|
||||||
|
z-index: 999999999 !important;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user