mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/core_updates_3'
# Conflicts: # ci4/app/Views/themes/vuexy/main/menu_impresion.php
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="mb-3">
|
||||
<label for="add_email" class="form-label">
|
||||
<?= lang('ClienteDirecciones.email') ?>*
|
||||
<?= lang('ClienteDirecciones.email') ?>
|
||||
</label>
|
||||
<input type="text" id="add_email" tabindex="2" maxLength="100" class="form-control">
|
||||
</div><!--//.mb-3 -->
|
||||
@ -65,7 +65,7 @@
|
||||
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
|
||||
<div class="mb-3">
|
||||
<label for="add_provincia" class="form-label">
|
||||
<?=lang('ClienteDirecciones.provincia') ?>*
|
||||
<?=lang('ClienteDirecciones.provincia') ?>
|
||||
</label>
|
||||
<input type="text" id="add_provincia" tabindex="7" maxLength="100" class="form-control">
|
||||
</div><!--//.mb-3 -->
|
||||
@ -87,7 +87,7 @@
|
||||
<div class="col-md-12 col-lg-6 pl-4">
|
||||
<div class="mb-3">
|
||||
<label for="add_telefono" class="form-label">
|
||||
<?=lang('ClienteDirecciones.telefono') ?>*
|
||||
<?=lang('ClienteDirecciones.telefono') ?>
|
||||
</label>
|
||||
<input type="text" id="add_telefono" tabindex="9" maxLength="100" class="form-control"></input>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
<div class="col-12 pb-2">
|
||||
|
||||
<div id="containerTiradasEnvios" class="row mb-3">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mb-3">
|
||||
|
||||
<div class="col-sm-4 mb-3">
|
||||
<label for="direcciones" class="form-label">Mis direcciones</label>
|
||||
<select id="direcciones" name="direcciones" class="form-control select2bs2" style="width: 100%;"></select>
|
||||
</div>
|
||||
<div class="col-sm-2 mb-3">
|
||||
<label for="unidadesEnvio" class="form-label">
|
||||
Unidades
|
||||
</label>
|
||||
<input type="number" class="form-control" id="unidadesEnvio" name="unidadesEnvio" maxLength="8" step="1" class="form-control">
|
||||
</div><!--//.mb-3 -->
|
||||
<div class="col-sm-2 mb-3 mt-auto mb-0">
|
||||
<button id="insertarDireccion" type="button" class="btn btn-secondary waves-effect waves-light">Insertar</button>
|
||||
</div>
|
||||
<div id="errorDirecciones" class="fv-plugins-message-container invalid-feedback" style="display: none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divDirecciones" class="col-12 pb-2">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
window.routes_direcciones = {
|
||||
direcciones: "<?= route_to('getDirecciones') ?>",
|
||||
getDatos: "<?= route_to('getDatosDireccion') ?>",
|
||||
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
@ -73,6 +73,11 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div id="errorTiradas" class="fv-plugins-message-container invalid-feedback" style="display: none;">
|
||||
<div>No puede mezclar tiradas mayores de 30 unidades con tiradas menores de 30 unidades</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mb-3">
|
||||
<label for="tirada" class="form-label">
|
||||
<?= lang('Presupuestos.tirada') ?> 1
|
||||
@ -392,14 +397,7 @@
|
||||
|
||||
<div class="row sobrecubierta enable-sobrecubierta" style="display: none;">
|
||||
|
||||
<div class="col-sm-3 mb-md-0 mb-2 d-flex align-items-end">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input calcular-presupuesto input-sobrecubierta" type="checkbox" id="solapasSobrecubierta" name="solapasSobrecubierta" value="0">
|
||||
<label class="form-check-label" for="solapasSobrecubierta">Solapas sobrecubierta</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tamanioSolapasSobrecubierta" class="col-sm-3 mb-md-0 mb-2" style="display: none;">
|
||||
<div id="tamanioSolapasSobrecubierta" class="col-sm-3 mb-md-0 mb-2"">
|
||||
<label for="anchoSolapasSobrecubierta" class="form-label">Tamaño</label>
|
||||
<input type="number" id="anchoSolapasSobrecubierta" name="anchoSolapasSobrecubierta" maxLength="8" step="1" class="form-control input-sobrecubierta calcular-presupuesto" value="">
|
||||
</div>
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
<div class="col-12 pb-2">
|
||||
<div class="row mb-3">
|
||||
<h3>Resumen</h3>
|
||||
<div class="col-sm-6">
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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">
|
||||
<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>
|
||||
|
||||
|
||||
@ -57,8 +57,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row row-cols-3 d-flex justify-content-center d-flex justify-content-center"
|
||||
style="margin-bottom: 40px;">
|
||||
<div class="row row-cols-3 d-flex justify-content-center d-flex justify-content-center">
|
||||
<div class="col-md-4 mb-6 d-flex justify-content-center">
|
||||
<div>
|
||||
<div style="max-width:200px;max-height:200px;padding-right:0px" id="espiralDiv"
|
||||
@ -77,7 +76,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-6 d-flex justify-content-center" style="margin-bottom: 40px;">
|
||||
<div class="col-md-4 mb-6 d-flex justify-content-center" >
|
||||
<div>
|
||||
<div style="max-width:200px;max-height:200px;padding-right:0px" id="wireoDiv"
|
||||
class="form-check custom-option-tipo custom-option custom-option-image custom-option-image-radio">
|
||||
|
||||
@ -0,0 +1,303 @@
|
||||
function initDirecciones() {
|
||||
data = {
|
||||
id: $('#clienteId').val()
|
||||
},
|
||||
data = Object.assign(data, window.token_ajax)
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_direcciones.direcciones,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
$("#direcciones").empty();
|
||||
$.each(response.menu, function(index, value) {
|
||||
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
|
||||
});
|
||||
$("#direcciones").val('');
|
||||
},
|
||||
error: function() {
|
||||
$("#direcciones").empty();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function initTiradasDirecciones() {
|
||||
const _this = this
|
||||
|
||||
$('#containerTiradasEnvios').empty();
|
||||
|
||||
for (i = 1; i <= 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
|
||||
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=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>';
|
||||
html += '</span>';
|
||||
html += '<span class="custom-option-body">';
|
||||
html += '<small>' + $('#' + precio_u_id).text() + '</small>';
|
||||
html += '</span>';
|
||||
html += '</label>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
|
||||
$('#containerTiradasEnvios').append(html);
|
||||
|
||||
$('#' + id).hide();
|
||||
}
|
||||
}
|
||||
|
||||
const tiradasDireccionesList = [].slice.call(document.querySelectorAll('.custom-option-tiradasDirecciones .form-check-input'))
|
||||
tiradasDireccionesList.map(function (customOptionEL) {
|
||||
// Update custom options check on page load
|
||||
_this.updateTiradasDireccionesCheck(customOptionEL)
|
||||
|
||||
// Update custom options check on click
|
||||
customOptionEL.addEventListener('click', e => {
|
||||
_this.updateTiradasDireccionesCheck(customOptionEL)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function updateTiradasDireccionesCheck(el) {
|
||||
if (el.checked) {
|
||||
// If custom option element is radio, remove checked from the siblings (closest `.row`)
|
||||
if (el.type === 'radio') {
|
||||
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-tiradasDirecciones'))
|
||||
customRadioOptionList.map(function (customRadioOptionEL) {
|
||||
customRadioOptionEL.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
|
||||
})
|
||||
}
|
||||
el.closest('.custom-option-tiradasDirecciones').classList.add('checked')
|
||||
|
||||
} else {
|
||||
el.closest('.custom-option-tiradasDirecciones').classList.remove('checked')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function obtenerUnidadesEnvio(){
|
||||
|
||||
const elements = $('#divDirecciones').find('.row.mb-3');
|
||||
let total = 0;
|
||||
|
||||
if(elements.length > 0) {
|
||||
for (let index=0; index<elements.length; index++){
|
||||
let unidades_direcciones = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
|
||||
total += unidades_direcciones;
|
||||
};
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
$('#insertarDireccion').on('click', function() {
|
||||
|
||||
if( $('#direcciones').val() > 0 ) {
|
||||
|
||||
let unidades = $('#unidadesEnvio').val();
|
||||
if(unidades == '' || isNaN(unidades) || parseInt(unidades) <= 0){
|
||||
return false;
|
||||
}
|
||||
unidades = parseInt(unidades);
|
||||
|
||||
const seleccion = $('.custom-option-tiradasDirecciones.checked');
|
||||
if(seleccion.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const element_tirada =($(seleccion[0]).find('label input')[0]);
|
||||
const number = element_tirada.id.match(/\d+$/);
|
||||
if (number.length == 0) {
|
||||
return false;
|
||||
}
|
||||
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
|
||||
|
||||
let total = obtenerUnidadesEnvio();
|
||||
|
||||
if($('#prototipo').is(':checked')) {
|
||||
tirada += 1;
|
||||
}
|
||||
|
||||
if(total + unidades <= tirada) {
|
||||
|
||||
data = {
|
||||
id: $('#direcciones').val(),
|
||||
peso: $('#env_tiradaPrecio' + number[0]).attr('peso'),
|
||||
unidades: unidades
|
||||
},
|
||||
data = Object.assign(data, window.token_ajax)
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_direcciones.getDatos,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
if(response.data.length > 0) {
|
||||
let html = '';
|
||||
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">';
|
||||
html += '<h6 class="fw-semibold mb-0">' + response.data[0].att + '</h6>';
|
||||
html += '<span class="badge bg-label-primary">' + unidades + ' unidades</span>';
|
||||
html += '</span>';
|
||||
html += '<span class="custom-option-body">';
|
||||
html += '<small>' + response.data[0].direccion + '</small><br>';
|
||||
html += '<small>' + response.data[0].cp + '</small><br>';
|
||||
html += '<small>' + response.data[0].municipio +', ' + response.data[0].pais + '</small><br>';
|
||||
html += '<small>' + response.data[0].telefono + '</small><br>';
|
||||
html += '<small>' + response.data[0].email + '</small><br>';
|
||||
html += '<hr class="my-2">';
|
||||
html += '<span class="d-flex">';
|
||||
html += '<a class="eliminar-direccion" href="javascript:void(0)">Eliminar</a>';
|
||||
html += '</span>';
|
||||
html += '</span>';
|
||||
html += '</label>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
|
||||
$('#divDirecciones').append(html);
|
||||
$('#errorDirecciones').hide();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#direcciones").empty();
|
||||
},
|
||||
});
|
||||
}
|
||||
else{
|
||||
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
|
||||
$('#errorDirecciones').show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.eliminar-direccion', function(e) {
|
||||
|
||||
$(this).closest('.row.mb-3').remove();
|
||||
|
||||
const seleccion = $('.custom-option-tiradasDirecciones.checked');
|
||||
if(seleccion.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const element_tirada =($(seleccion[0]).find('label input')[0]);
|
||||
const number = element_tirada.id.match(/\d+$/);
|
||||
if (number.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
|
||||
|
||||
const elements = $('#divDirecciones').find('.row.mb-3');
|
||||
|
||||
let total = 0;
|
||||
if(elements.length > 0) {
|
||||
for (let index=0; index<elements.length; index++){
|
||||
let unidades_direcciones = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
|
||||
total += unidades_direcciones;
|
||||
};
|
||||
}
|
||||
|
||||
if(total <= tirada) {
|
||||
$('#errorDirecciones').hide();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#direcciones').on('change', function() {
|
||||
if( $('#direcciones').val() == 0 ) {
|
||||
$("#addressForm").attr('action','create')
|
||||
|
||||
var $newAddDialog = $("#addressForm")
|
||||
$newAddDialog.modal('show')
|
||||
|
||||
$newAddDialog.on('hidden.bs.modal', function (e) {
|
||||
$('#direcciones').val('');
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function saveAdd_callback(){
|
||||
if($('#addressForm').attr('action')=='create'){
|
||||
let data = {
|
||||
cliente_id: $('#clienteId').val(),
|
||||
alias: $('#add_alias').val(),
|
||||
att: $('#add_att').val(),
|
||||
email: $('#add_email').val(),
|
||||
direccion: $('#add_direccion').val(),
|
||||
pais_id: $("#add_pais_id option:selected").val(),
|
||||
municipio: $('#add_municipio').val(),
|
||||
provincia: $('#add_provincia').val(),
|
||||
cp: $('#add_cp').val(),
|
||||
telefono: $('#add_telefono').val(),
|
||||
}
|
||||
console.log(data);
|
||||
data = Object.assign(data, window.token_ajax)
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_direcciones.nuevaDireccion,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
$("#direcciones").empty();
|
||||
$.each(response.data, function(index, value) {
|
||||
$("#direcciones").append('<option value="' + value.id + '">' + value.text + '</option>');
|
||||
});
|
||||
$("#direcciones").val('');
|
||||
$('#addressForm').modal('hide');
|
||||
},
|
||||
error: function() {
|
||||
$('#addressForm').modal('hide');
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function validarEnvio(){
|
||||
|
||||
const seleccion = $('.custom-option-tiradasDirecciones.checked');
|
||||
if(seleccion.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const element_tirada =($(seleccion[0]).find('label input')[0]);
|
||||
|
||||
const number = element_tirada.id.match(/\d+$/);
|
||||
if (number.length == 0) {
|
||||
return false;
|
||||
}
|
||||
let tirada = parseInt($('#tiradaDireccionesValue' + number[0]).text());
|
||||
|
||||
let total = obtenerUnidadesEnvio();
|
||||
|
||||
if($('#prototipo').is(':checked')) {
|
||||
tirada += 1;
|
||||
}
|
||||
|
||||
if(total != tirada){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -137,7 +137,6 @@ $('#enableSobrecubierta').on('change', function () {
|
||||
$('#gramajeSobrecubierta').val('').trigger('change');
|
||||
$('#paperSobrecubierta').val('').trigger('change');
|
||||
$('#acabadosSobrecubierta').val('').trigger('change');
|
||||
$('#solapasSobrecubierta').prop('checked', false).trigger('change');
|
||||
$('#tamanioSolapasSobrecubierta').val();
|
||||
$('.enable-sobrecubierta').hide();
|
||||
|
||||
@ -170,7 +169,8 @@ $('.change-tipo-impresion').on('change', function () {
|
||||
//si es color hay que mostrar el numero de paginas a color
|
||||
if (isColor) {
|
||||
$('#pagColorDiv').show();
|
||||
$('#paginasColor').val('0');
|
||||
if($('#paginasColor').val() == '')
|
||||
$('#paginasColor').val('0');
|
||||
}
|
||||
else {
|
||||
$('#pagColorDiv').hide();
|
||||
@ -338,7 +338,7 @@ $('#papelSobrecubierta').on('change', function () {
|
||||
});
|
||||
|
||||
if (valSobrecubierta != undefined)
|
||||
$('#gramajeSobrecubierta option[value=' + valCubierta + ']').prop('selected', true).trigger('change');
|
||||
$('#gramajeSobrecubierta option[value=' + valSobrecubierta + ']').prop('selected', true).trigger('change');
|
||||
else
|
||||
$('#gramajeSobrecubierta').val('').trigger('change');
|
||||
}
|
||||
@ -355,14 +355,6 @@ $('#solapasCubierta').on('change', function () {
|
||||
}
|
||||
});
|
||||
|
||||
$('#solapasSobrecubierta').on('change', function () {
|
||||
if ($(this).is(":checked")) {
|
||||
$('#tamanioSolapasSobrecubierta').show();
|
||||
} else {
|
||||
$('#tamanioSolapasSobrecubierta').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Funcion que comprueba que están rellenos todos los datos necesarios para calcular el presupuesto
|
||||
function checkValues() {
|
||||
@ -377,6 +369,14 @@ function checkValues() {
|
||||
const papelFormatoAncho = $('#anchoLibro').val();
|
||||
const clienteId = $('#clienteId').val();
|
||||
|
||||
if (paginas == '' || isNaN(paginas) || parseInt(paginas) <= 0) {
|
||||
return false;
|
||||
}
|
||||
if(parseInt(paginas)%2!=0){
|
||||
$('#paginas').val(parseInt(paginas)+1).trigger('change');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(clienteId == '' || isNaN(clienteId) || parseInt(clienteId) <= 0){
|
||||
return false;
|
||||
}
|
||||
@ -385,10 +385,6 @@ function checkValues() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (paginas == '' || isNaN(paginas) || parseInt(paginas) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (papelInterior == '' || gramajeInterior == '') {
|
||||
return false;
|
||||
}
|
||||
@ -578,9 +574,31 @@ $('.calcular-presupuesto').on('change', function () {
|
||||
calcularPresupuesto();
|
||||
});
|
||||
|
||||
function comprobarTiradasPOD(){
|
||||
const tiradas = getTiradas();
|
||||
|
||||
//Comprobar que todos los elementos del array tiradas estan por encima de 30 o por debajo
|
||||
const tiradasPOD = tiradas.every(tirada => tirada <= 30);
|
||||
const tiradasNoPOD = tiradas.every(tirada => tirada > 30);
|
||||
if (tiradasPOD == !tiradasNoPOD) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#clienteId').on('select2:change', function () {
|
||||
calcularPresupuesto();
|
||||
});
|
||||
|
||||
|
||||
async function calcularPresupuesto() {
|
||||
|
||||
if(!comprobarTiradasPOD()){
|
||||
$('#errorTiradas').show();
|
||||
return;
|
||||
}
|
||||
$('#errorTiradas').hide();
|
||||
|
||||
// se obtiene la propiedad serv_id de los checkboxes seleccionados de la clase .servicio-extra
|
||||
if (!checkValues()) {
|
||||
return;
|
||||
@ -627,9 +645,8 @@ async function calcularPresupuesto() {
|
||||
gramaje: $('#gramajeSobrecubierta option:selected').text(),
|
||||
acabado: $('#acabadosSobrecubierta').val()
|
||||
}
|
||||
if ($('#solapasSobrecubierta').is(':checked')) {
|
||||
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
}
|
||||
|
||||
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,7 +661,7 @@ async function calcularPresupuesto() {
|
||||
|
||||
datos = Object.assign(datos, window.token_ajax)
|
||||
|
||||
|
||||
$('#divTiradasPrecio').empty();
|
||||
$('#loader').show();
|
||||
|
||||
$.ajax({
|
||||
@ -691,24 +708,36 @@ async function calcularPresupuesto() {
|
||||
|
||||
console.log(response);
|
||||
$('#loader').hide();
|
||||
if(error){
|
||||
$('#precios > tbody').empty();
|
||||
$('#precios').hide();
|
||||
}
|
||||
else{
|
||||
$('#precios > tbody').empty();
|
||||
|
||||
for (i = 0; i < response.tiradas.length; i++) {
|
||||
$('#precios > tbody').append('<tr class="table-light"><td>' + response.tiradas[i] + '</td><td>' + response.precio_u[i] + '€</td></tr>');
|
||||
}
|
||||
$('#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);
|
||||
|
||||
let html = '';
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
$('#loader').hide();
|
||||
$('#precios > tbody').empty();
|
||||
$('#precios').hide();
|
||||
$('#divTiradasPrecio').empty();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -208,6 +208,8 @@
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
validationStepper.next();
|
||||
initDirecciones();
|
||||
initTiradasDirecciones();
|
||||
});
|
||||
|
||||
const tirada = $('#tirada');
|
||||
@ -218,7 +220,7 @@
|
||||
FormValidation2.revalidateField('gramajeSobrecubierta');
|
||||
});
|
||||
|
||||
// Deal Usage
|
||||
// Direcciones
|
||||
const FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
|
||||
fields: {
|
||||
|
||||
@ -235,7 +237,18 @@
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
validationStepper.next();
|
||||
if(validarEnvio()){
|
||||
generarResumen();
|
||||
validationStepper.next();
|
||||
}
|
||||
else{
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
// Deal Usage
|
||||
@ -300,6 +313,12 @@
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let id = "tiradaPrecio" + i;
|
||||
if ($('#' + id).length > 0) {
|
||||
$('#' + id).show();
|
||||
}
|
||||
}
|
||||
validationStepper.previous();
|
||||
break;
|
||||
|
||||
|
||||
122
ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js
Normal file
122
ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js
Normal file
@ -0,0 +1,122 @@
|
||||
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) + '€');
|
||||
const envio = getTotalEnvio();
|
||||
$('#resumenEnvio').text('Envío: ' + envio.toFixed(2) + '€');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getTotalEnvio(){
|
||||
const elements = $('#divDirecciones').find('.row.mb-3');
|
||||
let total = 0.0;
|
||||
|
||||
if(elements.length > 0) {
|
||||
for (let index=0; index<elements.length; index++){
|
||||
let precio_envio = parseFloat($(elements[index]).attr('p'));
|
||||
total += precio_envio;
|
||||
};
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
<?= $this->section("content") ?>
|
||||
|
||||
<?= view("themes/vuexy/form/clientes/cliente/_clienteDireccionesForm") ?>
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div class="col-12">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
@ -62,20 +63,15 @@
|
||||
</div>
|
||||
|
||||
<div id="errorGeneral" class="fv-plugins-message-container invalid-feedback" style="display: none;">
|
||||
<p>Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador</p>
|
||||
<p>Se ha producido un error <br>
|
||||
al calcular el presupuesto. <br>
|
||||
Póngase en contacto con el <br>
|
||||
administrador.</p>
|
||||
</div>
|
||||
|
||||
<table id="precios" class="table table-sm" style="display: none;">
|
||||
<caption>Precio/Unidad por tirada</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id='divTiradasPrecio'>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -87,9 +83,8 @@
|
||||
<div id="tipo-libro" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<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>
|
||||
@ -122,11 +117,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Deal Usage -->
|
||||
<!-- Direcciones -->
|
||||
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div class="row g-3">
|
||||
|
||||
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/_direccionesItems") ?>
|
||||
|
||||
<div class="col-12 d-flex justify-content-between mt-4">
|
||||
<button class="btn btn-label-secondary btn-prev waves-effect">
|
||||
@ -145,15 +140,25 @@
|
||||
<div id="resumen-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div class="row g-3">
|
||||
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/_resumenItems") ?>
|
||||
|
||||
</div>
|
||||
<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>
|
||||
<span class="align-middle d-sm-inline-block d-none">Anterior</span>
|
||||
</button>
|
||||
<button class="btn btn-success btn-submit btn-next waves-effect waves-light">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Submit</span><i class="ti ti-check ti-xs"></i>
|
||||
</button>
|
||||
<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 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 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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -161,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") ?>
|
||||
@ -237,4 +238,6 @@ initDisenioLibro();
|
||||
<script src="<?= site_url('js_loader/presupuestoCliente_js') ?>"></script>
|
||||
<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() ?>
|
||||
@ -1268,34 +1268,34 @@ function get_tarifas_preimpresion(tarifa_id = -1){
|
||||
|
||||
function servicioPrototipo(){
|
||||
if($('#prototipo').prop('checked')){
|
||||
$('#add_servicio_preimpresion_list').val(serviciosAutomaticos.prototipo)
|
||||
$('#insertar_serv_preimpresion').click()
|
||||
$('#add_servicio_extra_list').val(serviciosAutomaticos.prototipo)
|
||||
$('#insertar_serv_extra').click()
|
||||
}
|
||||
else{
|
||||
var row_indexes = tableServiciosPreimpresion.rows().eq( 0 ).filter( function (rowIdx) {
|
||||
return tableServiciosPreimpresion.cell( rowIdx, 0 ).data() == serviciosAutomaticos.prototipo ? true : false;
|
||||
var row_indexes = tableServiciosExtra.rows().eq( 0 ).filter( function (rowIdx) {
|
||||
return tableServiciosExtra.cell( rowIdx, 0 ).data() == serviciosAutomaticos.prototipo ? true : false;
|
||||
} );
|
||||
if(row_indexes.length > 0){
|
||||
tableServiciosPreimpresion.row(row_indexes[0]).remove().draw()
|
||||
tableServiciosExtra.row(row_indexes[0]).remove().draw()
|
||||
check_serv_preimpresion_error()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function servicioFerro(){
|
||||
var row_indexes = tableServiciosPreimpresion.rows().eq( 0 ).filter( function (rowIdx) {
|
||||
return tableServiciosPreimpresion.cell( rowIdx, 0 ).data() == serviciosAutomaticos.ferro ? true : false;
|
||||
var row_indexes = tableServiciosExtra.rows().eq( 0 ).filter( function (rowIdx) {
|
||||
return tableServiciosExtra.cell( rowIdx, 0 ).data() == serviciosAutomaticos.ferro ? true : false;
|
||||
} );
|
||||
if($('#ferro').prop('checked')){
|
||||
if(row_indexes.length == 0){
|
||||
$('#add_servicio_preimpresion_list').val(serviciosAutomaticos.ferro)
|
||||
$('#insertar_serv_preimpresion').click()
|
||||
$('#add_servicio_extra_list').val(serviciosAutomaticos.ferro)
|
||||
$('#insertar_serv_extra').click()
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(row_indexes.length > 0){
|
||||
tableServiciosPreimpresion.row(row_indexes[0]).remove().draw()
|
||||
check_serv_preimpresion_error()
|
||||
tableServiciosExtra.row(row_indexes[0]).remove().draw()
|
||||
check_serv_extra_error()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user