mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
pruebas solapas max
This commit is contained in:
@ -694,7 +694,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
|
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
|
||||||
$excluirRotativa = intval($excluirRotativa);
|
$excluirRotativa = intval($excluirRotativa);
|
||||||
|
|
||||||
$tipo = $reqData['tipo'];
|
$tipo = $reqData['tipo'] ??'cosido';
|
||||||
$tipoCubierta = 'blanda'; // solapas sólo tapa blanda y sobre cubierta
|
$tipoCubierta = 'blanda'; // solapas sólo tapa blanda y sobre cubierta
|
||||||
|
|
||||||
$isColor = intval($reqData['isColor']) ?? 0;
|
$isColor = intval($reqData['isColor']) ?? 0;
|
||||||
|
|||||||
@ -367,6 +367,8 @@ class PresupuestoAdminEdit {
|
|||||||
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
this.calcularSolapas();
|
||||||
|
|
||||||
// Funciones para detectar cambios en el formulario
|
// Funciones para detectar cambios en el formulario
|
||||||
this.#checkChangesPresupuesto();
|
this.#checkChangesPresupuesto();
|
||||||
$('#bc-save').on("click", function () {
|
$('#bc-save').on("click", function () {
|
||||||
@ -382,29 +384,6 @@ class PresupuestoAdminEdit {
|
|||||||
).get();
|
).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
calcularSolapas() {
|
|
||||||
|
|
||||||
|
|
||||||
this.#getDatos(false, true);
|
|
||||||
if (Object.values(this.datos).every(this.#isValidDataForm)) {
|
|
||||||
new Ajax('/presupuestocliente/calcularsolapas',
|
|
||||||
this.datos,
|
|
||||||
{},
|
|
||||||
(response) => {
|
|
||||||
if (response === null || response === undefined || response === "") {
|
|
||||||
console.error("Error en el calculo máximo de solapas.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.disenioCubierta.tamanioSolapasCubierta.attr('max', response);
|
|
||||||
this.disenioCubierta.solapasSobrecubierta.attr('max', response);
|
|
||||||
this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm");
|
|
||||||
this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm");
|
|
||||||
},
|
|
||||||
() => { }
|
|
||||||
).post();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
checkPaginasPresupuesto() {
|
checkPaginasPresupuesto() {
|
||||||
|
|
||||||
@ -416,7 +395,7 @@ class PresupuestoAdminEdit {
|
|||||||
cantidad_total += parseInt(rowData.paginas)
|
cantidad_total += parseInt(rowData.paginas)
|
||||||
})
|
})
|
||||||
htmlString = ''
|
htmlString = ''
|
||||||
|
|
||||||
if (cantidad_total != parseInt($('#paginas').val())) {
|
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||||
htmlString = `
|
htmlString = `
|
||||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||||
@ -429,12 +408,12 @@ class PresupuestoAdminEdit {
|
|||||||
`</h5>
|
`</h5>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
$('#divAlarmasLineasPresupuesto').html(htmlString)
|
$('#divAlarmasLineasPresupuesto').html(htmlString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getPaginasColor(){
|
getPaginasColor() {
|
||||||
|
|
||||||
let paginasColor = 0;
|
let paginasColor = 0;
|
||||||
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
@ -442,42 +421,51 @@ class PresupuestoAdminEdit {
|
|||||||
if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') {
|
if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') {
|
||||||
return parseInt(rowData.paginas);
|
return parseInt(rowData.paginas);
|
||||||
}
|
}
|
||||||
if(rowData.row_id === 'lp_rot_color'){
|
if (rowData.row_id === 'lp_rot_color') {
|
||||||
return parseInt(rowData.numPagColor);
|
return parseInt(rowData.numPagColor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return paginasColor;
|
return paginasColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
calcularSolapas() {
|
calcularSolapas() {
|
||||||
|
|
||||||
let datos = {
|
let anchoTotal = 2*this.getDimensionLibro().ancho;
|
||||||
cliente_id: this.datosGenerales.cliente.getVal(),
|
let maxSolapas = 120;
|
||||||
tirada: this.datosGenerales.tirada.val(),
|
|
||||||
tamanio: this.getDimensionLibro(),
|
|
||||||
paginas: this.datosLibro.paginas.val(),
|
|
||||||
//paginasColor:
|
|
||||||
|
|
||||||
|
let mano = 0;
|
||||||
|
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if (rowData.row_id != 'lp_cubierta' || rowData.row_id === 'lp_sobrecubierta'
|
||||||
|
|| rowData.row_id === 'lp_guardas' || rowData.row_id === 'lp_faja'
|
||||||
|
) {
|
||||||
|
mano += parseInt(rowData.mano);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (mano > 0) {
|
||||||
|
anchoTotal += 6 + 5; // dobleces + sangre
|
||||||
|
maxSolapas = Math.min(Math.floor((865-anchoTotal)/2), 0.75*this.getDimensionLibro().ancho);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
/*if (Object.values(this.datos).every(this.#isValidDataForm)) {
|
maxSolapas = 0.75*this.getDimensionLibro().ancho;
|
||||||
new Ajax('/presupuestocliente/calcularsolapas',
|
}
|
||||||
this.datos,
|
if($('#solapas_ancho').length>0 && $('#solapas_ancho').attr('max') != maxSolapas){
|
||||||
{},
|
$('#solapas_ancho').attr('max', maxSolapas);
|
||||||
(response) => {
|
$('#solapas_ancho').trigger('change');
|
||||||
if (response === null || response === undefined || response === "") {
|
$('#solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
||||||
console.error("Error en el calculo máximo de solapas.");
|
}
|
||||||
return;
|
if($('#solapas_ancho_sobrecubierta').length>0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas){
|
||||||
}
|
$('#solapas_ancho_sobrecubierta').attr('max', maxSolapas);
|
||||||
this.disenioCubierta.tamanioSolapasCubierta.attr('max', response);
|
$('#solapas_ancho_sobrecubierta').trigger('change');
|
||||||
this.disenioCubierta.solapasSobrecubierta.attr('max', response);
|
$('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
||||||
this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm");
|
}
|
||||||
this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm");
|
if($('#solapas_ancho_faja').length>0 && $('#solapas_ancho_faja').attr('max') != maxSolapas){
|
||||||
},
|
$('#solapas_ancho_faja').attr('max', maxSolapas);
|
||||||
() => { }
|
$('#solapas_ancho_faja').trigger('change');
|
||||||
).post();
|
$('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
||||||
}*/
|
}
|
||||||
|
console.log('maxSolapas', maxSolapas);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDimensionLibro() {
|
getDimensionLibro() {
|
||||||
|
|||||||
@ -95,6 +95,24 @@ class DatosLibro {
|
|||||||
|
|
||||||
this.paginas.on('change', this.changePaginas.bind(this));
|
this.paginas.on('change', this.changePaginas.bind(this));
|
||||||
this.tirada.on('change', this.changeTirada.bind(this));
|
this.tirada.on('change', this.changeTirada.bind(this));
|
||||||
|
|
||||||
|
this.anchoSolapasCubierta.on('focusout', this.checkSolapasMax.bind(this));
|
||||||
|
this.anchoSolapasSobrecubierta.on('focusout', this.checkSolapasMax.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkSolapasMax(event) {
|
||||||
|
const el = event.target;
|
||||||
|
if (el.value != "") {
|
||||||
|
if (parseInt(el.value) < parseInt(el.min)) {
|
||||||
|
el.value = el.min;
|
||||||
|
}
|
||||||
|
if (parseInt(el.value) > parseInt(el.max)) {
|
||||||
|
el.value = el.max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
el.value = el.min;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +190,8 @@ class DatosLibro {
|
|||||||
this.checkPaginasPresupuesto();
|
this.checkPaginasPresupuesto();
|
||||||
|
|
||||||
$(document).trigger('update-presupuesto', {
|
$(document).trigger('update-presupuesto', {
|
||||||
update_lineas : true,
|
update_lineas: true,
|
||||||
update_servicios : true,
|
update_servicios: true,
|
||||||
update_envios: true,
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
@ -199,10 +217,10 @@ class DatosLibro {
|
|||||||
$("#label_papelFormatoId").text(
|
$("#label_papelFormatoId").text(
|
||||||
window.language.Presupuestos.papelFormatoId + '*');
|
window.language.Presupuestos.papelFormatoId + '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).trigger('update-presupuesto', {
|
$(document).trigger('update-presupuesto', {
|
||||||
update_lineas : true,
|
update_lineas: true,
|
||||||
update_servicios : false,
|
update_servicios: false,
|
||||||
update_envios: false,
|
update_envios: false,
|
||||||
update_resumen: false,
|
update_resumen: false,
|
||||||
update_tiradas_alternativas: false
|
update_tiradas_alternativas: false
|
||||||
@ -228,12 +246,12 @@ class DatosLibro {
|
|||||||
this.updateComparador();
|
this.updateComparador();
|
||||||
}
|
}
|
||||||
|
|
||||||
changeAnchoSolapasCubierta(){
|
changeAnchoSolapasCubierta() {
|
||||||
|
|
||||||
if(this.checkSolapasGrandes('cubierta')){
|
if (this.checkSolapasGrandes('cubierta')) {
|
||||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta');
|
$(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta');
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
|
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,12 +277,12 @@ class DatosLibro {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
changeAnchoSolapasSobrecubierta(){
|
changeAnchoSolapasSobrecubierta() {
|
||||||
|
|
||||||
if(this.checkSolapasGrandes('cubierta')){
|
if (this.checkSolapasGrandes('cubierta')) {
|
||||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
$(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,24 +292,24 @@ class DatosLibro {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkSolapasGrandes(elemento) {
|
checkSolapasGrandes(elemento) {
|
||||||
|
|
||||||
const ancho_libro = 2 * this.getDimensionLibro().ancho;
|
const ancho_libro = 2 * this.getDimensionLibro().ancho;
|
||||||
let ancho_solapas = 0.0;
|
let ancho_solapas = 0.0;
|
||||||
let lomo = 0.0;
|
let lomo = 0.0;
|
||||||
if(elemento == 'cubierta'){
|
if (elemento == 'cubierta') {
|
||||||
ancho_solapas = 2 * parseFloat($('solapas_ancho').val());
|
ancho_solapas = 2 * parseFloat($('solapas_ancho').val());
|
||||||
lomo = parseFloat($('lomo_cubierta').val());
|
lomo = parseFloat($('lomo_cubierta').val());
|
||||||
}
|
}
|
||||||
else if (elemento == 'sobrecubierta'){
|
else if (elemento == 'sobrecubierta') {
|
||||||
ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val());
|
ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val());
|
||||||
lomo = parseFloat($('lomo_sobrecubierta').val());
|
lomo = parseFloat($('lomo_sobrecubierta').val());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ancho_libro + ancho_solapas + lomo > 630)
|
if (ancho_libro + ancho_solapas + lomo > 630)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,32 +338,32 @@ class DatosLibro {
|
|||||||
$('#compPaginasNegrohq').trigger('change');
|
$('#compPaginasNegrohq').trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$(document).trigger('update-presupuesto', {
|
$(document).trigger('update-presupuesto', {
|
||||||
update_lineas : true,
|
update_lineas: true,
|
||||||
update_servicios : true,
|
update_servicios: true,
|
||||||
update_envios: true,
|
update_envios: true,
|
||||||
update_resumen: true,
|
update_resumen: true,
|
||||||
update_tiradas_alternativas: true
|
update_tiradas_alternativas: true
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateComparador(){
|
updateComparador() {
|
||||||
|
|
||||||
if($("#compPaginasNegro").hasClass('d-none')){
|
if ($("#compPaginasNegro").hasClass('d-none')) {
|
||||||
$('#compPaginasNegrohq').trigger('change');
|
$('#compPaginasNegrohq').trigger('change');
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$('#compPaginasNegro').trigger('change');
|
$('#compPaginasNegro').trigger('change');
|
||||||
}
|
}
|
||||||
$('#compCarasCubierta').trigger('change');
|
$('#compCarasCubierta').trigger('change');
|
||||||
|
|
||||||
if($('#compSobrecubierta').length){
|
if ($('#compSobrecubierta').length) {
|
||||||
$('#compSobrecubierta').trigger('change');
|
$('#compSobrecubierta').trigger('change');
|
||||||
}
|
}
|
||||||
if($('#compCarasGuardas').length){
|
if ($('#compCarasGuardas').length) {
|
||||||
$('#compCarasGuardas').trigger('change');
|
$('#compCarasGuardas').trigger('change');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,13 +379,13 @@ class DatosLibro {
|
|||||||
|
|
||||||
if (url_parts2[url_parts2.length - 2] == 'edit') {
|
if (url_parts2[url_parts2.length - 2] == 'edit') {
|
||||||
$(document).trigger('update-presupuesto', {
|
$(document).trigger('update-presupuesto', {
|
||||||
update_lineas : true,
|
update_lineas: true,
|
||||||
update_servicios : false,
|
update_servicios: false,
|
||||||
update_envios: false,
|
update_envios: false,
|
||||||
update_resumen: false,
|
update_resumen: false,
|
||||||
update_tiradas_alternativas: false
|
update_tiradas_alternativas: false
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).trigger('ckeck-lineas-envios');
|
$(document).trigger('ckeck-lineas-envios');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user