Merge branch 'mod/papel_seleccionable_sobre_guardas' into 'main'

papel y gramaje  sobrecubierta y guardas seleccionable

See merge request jjimenez/safekat!529
This commit is contained in:
2025-02-09 12:16:23 +00:00
7 changed files with 218 additions and 65 deletions

View File

@ -313,6 +313,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
$guardas = goSanitize($this->request->getGet('guardas'))[0] ?? 0;
$ancho = floatval($this->request->getGet('ancho') ?? 0);
$alto = floatval($this->request->getGet('alto') ?? 0);
@ -323,8 +324,8 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
$menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
$menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $guardas, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $guardas, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
if ($forSelect2) {
$menu = array_map(function ($item) {

View File

@ -353,7 +353,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$guardas = $reqData['guardas'] ?? [];
if ($guardas != "false" && $guardas != null) {
$datos_guardas = [
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
'papel' => intval($guardas['papel']),
'gramaje' => intval($guardas['gramaje']),
'caras' => intval($guardas['caras']),
];
@ -366,7 +366,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (count($datos_guardas) != 0 && $datos_guardas) {
$guardas = $datos_guardas;
$input_data['papel_generico'] = $datos_guardas['papel'] ?? 0;
$input_data['papel_generico']['id'] = $datos_guardas['papel'] ?? 0;
$input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0;
$input_data['datosPedido']->paginas = 8;
$input_data['paginas_color'] = 8;
@ -508,7 +508,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Sobrecubierta
if ($sobrecubierta != "false" && $sobrecubierta != null) {
$sobrecubierta = [
'papel' => $modelPapelGenerico->getIdFromCode($sobrecubierta['papel']),
'papel' => $modelPapelGenerico->where('id', $sobrecubierta['papel'])->first()->toArray(),
'gramaje' => intval($sobrecubierta['gramaje']),
'solapas' => intval($sobrecubierta['solapas'] ?? 0),
'acabado' => $sobrecubierta['acabado'] ?? 0,
@ -519,7 +519,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Guardas
if ($guardas != "false" && $guardas != null) {
$datos_guardas = [
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
'papel' => $modelPapelGenerico->where('id', $guardas['papel'])->first()->toArray(),
'gramaje' => intval($guardas['gramaje']),
'caras' => intval($guardas['caras']),
];
@ -1024,7 +1024,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Sobrecubierta
if ($sobrecubierta != "false" && $sobrecubierta != null) {
$sobrecubierta = [
'papel' => $modelPapelGenerico->getIdFromCode($sobrecubierta['papel']),
'papel' => $modelPapelGenerico->where('id', $sobrecubierta['papel'])->first()->toArray(),
'gramaje' => intval($sobrecubierta['gramaje']),
'solapas' => intval($sobrecubierta['solapas'] ?? 0),
'acabado' => $sobrecubierta['acabado'] ?? 0,
@ -1035,7 +1035,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Guardas
if ($guardas != "false" && $guardas != null) {
$datos_guardas = [
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
'papel' => $modelPapelGenerico->where('id', $guardas['papel'])->first()->toArray(),
'gramaje' => intval($guardas['gramaje']),
'caras' => intval($guardas['caras']),
];
@ -3161,7 +3161,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$return_data['cubierta']['gramaje'] = $linea->gramaje;
$return_data['cubierta']['paginas'] = $linea->paginas;
} else if ($linea->tipo == 'lp_sobrecubierta') {
$return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
$return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id)['nombre'];
$return_data['sobrecubierta']['papel_id'] = $linea->papel_id;
$return_data['sobrecubierta']['gramaje'] = $linea->gramaje;
$return_data['sobrecubierta']['paginas'] = $linea->paginas;
} else if ($linea->tipo == 'lp_faja') {
@ -3170,7 +3171,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$return_data['faja']['gramaje'] = $linea->gramaje;
$return_data['faja']['paginas'] = $linea->paginas;
} else if ($linea->tipo == 'lp_guardas') {
$return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
$return_data['guardas']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id)['nombre'];
$return_data['guardas']['papel_id'] = $linea->papel_id;
$return_data['guardas']['gramaje'] = $linea->gramaje;
$return_data['guardas']['paginas'] = $linea->paginas;
}

View File

@ -94,7 +94,8 @@ return [
'retractilado' => 'Retractilado individual',
'retractilado5' => 'Retractilado de 5',
'Guardas' => 'Guardas',
'papelGuardas' => 'Papel de guardas',
'papelGuardas' => 'Papel guardas',
'gramajeGuardas' => 'Gramaje guardas',
'offsetBlancoGuardas' => 'Offset blanco 170 gr',
'offsetAhuesadoGuardas' => 'Offset ahuesado 170 gr',
'guardasImpresas' => "Guardas impresas",
@ -121,6 +122,7 @@ return [
'bronce' => 'Bronce',
'retractiladoTitle' => 'Retractilado',
'papelSobrecubierta' => 'Papel sobrecubierta',
'gramajeSobrecubierta' => 'Gramaje sobrecubierta',
'tamanioSolapasSobrecubierta' => 'Tamaño solapas sobrecubierta',
'plastificadoSobrecubierta' => 'Plastificado sobrecubierta',
'faja' => 'Faja',

View File

@ -414,6 +414,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
$tipo,
$is_cubierta = false,
$is_sobrecubierta = false,
$is_guardas = false,
$selected_papel_id = null,
$tapa_dura = null,
$papel_especial = false,
@ -521,6 +522,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
} else if ($is_sobrecubierta == true) {
$builder->where("t2.sobrecubierta", 1);
$builder->where("t5.uso", 'sobrecubierta');
} else if ($is_guardas == true) {
$builder->where("t2.guardas", 1);
$builder->where("t5.uso", 'interior');
} else {
$builder->where("t2.interior", 1);
$builder->where("t5.uso", 'interior');

View File

@ -98,17 +98,25 @@
</div>
<div id="divConfigTapaDura" class="row col-sm-10 mb-5 justify-content-center d-none">
<div id="divConfigTapaDura" name="div_config_tapa_dura" class="row col-sm-10 mb-5 justify-content-center d-none">
<div class="row justify-content-center">
<div class="col-sm-3">
<label for="papelGuardas" class="form-label">
<?= lang('Presupuestos.papelGuardas') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelGuardas" name="papel_guardas">
<option value="OFF1_170"><?= lang('Presupuestos.offsetBlancoGuardas') ?></option>
<option value="OFF2_170"><?= lang('Presupuestos.offsetAhuesadoGuardas') ?></option>
</select>
<div class="row col-sm-4">
<div class="">
<label for="papelGuardas" class="form-label">
<?= lang('Presupuestos.papelGuardas') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelGuardas" name="papel_guardas">
</select>
</div>
<div class="">
<label for="gramajeGuardas" class="form-label">
<?= lang('Presupuestos.gramajeGuardas') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="gramajeGuardas"
name="gramaje_guardas">
</select>
</div>
</div>
<div class="col-sm-3">
@ -188,8 +196,8 @@
<h3 class="mb-1 fw-bold"> Extras </h3>
</div><!--//.mb-3 -->
<div id="divExtras" name="div_extras" class="row col-sm-12 mb-3 justify-content-center align-items-top">
<div class="row col-sm-12 mb-3 justify-content-center align-items-top">
<div class="row col-sm-2 mb-3 d-flex flex-column align-items-center sobrecubierta-items">
<div class="form-check form-switch mb-2">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addSobrecubierta"
@ -199,14 +207,20 @@
</div>
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
<label for="papelSobrecubierta" class="form-label">
<?= lang('Presupuestos.papelSobrecubierta') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelSobrecubierta"
name="papel_sobrecubierta">
<option value="EST2_170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
<option value="EST2_200"><?= lang('Presupuestos.estucadoMate200gr') ?></option>
</select>
<div class="">
<label for="papelSobrecubierta" class="form-label">
<?= lang('Presupuestos.papelSobrecubierta') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="papelSobrecubierta" name="papel_sobrecubierta">
</select>
</div>
<div class="">
<label for="gramajeSobrecubierta" class="form-label">
<?= lang('Presupuestos.gramajeSobrecubierta') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="gramajeSobrecubierta" name="gramaje_sobrecubierta">
</select>
</div>
</div>
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
@ -231,7 +245,7 @@
</div>
</div>
<div class="row col-sm-12 mb-0 justify-content-center">
<div id="divExtras" name="div_extras" class="row col-sm-12 mb-0 justify-content-center">
<div class="row justify-content-center">
@ -252,7 +266,7 @@
</select>
</div>
<div class="">
<label for="papelFaja" class="form-label">
<label for="gramajeFaja" class="form-label">
<?= lang('Presupuestos.gramajeFaja') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="gramajeFaja" name="gramaje_faja">
@ -289,8 +303,7 @@
<label for="acabadoFaja" class="form-label">
<?= lang('Presupuestos.plastificadoFaja') ?>
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoFaja"
name="plastificado_faja">
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoFaja" name="plastificado_faja">
<option value="0"> <?= lang('Presupuestos.acabadoNinguno') ?> </option>
</select>
</div>

View File

@ -4,11 +4,12 @@
* @param {String} url
* @param {String} placeholder
*/
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "") {
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "", hideSearch = false) {
this.url = url;
this.item = domItem;
this.params = params;
this.dropdownParent = dropdownParent;
this.hideSearch = hideSearch;
this.config = {
placeholder: placeholder,
@ -48,6 +49,11 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param
};
this.init = function () {
if (this.item.length) {
if(this.hideSearch){
this.config.minimumResultsForSearch = -1;
}
this.item = this.item.select2(this.config);
// $.fn.modal.Constructor.prototype.enforceFocus = function () {};
}

View File

@ -58,7 +58,43 @@ class DisenioCubierta {
this.textoSolapasCubierta = this.domItem.find("#textoSolapasCubierta");
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
this.papelGuardas = this.domItem.find("#papelGuardas");
this.papelGuardas = new ClassSelect($("#papelGuardas"),
'/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
[this.csrf_token]: this.csrf_hash,
tipo: () => 'colorhq',
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
solapas: 0,
lomo: 0,
guardas: 1,
forSelect2: 1,
},
"",
true,
);
this.gramajeGuardas = new ClassSelect($("#gramajeGuardas"),
'/papelesgenericos/getpapelcliente',
window.translations["selectGramaje"],
false,
{
[this.csrf_token]: this.csrf_hash,
tipo: 'colorhq',
papel: () => { return this.papelGuardas.getVal() },
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
alto: () => { return $('#altoFaja').val() },
solapas: 0,
lomo: 0,
guardas: 1,
forSelect2: 1,
},
"",
true
);
this.guardasImpresas = this.domItem.find("#guardasImpresas");
this.cabezada = this.domItem.find("#cabezada");
@ -72,7 +108,43 @@ class DisenioCubierta {
this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta");
this.sobrecubierta = this.domItem.find("#addSobrecubierta");
this.papelSobrecubierta = this.domItem.find("#papelSobrecubierta");
this.papelSobrecubierta = new ClassSelect($("#papelSobrecubierta"),
'/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
[this.csrf_token]: this.csrf_hash,
tipo: 'colorhq',
sobrecubierta: 1,
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
solapas: () => { return $('#solapasSobrecubierta').val() },
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
forSelect2: 1,
},
"",
true,
);
this.gramajeSobrecubierta = new ClassSelect($("#gramajeSobrecubierta"),
'/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
[this.csrf_token]: this.csrf_hash,
tipo: 'colorhq',
sobrecubierta: 1,
papel: () => { return this.papelSobrecubierta.getVal() },
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
solapas: () => { return $('#solapasSobrecubierta').val() },
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
forSelect2: 1,
},
"",
true,
);
this.acabadoSobrecubierta = this.domItem.find("#acabadoSobrecubierta");
this.configuracionFaja = this.domItem.find(".config-faja");
@ -91,7 +163,9 @@ class DisenioCubierta {
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
forSelect2: 1,
}
},
"",
true,
);
this.gramajeFaja = new ClassSelect($("#gramajeFaja"),
'/papelesgenericos/getpapelcliente',
@ -108,7 +182,9 @@ class DisenioCubierta {
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
forSelect2: 1,
}
},
"",
true
);
@ -201,6 +277,12 @@ class DisenioCubierta {
this.acabadoSobrecubierta.init();
this.acabadoFaja.init();
this.papelGuardas.init();
this.gramajeGuardas.init();
this.papelSobrecubierta.init();
this.gramajeSobrecubierta.init();
this.papelFaja.init();
this.gramajeFaja.init();
@ -228,6 +310,8 @@ class DisenioCubierta {
this.papelFaja.item.on('change', () => { this.gramajeFaja.empty(); });
this.papelGuardas.item.on('change', () => { this.gramajeGuardas.empty(); });
// Observadores
this.observer.observe(this.tapaBlanda[0], { attributes: true });
this.observer.observe(this.tapaDuraLomoRecto[0], { attributes: true });
@ -255,7 +339,8 @@ class DisenioCubierta {
}
if (datosCubierta.tapa == "dura") {
this.papelGuardas.val(datosGuardas.papel.code + "_" + datosGuardas.gramaje).trigger('change');
this.papelGuardas.setOption(datosGuardas.papel_id, datosGuardas.papel);
this.gramajeGuardas.setOption(datosGuardas.gramaje, datosGuardas.gramaje);
this.guardasImpresas.val(datosGuardas.paginas).trigger('change');
this.cabezada.val(datosCubierta.cabezada).trigger('change');
}
@ -281,7 +366,8 @@ class DisenioCubierta {
if (datosSobrecubierta && datosSobrecubierta.papel) {
this.sobrecubierta.trigger('click');
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
this.papelSobrecubierta.setOption(datosSobrecubierta.papel_id, datosSobrecubierta.papel);
this.gramajeSobrecubierta.setOption(datosSobrecubierta.gramaje, datosSobrecubierta.gramaje);
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
this.acabadoSobrecubierta.setOption(datosSobrecubierta.acabado.id, datosSobrecubierta.acabado.text);
}
@ -432,6 +518,37 @@ class DisenioCubierta {
}
}
},
div_config_tapa_dura: {
validators: {
callback: {
callback: function (input) {
const div = $('#divConfigTapaDura'); // Selecciona el div
div.find('.fv-plugins-message-container').remove();
if ($('divConfigTapaDura').hasClass('d-none'))
return true;
const papelGuardas = $('#papelGuardas').select2('data').length > 0;
const gramajeGuardas = $('#gramajeGuardas').select2('data').length > 0;
if (papelGuardas && gramajeGuardas) {
return true;
}
else {
div.append(`
<div class="fv-plugins-message-container invalid-feedback">
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
${window.translations["validation"].extras_cubierta}
</div>
</div>
`);
return false;
}
},
}
}
},
div_extras: {
validators: {
callback: {
@ -440,22 +557,33 @@ class DisenioCubierta {
const div = $('#divExtras'); // Selecciona el div
div.find('.fv-plugins-message-container').remove();
if($("#addFaja").prop("checked") == false)
return true;
const papelFaja = $('#papelFaja').select2('data').length > 0;
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
if (papelFaja && gramajeFaja) {
return true;
let error = false;
if ($("#addFaja").prop("checked") == true) {
const papelFaja = $('#papelFaja').select2('data').length > 0;
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
if (!papelFaja || !gramajeFaja) {
error = true;
}
}
else {
if ($("#addSobrecubierta").prop("checked") == true) {
const papelSobrecubierta = $('#papelSobrecubierta').select2('data').length > 0;
const gramajeSobrecubierta = $('#gramajeSobrecubierta').select2('data').length > 0;
if (!papelSobrecubierta || !gramajeSobrecubierta) {
error = true;
}
}
if (error) {
div.append(`
<div class="fv-plugins-message-container invalid-feedback">
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
${window.translations["validation"].extras_cubierta}
<div class="fv-plugins-message-container invalid-feedback">
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
${window.translations["validation"].extras_cubierta}
</div>
</div>
</div>
`);
`);
return false;
}
},
@ -478,6 +606,7 @@ class DisenioCubierta {
case 'div_papel_cubierta':
case 'div_gramaje_cubierta':
case 'div_papel_especial_cubierta':
case 'div_config_tapa_dura':
return '.col-sm-10';
case 'div_extras':
return '.col-sm-12';
@ -675,15 +804,13 @@ class DisenioCubierta {
let guardas = {};
if (forResumen) {
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text();
guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1];
guardas.gramaje = papelGuardas.split(' ')[2];
guardas.papel = this.papelGuardas.getText();
guardas.gramaje = this.gramajeGuardas.getText();
guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").text();
}
else {
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val();
guardas.papel = papelGuardas.split('_')[0];
guardas.gramaje = papelGuardas.split('_')[1];
guardas.papel = this.papelGuardas.getVal();
guardas.gramaje = this.gramajeGuardas.getVal();
guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").val();
}
return guardas;
@ -703,18 +830,16 @@ class DisenioCubierta {
else {
if (forResumen) {
let sobrecubierta = {};
const papel = this.domItem.find("#papelSobrecubierta").children("option:selected").text();
sobrecubierta.papel = papel.split(' ')[0] + ' ' + papel.split(' ')[1];
sobrecubierta.gramaje = papel.split(' ')[2];
sobrecubierta.papel = this.papelSobrecubierta.getText();
sobrecubierta.gramaje = this.gramajeSobrecubierta.getText();
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
sobrecubierta.acabado = this.acabadoSobrecubierta.getText();
return sobrecubierta;
}
else {
let sobrecubierta = {};
let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val();
sobrecubierta.papel = papel.split('_')[0];
sobrecubierta.gramaje = papel.split('_')[1];
sobrecubierta.papel = this.papelSobrecubierta.getVal();
sobrecubierta.gramaje = this.gramajeSobrecubierta.getVal();
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
sobrecubierta.acabado = this.acabadoSobrecubierta.getVal();
return sobrecubierta;