trabajando en el envio del presupuesto al backend

This commit is contained in:
jaimejimenezortega
2024-04-29 20:47:14 +02:00
parent 7c754599f9
commit 5200aa4079
5 changed files with 4147 additions and 346 deletions

View File

@ -325,7 +325,7 @@
<select id="acabadosCubierta" name="acabadosCubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
<?php if (isset($datosPresupuesto->acabadosCubierta) && is_array($datosPresupuesto->acabadosCubierta) && !empty($datosPresupuesto->acabadosCubierta)) :
foreach ($datosPresupuesto->acabadosCubierta as $acabado) : ?>
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_sobrecubierta_id ? ' selected' : '' ?>>
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_cubierta_id ? ' selected' : '' ?>>
<?= $acabado->label ?>
</option>
<?php endforeach;
@ -465,7 +465,7 @@
<div class="mb-3">
<div class="form-check">
<label for="retractilado" class="form-check-label">
<input type="checkbox" id="retractilado" name="retractilado" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->retractilado == true ? 'checked' : ''; ?>>
<input type="checkbox" id="retractilado" name="retractilado" serv_id="3" value="1" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->retractilado == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.retractilado') ?>
</label>
</div><!--//.form-check -->
@ -476,7 +476,7 @@
<div class="mb-3">
<div class="form-check">
<label for="retractilado5" class="form-check-label">
<input type="checkbox" id="retractilado5" name="retractilado_5" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->retractilado5 == true ? 'checked' : ''; ?>>
<input type="checkbox" id="retractilado5" name="retractilado_5" serv_id="5" value="1" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->retractilado5 == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.retractilado5') ?>
</label>
</div><!--//.form-check -->
@ -488,7 +488,7 @@
<div class="mb-3">
<div class="form-check">
<label for="fajaColor" class="form-check-label">
<input type="checkbox" id="fajaColor" name="faja_color" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->faja_color == true ? 'checked' : ''; ?>>
<input type="checkbox" id="fajaColor" name="faja_color" value="1" serv_id="16" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->faja_color == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.fajaColor') ?>
</label>
</div><!--//.form-check -->
@ -499,7 +499,7 @@
<div class="mb-3">
<div class="form-check">
<label for="prototipo" class="form-check-label">
<input type="checkbox" id="prototipo" name="prototipo" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->prototipo == true ? 'checked' : ''; ?>>
<input type="checkbox" id="prototipo" name="prototipo" value="1" serv_id="9" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->prototipo == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.prototipo') ?>
</label>
</div><!--//.form-check -->
@ -513,38 +513,16 @@
<div class="mb-3">
<div class="form-check">
<label for="ferro" class="form-check-label">
<input type="checkbox" id="ferro" name="ferro" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->ferro == true ? 'checked' : ''; ?>>
<input type="checkbox" id="ferro" name="ferro" value="1" serv_id="24" class="form-check-input servicio-extra calcular-presupuesto" <?= $presupuestoEntity->ferro == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.ferro') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferroDigital" class="form-check-label">
<input type="checkbox" id="ferroDigital" name="ferro_digital" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->ferro_digital == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.ferroDigital') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="marcapaginas" class="form-check-label">
<input type="checkbox" id="marcapaginas" name="marcapaginas" value="1" class="form-check-input calcular-presupuesto" <?= $presupuestoEntity->marcapaginas == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.marcapaginas') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!--//.row -->
<!--SECCION DE SERVICIOS EXTRA -->
<!--SECCION DE OTRAS OPCIONES -->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5>Otras opciones</h5>

View File

