falta sumar envios

This commit is contained in:
jaimejimenezortega
2024-05-09 22:08:38 +02:00
parent 4debac578a
commit 5ae6618c37
9 changed files with 25826 additions and 162 deletions

View File

@ -1,40 +1,47 @@
<div class="col-12 pb-2">
<div class="row mb-3">
<h3>Resumen</h3>
<div class="col-sm-6">
<h3>Resumen</h3>
<h4>Libro</h4>
<p>Rústica cosido tapa blanda</p>
<p>Número de páginas: 200</p>
<p>Tirada: 200</p>
<p>Prototipo: NO</p>
<h5 class="mb-1">Libro</h5>
<p class="mb-0"><small id="tipoLibro">Rústica cosido tapa blanda</small></p>
<p class="mb-0"><small id="resumenTamanio">Tamaño: 100x100</small></p>
<p class="mb-0"><small id="resumenPaginas">Número de páginas: 200</small></p>
<p class="mb-0"><small id="resumenTirada">Tirada: 200</small></p>
<p class="mb-0"><small id="resumenPrototipo">Prototipo: NO</small></p>
<p class="mb-3"><small id="resumenFerro">Ferro: NO</small></p>
<h4>Interior</h4>
<p>Impresion: Negro premium</p>
<p>Páginas a color: 100</p>
<p>Papel: Blanco Offset 70gr/m^2</p>
<h5 class="mb-1">Interior</h5>
<p class="mb-0"><small id="tipoImpresion">Impresion: Negro premium</small></p>
<p id="pResumenPaginasColor" class="mb-0" style="display:none"><small id="resumenPaginasColor">Páginas a color: 100</small></p>
<p class="mb-3"><small id="resumenPapelInterior">Papel: Blanco Offset 70gr/m²</small></p>
<h4>Cubierta</h4>
<p>Papel: Blanco Offset 70gr/m^2</p>
<p>Impresión: 1 cara</p>
<h5 class="mb-1">Cubierta</h5>
<p class="mb-0"><small id="resumenPapelCubierta">Papel: Blanco Offset 70gr/m²</small></p>
<p class="mb-0"><small id="resumenCarasCubierta">Impresión: 1 cara</small></p>
<p class="mb-0"><small id="resumenSolapasCubierta">Solapas: 25mm</small></p>
<p class="mb-3"><small id="resumenAcabadoCubierta">Acabado: Ninguno</small></p>
<h4>Sobrecubierta</h4>
<p>Papel: Blanco Offset 70gr/m^2</p>
<p>Impresión: sin impresion</p>
<h5 class="mb-1 resumen-sobrecubierta">Sobrecubierta</h5>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenPapelSobrecubierta">Papel: Blanco Offset 70gr/m<sup>2</sup></small></p>
<p class="mb-0 resumen-sobrecubierta"><small id="resumenSolapasCubierta">Ancho solapas: 25mm</small></p>
<p class="mb-3 resumen-sobrecubierta"><small id="resumenAcabadoCubierta">Acabado: Ninguno</small></p>
<h4>Guardas</h4>
<p>Papel: Blanco Offset 70gr/m^2</p>
<p>Impresión: 1 cara</p>
<h5 class="mb-1 resumen-guardas">Guardas</h5>
<p class="mb-0 resumen-guardas"><small id="resumenGuardasPapel">Papel: Blanco Offset 70gr/m<sup>2</sup></small></p>
<p class="mb-3 resumen-guardas"><small id="resumenGuardasCaras">Impresión: 1 cara</small></p>
<h4>Extras</h4>
<p>Retractilado de 5</p>
<h5 class="mb-1 resumen-extras">Extras</h5>
<p class="mb-0 resumen-extras" id="resumenRetractilado1"><small>Retractilado individual</small></p>
<p class="mb-0 resumen-extras" id="resumenRetractilado5"><small>Retractilado de 5</small></p>
<p class="mb-0 resumen-extras" id="resumenFajaColor"><small>Imprimir faja a color</small></p>
</div>
<div class="col-sm-6">
<h6>Coste impresion: 100</h6>
<h6>Coste impresion (4% IVA): 104</h6>
<h6>Precio unidad (I.V.A. incl): 10.4</h6>
<h6>Coste Envío: 30</h6>
<h6>Total (I.V.A. inc.): 134</h6>
<h4 id="resumenTotal" class="mb-1">Total: 100</h4>
<h6 id="resumenPrecioU" class="mb-0">10.4/ud</h6>
<h6 id="resumenTotalIVA"class="mb-0">Coste impresion (4% IVA): 104</h6>
<h6 id="resumenEnvio" class="mb-1">Envío: 30</h6>
</div>
</div>
</div>

