mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
se añaden los limites del numero de paginas en el presupuesto admin dependiendo del tipo de libro
This commit is contained in:
@ -2077,18 +2077,21 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
$merma = 0;
|
$merma = 0;
|
||||||
|
|
||||||
if ($tirada == 0) {
|
if ($tirada == 1) {
|
||||||
$merma = 0;
|
$merma = 0;
|
||||||
}
|
}
|
||||||
else if ($tirada > $POD) {
|
else if ($tirada > intval($POD)) {
|
||||||
$merma = $tirada * 0.1;
|
$merma = $tirada * 0.1;
|
||||||
} else {
|
} else {
|
||||||
$merma_lineas = [];
|
$merma_lineas = [];
|
||||||
foreach ($formas_lineas_interior as $formas_linea) {
|
foreach ($formas_lineas_interior as $formas_linea) {
|
||||||
if ($formas_linea > $tirada)
|
if ($formas_linea > $tirada)
|
||||||
array_push($merma_lineas, $formas_linea - $tirada);
|
array_push($merma_lineas, $formas_linea - $tirada);
|
||||||
else
|
else{
|
||||||
array_push($merma_lineas, $tirada % $formas_linea);
|
$total_pliegos = ceil($tirada / $formas_linea);
|
||||||
|
$total_formas = $total_pliegos * $formas_linea;
|
||||||
|
array_push($merma_lineas, $total_formas - $tirada);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (count($merma_lineas) > 0)
|
if (count($merma_lineas) > 0)
|
||||||
$merma = max($merma_lineas);
|
$merma = max($merma_lineas);
|
||||||
|
|||||||
@ -64,6 +64,49 @@ class PresupuestoAdminAdd {
|
|||||||
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
||||||
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
||||||
this.tirada.on('change', this.calcular_mermas.bind(this));
|
this.tirada.on('change', this.calcular_mermas.bind(this));
|
||||||
|
|
||||||
|
actualizarLimitesPaginas();
|
||||||
|
}
|
||||||
|
|
||||||
|
actualizarLimitesPaginas() {
|
||||||
|
let min = 1;
|
||||||
|
let max = null;
|
||||||
|
|
||||||
|
switch (this.tipo_impresion.val()) {
|
||||||
|
case 1: // Fresado
|
||||||
|
case 2:
|
||||||
|
case 3: // Cosido
|
||||||
|
case 4:
|
||||||
|
min = 32;
|
||||||
|
max = null; // Sin límite superior
|
||||||
|
break;
|
||||||
|
case 5: // Espiral
|
||||||
|
case 6:
|
||||||
|
case 7: // Wire-O
|
||||||
|
case 8:
|
||||||
|
min = 1;
|
||||||
|
max = null; // Sin límite superior
|
||||||
|
break;
|
||||||
|
case 21: // Grapado
|
||||||
|
min = 12;
|
||||||
|
max = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
min = 1;
|
||||||
|
max = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.paginas.attr('min', min);
|
||||||
|
this.paginas.attr('max', max);
|
||||||
|
|
||||||
|
// Verificamos y corregimos el valor actual si está fuera de rango
|
||||||
|
let valorActual = parseInt(this.paginas.val(), 10);
|
||||||
|
|
||||||
|
if (isNaN(valorActual) || valorActual < min) {
|
||||||
|
this.paginas.val(min);
|
||||||
|
} else if (valorActual > max) {
|
||||||
|
this.paginas.val(max);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeTipoTamanio() {
|
changeTipoTamanio() {
|
||||||
|
|||||||
@ -14,6 +14,8 @@ class DatosLibro {
|
|||||||
this.csrf_token = getToken();
|
this.csrf_token = getToken();
|
||||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.tipo_impresion_id = parseInt($("#tipo_impresion_id").val());
|
||||||
|
|
||||||
this.paginas = this.domItem.find('#paginas');
|
this.paginas = this.domItem.find('#paginas');
|
||||||
this.tirada = this.domItem.find('#tirada');
|
this.tirada = this.domItem.find('#tirada');
|
||||||
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
||||||
@ -77,6 +79,8 @@ class DatosLibro {
|
|||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
this.actualizarLimitesPaginas();
|
||||||
|
|
||||||
this.tamanio.init();
|
this.tamanio.init();
|
||||||
this.acabadoCubierta.init();
|
this.acabadoCubierta.init();
|
||||||
this.acabadoSobrecubierta.init();
|
this.acabadoSobrecubierta.init();
|
||||||
@ -84,7 +88,7 @@ class DatosLibro {
|
|||||||
|
|
||||||
this.acabadoCubierta.item.on('select2:select', function () {
|
this.acabadoCubierta.item.on('select2:select', function () {
|
||||||
|
|
||||||
if (this.cargando){
|
if (this.cargando) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ class DatosLibro {
|
|||||||
|
|
||||||
this.acabadoSobrecubierta.item.on('select2:select', function () {
|
this.acabadoSobrecubierta.item.on('select2:select', function () {
|
||||||
|
|
||||||
if (this.cargando){
|
if (this.cargando) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +249,7 @@ class DatosLibro {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(document).trigger('remove-servicio-lineas', 'ferro');
|
$(document).trigger('remove-servicio-lineas', 'ferro');
|
||||||
if(!this.prototipo.prop('checked')){
|
if (!this.prototipo.prop('checked')) {
|
||||||
const table = $('#tableOfDireccionesEnvio').DataTable();
|
const table = $('#tableOfDireccionesEnvio').DataTable();
|
||||||
const rows = table.rows().data();
|
const rows = table.rows().data();
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
@ -297,7 +301,7 @@ class DatosLibro {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(document).trigger('remove-servicio-lineas', 'prototipo');
|
$(document).trigger('remove-servicio-lineas', 'prototipo');
|
||||||
if(!this.ferro.prop('checked')){
|
if (!this.ferro.prop('checked')) {
|
||||||
const table = $('#tableOfDireccionesEnvio').DataTable();
|
const table = $('#tableOfDireccionesEnvio').DataTable();
|
||||||
const rows = table.rows().data();
|
const rows = table.rows().data();
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
@ -754,6 +758,47 @@ class DatosLibro {
|
|||||||
this.ferroDigital.prop('checked', datos.ferroDigital);
|
this.ferroDigital.prop('checked', datos.ferroDigital);
|
||||||
this.marcapaginas.prop('checked', datos.marcapaginas);
|
this.marcapaginas.prop('checked', datos.marcapaginas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actualizarLimitesPaginas() {
|
||||||
|
let min = 1;
|
||||||
|
let max = null;
|
||||||
|
|
||||||
|
switch (this.tipo_impresion_id) {
|
||||||
|
case 1: // Fresado
|
||||||
|
case 2:
|
||||||
|
case 3: // Cosido
|
||||||
|
case 4:
|
||||||
|
min = 32;
|
||||||
|
max = null; // Sin límite superior
|
||||||
|
break;
|
||||||
|
case 5: // Espiral
|
||||||
|
case 6:
|
||||||
|
case 7: // Wire-O
|
||||||
|
case 8:
|
||||||
|
min = 1;
|
||||||
|
max = null; // Sin límite superior
|
||||||
|
break;
|
||||||
|
case 21: // Grapado
|
||||||
|
min = 12;
|
||||||
|
max = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
min = 1;
|
||||||
|
max = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.paginas.attr('min', min);
|
||||||
|
this.paginas.attr('max', max);
|
||||||
|
|
||||||
|
// Verificamos y corregimos el valor actual si está fuera de rango
|
||||||
|
let valorActual = parseInt(this.paginas.val(), 10);
|
||||||
|
|
||||||
|
if (isNaN(valorActual) || valorActual < min) {
|
||||||
|
this.paginas.val(min);
|
||||||
|
} else if (valorActual > max) {
|
||||||
|
this.paginas.val(max);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user