@ -13,7 +13,7 @@
src="<?= site_url("assets/img/libro_cosido.png") ?>" alt="radioImg">
</span>
</label>
<input name="cosido" class="form-check-input elementos-libro" type="radio" value="tipoCosido"
<input name="cosido" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoCosido"
id="tipoCosido" checked="">
</div>
<h4 class="text-center">Rústica cosido</h4>
@ -31,7 +31,7 @@
src="<?= site_url("assets/img/libro_fresado.png") ?>" alt="radioImg2">
</span>
</label>
<input name="fresado" class="form-check-input elementos-libro" type="radio" value="tipoFresado"
<input name="fresado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoFresado"
id="tipoFresado">
</div>
<h4 class="text-center">Rústica fresado</h4>
@ -49,7 +49,7 @@
src="<?= site_url("assets/img/libro_grapado.png") ?>" alt="radioImg3">
</span>
</label>
<input name="grapado" class="form-check-input elementos-libro" type="radio" value="tipoGrapado"
<input name="grapado" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoGrapado"
id="tipoGrapado">
</div>
<h4 class="text-center">Cosido con grapas</h4>
@ -70,7 +70,7 @@
src="<?= site_url("assets/img/libro_espiral.png") ?>" alt="radioImg4">
</span>
</label>
<input name="espiral" class="form-check-input elementos-libro" type="radio" value="tipoEspiral"
<input name="espiral" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoEspiral"
id="tipoEspiral">
</div>
<h4 class="text-center">Espiral</h4>
@ -88,7 +88,7 @@
src="<?= site_url("assets/img/libro_wire-o.png") ?>" alt="radioImg5">
</span>
</label>
<input name="wireo" class="form-check-input elementos-libro" type="radio" value="tipoWireO"
<input name="wireo" class="form-check-input elementos-libro calcular-presupuesto" type="radio" value="tipoWireO"
id="tipoWireO">
</div>
<h4 class="text-center">Wire-o</h4>

View File

