mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado guardar en el add
This commit is contained in:
@ -1,28 +1,55 @@
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
class PresupuestoAdminAdd{
|
||||
class PresupuestoAdminAdd {
|
||||
|
||||
constructor(){
|
||||
constructor() {
|
||||
|
||||
this.cosido = $("#isCosido");
|
||||
this.tipo_impresion = $("#tipo_impresion_id");
|
||||
this.POD = $("#POD");
|
||||
|
||||
this.inc_rei = $('#incRei');
|
||||
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
|
||||
this.pais = new ClassSelect($('#paisId'), '/paises/menuitems2', 'Seleccione País');
|
||||
|
||||
$('#solapas').addClass('d-none');
|
||||
$('#solapas_sobrecubierta').addClass('d-none');
|
||||
$('#div_solapas_ancho').addClass('d-none');
|
||||
$('#div_solapas_ancho_sobrecubierta').addClass('d-none');
|
||||
this.fecha = $('#updated_at');
|
||||
this.estado = $('#estado_id');
|
||||
this.titulo = $('#titulo');
|
||||
this.autor = $('#autor');
|
||||
this.coleccion = $('#coleccion');
|
||||
this.numeroEdicion = $('#numeroEdicion');
|
||||
this.isbn = $('#isbn');
|
||||
this.referenciaCliente = $('#referenciaCliente');
|
||||
|
||||
this.paginas = $('#paginas');
|
||||
this.tirada = $('#tirada');
|
||||
this.merma = $('#merma');
|
||||
this.mermaCubierta = $('#mermacubierta');
|
||||
|
||||
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
||||
this.tamanioPersonalizado = $('#papelFormatoPersonalizado');
|
||||
this.anchoPersonalizado = $('#papelFormatoAncho');
|
||||
this.altoPersonalizado = $('#papelFormatoAlto');
|
||||
|
||||
this.guardar = $('#saveForm');
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
init(){
|
||||
init() {
|
||||
|
||||
// Fuerza el foco en el campo de búsqueda de select2
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
});
|
||||
|
||||
$('#solapas').addClass('d-none');
|
||||
$('#solapas_sobrecubierta').addClass('d-none');
|
||||
$('#div_solapas_ancho').addClass('d-none');
|
||||
$('#div_solapas_ancho_sobrecubierta').addClass('d-none');
|
||||
$('.solapas-cubierta-div').addClass('d-none');
|
||||
$('.solapas-sobrecubierta-div').addClass('d-none');
|
||||
|
||||
this.cliente.init();
|
||||
this.pais.init();
|
||||
@ -34,6 +61,8 @@ class PresupuestoAdminAdd{
|
||||
});
|
||||
|
||||
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
||||
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
||||
this.tirada.on('change', this.calcular_mermas.bind(this));
|
||||
}
|
||||
|
||||
changeTipoTamanio() {
|
||||
@ -54,7 +83,88 @@ class PresupuestoAdminAdd{
|
||||
$("#label_papelFormatoId").text(
|
||||
window.language.Presupuestos.papelFormatoId + '*');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async guardarPresupuesto() {
|
||||
|
||||
$('#loader').modal('show');
|
||||
|
||||
try {
|
||||
|
||||
let data = this.getFormData();
|
||||
|
||||
new Ajax('/presupuestoadmin/add/', 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.cliente_id = this.cliente.getVal();
|
||||
datos.tipo_impresion_id = this.tipo_impresion.val();
|
||||
datos.cosido = this.cosido.val();
|
||||
|
||||
datos = {
|
||||
...datos, ...{
|
||||
inc_rei: this.inc_rei.select2('data')[0].id,
|
||||
titulo: this.titulo.val(),
|
||||
autor: this.autor.val(),
|
||||
isbn: this.isbn.val(),
|
||||
pais_id: this.pais.getVal(),
|
||||
coleccion: this.coleccion.val(),
|
||||
numero_edicion: this.numeroEdicion.val(),
|
||||
referencia_cliente: this.referenciaCliente.val(),
|
||||
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' '),
|
||||
}
|
||||
}
|
||||
|
||||
datos = {
|
||||
...datos, ...{
|
||||
paginas: this.paginas.val(),
|
||||
tirada: this.tirada.val(),
|
||||
papel_formato_id: this.tamanio.item.hasClass('d-none') ? 0 : this.tamanio.getVal(),
|
||||
papel_formato_personalizado: this.tamanio.item.hasClass('d-none') ? 1 : 0,
|
||||
merma: this.merma.val(),
|
||||
merma_cubierta: this.mermaCubierta.val(),
|
||||
solapas_ancho: "0",
|
||||
solapas_ancho_sobrecubierta: "0",
|
||||
}
|
||||
}
|
||||
if (datos.papel_formato_personalizado) {
|
||||
datos.papel_formato_ancho = this.anchoPersonalizado.val(),
|
||||
datos.papel_formato_alto = this.altoPersonalizado.val()
|
||||
}
|
||||
datos.selectedTirada = this.tirada.val();
|
||||
|
||||
return datos;
|
||||
}
|
||||
|
||||
calcular_mermas() {
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -122,12 +122,25 @@ class PresupuestoAdminEdit {
|
||||
|
||||
try {
|
||||
|
||||
let formData = $('#presupuestoForm').serialize()
|
||||
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');
|
||||
@ -142,13 +155,18 @@ class PresupuestoAdminEdit {
|
||||
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.val();
|
||||
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(),
|
||||
@ -160,29 +178,53 @@ class PresupuestoAdminEdit {
|
||||
...datos, ...{
|
||||
paginas: this.datosLibro.paginas.val(),
|
||||
tirada: this.datosLibro.tirada.val(),
|
||||
papel_formato_id: this.datosLibro.papelFormatoId.hasClass('d-none') ? 0 : this.datosLibro.papelFormatoId.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.servicios = {
|
||||
'prototipo': this.datosLibro.prototipo.is(':checked') ? 1 : 0,
|
||||
'ferro': this.datosLibro.ferro.is(':checked') ? 1 : 0,
|
||||
'ferroDigital': 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 = {
|
||||
...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;
|
||||
}
|
||||
|
||||
this.datos.entrega_taller = this.envios.entrega_taller.is(':checked') ? 1 : 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 = "";
|
||||
@ -202,6 +244,9 @@ class PresupuestoAdminEdit {
|
||||
datos.comentarios_presupuesto = $('#comentariosPdf').val();
|
||||
datos.comentarios_produccion = $('#comentariosProduccion').val();
|
||||
|
||||
datos = { ...datos, ...this.resumen.getData() };
|
||||
|
||||
return datos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -352,64 +352,67 @@ class Comparador {
|
||||
|
||||
this.tipo_impresion.val(datos.tipo_impresion).trigger('change');
|
||||
this.updateOpcionesComparador();
|
||||
this.comparador_json.val(JSON.stringify(datos.json_data));
|
||||
|
||||
if (datos.json_data.bn) {
|
||||
this.paginasNegro.val(datos.json_data.bn.paginas);
|
||||
this.papelNegro.setOption(datos.json_data.bn.papel_id, datos.json_data.bn.papel_nombre);
|
||||
this.gramajeNegro.setOption(datos.json_data.bn.gramaje, datos.json_data.bn.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasNegro.val(0);
|
||||
}
|
||||
if (datos.json_data.bnhq) {
|
||||
this.paginasNegrohq.val(datos.json_data.bnhq.paginas);
|
||||
this.papelNegrohq.setOption(datos.json_data.bnhq.papel_id, datos.json_data.bnhq.papel_nombre);
|
||||
this.gramajeNegrohq.setOption(datos.json_data.bnhq.gramaje, datos.json_data.bnhq.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasNegrohq.val(0);
|
||||
}
|
||||
if (datos.json_data.color) {
|
||||
this.paginasColor.val(datos.json_data.color.paginas);
|
||||
this.papelColor.setOption(datos.json_data.color.papel_id, datos.json_data.color.papel_nombre);
|
||||
this.gramajeColor.setOption(datos.json_data.color.gramaje, datos.json_data.color.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasColor.val(0);
|
||||
}
|
||||
if (datos.json_data.colorhq) {
|
||||
this.paginasColorhq.val(datos.json_data.colorhq.paginas);
|
||||
this.papelColorhq.setOption(datos.json_data.colorhq.papel_id, datos.json_data.colorhq.papel_nombre);
|
||||
this.gramajeColorhq.setOption(datos.json_data.colorhq.gramaje, datos.json_data.colorhq.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasColorhq.val(0);
|
||||
}
|
||||
if (datos.json_data.cubierta) {
|
||||
this.paginasCubierta.val(datos.json_data.cubierta.paginas);
|
||||
this.papelCubierta.setOption(datos.json_data.cubierta.papel_id, datos.json_data.cubierta.papel_nombre);
|
||||
this.gramajeCubierta.setOption(datos.json_data.cubierta.gramaje, datos.json_data.cubierta.gramaje);
|
||||
}
|
||||
if (datos.json_data.sobrecubierta) {
|
||||
this.sobrecubierta.val(datos.json_data.sobrecubierta.imprimir).trigger('change');
|
||||
this.papelSobrecubierta.setOption(datos.json_data.sobrecubierta.papel_id, datos.json_data.sobrecubierta.papel_nombre);
|
||||
this.gramajeSobrecubierta.setOption(datos.json_data.sobrecubierta.gramaje, datos.json_data.sobrecubierta.gramaje);
|
||||
}
|
||||
if (datos.json_data.guardas) {
|
||||
this.carasGuardas.val(datos.json_data.guardas.paginas).trigger('change');
|
||||
this.papelGuardas.setOption(datos.json_data.guardas.papel_id, datos.json_data.guardas.papel_nombre);
|
||||
this.gramajeGuardas.setOption(datos.json_data.guardas.gramaje, datos.json_data.guardas.gramaje);
|
||||
}
|
||||
if (datos.json_data != null) {
|
||||
this.comparador_json.val(JSON.stringify(datos.json_data));
|
||||
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
|
||||
this.lomoRedondo.val(datos.lomoRedondo ? 1 : 0).trigger('change');
|
||||
this.cabezada.val(datos.cabezada).trigger('change');
|
||||
}
|
||||
if (datos.json_data.bn) {
|
||||
this.paginasNegro.val(datos.json_data.bn.paginas);
|
||||
this.papelNegro.setOption(datos.json_data.bn.papel_id, datos.json_data.bn.papel_nombre);
|
||||
this.gramajeNegro.setOption(datos.json_data.bn.gramaje, datos.json_data.bn.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasNegro.val(0);
|
||||
}
|
||||
if (datos.json_data.bnhq) {
|
||||
this.paginasNegrohq.val(datos.json_data.bnhq.paginas);
|
||||
this.papelNegrohq.setOption(datos.json_data.bnhq.papel_id, datos.json_data.bnhq.papel_nombre);
|
||||
this.gramajeNegrohq.setOption(datos.json_data.bnhq.gramaje, datos.json_data.bnhq.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasNegrohq.val(0);
|
||||
}
|
||||
if (datos.json_data.color) {
|
||||
this.paginasColor.val(datos.json_data.color.paginas);
|
||||
this.papelColor.setOption(datos.json_data.color.papel_id, datos.json_data.color.papel_nombre);
|
||||
this.gramajeColor.setOption(datos.json_data.color.gramaje, datos.json_data.color.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasColor.val(0);
|
||||
}
|
||||
if (datos.json_data.colorhq) {
|
||||
this.paginasColorhq.val(datos.json_data.colorhq.paginas);
|
||||
this.papelColorhq.setOption(datos.json_data.colorhq.papel_id, datos.json_data.colorhq.papel_nombre);
|
||||
this.gramajeColorhq.setOption(datos.json_data.colorhq.gramaje, datos.json_data.colorhq.gramaje);
|
||||
}
|
||||
else {
|
||||
this.paginasColorhq.val(0);
|
||||
}
|
||||
if (datos.json_data.cubierta) {
|
||||
this.paginasCubierta.val(datos.json_data.cubierta.paginas);
|
||||
this.papelCubierta.setOption(datos.json_data.cubierta.papel_id, datos.json_data.cubierta.papel_nombre);
|
||||
this.gramajeCubierta.setOption(datos.json_data.cubierta.gramaje, datos.json_data.cubierta.gramaje);
|
||||
}
|
||||
if (datos.json_data.sobrecubierta) {
|
||||
this.sobrecubierta.val(datos.json_data.sobrecubierta.imprimir).trigger('change');
|
||||
this.papelSobrecubierta.setOption(datos.json_data.sobrecubierta.papel_id, datos.json_data.sobrecubierta.papel_nombre);
|
||||
this.gramajeSobrecubierta.setOption(datos.json_data.sobrecubierta.gramaje, datos.json_data.sobrecubierta.gramaje);
|
||||
}
|
||||
if (datos.json_data.guardas) {
|
||||
this.carasGuardas.val(datos.json_data.guardas.paginas).trigger('change');
|
||||
this.papelGuardas.setOption(datos.json_data.guardas.papel_id, datos.json_data.guardas.papel_nombre);
|
||||
this.gramajeGuardas.setOption(datos.json_data.guardas.gramaje, datos.json_data.guardas.gramaje);
|
||||
}
|
||||
|
||||
if (datos.posPagColor != null && datos.posPagColor.length > 0) {
|
||||
this.posPagColor.val(datos.posPagColor);
|
||||
this.#computarPaginasColor(datos.posPagColor);
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
|
||||
this.lomoRedondo.val(datos.lomoRedondo ? 1 : 0).trigger('change');
|
||||
this.cabezada.val(datos.cabezada).trigger('change');
|
||||
}
|
||||
|
||||
if (datos.posPagColor != null && datos.posPagColor.length > 0) {
|
||||
this.posPagColor.val(datos.posPagColor);
|
||||
this.#computarPaginasColor(datos.posPagColor);
|
||||
}
|
||||
}
|
||||
|
||||
this.cargando = false;
|
||||
|
||||
@ -626,7 +626,6 @@ class LineasPresupuesto {
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
|
||||
token = response[window.csrf_token];
|
||||
}
|
||||
}).fail(function (jqXHR, textStatus, error) {
|
||||
// Handle error here
|
||||
|
||||
@ -42,12 +42,12 @@ class Resumen {
|
||||
$("#totalMargenes").text(resumen.total_margenes + "€" || "0€");
|
||||
|
||||
$("#totalAntesDescuento").text(resumen.total_antes_descuento + "€" || "0€");
|
||||
$("#total_descuentoPercent").val(resumen.total_descuentoPercent + "€" || "0€");
|
||||
$("#total_descuentoPercent").val(resumen.total_descuentoPercent || "0");
|
||||
$("#descuentoTotal").text(resumen.total_descuento + "€" || "0€");
|
||||
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€");
|
||||
$("#precioUnidadPresupuesto").text(resumen.total_precio_unidad + "€" || "0€");
|
||||
$("#factor").text(resumen.total_factor + "€" || "0€");
|
||||
$("#factor_ponderado").text(resumen.total_factor_ponderado + "€" || "0€");
|
||||
$("#factor").text(resumen.total_factor || "0");
|
||||
$("#factor_ponderado").text(resumen.total_factor_ponderado || "0");
|
||||
|
||||
if (resumen.total_aceptado !== undefined) {
|
||||
$("#totalAceptado").val(resumen.total_aceptado + "€" || "0€");
|
||||
@ -143,10 +143,10 @@ class Resumen {
|
||||
})
|
||||
}
|
||||
|
||||
totalImpresion -= margenImpresion
|
||||
totalPapel -= margenPapel
|
||||
totalImpresion -= parseFloat(margenImpresion);
|
||||
totalPapel -= parseFloat(margenPapel);
|
||||
|
||||
margenImpresion += margenPorHoras
|
||||
margenImpresion += parseFloat(margenPorHoras);
|
||||
|
||||
let porcentajeMargenPapel = isNaN(margenPapel / (totalPapel) * 100.0) ? 0 : margenPapel / (totalPapel) * 100.0
|
||||
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
|
||||
@ -177,8 +177,8 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = rowData.precio_total;
|
||||
let margen_servicio = rowData.margen;
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
@ -188,8 +188,8 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = rowData.precio_total;
|
||||
let margen_servicio = rowData.margen;
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
@ -199,8 +199,8 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = rowData.precio;
|
||||
let coste_servicio = rowData.coste;
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
totalServicios += total_servicio
|
||||
margenServicios = total_servicio - coste_servicio;
|
||||
});
|
||||
@ -209,8 +209,8 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = rowData.precio;
|
||||
let coste_servicio = rowData.coste;
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
totalServicios += total_servicio
|
||||
margenServicios = total_servicio - coste_servicio;
|
||||
});
|
||||
@ -219,8 +219,8 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = rowData.precio_total;
|
||||
let margen_servicio = rowData.margen;
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
@ -306,6 +306,46 @@ class Resumen {
|
||||
$('#factor_ponderado').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactorPonderado).toFixed(2))
|
||||
|
||||
}
|
||||
|
||||
|
||||
getData(){
|
||||
|
||||
let data = {
|
||||
'total_coste_papel': $('#totalCostePapel').attr('val').replace('€', ''),
|
||||
'total_margen_papel': $('#margenPapel').attr('val').replace('€', ''),
|
||||
'total_margenPercent_papel': $('#porcentajeMargenPapel').text().replace('%', ''),
|
||||
|
||||
'total_coste_impresion': $('#totalCosteImpresion').attr('val').replace('€', ''),
|
||||
'total_margen_impresion': $('#margenImpresion').attr('val').replace('€', ''),
|
||||
'total_margenPercent_impresion': $('#porcentajeMargenImpresion').text().replace('%', ''),
|
||||
|
||||
'total_coste_servicios': $('#totalServicios').attr('val').replace('€', ''),
|
||||
'total_margen_servicios': $('#margenServicios').attr('val').replace('€', ''),
|
||||
'total_margenPercent_servicios': $('#porcentajeMargenServicios').text().replace('%', ''),
|
||||
|
||||
'total_coste_envios': $('#totalEnvios').attr('val').replace('€', ''),
|
||||
'total_margen_envios': $('#margenEnvios').attr('val').replace('€', ''),
|
||||
|
||||
'total_costes': $('#totalCostes').attr('val').replace('€', ''),
|
||||
'total_margenes': $('#totalMargenes').attr('val').replace('€', ''),
|
||||
|
||||
'total_antes_descuento': $('#totalAntesDescuento').attr('val').replace('€', ''),
|
||||
'total_descuento': $('#descuentoTotal').attr('val').replace('€', ''),
|
||||
'total_descuentoPercent': $('#total_descuentoPercent').val().replace('€', ''),
|
||||
'total_presupuesto': $('#totalDespuesDecuento').attr('val').replace('€', ''),
|
||||
'total_precio_unidad': $('#precioUnidadPresupuesto').attr('val').replace('€', ''),
|
||||
|
||||
'total_factor': $('#factor').text().replace(/,/g, '.'),
|
||||
'total_factor_ponderado': $('#factor_ponderado').text().replace(/,/g, '.'),
|
||||
};
|
||||
|
||||
if($('#confirmar_presupuesto').prop('checked')){
|
||||
data.confirmar = '1';
|
||||
data.total_aceptado = $('#totalDespuesDecuento').attr('val').replace('€', '');
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export default Resumen;
|
||||
Reference in New Issue
Block a user