mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
583 lines
22 KiB
JavaScript
583 lines
22 KiB
JavaScript
import { getToken } from '../../common/common.js';
|
|
import Ajax from '../../components/ajax.js';
|
|
|
|
import DatosGenerales from './sections/datosGenerales.js';
|
|
import DatosLibro from './sections/datosLibro.js';
|
|
import Comparador from './sections/comparador.js';
|
|
import LineasPresupuesto from './sections/lineasPresupuesto.js';
|
|
import PreviewFormasAdmin from './sections/previewFormasAdmin.js';
|
|
import Servicios from './sections/servicios.js';
|
|
import Envios from './sections/envios.js';
|
|
import TiradasAlernativas from './sections/tiradasAlternativas.js';
|
|
import Resumen from './sections/resumen.js';
|
|
import FileUploadDropzone from '../../components/forms/fileUploadDropzone.js';
|
|
|
|
class PresupuestoAdminEdit {
|
|
|
|
constructor() {
|
|
|
|
this.domItem = $('#presupuestoForm');
|
|
|
|
this.csrf_token = getToken();
|
|
this.csrf_hash = $('#presupuestoForm').find('input[name="' + this.csrf_token + '"]').val();
|
|
|
|
this.lc = $("#lomo_cubierta");
|
|
this.lsc = $("#lomo_sobrecubierta");
|
|
this.cosido = $("#isCosido");
|
|
this.tipo_impresion = $("#tipo_impresion_id");
|
|
this.POD = $("#POD");
|
|
|
|
this.tipoTapa = $('.card-title').text().toLowerCase().includes('dura') ? 'dura' : 'blanda';
|
|
|
|
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
|
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'),
|
|
{
|
|
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
|
getDimensionLibro: this.getDimensionLibro,
|
|
});
|
|
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'),
|
|
{
|
|
getDimensionLibro: this.getDimensionLibro,
|
|
});
|
|
this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'),
|
|
{
|
|
getDimensionLibro: this.getDimensionLibro,
|
|
});
|
|
|
|
this.previewFormasAdmin = null;
|
|
this.servicios = new Servicios();
|
|
this.envios = new Envios();
|
|
this.tiradasAlternativas = new TiradasAlernativas({
|
|
getDimensionLibro: this.getDimensionLibro,
|
|
});
|
|
this.resumen = new Resumen();
|
|
|
|
this.guardar = $('#saveForm');
|
|
|
|
this.calcularPresupuesto = false;
|
|
this.configUploadDropzone = {
|
|
domElement: '#dropzone-presupuesto-admin-files',
|
|
nameId: "presupuesto_id",
|
|
getUri: '/presupuestos/presupuestocliente/get_files',
|
|
postUri: '/presupuestos/presupuestocliente/upload_files'
|
|
}
|
|
if ($(this.configUploadDropzone.domElement).length > 0) {
|
|
this.fileUploadDropzone = new FileUploadDropzone(this.configUploadDropzone)
|
|
}
|
|
}
|
|
|
|
init() {
|
|
|
|
// Fuerza el foco en el campo de búsqueda de select2
|
|
$(document).on('select2:open', () => {
|
|
document.querySelector('.select2-search__field').focus();
|
|
});
|
|
|
|
const impresion_id = $('#tipo_impresion_id').val();
|
|
let tipoLibro = '';
|
|
if (impresion_id == 1 || impresion_id == 2) {
|
|
tipoLibro = 'fresado';
|
|
} else if (impresion_id == 3 || impresion_id == 4) {
|
|
tipoLibro = 'cosido';
|
|
} else if (impresion_id == 5 || impresion_id == 6) {
|
|
tipoLibro = 'espiral';
|
|
} else if (impresion_id == 7 || impresion_id == 8) {
|
|
tipoLibro = 'wireo';
|
|
} else if (impresion_id == 21) {
|
|
tipoLibro = 'grapado';
|
|
}
|
|
|
|
|
|
this.datosGenerales.init();
|
|
this.datosLibro.init();
|
|
this.comparador.init();
|
|
this.lineasPresupuesto.init();
|
|
|
|
this.previewFormasAdmin = new PreviewFormasAdmin(tipoLibro, this.tipoTapa,
|
|
{
|
|
ancho: () => this.getDimensionLibro().ancho,
|
|
alto: () => this.getDimensionLibro().alto,
|
|
lomo: () => $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
|
lomoSobrecubierta: () => $('#lomo_sobrecubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_sobrecubierta').val()),
|
|
solapas: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0,
|
|
solapas_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0,
|
|
lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0,
|
|
}
|
|
);
|
|
this.previewFormasAdmin.init();
|
|
this.servicios.init();
|
|
this.envios.init();
|
|
this.tiradasAlternativas.init();
|
|
this.resumen.init();
|
|
|
|
if (window.location.href.includes("edit")) {
|
|
|
|
setTimeout(() => {
|
|
this.#cargarPresupuesto();
|
|
}, 0);
|
|
|
|
const successMessage = sessionStorage.getItem('message');
|
|
if (successMessage) {
|
|
popSuccessAlert(successMessage);
|
|
sessionStorage.removeItem('message');
|
|
}
|
|
}
|
|
this.downloadPreviewImage();
|
|
|
|
$(document).on('update-presupuesto', this.updatePresupuesto.bind(this));
|
|
|
|
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
|
|
|
$('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta);
|
|
$('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta);
|
|
if ($(this.configUploadDropzone.domElement).length > 0) {
|
|
this.fileUploadDropzone.init()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
async guardarPresupuesto() {
|
|
|
|
$('#loader').modal('show');
|
|
|
|
try {
|
|
|
|
const id = window.location.href.split("/").pop();
|
|
let data = this.getFormData();
|
|
|
|
await this.servicios.guardar();
|
|
await this.envios.guardarEnvios();
|
|
await this.lineasPresupuesto.guardarLineasPresupuesto();
|
|
|
|
new Ajax('/presupuestoadmin/edit/' + id, data, {},
|
|
function (response) {
|
|
popSuccessAlert(response.mensaje);
|
|
$('#loader').modal('hide');
|
|
},
|
|
function (error) {
|
|
console.error(error);
|
|
$('#loader').modal('hide');
|
|
}
|
|
).post();
|
|
|
|
|
|
} catch (error) {
|
|
console.error(error);
|
|
$('#loader').modal('hide');
|
|
}
|
|
}
|
|
|
|
|
|
getFormData() {
|
|
|
|
let datos = {};
|
|
|
|
datos.id = window.location.href.split("/").pop();
|
|
datos.cliente_id = this.datosGenerales.cliente.getVal();
|
|
datos.tipo_impresion_id = this.tipo_impresion.val();
|
|
datos.cosido = this.cosido.val();
|
|
datos.lomo_cubierta = this.lc.val();
|
|
datos.lomo_sobrecubierta = this.lsc.val();
|
|
datos.envio_base = $('#envio_base').val();
|
|
|
|
datos = {
|
|
...datos, ...{
|
|
inc_rei: this.datosGenerales.inc_rei.select2('data')[0].id,
|
|
titulo: this.datosGenerales.titulo.val(),
|
|
autor: this.datosGenerales.autor.val(),
|
|
isbn: this.datosGenerales.isbn.val(),
|
|
pais_id: this.datosGenerales.pais.getVal(),
|
|
coleccion: this.datosGenerales.coleccion.val(),
|
|
numero_edicion: this.datosGenerales.numeroEdicion.val(),
|
|
referencia_cliente: this.datosGenerales.referenciaCliente.val(),
|
|
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' '),
|
|
}
|
|
}
|
|
|
|
datos = {
|
|
...datos, ...{
|
|
paginas: this.datosLibro.paginas.val(),
|
|
tirada: this.datosLibro.tirada.val(),
|
|
papel_formato_id: this.datosLibro.tamanio.item.hasClass('d-none') ? 0 : this.datosLibro.tamanio.getVal(),
|
|
papel_formato_personalizado: this.datosLibro.tamanio.item.hasClass('d-none') ? 1 : 0,
|
|
merma: this.datosLibro.merma.val(),
|
|
merma_cubierta: this.datosLibro.mermaCubierta.val()
|
|
}
|
|
}
|
|
if (datos.papel_formato_personalizado) {
|
|
datos.papel_formato_ancho = this.datosLibro.anchoPersonalizado.val(),
|
|
datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val()
|
|
}
|
|
datos.selectedTirada = this.datosLibro.tirada.val();
|
|
datos.acabado_cubierta_id = this.datosLibro.acabadoCubierta.getVal();
|
|
datos.acabado_sobrecubierta_id = this.datosLibro.acabadoSobrecubierta.getVal();
|
|
|
|
datos = {
|
|
...datos, ...{
|
|
'prototipo': this.datosLibro.prototipo.is(':checked') ? 1 : 0,
|
|
'ferro': this.datosLibro.ferro.is(':checked') ? 1 : 0,
|
|
'ferro_digital': this.datosLibro.ferroDigital.is(':checked') ? 1 : 0,
|
|
'marcapaginas': this.datosLibro.marcapaginas.is(':checked') ? 1 : 0,
|
|
'retractilado': this.datosLibro.retractilado.is(':checked') ? 1 : 0,
|
|
'retractilado5': this.datosLibro.retractilado5.is(':checked') ? 1 : 0,
|
|
}
|
|
};
|
|
|
|
datos.comp_tipo_impresion = this.comparador.tipo_impresion.val();
|
|
datos.comp_pos_paginas_color = this.comparador.posPagColor.val();
|
|
|
|
|
|
if (this.comparador.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
|
|
datos.lomoRedondo = this.comparador.lomoRedondo.select2('data')[0].id;
|
|
datos.cabezada = this.comparador.cabezada.val();
|
|
}
|
|
else {
|
|
datos.lomoRedondo = 0;
|
|
}
|
|
|
|
if ($('#tipo_impresion_id').val() != 1 && $('#tipo_impresion_id').val() != 3 &&
|
|
$('#tipo_impresion_id').val() != 5 && $('#tipo_impresion_id').val() != 7) {
|
|
datos.solapas = this.datosLibro.solapasCubierta.is(':checked') ? 1 : 0;
|
|
datos.solapas_ancho = this.datosLibro.anchoSolapasCubierta.val();
|
|
}
|
|
|
|
datos.solapas_sobrecubierta = this.datosLibro.solapasSobrecubierta.is(':checked') ? 1 : 0;
|
|
datos.solapas_ancho_sobrecubierta = this.datosLibro.anchoSolapasSobrecubierta.val();
|
|
|
|
datos.entrega_taller = this.envios.recogerTaller.is(':checked') ? 1 : 0;
|
|
if (parseInt(this.cosido.val())) {
|
|
|
|
let paginas_por_cuadernillo = "";
|
|
|
|
this.servicios.ServiciosEncuadernacion.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
var rowData = this.data();
|
|
if (rowData.paginas_por_cuadernillo != null) {
|
|
paginas_por_cuadernillo = rowData.paginas_por_cuadernillo;
|
|
}
|
|
});
|
|
|
|
datos.paginas_por_cuadernillo = paginas_por_cuadernillo;
|
|
}
|
|
|
|
datos.comentarios_cliente = $('#comentariosCliente').val();
|
|
datos.comentarios_safekat = $('#comentariosSafekat').val();
|
|
datos.comentarios_presupuesto = $('#comentariosPdf').val();
|
|
datos.comentarios_produccion = $('#comentariosProduccion').val();
|
|
|
|
datos = { ...datos, ...this.resumen.getData() };
|
|
|
|
this.comparador.generateCompJSON();
|
|
datos.comparador_json_data = $('#comparador_json_data').val();
|
|
|
|
return datos;
|
|
}
|
|
|
|
|
|
async updatePresupuesto(event, {
|
|
|
|
update_lineas = true,
|
|
update_servicios = true,
|
|
update_envios = true,
|
|
update_resumen = true,
|
|
update_tiradas_alternativas = true
|
|
}) {
|
|
const waitForEvent = (eventName) => {
|
|
return new Promise((resolve) => {
|
|
$(document).one(eventName, () => {
|
|
resolve();
|
|
});
|
|
});
|
|
};
|
|
|
|
// Ejecutar los pasos de forma secuencial si están habilitados
|
|
if (update_lineas) {
|
|
$(document).trigger('update-lineas-presupuesto');
|
|
await waitForEvent('update-lineas-presupuesto-completed');
|
|
}
|
|
|
|
if (update_servicios) {
|
|
$(document).trigger('update-servicios');
|
|
await waitForEvent('update-servicios-completed');
|
|
}
|
|
|
|
if (update_envios) {
|
|
$(document).trigger('update-envios');
|
|
await waitForEvent('update-envios-completed');
|
|
}
|
|
|
|
if (update_resumen) {
|
|
$(document).trigger('update-totales');
|
|
await waitForEvent('update-totales-completed');
|
|
}
|
|
|
|
if (update_tiradas_alternativas) {
|
|
$(document).trigger('update-tiradas-alternativas');
|
|
await waitForEvent('update-tiradas-alternativas-completed');
|
|
}
|
|
}
|
|
|
|
|
|
#cargarPresupuesto() {
|
|
|
|
const self = this;
|
|
|
|
$('#loader').modal('show');
|
|
let id = window.location.href.split("/").pop()
|
|
new Ajax('/presupuestoadmin/cargar/' + id,
|
|
{},
|
|
{},
|
|
(response) => {
|
|
|
|
if (response.status === 1) {
|
|
|
|
self.lc.val(parseFloat(response.data.lc).toFixed(2));
|
|
self.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
|
self.cosido.val(response.data.cosido ? 1 : 0);
|
|
self.tipo_impresion.val(response.data.tipo_impresion);
|
|
self.POD.val(response.data.POD);
|
|
|
|
self.calcularPresupuesto = false;
|
|
|
|
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
|
self.datosLibro.cargarDatos(response.data.datosLibro);
|
|
self.comparador.cargarDatos(response.data.comparador);
|
|
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
|
|
|
|
self.servicios.cargar(response.data.servicios);
|
|
self.envios.cargar(response.data.direcciones);
|
|
|
|
$('#comentariosCliente').val(response.data.comentarios_cliente);
|
|
$('#comentariosSafekat').val(response.data.comentarios_safekat);
|
|
$('#comentariosPdf').val(response.data.comentarios_presupuesto);
|
|
$('#comentariosProduccion').val(response.data.comentarios_produccion);
|
|
|
|
self.tiradasAlternativas.cargar(response.data.tiradasAlternativas);
|
|
|
|
self.resumen.cargar(response.data.resumen);
|
|
|
|
setTimeout(() => {
|
|
|
|
$('#loader').modal('hide');
|
|
|
|
if (response.data.state != 2) {
|
|
|
|
self.calcularPresupuesto = true;
|
|
}
|
|
|
|
}, 0);
|
|
|
|
this.calcularSolapas();
|
|
|
|
// Funciones para detectar cambios en el formulario
|
|
this.#checkChangesPresupuesto();
|
|
$('#bc-save').on("click", function () {
|
|
showBreadCrumbSaveButton(false);
|
|
$('#saveForm').trigger('click');
|
|
});
|
|
}
|
|
},
|
|
() => {
|
|
$('#loader').modal('hide');
|
|
this.calcularPresupuesto = true;
|
|
}
|
|
).get();
|
|
}
|
|
|
|
|
|
checkPaginasPresupuesto() {
|
|
|
|
let cantidad_total = 0;
|
|
|
|
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
var rowData = this.data();
|
|
if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
|
|
cantidad_total += parseInt(rowData.paginas)
|
|
})
|
|
htmlString = ''
|
|
|
|
if (cantidad_total != parseInt($('#paginas').val())) {
|
|
htmlString = `
|
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
<i class="ti ti-bell ti-sm"></i>
|
|
</span>
|
|
<div class="d-flex flex-column ps-1">
|
|
<h5 class="alert-heading mb-2">` +
|
|
window.Presupuestos.errores.paginasLP +
|
|
`</h5>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
$('#divAlarmasLineasPresupuesto').html(htmlString)
|
|
}
|
|
|
|
|
|
getPaginasColor() {
|
|
|
|
let paginasColor = 0;
|
|
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
var rowData = this.data();
|
|
if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') {
|
|
return parseInt(rowData.paginas);
|
|
}
|
|
if (rowData.row_id === 'lp_rot_color') {
|
|
return parseInt(rowData.numPagColor);
|
|
}
|
|
});
|
|
return paginasColor;
|
|
}
|
|
|
|
calcularSolapas() {
|
|
|
|
let anchoTotal = 2*this.getDimensionLibro().ancho;
|
|
let maxSolapas = 120;
|
|
|
|
let mano = 0;
|
|
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
var rowData = this.data();
|
|
if (rowData.row_id != 'lp_cubierta' || rowData.row_id === 'lp_sobrecubierta'
|
|
|| rowData.row_id === 'lp_guardas' || rowData.row_id === 'lp_faja'
|
|
) {
|
|
mano += parseInt(rowData.mano);
|
|
}
|
|
});
|
|
|
|
if (mano > 0) {
|
|
anchoTotal += 6 + 5; // dobleces + sangre
|
|
maxSolapas = Math.min(Math.floor((865-anchoTotal)/2), 0.75*this.getDimensionLibro().ancho);
|
|
}
|
|
else{
|
|
maxSolapas = 0.75*this.getDimensionLibro().ancho;
|
|
}
|
|
if($('#solapas_ancho').length>0 && $('#solapas_ancho').attr('max') != maxSolapas){
|
|
$('#solapas_ancho').attr('max', maxSolapas);
|
|
$('#solapas_ancho').trigger('change');
|
|
$('#solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
|
}
|
|
if($('#solapas_ancho_sobrecubierta').length>0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas){
|
|
$('#solapas_ancho_sobrecubierta').attr('max', maxSolapas);
|
|
$('#solapas_ancho_sobrecubierta').trigger('change');
|
|
$('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
|
}
|
|
if($('#solapas_ancho_faja').length>0 && $('#solapas_ancho_faja').attr('max') != maxSolapas){
|
|
$('#solapas_ancho_faja').attr('max', maxSolapas);
|
|
$('#solapas_ancho_faja').trigger('change');
|
|
$('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
|
}
|
|
console.log('maxSolapas', maxSolapas);
|
|
}
|
|
|
|
getDimensionLibro() {
|
|
|
|
var ancho = 0;
|
|
var alto = 0;
|
|
|
|
|
|
if ($('#papelFormatoPersonalizado').is(':checked')) {
|
|
ancho = parseFloat($('#papelFormatoAncho').val());
|
|
alto = parseFloat($('#papelFormatoAlto').val());
|
|
}
|
|
else {
|
|
const selectedText = $('#papelFormatoId').find('option:selected').text();
|
|
if (selectedText.length > 0) {
|
|
ancho = parseFloat(selectedText.trim().split(" x ")[0]);
|
|
alto = parseFloat(selectedText.trim().split(" x ")[1]);
|
|
}
|
|
}
|
|
|
|
return {
|
|
ancho: ancho,
|
|
alto: alto
|
|
}
|
|
}
|
|
|
|
|
|
#checkChangesPresupuesto() {
|
|
// Detectar cambios en inputs de texto
|
|
$('input[type="text"]').on('change', function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
// Detectar cambios en inputs de texto
|
|
$('input[type="number"]').on('change', function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
// Detectar cambios en select
|
|
$('select').on('change', function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
$('.select2bs').on('change', function (e) {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
// Detectar cambios en checkboxes
|
|
$('input[type="checkbox"]').change(function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
// Detectar cambios en textareas
|
|
$('textarea').on('input', function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
// Detectar cambios en otros tipos de input
|
|
$('input[type="radio"]').change(function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
|
|
// Detectar cambios en otros tipos de input
|
|
$('input:not([type])').on('input', function () {
|
|
showBreadCrumbSaveButton(true);
|
|
});
|
|
}
|
|
downloadPreviewImage() {
|
|
$(document).on("click", ".download-shape", (event) => {
|
|
let parentDiv = $(event.currentTarget).parent().parent();
|
|
let shapeSvgElQuery = $(parentDiv).find("svg");
|
|
let shapeSvgEl = shapeSvgElQuery[0];
|
|
const filename = shapeSvgElQuery.parent().attr("id") ?? "image"
|
|
const serializer = new XMLSerializer();
|
|
const svgData = serializer.serializeToString(shapeSvgEl);
|
|
const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' });
|
|
const svgUrl = URL.createObjectURL(svgBlob);
|
|
const img = new Image();
|
|
img.onload = () => {
|
|
const canvas = document.createElement('canvas');
|
|
canvas.width = img.width;
|
|
canvas.height = img.height;
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.drawImage(img, 0, 0);
|
|
const pngUrl = canvas.toDataURL('image/png');
|
|
const downloadLink = document.createElement('a');
|
|
downloadLink.href = pngUrl;
|
|
downloadLink.download = filename ?? '.png';
|
|
document.body.appendChild(downloadLink);
|
|
downloadLink.click();
|
|
document.body.removeChild(downloadLink);
|
|
|
|
URL.revokeObjectURL(svgUrl);
|
|
};
|
|
|
|
img.src = svgUrl;
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
|
|
|
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();
|
|
}); |