@ -1,5 +1,4 @@
$('#papelFormatoPersonalizado').on('change', function()
{
$('#papelFormatoPersonalizado').on('change', function () {
if ($(this).is(":checked")) {
$('#tamanioLibroDiv').hide();
$('#anchoLibroDiv').show();
@ -14,8 +13,7 @@ $('#papelFormatoPersonalizado').on('change', function()
// Init custom option check
function initTapaCheck()
{
function initTapaCheck() {
const _this = this
const tapaOptionList = [].slice.call(document.querySelectorAll('.custom-option-tapa .form-check-input'))
@ -30,8 +28,7 @@ function initTapaCheck()
})
}
function updateTapaCheck(el)
{
function updateTapaCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
@ -41,7 +38,7 @@ function updateTapaCheck(el)
})
}
el.closest('.custom-option-tapa').classList.add('checked')
if(el.closest('.custom-option-tapa').id == 'tapaBlandaInnerDiv') {
if (el.closest('.custom-option-tapa').id == 'tapaBlandaInnerDiv') {
$('#tapaBlanda').prop('checked', true);
$('#tapaDura').prop('checked', false);
}
@ -55,8 +52,7 @@ function updateTapaCheck(el)
}
function initColorCheck()
{
function initColorCheck() {
const _this = this
const custopOptionList = [].slice.call(document.querySelectorAll('.custom-option-color .form-check-input'))
@ -71,8 +67,7 @@ function initColorCheck()
})
}
function updateColorCheck(el)
{
function updateColorCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
@ -82,7 +77,7 @@ function updateColorCheck(el)
})
}
el.closest('.custom-option-color').classList.add('checked')
if(el.closest('.custom-option-color').id == 'colorNegroDiv') {
if (el.closest('.custom-option-color').id == 'colorNegroDiv') {
$('#colorNegro').prop('checked', true);
$('#colorColor').prop('checked', false);
}
@ -90,15 +85,14 @@ function updateColorCheck(el)
$('#colorNegro').prop('checked', false);
$('#colorColor').prop('checked', true);
}
} else {
el.closest('.custom-option-color').classList.remove('checked')
}
}
function initCalidadCheck()
{
function initCalidadCheck() {
const _this = this
const calidadOptionList = [].slice.call(document.querySelectorAll('.custom-option-calidad .form-check-input'))
@ -113,8 +107,7 @@ function initCalidadCheck()
})
}
function updateCalidadCheck(el)
{
function updateCalidadCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
@ -124,7 +117,7 @@ function updateCalidadCheck(el)
})
}
el.closest('.custom-option-calidad').classList.add('checked')
if(el.closest('.custom-option-calidad').id == 'calidadEstandarDiv') {
if (el.closest('.custom-option-calidad').id == 'calidadEstandarDiv') {
$('#calidadEstandar').prop('checked', true);
$('#calidadPremium').prop('checked', false);
}
@ -137,7 +130,7 @@ function updateCalidadCheck(el)
}
}
$('#enableSobrecubierta').on('change', function() {
$('#enableSobrecubierta').on('change', function () {
if ($(this).is(":checked")) {
$('.enable-sobrecubierta').show();
} else {
@ -146,7 +139,7 @@ $('#enableSobrecubierta').on('change', function() {
});
function initDisenioLibro(){
function initDisenioLibro() {
initTapaCheck();
initColorCheck();
initCalidadCheck();
@ -158,7 +151,7 @@ function initDisenioLibro(){
$('#papelCubierta').val('').trigger('change');
$('#papelSobrecubierta').val('').trigger('change');
$('#enableSobrecubierta').trigger('change');
}
@ -168,31 +161,31 @@ $('.change-tipo-impresion').on('change', function () {
isHq = $('#calidadEstandarDiv').hasClass('checked') ? false : true;
//si es color hay que mostrar el numero de paginas a color
if(isColor){
if (isColor) {
$('#pagColorDiv').show();
}
else{
else {
$('#pagColorDiv').hide();
}
var data = [];
if(!isColor && !isHq) {
if (!isColor && !isHq) {
data = window.datosPresupuesto.papelInteriorNegro;
}
else if(!isColor && isHq) {
else if (!isColor && isHq) {
data = window.datosPresupuesto.papelInteriorNegroHq;
}
else if(isColor && !isHq) {
else if (isColor && !isHq) {
data = window.datosPresupuesto.papelInteriorColor;
}
else if(isColor && isHq) {
else if (isColor && isHq) {
data = window.datosPresupuesto.papelInteriorColorHq;
}
var dropdown = $("#papelInterior");
dropdown.empty();
$.each(data, function() {
$.each(data, function () {
dropdown.append($("<option />").val(this.id).text(this.nombre));
});
//Se quita la seleccion del dropdown
@ -201,7 +194,7 @@ $('.change-tipo-impresion').on('change', function () {
});
$('#tirada').on('change', function() {
$('#tirada').on('change', function () {
const valInterior = $('#gramajeInterior option:selected').val();
const valCubierta = $('#gramajeCubierta option:selected').val();
@ -214,23 +207,23 @@ $('#tirada').on('change', function() {
});
$('#papelInterior').on('change', function() {
$('#papelInterior').on('change', function () {
isColor = $('#colorNegroDiv').hasClass('checked') ? false : true;
isHq = $('#calidadEstandarDiv').hasClass('checked') ? false : true;
if($('#papelInterior option:selected').val() != undefined){
if ($('#papelInterior option:selected').val() != undefined) {
var uso = 'bn';
if(!isColor && !isHq) {
if (!isColor && !isHq) {
uso = 'bn';
}
else if(!isColor && isHq) {
else if (!isColor && isHq) {
uso = 'bnhq';
}
else if(isColor && !isHq) {
else if (isColor && !isHq) {
uso = 'color';
}
else if(isColor && isHq) {
else if (isColor && isHq) {
uso = 'colorhq';
}
datos = {
@ -247,27 +240,27 @@ $('#papelInterior').on('change', function() {
url: window.routes_disenio_libro.obtenerGramaje,
type: 'POST',
data: datos,
success: function(response) {
success: function (response) {
$('#gramajeInterior').empty();
$(response.menu).each(function( index, element ) {
$(response.menu).each(function (index, element) {
$('#gramajeInterior').append($("<option />").val(element.id).text(element.text));
});
if(valInterior != undefined)
$('#gramajeInterior option[value='+valInterior + ']').prop('selected', true).trigger('change');
if (valInterior != undefined)
$('#gramajeInterior option[value=' + valInterior + ']').prop('selected', true).trigger('change');
}
});
}
});
$('#papelCubierta').on('change', function() {
$('#papelCubierta').on('change', function () {
isColor = true;
isHq = true;
if($('#papelCubierta option:selected').val() != undefined){
if ($('#papelCubierta option:selected').val() != undefined) {
var uso = 'colorhq';
datos = {
@ -284,26 +277,26 @@ $('#papelCubierta').on('change', function() {
url: window.routes_disenio_libro.obtenerGramaje,
type: 'POST',
data: datos,
success: function(response) {
success: function (response) {
$('#gramajeCubierta').empty();
$(response.menu).each(function( index, element ) {
$(response.menu).each(function (index, element) {
$('#gramajeCubierta').append($("<option />").val(element.id).text(element.text));
});
if(valCubierta != undefined)
$('#gramajeCubierta option[value='+ valCubierta + ']').prop('selected', true).trigger('change');
if (valCubierta != undefined)
$('#gramajeCubierta option[value=' + valCubierta + ']').prop('selected', true).trigger('change');
}
});
}
});
$('#papelSobrecubierta').on('change', function() {
$('#papelSobrecubierta').on('change', function () {
isColor = true;
isHq = true;
if($('#papelSobrecubierta option:selected').val() != undefined){
if ($('#papelSobrecubierta option:selected').val() != undefined) {
var uso = 'colorhq';
datos = {
@ -320,22 +313,22 @@ $('#papelSobrecubierta').on('change', function() {
url: window.routes_disenio_libro.obtenerGramaje,
type: 'POST',
data: datos,
success: function(response) {
success: function (response) {
$('#gramajeSobrecubierta').empty();
$(response.menu).each(function( index, element ) {
$(response.menu).each(function (index, element) {
$('#gramajeSobrecubierta').append($("<option />").val(element.id).text(element.text));
});
if(valSobrecubierta != undefined)
$('#gramajeSobrecubierta option[value='+ valCubierta + ']').prop('selected', true).trigger('change');
if (valSobrecubierta != undefined)
$('#gramajeSobrecubierta option[value=' + valCubierta + ']').prop('selected', true).trigger('change');
}
});
}
});
$('#solapasCubierta').on('change', function() {
$('#solapasCubierta').on('change', function () {
if ($(this).is(":checked")) {
$('#tamanioSolapasCubierta').show();
} else {
@ -343,7 +336,7 @@ $('#solapasCubierta').on('change', function() {
}
});
$('#solapasSobrecubierta').on('change', function() {
$('#solapasSobrecubierta').on('change', function () {
if ($(this).is(":checked")) {
$('#tamanioSolapasSobrecubierta').show();
} else {
@ -353,7 +346,7 @@ $('#solapasSobrecubierta').on('change', function() {
// Funcion que comprueba que están rellenos todos los datos necesarios para calcular el presupuesto
function checkValues(){
function checkValues() {
const tirada = $('#tirada').val();
const paginas = $('#paginas').val();
@ -364,27 +357,27 @@ function checkValues(){
const papelFormatoAlto = $('#altoLibro').val();
const papelFormatoAncho = $('#anchoLibro').val();
if(tirada == '' || isNaN(tirada) || parseInt(tirada) <= 0){
return false;
}
if(paginas == '' || isNaN(paginas) || parseInt(paginas) <= 0){
if (tirada == '' || isNaN(tirada) || parseInt(tirada) <= 0) {
return false;
}
if(papelInterior == '' || gramajeInterior == ''){
return false;
}
if(papelCubierta == '' || gramajeCubierta == ''){
if (paginas == '' || isNaN(paginas) || parseInt(paginas) <= 0) {
return false;
}
if($('#papelFormatoId').val() == '' ||
if (papelInterior == '' || gramajeInterior == '') {
return false;
}
if (papelCubierta == '' || gramajeCubierta == '') {
return false;
}
if ($('#papelFormatoId').val() == '' ||
($('#papelFormatoPersonalizado').is(':checked') &&
((papelFormatoAncho == '' || isNaN(papelFormatoAncho) || parseInt(papelFormatoAncho) <= 0) ||
(papelFormatoAlto == '' || isNaN(papelFormatoAlto) || parseInt(papelFormatoAlto) <= 0) )
)){
((papelFormatoAncho == '' || isNaN(papelFormatoAncho) || parseInt(papelFormatoAncho) <= 0) ||
(papelFormatoAlto == '' || isNaN(papelFormatoAlto) || parseInt(papelFormatoAlto) <= 0))
)) {
return false;
}
@ -392,26 +385,220 @@ function checkValues(){
}
$('.calcular-presupuesto').on('change', function() {
function getTiradas() {
let tiradas = [];
tiradas.push(parseInt($('#tirada').val()));
if ($('#tirada2').val().length > 0 && parseInt($('#tirada2').val()) > 0)
tiradas.push(parseInt($('#tirada2').val()));
if ($('#tirada3').val().length > 0 && parseInt($('#tirada3').val()) > 0)
tiradas.push(parseInt($('#tirada3').val()));
if ($('#tirada4').val().length > 0 && parseInt($('#tirada4').val()) > 0)
tiradas.push(parseInt($('#tirada4').val()));
return tiradas;
}
function getDimensionLibro() {
var ancho = 0;
var alto = 0;
if ($('#papelFormatoId').select2('data').length > 0) {
if ($('#papelFormatoId').select2('data')[0].id.length > 0) {
ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]);
alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]);
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
return {
ancho: ancho,
alto: alto
}
}
$('#retractilado').on('change', function () {
if ($(this).is(':checked')) {
if ($('#retractilado5').is(':checked'))
$('#retractilado5').prop('checked', false);
}
});
$('#retractilado5').on('change', function () {
if ($(this).is(':checked')) {
if ($('#retractilado').is(':checked'))
$('#retractilado').prop('checked', false);
}
});
$('.elementos-libro').on('change', function () {
// Libro cosido
if ($('#cosidoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Rústica cosido");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// Cosido tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
else {
// Cosido tapa dura
$('.guardas').show();
numCarasGuardas(2);
$('.solapas-cubierta').hide();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
}
// Libro fresado
else if ($('#fresadoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Rústica fresado");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// fresado tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
else {
// fresado tapa dura
$('.guardas').show();
numCarasGuardas(2);
$('.solapas-cubierta').hide();
$('.sobrecubierta').show();
$('#enableSobrecubierta').trigger('change');
}
}
// Libro grapado
else if ($('#grapadoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Cosido con grapas");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// grapado tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
// Libro wire-o
else if ($('#wireoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Wire-O");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// wire-o tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
else {
// wire-o tapa dura
$('.guardas').show();
numCarasGuardas(1);
$('.solapas-cubierta').hide();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
// Libro espiral
else if ($('#espiralDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Espiral");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// espiral tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
else {
// espiral tapa dura
$('.espiral').show();
numCarasGuardas(1);
$('.solapas-cubierta').hide();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
});
function numCarasGuardas(numCaras) {
if (numCaras == 1) {
$("#impresionGuardas option[value='8']").remove();
}
else {
if ($("#impresionGuardas option[value='8']").length == 0)
$("#impresionGuardas").append('<option value="8">' + window.Presupuestos.dosCaras + '</option>');
}
}
$('.calcular-presupuesto').on('change', function () {
calcularPresupuesto();
});
async function calcularPresupuesto(){
async function calcularPresupuesto() {
if(!checkValues()){
// se obtiene la propiedad serv_id de los checkboxes seleccionados de la clase .servicio-extra
if (!checkValues()) {
return;
}
var datos = {
tirada: $('#tirada').val(),
merma: $('#merma').val(),
uso: 'colorhq',
papelInterior: $('#papelInterior option:selected').text(),
let servicios = [];
$('.servicio-extra:checked').each(function () {
servicios.push($(this).attr('serv_id'));
})
let datos = {
tamanio: getDimensionLibro(),
tirada: getTiradas(),
paginas: $('#paginas').val(),
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
isColor: $('#colorNegroDiv').hasClass('checked') ? false : true,
isHq: $('#calidadEstandarDiv').hasClass('checked') ? false : true,
papelInterior: $('#papelInterior option:selected').val(),
gramajeInterior: $('#gramajeInterior option:selected').text(),
papelCubierta: $('#papelCubierta option:selected').text(),
excluirRotativa: $('#excluirRotativa').is(':checked'),
papelCubierta: $('#papelCubierta option:selected').val(),
gramajeCubierta: $('#gramajeCubierta option:selected').text(),
papelSobrecubierta: $('#papelSobrecubierta option:selected').text(),
gramajeSobrecubierta: $('#gramajeSobrecubierta option:selected').text(),
carasCubierta: $('#carasCubierta').val(),
acabadoCubierta: $('#acabadosCubierta').val(),
servicios: servicios,
}
// Si hay solapas de cubierta
if ($('#solapasCubierta').is(':checked')) {
datos.solapasCubierta = $('#anchoSolapasCubierta').val()
}
// Si hay sobrecubierta
if($('.enable-sobrecubierta').is(':visible')) {
datos.sobrecubierta = {
papel: $('#papelSobrecubierta option:selected').val(),
gramaje: $('#gramajeSobrecubierta option:selected').text(),
acabado: $('#acabadosSobrecubierta').val()
}
if($('#solapasSobrecubierta').is(':checked')) {
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
}
}
if($('.guardas').is(':visible')){
datos.guardas = {
papel: $('#papelGuardas option:selected').val(),
caras: $('#impresionGuardas option:selected').val()
}
}
}

View File

@ -318,231 +318,3 @@
})();
$('.elementos-libro').on('change', function () {
// Libro cosido
if ($('#cosidoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Rústica cosido");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// Cosido tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').show();
}
else {
// Cosido tapa dura
$('.guardas').show();
numCarasGuardas(2);
$('.solapas-cubierta').hide();
$('.sobrecubierta').show();
}
}
// Libro fresado
else if ($('#fresadoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Rústica fresado");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// fresado tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').show();
}
else {
// fresado tapa dura
$('.guardas').show();
numCarasGuardas(2);
$('.solapas-cubierta').hide();
$('.sobrecubierta').show();
}
}
// Libro grapado
else if ($('#grapadoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Cosido con grapas");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// grapado tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
}
}
// Libro wire-o
else if ($('#wireoDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Wire-O");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// wire-o tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
else {
// wire-o tapa dura
$('.guardas').show();
numCarasGuardas(1);
$('.solapas-cubierta').hide();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
// Libro espiral
else if ($('#espiralDiv').hasClass('checked')) {
$('#tituloDisenioLibro').text("Espiral");
if ($('#tapaBlandaInnerDiv').hasClass('checked')) {
// espiral tapa blanda
$('.guardas').hide();
$('.solapas-cubierta').show();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
else {
// espiral tapa dura
$('.espiral').show();
numCarasGuardas(1);
$('.solapas-cubierta').hide();
$('.sobrecubierta').hide();
$('#enableSobrecubierta').prop('checked', false);
}
}
});
function numCarasGuardas(numCaras) {
if (numCaras == 1) {
$("#impresionGuardas option[value='8']").remove();
}
else {
if ($("#impresionGuardas option[value='8']").length == 0)
$("#impresionGuardas").append('<option value="8">' + window.Presupuestos.dosCaras + '</option>');
}
}
function calcular_mermas() {
const tirada = parseInt($('#tirada').val())
var merma = 0
if (tirada > window.datosPresupuesto.POD) {
merma = tirada * 0.1 <= 30 ? tirada * 0.1 : 30
}
else {
/*merma_lineas = []
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
if(formas_linea > tirada)
merma_lineas.push(formas_linea-tirada)
else
merma_lineas.push(tirada%formas_linea)
}
})
if(merma_lineas.length>0)
merma = Math.max(...merma_lineas)
else{
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.validation.no_lp_for_merma +
`</h5>
</div>
</div>`;
merma = 0
}*/
}
return merma;
}
function getDimensionLibro() {
var ancho = 0;
var alto = 0;
if ($('#papelFormatoId').select2('data').length > 0) {
if ($('#papelFormatoId').select2('data')[0].id.length > 0) {
ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]);
alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]);
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
return {
ancho: ancho,
alto: alto
}
}
function getTiradas() {
let tiradas = [];
tiradas.push(parseInt($('#tirada').val()));
if($('#tirada2').val().length > 0 && parseInt($('#tirada2').val()) > 0)
tiradas.push(parseInt($('#tirada2').val()));
if($('#tirada3').val().length > 0 && parseInt($('#tirada3').val()) > 0)
tiradas.push(parseInt($('#tirada3').val()));
if($('#tirada4').val().length > 0 && parseInt($('#tirada4').val()) > 0)
tiradas.push(parseInt($('#tirada4').val()));
return tiradas;
}
function checkPresupuestoData(){
if(
$('#clienteId').val().length > 0 &&
$('#paginas').val().length > 0 &&
$('#tirada').val().length > 0 &&
$('#papelInterior').val().length > 0 &&
$('#gramajeInterior').val().length > 0 &&
$('#papelCubierta').val().length > 0 &&
$('#gramajeCubierta').val().length > 0
){
return true;
}
return false;
}
function obtenerDatos() {
if(!checkPresupuestoData()){
return;
}
libro = getDimensionLibro();
let data = {
clienteId: $('#clienteId').val(),
ancho: libro.ancho,
alto: libro.alto,
paginas: parseInt($('#paginas').val()),
tiradas: getTiradas(),
papelInterior: $('#papelInterior').val(),
gramajeInterior: $('#gramajeInterior').val(),
papelCubierta: $('#papelCubierta').val(),
gramajeCubierta: $('#gramajeCubierta').val(),
carasCubierta: $('#carasCubierta').val(),
acabadoCubierta: $('#acabadoCubiertaId').val(),
solapasCubierta: $('#solapasCubierta').is(':checked'),
tamanioSolapasCubierta: $('#anchoSolapasCubierta').val(),
}
}

3864
xdebug.log

File diff suppressed because it is too large Load Diff