mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Version 1.0
This commit is contained in:
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateCatalogoLibros extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->db->query('SET foreign_key_checks = 0');
|
||||
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'auto_increment' => true],
|
||||
'cliente_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'proveedor_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'user_created_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'default' => 1],
|
||||
'user_update_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'default' => 1],
|
||||
'cubierta_archivo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'cubierta_url' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true],
|
||||
'ancho' => ['type' => 'DOUBLE', 'constraint' => '8,2'],
|
||||
'alto' => ['type' => 'DOUBLE', 'constraint' => '8,2'],
|
||||
'peso' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'null' => true],
|
||||
'titulo' => ['type' => 'VARCHAR', 'constraint' => 300],
|
||||
'autor' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'autor_entidad' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'traductor' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'ilustrador' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'idioma' => ['type' => 'VARCHAR', 'constraint' => 3, 'default' => 'spa'],
|
||||
'num_edic' => ['type' => 'INT', 'default' => 1, 'null' => true],
|
||||
'fecha_disponibilidad' => ['type' => 'DATE', 'null' => true],
|
||||
'fecha_public' => ['type' => 'DATE', 'null' => true],
|
||||
'num_fotos' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr_color' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr_bn' => ['type' => 'INT', 'default' => 0],
|
||||
'coleccion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'isk' => ['type' => 'VARCHAR', 'constraint' => 64, 'null' => true],
|
||||
'isbn' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'ean' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'editorial' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'resumen' => ['type' => 'TEXT', 'null' => true],
|
||||
'resumen_breve' => ['type' => 'TEXT', 'null' => true],
|
||||
'sello' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'paginas' => ['type' => 'INT'],
|
||||
'tipo_impresion' => ['type' => 'ENUM', 'constraint' => ['negro','negrohq','color','colorhq'], 'null' => true],
|
||||
'comentarios' => ['type' => 'TEXT', 'null' => true],
|
||||
'negro_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'negro_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'negro_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'negro_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'negro_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'color_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'color_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'color_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'color_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'color_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'cubierta_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'cubierta_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'cubierta_acabado_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_ancho_solapas' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'default' => 0.00, 'unsigned' => true],
|
||||
'cubierta_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'sobrecubierta_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'sobrecubierta_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'sobrecubierta_acabado_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_ancho_solapas' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'default' => 0.00, 'unsigned' => true],
|
||||
'sobrecubierta_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'encuadernacion_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'ubicacion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'created_at' => ['type' => 'TIMESTAMP', 'default' => 'CURRENT_TIMESTAMP'],
|
||||
'updated_at' => ['type' => 'TIMESTAMP', 'null' => true],
|
||||
'deleted_at' => ['type' => 'TIMESTAMP', 'null' => true],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addUniqueKey('isk');
|
||||
$this->forge->addForeignKey('cliente_id', 'clientes', 'id');
|
||||
|
||||
$this->forge->createTable('catalogo_libros');
|
||||
|
||||
$this->db->query('SET foreign_key_checks = 1');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('catalogo_libros');
|
||||
}
|
||||
}
|
||||
1813
ci4/app/Database/Seeds/CatalogoLibrosSeeder.php
Normal file
1813
ci4/app/Database/Seeds/CatalogoLibrosSeeder.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -51,21 +51,28 @@ class CatalogoLibroEntity extends Entity
|
||||
'negro_papel' => null,
|
||||
'negro_papel_id' => null,
|
||||
'negro_gramaje' => null,
|
||||
'negro_pod_papel_id' => null,
|
||||
'negro_pod_gramaje' => null,
|
||||
'color_paginas' => null,
|
||||
'color_papel' => null,
|
||||
'color_papel_id' => null,
|
||||
'color_gramaje' => null,
|
||||
'color_pod_papel_id' => null,
|
||||
'color_pod_gramaje' => null,
|
||||
'cubierta_paginas' => null,
|
||||
'cubierta_papel' => null,
|
||||
'cubierta_papel_id' => null,
|
||||
'cubierta_gramaje' => null,
|
||||
'cubierta_acabado' => null,
|
||||
'cubierta_pod_papel_id' => null,
|
||||
'cubierta_pod_gramaje' => null,
|
||||
'sobrecubierta_paginas' => null,
|
||||
'sobrecubierta_papel' => null,
|
||||
'sobrecubierta_papel_id' => null,
|
||||
'sobrecubierta_gramaje' => null,
|
||||
'sobrecubierta_acabado' => null,
|
||||
'encuardenacion' => '',
|
||||
'sobrecubierta_pod_papel_id' => null,
|
||||
'sobrecubierta_pod_gramaje' => null,
|
||||
'encuardenacion_id' => 'null',
|
||||
'ubicacion' => null,
|
||||
'created_at' => null,
|
||||
@ -95,16 +102,26 @@ class CatalogoLibroEntity extends Entity
|
||||
'negro_paginas' => '?int',
|
||||
'negro_gramaje' => '?float',
|
||||
'negro_papel_id' => '?int',
|
||||
'negro_pod_papel_id' => '?int',
|
||||
'negro_pod_gramaje' => '?float',
|
||||
'color_paginas' => '?int',
|
||||
'color_gramaje' => '?float',
|
||||
'color_papel_id' => '?int',
|
||||
'color_pod_papel_id' => '?int',
|
||||
'color_pod_gramaje' => '?float',
|
||||
'cubierta_paginas' => '?int',
|
||||
'cubierta_gramaje' => '?float',
|
||||
'cubierta_papel_id' => '?int',
|
||||
'cubierta_pod_papel_id' => '?int',
|
||||
'cubierta_pod_gramaje' => '?float',
|
||||
'sobrecubierta_paginas' => '?int',
|
||||
'sobrecubierta_gramaje' => '?float',
|
||||
'sobrecubierta_papel_id' => '?int',
|
||||
|
||||
'sobrecubierta_pod_papel_id' => '?int',
|
||||
'sobrecubierta_pod_gramaje' => '?float',
|
||||
'fecha_disponibilidad' => 'datetime',
|
||||
'fecha_public' => 'datetime',
|
||||
|
||||
];
|
||||
|
||||
public function getClienteName()
|
||||
@ -156,6 +173,16 @@ class CatalogoLibroEntity extends Entity
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getNegroPodPapelName()
|
||||
{
|
||||
if (!$this->negro_pod_papel_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->negro_pod_papel_id);
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getColorPapelName()
|
||||
{
|
||||
if (!$this->color_papel_id) {
|
||||
@ -166,6 +193,16 @@ class CatalogoLibroEntity extends Entity
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getColorPodPapelName()
|
||||
{
|
||||
if (!$this->color_pod_papel_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->color_pod_papel_id);
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getCubiertaPapelName()
|
||||
{
|
||||
if (!$this->cubierta_papel_id) {
|
||||
@ -176,6 +213,16 @@ class CatalogoLibroEntity extends Entity
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getCubiertaPodPapelName()
|
||||
{
|
||||
if (!$this->cubierta_pod_papel_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->cubierta_pod_papel_id);
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getSobrecubiertaPapelName()
|
||||
{
|
||||
if (!$this->sobrecubierta_papel_id) {
|
||||
@ -186,6 +233,16 @@ class CatalogoLibroEntity extends Entity
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getSobrecubiertaPodPapelName()
|
||||
{
|
||||
if (!$this->sobrecubierta_pod_papel_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->sobrecubierta_pod_papel_id);
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getCubiertaAcabadoName()
|
||||
{
|
||||
if (!$this->cubierta_acabado_id) {
|
||||
|
||||
@ -10,8 +10,10 @@ return [
|
||||
'color' => 'Color',
|
||||
'createdAt' => 'Creado en',
|
||||
'cubierta' => 'Cubierta',
|
||||
'cubierta_pod' => 'Cubierta (POD)',
|
||||
'use_for_tapa_dura' => 'Papel tapa dura',
|
||||
'sobrecubierta' => 'Sobrecubierta',
|
||||
'sobrecubierta_pod' => 'Sobrecubierta (POD)',
|
||||
'guardas' => 'Guardas',
|
||||
'defecto' => 'Por defecto',
|
||||
'deletedAt' => 'Borrado en',
|
||||
|
||||
@ -47,19 +47,27 @@ class CatalogoLibroModel extends Model
|
||||
'negro_paginas',
|
||||
'negro_papel_id',
|
||||
'negro_gramaje',
|
||||
'negro_pod_papel_id',
|
||||
'negro_pod_gramaje',
|
||||
'color_paginas',
|
||||
'color_papel_id',
|
||||
'color_gramaje',
|
||||
'color_pod_papel_id',
|
||||
'color_pod_gramaje',
|
||||
'cubierta_paginas',
|
||||
'cubierta_papel_id',
|
||||
'cubierta_gramaje',
|
||||
'cubierta_acabado_id',
|
||||
'cubierta_ancho_solapas',
|
||||
'cubierta_pod_papel_id',
|
||||
'cubierta_pod_gramaje',
|
||||
'sobrecubierta_paginas',
|
||||
'sobrecubierta_papel_id',
|
||||
'sobrecubierta_gramaje',
|
||||
'sobrecubierta_acabado_id',
|
||||
'sobrecubierta_ancho_solapas',
|
||||
'sobrecubierta_pod_papel_id',
|
||||
'sobrecubierta_pod_gramaje',
|
||||
'encuadernacion_id',
|
||||
'ubicacion',
|
||||
];
|
||||
|
||||
@ -13,10 +13,6 @@
|
||||
data-bs-parent="#accordionConfiguracionLibro">
|
||||
<div class="accordion-body">
|
||||
|
||||
<!-- Alertas + campo oculto -->
|
||||
<div id="divAlarmasComparador"></div>
|
||||
<input type="hidden" name="comparador_json_data" id="comparador_json_data" value="">
|
||||
|
||||
<?php
|
||||
// 1) TIPO DE IMPRESIÓN + ENCUADERNACIÓN
|
||||
$tipos = ['negro', 'negrohq', 'color', 'colorhq'];
|
||||
@ -28,7 +24,7 @@
|
||||
</div>
|
||||
<div class="row px-4 mt-1">
|
||||
<div class="col-lg-3 col-md-12">
|
||||
<select id="tipo_impresion" name="tipo_impresion" class="form-control select2bs2"
|
||||
<select id="tipo_impresion" name="tipo_impresion" class="form-control select2bs2 warning-change"
|
||||
style="width:100%" data-placeholder="<?= lang('Catalogo.seleccionarTipoImpresion') ?>">
|
||||
<option></option>
|
||||
<?php foreach ($tipos as $t): ?>
|
||||
@ -109,14 +105,16 @@
|
||||
<?php
|
||||
$especiales = [
|
||||
'cubierta' => ['faces' => [2 => 'unaCara', 4 => 'dosCaras'], 'disable' => false],
|
||||
'sobrecubierta' => ['faces' => [0 => 'no', 1 => 'si'], 'disable' => in_array($catalogoLibrosEntity->tipo_impresion_id, [5, 6, 7, 8, 21])]
|
||||
'cubierta_pod' => ['faces' => [2 => 'unaCara', 4 => 'dosCaras'], 'disable' => false],
|
||||
'sobrecubierta' => ['faces' => [0 => 'no', 1 => 'si'], 'disable' => in_array($catalogoLibrosEntity->tipo_impresion_id, [5, 6, 7, 8, 21])],
|
||||
'sobrecubierta_pod' => ['faces' => [0 => 'no', 1 => 'si'], 'disable' => in_array($catalogoLibrosEntity->tipo_impresion_id, [5, 6, 7, 8, 21])]
|
||||
];
|
||||
foreach ($especiales as $tipo => $cfg):
|
||||
$pag = $catalogoLibrosEntity->{"{$tipo}_paginas"};
|
||||
$papId = $catalogoLibrosEntity->{"{$tipo}_papel_id"};
|
||||
$papNm = $catalogoLibrosEntity->{"{$tipo}PapelName"};
|
||||
$gram = $catalogoLibrosEntity->{"{$tipo}_gramaje"};
|
||||
$sol = old("{$tipo}_solapas_ancho", $catalogoLibrosEntity->{"{$tipo}_solapas_ancho"});
|
||||
$sol = old("{$tipo}_solapas_ancho", $catalogoLibrosEntity->{"{$tipo}_ancho_solapas"});
|
||||
$acId = $catalogoLibrosEntity->{"{$tipo}_acabado_id"};
|
||||
$acNm = $catalogoLibrosEntity->{"{$tipo}AcabadoName"};
|
||||
|
||||
@ -134,11 +132,11 @@
|
||||
. "</select>",
|
||||
"<select id=\"{$tipo}_gramaje\" name=\"{$tipo}_gramaje\" class=\"form-control select2bs2 {$tipo}_items\" style=\"width:100%\"" . ($cfg['disable'] ? ' disabled' : '') . ">"
|
||||
. "<option value=\"" . esc($gram) . "\" selected>" . esc($gram) . "</option></select>",
|
||||
"<input type=\"text\" id=\"{$tipo}_solapas_ancho\" name=\"{$tipo}_solapas_ancho\" placeholder=\"0\" maxlength=\"5\" class=\"form-control {$tipo}_items\" value=\"" . esc($sol) . "\"" . ($cfg['disable'] ? ' disabled' : '') . ">",
|
||||
"<input type=\"text\" id=\"{$tipo}_ancho_solapas\" name=\"{$tipo}_ancho_solapas\" placeholder=\"0\" maxlength=\"5\" class=\"form-control {$tipo}_items\" value=\"" . esc($sol) . "\"" . ($cfg['disable'] ? ' disabled' : '') . ">",
|
||||
"<select id=\"{$tipo}_acabado_id\" name=\"{$tipo}_acabado_id\" class=\"form-control select2bs2 {$tipo}_items\" style=\"width:100%\"" . ($cfg['disable'] ? ' disabled' : '') . ">"
|
||||
. "<option value=\"" . esc($acId) . "\" selected>" . esc($acNm) . "</option></select>",
|
||||
];
|
||||
$renderRow($cells);
|
||||
$renderRow($cells, $tipo);
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
@ -19,11 +19,9 @@
|
||||
<img src="<?= esc($catalogoLibrosEntity->cubierta_url) ?>" class="img-fluid mb-2"
|
||||
alt="Portada">
|
||||
<?php else: ?>
|
||||
<img src="<?= base_url('assets/img/default_cover.png') ?>" class="img-fluid mb-2"
|
||||
<img src="https://static.cegal.es/imagenes/marcadas/9788415/978841f45711.gif" class="img-fluid mb-2"
|
||||
alt="Sin portada">
|
||||
<?php endif; ?>
|
||||
<input type="file" name="cubierta_archivo" class="form-control" accept="image/*">
|
||||
<small class="form-text text-muted">Subir portada</small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -97,9 +95,9 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="cubierta_archivo" class="form-label">Archivo</label>
|
||||
<input type="text" id="cubierta_archivo" name="cubierta_archivo" class="form-control"
|
||||
value="<?= old('cubierta_archivo', $catalogoLibrosEntity->cubierta_archivo) ?>">
|
||||
<label for="ubicacion" class="form-label">Ubicación</label>
|
||||
<input type="text" id="ubicacion" name="ubicacion" class="form-control"
|
||||
value="<?= old('ubicacion', $catalogoLibrosEntity->ubicacion) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
|
||||
@ -50,13 +50,13 @@
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="fecha_disponibilidad" class="form-label">Fecha Disponibilidad</label>
|
||||
<input type="date" id="fecha_disponibilidad" name="fecha_disponibilidad" class="form-control"
|
||||
value="<?= old('fecha_disponibilidad', $catalogoLibrosEntity->fecha_disponibilidad) ?>">
|
||||
value="<?= old('fecha_disponibilidad', $catalogoLibrosEntity->fecha_disponibilidad?->format('Y-m-d')) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="fecha_public" class="form-label">Fecha Publicación</label>
|
||||
<input type="date" id="fecha_public" name="fecha_public" class="form-control"
|
||||
value="<?= old('fecha_public', $catalogoLibrosEntity->fecha_public) ?>">
|
||||
value="<?= old('fecha_public', $catalogoLibrosEntity->fecha_public?->format('Y-m-d')) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
|
||||
@ -5,18 +5,28 @@ class Catalogo {
|
||||
|
||||
constructor() {
|
||||
|
||||
/* Definiciones */
|
||||
this.tirada_no_pod = 100;
|
||||
this.tirada_pod = 1;
|
||||
|
||||
this.cliente = new ClassSelect($("#cliente_id"), '/catalogo/libros/clientlist', "Seleccione un cliente");
|
||||
/* Mapeado de elementos */
|
||||
this.tipo_impresion = $("#tipo_impresion");
|
||||
this.paginas_cubierta = $("#cubierta_paginas");
|
||||
this.sobrecubiertaItems = $('.sobrecubierta_items').add('.sobrecubierta_pod_items');
|
||||
this.paginasSobrecubierta = $('#sobrecubierta_paginas');
|
||||
this.negro = $('#negro_paginas');
|
||||
this.color = $('#color_paginas');
|
||||
this.total = $('#paginas');
|
||||
|
||||
/* Select2 para clientes */
|
||||
this.cliente = new ClassSelect($("#cliente_id"), '/catalogo/libros/clientlist', "Seleccione un cliente");
|
||||
|
||||
/* Select2 para tipos de encuadernacion */
|
||||
this.encuadernacion = new ClassSelect($("#encuadernacion_id"), '/importador/getencuadernacion', "Seleccione una encuadernación");
|
||||
|
||||
this.compPapelNegro = new ClassSelect($("#negro_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
/* Select2 para impresion en Negro */
|
||||
this.selectPapelNegro = new ClassSelect($("#negro_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
@ -26,7 +36,7 @@ class Catalogo {
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
this.compPapelNegroPod = new ClassSelect($("#negro_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
this.selectPapelNegroPod = new ClassSelect($("#negro_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
@ -37,10 +47,10 @@ class Catalogo {
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
this.compGramajeNegro = new ClassSelect($('#negro_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
this.selectGramajeNegro = new ClassSelect($('#negro_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.compPapelNegro.getVal(),
|
||||
papel_generico: () => this.selectPapelNegro.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
@ -49,7 +59,21 @@ class Catalogo {
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
this.compPapelColor = new ClassSelect($("#color_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
this.selectGramajeNegroPod = new ClassSelect($('#negro_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelNegroPod.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
|
||||
/* Select2 para impresion en Color */
|
||||
this.selectPapelColor = new ClassSelect($("#color_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
@ -60,10 +84,21 @@ class Catalogo {
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
|
||||
});
|
||||
|
||||
this.compGramajeColor = new ClassSelect($('#color_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
this.selectPapelColorPod = new ClassSelect($("#color_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.compPapelColor.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
|
||||
});
|
||||
|
||||
this.selectGramajeColor = new ClassSelect($('#color_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelColor.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
@ -72,47 +107,63 @@ class Catalogo {
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
|
||||
});
|
||||
|
||||
this.compPapelCubierta = new ClassSelect($("#cubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
this.selectGramajeColorPod = new ClassSelect($('#color_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelColorPod.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
|
||||
});
|
||||
|
||||
/* Select2 para impresion de cubiertas */
|
||||
this.selectPapelCubierta = new ClassSelect($("#cubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#cubierta_solapas_ancho').val(),
|
||||
sopalas: () => $('#cubierta_ancho_solapas').val(),
|
||||
lomo: () => 0,
|
||||
tipo: 'colorhq',
|
||||
uso: 'cubierta',
|
||||
});
|
||||
this.compGramajeCubierta = new ClassSelect($('#cubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
|
||||
this.selectPapelCubiertaPod = new ClassSelect($("#cubierta_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#cubierta_ancho_solapas').val(),
|
||||
lomo: () => 0,
|
||||
tipo: 'colorhq',
|
||||
uso: 'cubierta',
|
||||
});
|
||||
|
||||
this.selectGramajeCubierta = new ClassSelect($('#cubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.compPapelCubierta.getVal(),
|
||||
papel_generico: () => this.selectPapelCubierta.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#cubierta_solapas_ancho').val(),
|
||||
sopalas: () => $('#cubierta_ancho_solapas').val(),
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
this.compPapelSobrecubierta = new ClassSelect($("#sobrecubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#compSolapasSobrecubierta').val(),
|
||||
lomo: () => 0,
|
||||
tipo: 'colorhq',
|
||||
uso: 'sobrecubierta',
|
||||
});
|
||||
this.compGramajeSobrecubierta = new ClassSelect($('#sobrecubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
|
||||
this.selectGramajeCubiertaPod = new ClassSelect($('#cubierta_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.compPapelSobrecubierta.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
papel_generico: () => this.selectPapelCubiertaPod.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#compSolapasSobrecubierta').val(),
|
||||
sopalas: () => $('#cubierta_ancho_solapas').val(),
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
@ -125,6 +176,56 @@ class Catalogo {
|
||||
"cubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
/* Select2 para impresion de sobrecubierta */
|
||||
this.selectPapelSobrecubierta = new ClassSelect($("#sobrecubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
|
||||
lomo: () => 0,
|
||||
tipo: 'colorhq',
|
||||
uso: 'sobrecubierta',
|
||||
});
|
||||
|
||||
this.selectPapelSobrecubiertaPod = new ClassSelect($("#sobrecubierta_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
|
||||
lomo: () => 0,
|
||||
tipo: 'colorhq',
|
||||
uso: 'sobrecubierta',
|
||||
});
|
||||
|
||||
this.selectGramajeSobrecubierta = new ClassSelect($('#sobrecubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelSobrecubierta.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
|
||||
this.selectGramajeSobrecubiertaPod = new ClassSelect($('#sobrecubierta_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelSobrecubiertaPod.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
|
||||
this.acabadosSobrecubierta = new ClassSelect($("#sobrecubierta_acabado_id"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'Seleccione acabado',
|
||||
@ -134,15 +235,18 @@ class Catalogo {
|
||||
}
|
||||
);
|
||||
|
||||
this.sobrecubiertaItems = $('.sobrecubierta_items');
|
||||
this.paginasSobrecubierta = $('#sobrecubierta_paginas');
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const self = this;
|
||||
|
||||
// Eliminar elementos que no se usan
|
||||
$('[id*="_pod_paginas"]').remove();
|
||||
$('[id*="_pod_ancho_solapas"]').remove();
|
||||
$('[id*="_pod_acabado_id"]').remove();
|
||||
|
||||
|
||||
// Fuerza el foco en el campo de búsqueda de select2
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
@ -155,39 +259,52 @@ class Catalogo {
|
||||
|
||||
this.encuadernacion.init();
|
||||
|
||||
this.compPapelNegro.init();
|
||||
this.compPapelNegroPod.init();
|
||||
this.compGramajeNegro.init();
|
||||
this.compPapelColor.init();
|
||||
this.compGramajeColor.init();
|
||||
this.compPapelCubierta.init();
|
||||
this.compGramajeCubierta.init();
|
||||
this.compPapelSobrecubierta.init();
|
||||
this.compGramajeSobrecubierta.init();
|
||||
this.selectPapelNegro.init();
|
||||
this.selectPapelNegroPod.init();
|
||||
this.selectGramajeNegro.init();
|
||||
this.selectGramajeNegroPod.init();
|
||||
|
||||
this.selectPapelColor.init();
|
||||
this.selectPapelColorPod.init();
|
||||
this.selectGramajeColor.init();
|
||||
this.selectGramajeColorPod.init();
|
||||
|
||||
this.selectPapelCubierta.init();
|
||||
this.selectPapelCubiertaPod.init();
|
||||
this.selectGramajeCubierta.init();
|
||||
this.selectGramajeCubiertaPod.init();
|
||||
this.acabadoCubierta.init();
|
||||
|
||||
this.selectPapelSobrecubierta.init();
|
||||
this.selectPapelSobrecubiertaPod.init();
|
||||
this.selectGramajeSobrecubierta.init();
|
||||
this.selectGramajeSobrecubiertaPod.init();
|
||||
this.acabadosSobrecubierta.init();
|
||||
|
||||
|
||||
// Al cargar la página
|
||||
this.toggleSobrecubiertaFields();
|
||||
|
||||
this.compPapelNegro.item.on('select2:select', function () {
|
||||
self.compGramajeNegro.empty();
|
||||
});
|
||||
|
||||
this.cliente.item.on('change', () => {
|
||||
|
||||
|
||||
});
|
||||
|
||||
// Inicializacino de eventos
|
||||
this.tipo_impresion.on("change", this.updateOpcionesComparador.bind(this));
|
||||
this.selectPapelNegro.item.on('select2:select', function () {
|
||||
self.selectGramajeNegro.empty();
|
||||
});
|
||||
|
||||
this.total.on('input change', () => {
|
||||
this.validarMultiploDe4([this.total, this.color, this.negro]);
|
||||
});
|
||||
this.color.on('input change', this.actualizarDesdeColor.bind(this));
|
||||
this.negro.on('input change', this.actualizarDesdeNegro.bind(this));
|
||||
this.tipo_impresion.on("change", this.updateOpcionesImpresion.bind(this));
|
||||
|
||||
// Al cambiar el selector de paginas de sobrecubierta
|
||||
this.paginasSobrecubierta.on('change', this.toggleSobrecubiertaFields.bind(this));
|
||||
|
||||
this.updateOpcionesComparador();
|
||||
// Al cambiar el tipo de encuadernacion
|
||||
this.encuadernacion.onChange(this.enableSobrecubiertaLines.bind(this));
|
||||
|
||||
|
||||
this.updateOpcionesImpresion();
|
||||
|
||||
$(document).on('change', '.warning-change', function () {
|
||||
$(this).addClass('bg-warning');
|
||||
@ -196,33 +313,59 @@ class Catalogo {
|
||||
});
|
||||
}
|
||||
|
||||
actualizarDesdeColor() {
|
||||
const total = parseInt(this.total.val(), 10) || 0;
|
||||
const color = parseInt(this.color.val(), 10) || 0;
|
||||
const negro = Math.max(total - color, 0);
|
||||
this.negro.val(negro);
|
||||
this.validarMultiploDe4([this.total, this.color, this.negro]);
|
||||
}
|
||||
|
||||
updateOpcionesComparador() {
|
||||
actualizarDesdeNegro() {
|
||||
const total = parseInt(this.total.val(), 10) || 0;
|
||||
const negro = parseInt(this.negro.val(), 10) || 0;
|
||||
const color = Math.max(total - negro, 0);
|
||||
this.color.val(color);
|
||||
this.validarMultiploDe4([this.total, this.color, this.negro]);
|
||||
}
|
||||
|
||||
validarMultiploDe4(campos) {
|
||||
campos.forEach($el => {
|
||||
const val = parseInt($el.val(), 10) || 0;
|
||||
if (val % 4 !== 0) {
|
||||
$el.css('color', 'red');
|
||||
} else {
|
||||
$el.css('color', '');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateOpcionesImpresion() {
|
||||
$('.negro_items').off('change');
|
||||
$('.color_items').off('change');
|
||||
|
||||
const selValue = this.tipo_impresion.val();
|
||||
const elements_negro = $('.negro-line');
|
||||
const elements_color = $('.color-line');
|
||||
|
||||
if (selValue.includes('color')) {
|
||||
Array.from(elements_color).forEach(element => {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
else {
|
||||
Array.from(elements_color).forEach(element => {
|
||||
$(element).addClass('d-none');
|
||||
});
|
||||
}
|
||||
Array.from(elements_negro).forEach(element => {
|
||||
$(element).removeClass('d-none');
|
||||
|
||||
// Buscar elementos por clase dinámica (negro-*-line y color-*-line)
|
||||
const elements_negro = $('*').filter(function () {
|
||||
return [...this.classList].some(cls => /^negro.*line$/.test(cls));
|
||||
});
|
||||
|
||||
const elements_color = $('*').filter(function () {
|
||||
return [...this.classList].some(cls => /^color.*line$/.test(cls));
|
||||
});
|
||||
|
||||
if (selValue.includes('color')) {
|
||||
elements_color.removeClass('d-none');
|
||||
} else {
|
||||
elements_color.addClass('d-none');
|
||||
}
|
||||
|
||||
elements_negro.removeClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
|
||||
getDimensionLibro() {
|
||||
let ancho = $('#ancho').val();
|
||||
let alto = $('#alto').val();;
|
||||
@ -237,6 +380,33 @@ class Catalogo {
|
||||
}
|
||||
}
|
||||
|
||||
enableSobrecubiertaLines() {
|
||||
|
||||
// Buscar elementos por clase dinámica (sobrecubierta-*-line)
|
||||
const elements_sobrecubierta = $('*').filter(function () {
|
||||
return [...this.classList].some(cls => /^sobrecubierta.*line$/.test(cls));
|
||||
});
|
||||
|
||||
switch (parseInt(this.encuadernacion.getVal(), 10)) {
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 21:
|
||||
console.log("Desactivar sobrecubierta:" + this.encuadernacion.getVal());
|
||||
elements_sobrecubierta.addClass('d-none');
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log("Activar sobrecubierta:" + this.encuadernacion.getVal());
|
||||
elements_sobrecubierta.removeClass('d-none');
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
Reference in New Issue
Block a user