View File

@ -33,12 +33,13 @@ function initTiradasDirecciones() {
let tirada_id = "ud_tiradaPrecio" + i;
let total_id = "tot_tiradaPrecio" + i;
let precio_u_id = "pu_tiradaPrecio" + i;
let peso = $('#' + id).attr('peso');
let html = '';
html += '<div class="col-sm-3">';
html += '<div class="form-check custom-option custom-option-basic custom-option-tiradasDirecciones' + (i==1?' checked':'')+ ' ">';
html += '<label class="form-check-label custom-option-content" for="tiradaEnvios' + i + '">';
html += '<input name="' + id + '" class="form-check-input" type="radio" value="" id="' + id + '">';
html += '<input name=env_"' + id + '" peso="' + peso + '" class="form-check-input" type="radio" value="" id="env_' + id + '">';
html += '<span class="custom-option-header">';
html += '<span id="tiradaDireccionesValue' + i + '" class="h6 mb-0">' + $('#' + tirada_id).text().split(' ')[0] + '</span>';
html += '<span class="text-muted">' + $('#' + total_id).text() + '</span>';
@ -127,11 +128,13 @@ $('#insertarDireccion').on('click', function() {
if($('#prototipo').is(':checked')) {
tirada += 1;
}
if(total + unidades <= tirada) {
data = {
id: $('#direcciones').val()
id: $('#direcciones').val(),
peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
unidades: unidades
},
data = Object.assign(data, window.token_ajax)
@ -142,7 +145,7 @@ $('#insertarDireccion').on('click', function() {
success: function(response) {
if(response.data.length > 0) {
let html = '';
html += '<div id="envioId' + response.data[0].id + '" class="row mb-3">';
html += '<div id="envioId' + response.data[0].id + '" p= ' +response.data[0].coste + ' class="row mb-3">';
html += '<div class="col-sm-5 form-check custom-option custom-option-basic checked">';
html += '<label class="form-check-label custom-option-content" for="customRadioAddress1">';
html += '<span class="custom-option-header mb-2">';

View File

@ -708,35 +708,32 @@ async function calcularPresupuesto() {
console.log(response);
$('#loader').hide();
if(error){
$('#divTiradasPrecio').empty();
}
else{
$('#precios').show();
$('#divTiradasPrecio').empty();
$('#precios').show();
for (i = 0; i < response.tiradas.length; i++) {
const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ;
const label = "tiradaPrecio" + parseInt(i+1);
for (i = 0; i < response.tiradas.length; i++) {
const total = (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2) ;
const label = "tiradaPrecio" + parseInt(i+1);
let html = '';
let html = '';
html += '<div id="' + label + '" class="list-group" >';
html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">';
html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >';
html += '<div class="list-content">';
html += '<h7 id="ud_' + label + '" class="mb-1">' + (response.tiradas[i] + ' ud.') + '</h7>';
html += '<h6 id="tot_' + label + '" class="mb-1">' + ('Total: ' + total + '€') + '</h6>';
html += '<h7 id="pu_' + label + '" class="mb-1">' + (response.precio_u[i] + '€/ud') + '</h7>';
html += '</div>';
html += '</div>'
html += '</a>';
html += '</div>';
html += '<div id="' + label + '" peso="' +response.peso[i]+ '" class="list-group" >';
html += '<a href="javascript:void(0);" class="list-group-item list-group-item-action">';
html += '<div class="li-wrapper d-flex justify-content-start align-items-center" >';
html += '<div class="list-content">';
html += '<h7 id="ud_' + label + '" class="mb-1">' + (response.tiradas[i] + ' ud.') + '</h7>';
html += '<h6 id="tot_' + label + '" class="mb-1">' + ('Total: ' + total + '€') + '</h6>';
html += '<h7 id="pu_' + label + '" class="mb-1">' + (response.precio_u[i] + '€/ud') + '</h7>';
html += '</div>';
html += '</div>'
html += '</a>';
html += '</div>';
$('#divTiradasPrecio').append(html);
}
}
$('#divTiradasPrecio').append(html);
}
},
error: function (error) {
$('#loader').hide();

View File

@ -237,10 +237,16 @@
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
if(validarEnvio())
if(validarEnvio()){
generarResumen();
validationStepper.next();
}
else{
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
let text = "El número de unidades enviadas no coincie con la tirada seleccionada.";
if($('#prototipo').is(':checked')) {
text += "<br>(Tenga en cuenta que se ha seleccionado la opción de prototipo)";
}
$('#errorDirecciones').text(text);
$('#errorDirecciones').show();
}
});
@ -303,6 +309,10 @@
break;
case 3:
validationStepper.previous();
break;
case 2:
for (let i = 0; i < 4; i++) {
let id = "tiradaPrecio" + i;
if ($('#' + id).length > 0) {
@ -312,10 +322,6 @@
validationStepper.previous();
break;
case 2:
validationStepper.previous();
break;
case 1:
validationStepper.previous();
break;

View File

@ -0,0 +1,107 @@
function generarResumen(){
$('#tipoLibro').text($('#tituloDisenioLibro').text() + ' tapa ' + (($('#tapaBlandaInnerDiv').hasClass('checked'))?'blanda':'dura'));
$('#resumenTamanio').text('Dimensiones: ' + getDimensionLibro().ancho + 'x' + getDimensionLibro().alto + 'mm');
$('#resumenPaginas').text('Páginas: '+ $('#paginas').val() + ' páginas');
const seleccion = $('.custom-option-tiradasDirecciones.checked');
let tirada = 0;
if(seleccion.length != 0) {
const element_tirada =($(seleccion[0]).find('label input')[0]);
const number = element_tirada.id.match(/\d+$/);
if (number.length != 0) {
tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
}
}
$('#resumenTirada').text('Tirada: '+ tirada + ' unidades');
$('#resumenPrototipo').text('Prototipo: ' + (($('#prototipo').is(':checked'))?'Sí':'No'));
$('#resumenFerro').text('Ferro: ' + (($('#ferro').is(':checked'))?'Sí':'No'));
$('#tipoImpresion').text('Impresión: ' +
($('#colorNegroDiv').hasClass('checked')?'Negro ':'Color ') +
($('#calidadEstandarDiv').hasClass('checked')?'Estándar': 'Premium'));
if($('#colorNegroDiv').hasClass('checked')){
$('#pResumenPaginasColor').hide();
}
else{
$('#pResumenPaginasColor').show();
$('#resumenPaginasColor').text($('#paginasColor').val());
}
$('#resumenPapelInterior').text($('#papelInterior option:selected').text().trim() + ' ' +
$('#gramajeInterior option:selected').text() + 'gr/m²');
let papelCubierta = $('#papelCubierta option:selected').text().trim() + ' ' +
$('#gramajeCubierta option:selected').text();
papelCubierta += 'gr/m<sup>2</sup>';
$('#resumenPapelCubierta').text(papelCubierta);
$('#resumenCarasCubierta').text('Impresión: ' + $('#carasCubierta option:selected').text())
$('#resumenAcabadoCubierta').text('Acabado: ' + $('#acabadosCubierta option:selected').text())
if ($('#solapasCubierta').is(':checked')) {
$('#resumenSolapasCubierta').text('Solapas: ' + $('#anchoSolapasCubierta').val())
}
else{
$('#resumenSolapasCubierta').text('Solapas: No')
}
if ($('.enable-sobrecubierta').is(':visible')) {
$(".resumen-sobrecubierta").show();
$('#resumenPapelCubierta').text($('#papelSobrecubierta option:selected').text().trim() + ' ' +
$('#gramajeSobrecubierta option:selected').text() + 'gr/m²');
$('#resumenAcabadoSobrecubierta').text('Acabado: ' + $('#acabadosSobrecubierta option:selected').text())
$('#resumenSolapasSobrecubierta').text('Solapas: ' + $('#anchoSolapasSobrecubierta').val())
}
else{
$(".resumen-sobrecubierta").hide();
}
if ($('.guardas').is(':visible')) {
$(".resumen-guardas").show();
$('#resumenGuardasPapel').text($('#papelGuardas option:selected').text().trim() + ' ' + '170gr/m²');
$('#resumenGuardasCaras').text('Impresión: ' + $('#impresionGuardas option:selected').text())
}
else{
$(".resumen-guardas").hide();
}
if($('#retractilado').is(':checked') || $('#retractilado5').is(':checked') || $('#fajaColor').is(':checked')){
$('.resumen-extras').show();
$('#retractilado').is(':checked')?$('#resumenRetractilado1').show():$('#resumenRetractilado1').hide();
$('#retractilado5').is(':checked')?$('#resumenRetractilado5').show():$('#resumenRetractilado5').hide();
$('#fajaColor').is(':checked')?$('#resumenFajaColor').show():$('#resumenFajaColor').hide();
}
else{
$('.resumen-extras').hide();
}
for (i = 1; i <= 4; i++) {
let id = "tiradaPrecio" + i;
if ($('#' + id).length > 0) {
let tirada_id = "ud_tiradaPrecio" + i;
if(parseInt($('#' + tirada_id).text().replace(' ud.', '')) != tirada){
continue;
}
let total_id = "tot_tiradaPrecio" + i;
let precio_u_id = "pu_tiradaPrecio" + i;
$('#resumenTotal').text($('#' + total_id).text());
$('#resumenPrecioU').text($('#' + precio_u_id).text());
let total = parseFloat($('#' + total_id).text().replace('€', '').replace('Total: ', ''));
let total_iva = 0.0;
if($('#ivaReducido').val() == '1'){
total_iva = total * 1.04;
}
else{
total_iva = total * 1.21;
}
$('#resumenTotalIVA').text('Total (I.V.A. ' + (($('#ivaReducido').val() == '1')?'4':'21') + '%): ' + total_iva.toFixed(2) + '€');
$('resumenEnvio').text('Envío: ' + '30' + '€');
}
}
}

View File

@ -84,7 +84,7 @@
<div class="row g-3">
<?= view("themes/vuexy/form/presupuestos/cliente/_tipoLibroItems") ?>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
@ -144,18 +144,18 @@
</div>
<div class="col-12 d-flex justify-content-between mt-4">
<div class="col-6 flex-row">
<div class="col-6 d-flex flex-row">
<button class="btn btn-label-secondary btn-prev waves-effect">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
</button>
</div>
<div class="col-6 flex-row-reverse">
<button class="btn btn-primary btn-submit waves-effect waves-light">
<div class="col-6 d-flex flex-row-reverse">
<button class="btn btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
<button class="btn btn-success btn-submit btn-next waves-effect waves-light">
<button class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
</button>
</div>
@ -166,12 +166,8 @@
</div>
</div>
</div><!--//.col -->
<div class="pt-4">
<input type="submit" class="btn btn-primary float-start me-sm-3 me-1" name="save" id="saveForm" value="<?= lang("Basic.global.Save") ?>" />
</div>
</div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
@ -243,4 +239,5 @@ initDisenioLibro();
<script src="<?= site_url('js_loader/presupuestoClienteTipoLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDisenioLibro_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteDirecciones_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoClienteResumen_js') ?>"></script>
<?= $this->endSection() ?>