mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en guardar presupuesto
This commit is contained in:
@ -40,8 +40,8 @@
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
window.routes_direcciones = {
|
||||
direcciones: "<?= route_to('getDirecciones') ?>",
|
||||
getDatos: "<?= route_to('getDatosDireccion') ?>",
|
||||
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
|
||||
direcciones: "<?= route_to('getDirecciones') ?>",
|
||||
getDatos: "<?= route_to('getDatosDireccion') ?>",
|
||||
nuevaDireccion: "<?= route_to('nuevaDireccion') ?>",
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
@ -47,3 +47,9 @@
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
window.routes_resumen = {
|
||||
guardarPresupuesto: "<?= route_to('guardarPresupuesto') ?>",
|
||||
}
|
||||
<?= $this->endSection() ?>
|
||||
@ -192,8 +192,6 @@ $('#insertarDireccion').on('click', function() {
|
||||
$('#errorDirecciones').text('El número de unidades supera la tirada seleccionada.');
|
||||
$('#errorDirecciones').show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
})
|
||||
@ -311,4 +309,25 @@ function validarEnvio(){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getDireccionesEnvio(){
|
||||
|
||||
const elements = $('#divDirecciones').find('.row.mb-3');
|
||||
|
||||
let direcciones = [];
|
||||
|
||||
if(elements.length > 0) {
|
||||
for (let index=0; index<elements.length; index++){
|
||||
const unidades = parseInt($(elements[index]).find('div label span span').text().split(' ')[0]);
|
||||
const id = $(elements[index]).attr('id').replace('envioId', '');
|
||||
const tipo = $(elements[index]).attr('t');
|
||||
direcciones.push({
|
||||
unidades: unidades,
|
||||
id: id,
|
||||
tipo: tipo,
|
||||
})
|
||||
};
|
||||
}
|
||||
return direcciones;
|
||||
}
|
||||
@ -118,4 +118,108 @@ function getTotalEnvio(){
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('#btnSave').on('click', function() {
|
||||
|
||||
let servicios = [];
|
||||
$('.servicio-extra:checked').each(function () {
|
||||
servicios.push($(this).attr('serv_id'));
|
||||
})
|
||||
|
||||
let datos_libro = {
|
||||
tamanio: getDimensionLibro(),
|
||||
tirada: getTiradas(),
|
||||
paginas: $('#paginas').val(),
|
||||
paginasColor: $('#paginasColor').val(),
|
||||
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
|
||||
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
|
||||
isColor: $('#colorNegroDiv').hasClass('checked') ? 0 : 1,
|
||||
isHq: $('#calidadEstandarDiv').hasClass('checked') ? 0 : 1,
|
||||
papelInterior: $('#papelInterior option:selected').val(),
|
||||
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
|
||||
gramajeInterior: $('#gramajeInterior option:selected').text(),
|
||||
excluirRotativa: $('#excluirRotativa').is(':checked')? 1 : 0,
|
||||
papelCubierta: $('#papelCubierta option:selected').val(),
|
||||
papelCubiertaNombre: $('#papelCubierta option:selected').text().trim(),
|
||||
gramajeCubierta: $('#gramajeCubierta option:selected').text(),
|
||||
carasCubierta: $('#carasCubierta').val(),
|
||||
acabadoCubierta: $('#acabadosCubierta').val(),
|
||||
clienteId: $('#clienteId').val(),
|
||||
servicios: servicios,
|
||||
};
|
||||
// Si hay solapas de cubierta
|
||||
if ($('#solapasCubierta').is(':checked')) {
|
||||
datos_libro.solapasCubierta = $('#anchoSolapasCubierta').val()
|
||||
}
|
||||
|
||||
// Si hay sobrecubierta
|
||||
if ($('.enable-sobrecubierta').is(':visible')) {
|
||||
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
|
||||
|
||||
datos_libro.sobrecubierta = {
|
||||
papel: $('#papelSobrecubierta option:selected').val(),
|
||||
papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
|
||||
gramaje: $('#gramajeSobrecubierta option:selected').text(),
|
||||
acabado: $('#acabadosSobrecubierta').val()
|
||||
}
|
||||
|
||||
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
}
|
||||
}
|
||||
|
||||
if ($('.guardas').is(':visible')) {
|
||||
datos_libro.guardas = {
|
||||
papel: $('#papelGuardas option:selected').val(),
|
||||
papel_nombre: $('#papelGuardas option:selected').text().trim(),
|
||||
gramaje: 170,
|
||||
caras: $('#impresionGuardas option:selected').val()
|
||||
}
|
||||
}
|
||||
|
||||
let datos_cabecera = {
|
||||
titulo: $('#titulo').val(),
|
||||
referenciaCliente: $('#referenciaCliente').val(),
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
let direcciones = getDireccionesEnvio();
|
||||
datos = {
|
||||
datos_libro : datos_libro,
|
||||
datos_cabecera: datos_cabecera,
|
||||
direcciones: direcciones,
|
||||
tirada: tirada,
|
||||
iva_reducido: $('#ivaReducido').val()==1?1:0,
|
||||
},
|
||||
datos = Object.assign(datos, window.token_ajax)
|
||||
|
||||
$('#loader').show();
|
||||
|
||||
$.ajax({
|
||||
url: window.routes_resumen.guardarPresupuesto,
|
||||
type: 'POST',
|
||||
data: datos,
|
||||
success: function(response) {
|
||||
if(response.length > 0) {
|
||||
|
||||
|
||||
}
|
||||
$('#loader').hide();
|
||||
},
|
||||
error: function() {
|
||||
$('#loader').hide();
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
@ -151,7 +151,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-6 d-flex flex-row-reverse">
|
||||
<button class="btn btn-primary btn-submit waves-effect waves-light ml-2">
|
||||
<button id="btnSave" 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>
|
||||
@ -236,10 +236,10 @@ initDisenioLibro();
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
|
||||
<script src="<?= site_url('js_loader/presupuestoClienteResumen_js') ?>"></script>
|
||||
<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>
|
||||
<script src="<?= site_url('js_loader/presupuestoClientePreview_js') ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
Reference in New Issue
Block a user