mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into feat/sk-31
This commit is contained in:
@ -61,9 +61,12 @@ class Cliente {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
|
||||
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: ['ClienteContactos', 'ClientePrecios'] }, {},
|
||||
function(translations) {
|
||||
|
||||
@ -147,7 +147,12 @@ class ClienteList {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
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: ['Clientes', 'FormasPago', 'Users'] }, {},
|
||||
function (translations) {
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
})
|
||||
@ -182,7 +182,12 @@ class MaquinasList {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
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: ['Maquinas'] }, {},
|
||||
function (translations) {
|
||||
|
||||
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;
|
||||
@ -775,10 +775,13 @@ class PlantillasTarifasClienteForm {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
|
||||
|
||||
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: ['ClientePrecios'] }, {},
|
||||
function (translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
|
||||
@ -152,7 +152,7 @@ class PresupuestoAdminAdd {
|
||||
datos.papel_formato_alto = this.altoPersonalizado.val()
|
||||
}
|
||||
datos.selectedTirada = this.tirada.val();
|
||||
|
||||
|
||||
return datos;
|
||||
}
|
||||
|
||||
@ -161,9 +161,9 @@ class PresupuestoAdminAdd {
|
||||
const tirada = parseInt($('#tirada').val());
|
||||
const POD = parseInt($('#POD').val());
|
||||
let merma = 0;
|
||||
|
||||
|
||||
merma = tirada * 0.1 <= POD ? tirada * 0.1 : POD;
|
||||
|
||||
|
||||
$('#mermacubierta').val(parseInt(merma))
|
||||
$('#merma').val(parseInt(merma))
|
||||
}
|
||||
@ -172,8 +172,13 @@ class PresupuestoAdminAdd {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
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);
|
||||
|
||||
@ -640,7 +640,12 @@ class PresupuestoAdminEdit {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
const dropdown = document.querySelector(".dropdown-language");
|
||||
const activeItem = dropdown.querySelector(".dropdown-menu .dropdown-item");
|
||||
let locale = 'es';
|
||||
if (activeItem) {
|
||||
locale = activeItem.getAttribute("data-language");
|
||||
}
|
||||
|
||||
$(document).on("keydown", "textarea", function (event) {
|
||||
if (event.key === "Enter" && !event.shiftKey) {
|
||||
|
||||
@ -15,6 +15,8 @@ class DatosGenerales{
|
||||
this.coleccion = this.domItem.find('#coleccion');
|
||||
this.numeroEdicion = this.domItem.find('#numeroEdicion');
|
||||
this.isbn = this.domItem.find('#isbn');
|
||||
|
||||
this.openCliente = this.domItem.find('#openCliente');
|
||||
|
||||
|
||||
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
|
||||
@ -31,6 +33,11 @@ class DatosGenerales{
|
||||
this.inc_rei.select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
this.openCliente.click(()=>{
|
||||
const urlObj = new URL(window.location.href);
|
||||
window.open(`${urlObj.origin}` + '/clientes/cliente/edit/' + this.cliente.getVal());
|
||||
});
|
||||
}
|
||||
|
||||
cargarDatos(datos){
|
||||
|
||||
@ -18,7 +18,7 @@ class Resumen {
|
||||
await self.updateTotales();
|
||||
$(document).trigger('update-totales-completed');
|
||||
});
|
||||
$("#totalDespuesDecuento").on('change',this.updateToastSummary.bind(this))
|
||||
$("#totalDespuesDecuento").on('change', this.updateToastSummary.bind(this))
|
||||
}
|
||||
|
||||
cargar(resumen) {
|
||||
@ -26,7 +26,7 @@ class Resumen {
|
||||
// Mapear los valores a los elementos HTML por ID
|
||||
$("#totalCostePapel").text(resumen.total_coste_papel.toString().replace('.', ',') + "€" || "0€");
|
||||
$("#porcentajeMargenPapel").text(resumen.total_margenPercent_papel ? resumen.total_margenPercent_papel.toString().replace('.', ',') + "%" : "0%");
|
||||
$("#margenPapel").text(resumen.total_margen_papel.toString().replace('.', ',')+ "€" || "0€");
|
||||
$("#margenPapel").text(resumen.total_margen_papel.toString().replace('.', ',') + "€" || "0€");
|
||||
|
||||
$("#totalCosteImpresion").text(resumen.total_coste_impresion.toString().replace('.', ',') + "€" || "0€");
|
||||
$("#porcentajeMargenImpresion").text(resumen.total_margenPercent_impresion ? resumen.total_margenPercent_impresion.toString().replace('.', ',') + "%" : "0%");
|
||||
@ -56,7 +56,7 @@ class Resumen {
|
||||
$("#totalAceptado").val(resumen.total_aceptado.toString().replace('.', ',') + "€" || "0€");
|
||||
}
|
||||
|
||||
$('#ivaReducido').val(resumen.iva_reducido ? 1: 0);
|
||||
$('#ivaReducido').val(resumen.iva_reducido ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
@ -100,6 +100,7 @@ class Resumen {
|
||||
let margenServicios = parseFloat(0);
|
||||
|
||||
let totalEnvios = 0;
|
||||
let totalEnvios_base = 0;
|
||||
let margenEnvios = 0;
|
||||
|
||||
let sumForFactor = 0.0;
|
||||
@ -134,7 +135,7 @@ class Resumen {
|
||||
|
||||
if (rowData.maquinaTipo == 'inkjet') {
|
||||
totalImpresion += parseFloat(rowData.totalTinta)
|
||||
totalImpresion += parseFloat(rowData.totalCorte)?? 0;
|
||||
totalImpresion += parseFloat(rowData.totalCorte) ?? 0;
|
||||
//sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
||||
}
|
||||
|
||||
@ -189,7 +190,7 @@ class Resumen {
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val())) * parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
@ -201,7 +202,7 @@ class Resumen {
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val())) * parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
@ -211,7 +212,7 @@ class Resumen {
|
||||
let rowData = this.data();
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let base = (parseFloat(rowData.precio / (1 + parseFloat(rowData.margen) / 100.0)).toFixed(2));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val())) * parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
totalServicios += total_servicio
|
||||
});
|
||||
@ -222,7 +223,7 @@ class Resumen {
|
||||
let rowData = this.data();
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let base = (parseFloat(rowData.precio / (1 + parseFloat(rowData.margen) / 100.0)).toFixed(2));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val())) * parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
totalServicios += total_servicio;
|
||||
});
|
||||
@ -235,7 +236,7 @@ class Resumen {
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val())) * parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
@ -262,15 +263,16 @@ class Resumen {
|
||||
|
||||
if (updateEnvio) {
|
||||
|
||||
totalEnvios = parseFloat($('#envio_base').val());
|
||||
totalEnvios_base = parseFloat($('#envio_base').val());
|
||||
if (typeof $('#tableOfDireccionesEnvio').DataTable() !== 'undefined' && $('#tableOfDireccionesEnvio').DataTable().rows().count() > 0) {
|
||||
$('#tableOfDireccionesEnvio').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (rowIdx == 0) {
|
||||
return;
|
||||
// el primer envio es el base, y no se debe de cobrar
|
||||
if (rowIdx != 0) {
|
||||
|
||||
let data = this.data()
|
||||
totalEnvios += parseFloat(data.precio)
|
||||
margenEnvios += parseFloat((data.precio) * data.margen / 100)
|
||||
}
|
||||
let data = this.data()
|
||||
totalEnvios += parseFloat(data.precio)
|
||||
margenEnvios += parseFloat((data.precio) * data.margen / 100)
|
||||
});
|
||||
}
|
||||
|
||||
@ -298,10 +300,11 @@ class Resumen {
|
||||
if ($('#total_descuentoPercent').val() < 0) {
|
||||
$('#total_descuentoPercent').val(0)
|
||||
}
|
||||
let totalAntesDescuento = totalCostes + totalMargenes
|
||||
let totalAntesDescuento = totalCostes + totalMargenes - parseFloat(totalEnvios.toFixed(2)) + totalEnvios_base;
|
||||
let totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val() || 0) / 100
|
||||
let totalPresupuesto = totalAntesDescuento - totalDescuento
|
||||
let totalPresupuesto = totalAntesDescuento - totalDescuento; // para el calculo del precio_u solo se tiene en cuenta el base
|
||||
let precioUnidad = totalPresupuesto / parseInt($('#tirada').val())
|
||||
totalPresupuesto += totalEnvios;
|
||||
|
||||
$('#totalAntesDescuento').text((this.addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||
$('#descuentoTotal').text((this.addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
|
||||
@ -313,15 +316,15 @@ class Resumen {
|
||||
$('#precioUnidadPresupuesto').attr('val', (precioUnidad).toFixed(4))
|
||||
$('#totalDespuesDecuento').trigger("change")
|
||||
|
||||
$('#factor').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2), ".", ",", "."))
|
||||
$('#factor').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2))
|
||||
$('#factor_ponderado').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
||||
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
||||
$('#factor').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - totalEnvios_base - margenEnvios) / sumForFactor).toFixed(2), ".", ",", "."))
|
||||
$('#factor').attr('val', ((totalPresupuesto - totalEnvios - totalEnvios_base - margenEnvios) / sumForFactor).toFixed(2))
|
||||
$('#factor_ponderado').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - totalEnvios_base - margenEnvios) / sumForFactorPonderado).toFixed(2), ".", ",", "."))
|
||||
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - totalEnvios_base - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
||||
|
||||
}
|
||||
|
||||
|
||||
getData(){
|
||||
getData() {
|
||||
|
||||
let data = {
|
||||
'total_coste_papel': $('#totalCostePapel').text().replace('€', '').replace(',', '.'),
|
||||
@ -354,7 +357,7 @@ class Resumen {
|
||||
'iva_reducido': $('#ivaReducido').val()
|
||||
};
|
||||
|
||||
if($('#confirmar_presupuesto').prop('checked')){
|
||||
if ($('#confirmar_presupuesto').prop('checked')) {
|
||||
data.confirmar = '1';
|
||||
data.total_aceptado = $('#totalDespuesDecuento').text().replace('€', '').replace(',', '.');
|
||||
}
|
||||
@ -365,15 +368,14 @@ class Resumen {
|
||||
roundToTwoDecimals(num) {
|
||||
return parseFloat(num.toFixed(2));
|
||||
}
|
||||
updateToastSummary()
|
||||
{
|
||||
if(this.toastPresupuestoTotal){
|
||||
updateToastSummary() {
|
||||
if (this.toastPresupuestoTotal) {
|
||||
this.toastPresupuestoTotal.close()
|
||||
}
|
||||
|
||||
this.toastPresupuestoTotal = toastPresupuestoSummary($("#totalDespuesDecuento").text() ?? 0)
|
||||
this.toastPresupuestoTotal.fire().then((result) => {
|
||||
if(result.isDismissed && result.dismiss == 'close'){
|
||||
if (result.isDismissed && result.dismiss == 'close') {
|
||||
this.updateToastSummary()
|
||||
$('html, body').animate(
|
||||
{
|
||||
|
||||
@ -622,7 +622,8 @@ class PresupuestoCliente {
|
||||
('precio-tiradas-' + response.tiradas[i]),
|
||||
response.tiradas[i],
|
||||
precio,
|
||||
response.precio_u[i]
|
||||
response.precio_u[i],
|
||||
response.coste_envio[i]
|
||||
);
|
||||
|
||||
if (this.actualizarTiradasEnvio) {
|
||||
@ -895,7 +896,10 @@ class PresupuestoCliente {
|
||||
$('#menu_resumen_button').trigger('click');
|
||||
setTimeout(() => {
|
||||
self.resumen.init_dropzone();
|
||||
self.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad, response.data.datosGenerales.ivaReducido);
|
||||
self.resumen.generate_total(response.data.resumen.base,
|
||||
response.data.resumen.precio_unidad,
|
||||
response.data.resumen.total_envio,
|
||||
response.data.datosGenerales.ivaReducido);
|
||||
}, 0);
|
||||
}
|
||||
}, 0);
|
||||
@ -988,7 +992,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
}
|
||||
}
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
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' }, {},
|
||||
initialize,
|
||||
|
||||
@ -48,6 +48,8 @@ class Resumen {
|
||||
|
||||
this.precio_unidad = $(this.domItem.find("#resumenPrecioU"));
|
||||
this.total_base = $(this.domItem.find("#resumenTotalBase"));
|
||||
this.total_envios = $(this.domItem.find("#resumenTotalEnvio"));
|
||||
this.total_antes_iva = $(this.domItem.find("#resumenTotalAntesIVA"));
|
||||
this.iva_porcentaje = $(this.domItem.find("#resumenIvaPorcentaje"));
|
||||
this.iva = $(this.domItem.find("#resumenIva"));
|
||||
this.total = $(this.domItem.find("#resumenTotal"));
|
||||
@ -308,19 +310,26 @@ class Resumen {
|
||||
return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades;
|
||||
});
|
||||
|
||||
|
||||
let envios = tarjetaPrecio.find('.tarjeta-tiradas-precios-envio').val();
|
||||
this.total_envios.text(this.#changeDecimalFormat(parseFloat(envios).toFixed(2)));
|
||||
|
||||
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
||||
precio_u_text = precio_u_text.replace('€/ud', '');
|
||||
|
||||
const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data');
|
||||
let base_text = this.#changeDecimalFormat(parseFloat(base).toFixed(2));
|
||||
|
||||
const total_antes_iva_text = this.#changeDecimalFormat((parseFloat(base) + parseFloat(envios)).toFixed(2));
|
||||
|
||||
const iva_porcentaje = parseInt(this.datosGenerales.ivaReducido.find('option:selected').val()) == 1 ? 0.04 : 0.21;
|
||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||
const iva = ((parseFloat(base) + parseFloat(envios))* iva_porcentaje).toFixed(2);
|
||||
let iva_text = this.#changeDecimalFormat(iva);
|
||||
|
||||
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
|
||||
const total = (parseFloat(base) + parseFloat(envios) +parseFloat(iva)).toFixed(2);
|
||||
let total_text = this.#changeDecimalFormat(total);
|
||||
|
||||
|
||||
this.precio_unidad.text(precio_u_text);
|
||||
this.total_base.text(base_text);
|
||||
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '4' : '21');
|
||||
@ -329,23 +338,28 @@ class Resumen {
|
||||
|
||||
}
|
||||
|
||||
generate_total(base, precio_u, iva_reducido) {
|
||||
generate_total(base, precio_u, total_envio, iva_reducido) {
|
||||
|
||||
let precio_u_text = String(precio_u);
|
||||
precio_u_text = precio_u_text.replace('€/u', '');
|
||||
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||
|
||||
let base_text = this.#changeDecimalFormat(String(base));
|
||||
let envios_text = this.#changeDecimalFormat(total_envio.toFixed(2));
|
||||
let total_antes_iva = parseFloat(base) + parseFloat(total_envio);
|
||||
let total_antes_iva_text = this.#changeDecimalFormat(total_antes_iva.toFixed(2));
|
||||
|
||||
const iva_porcentaje = !iva_reducido? 0.21 : 0.04;
|
||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||
const iva = ((parseFloat(base) + parseFloat(total_envio)) * iva_porcentaje).toFixed(2);
|
||||
let iva_text = this.#changeDecimalFormat(iva);
|
||||
|
||||
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
|
||||
const total = (parseFloat(base) + parseFloat(total_envio) + parseFloat(iva)).toFixed(2);
|
||||
let total_text = this.#changeDecimalFormat(total);
|
||||
|
||||
this.precio_unidad.text(precio_u_text);
|
||||
this.total_base.text(base_text);
|
||||
this.total_envios.text(envios_text);
|
||||
this.total_antes_iva.text(total_antes_iva_text);
|
||||
this.iva_porcentaje.text(!iva_reducido? '21' : '4');
|
||||
this.iva.text(iva_text);
|
||||
this.total.text(total_text);
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
class tarjetaTiradasPrecio {
|
||||
|
||||
constructor(domItem, id, tirada, precio, precio_unidad) {
|
||||
constructor(domItem, id, tirada, precio, precio_unidad, envio) {
|
||||
this.domItem = domItem;
|
||||
this.id = id;
|
||||
this.tirada = tirada;
|
||||
this.precio = precio;
|
||||
this.precio_unidad = precio_unidad;
|
||||
this.envio = envio;
|
||||
|
||||
this.card = this.#generateHTML(id, tirada, precio, precio_unidad);
|
||||
this.card = this.#generateHTML(id, tirada, precio, precio_unidad, envio);
|
||||
this.domItem.append(this.card);
|
||||
}
|
||||
|
||||
@ -15,7 +16,7 @@ class tarjetaTiradasPrecio {
|
||||
return value.toLocaleString("de-DE", { minimumFractionDigits: digits, maximumFractionDigits: digits });
|
||||
}
|
||||
|
||||
#generateHTML(id, tirada, precio, precio_unidad) {
|
||||
#generateHTML(id, tirada, precio, precio_unidad, envio) {
|
||||
|
||||
let $html = $('<div>', {
|
||||
id: id,
|
||||
@ -37,6 +38,7 @@ class tarjetaTiradasPrecio {
|
||||
|
||||
const formattedPrecio = this.formatNumber(precio, 2);
|
||||
const formattedPrecioUnidad = this.formatNumber(precio_unidad, 4);
|
||||
|
||||
|
||||
$listContent.append($('<h7>', {
|
||||
id: 'ud_' + id,
|
||||
@ -56,6 +58,12 @@ class tarjetaTiradasPrecio {
|
||||
text: formattedPrecioUnidad + '€/ud'
|
||||
}).attr('data', precio_unidad));
|
||||
|
||||
$listContent.append($('<input>', {
|
||||
id: 'envio_' + id,
|
||||
type: 'hidden',
|
||||
class: 'mb-1 tarjeta-tiradas-precios-envio',
|
||||
}).val(envio));
|
||||
|
||||
$liWrapper.append($listContent);
|
||||
$link.append($liWrapper);
|
||||
$html.append($link);
|
||||
|
||||
@ -293,7 +293,12 @@ class Ticket {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
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: ['Tickets', 'datePicker'] }, {},
|
||||
function (translations) {
|
||||
|
||||
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