mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Creado concepto de ISK
This commit is contained in:
@ -11,7 +11,8 @@ use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Presupuestos\ImportadorModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use App\Models\Usuarios\GroupModel;
|
||||
use App\Models\Usuarios\PermisosModel;
|
||||
use App\Models\Catalogo\CatalogoLibroModel;
|
||||
use App\Models\Catalogo\IdentificadorIskModel;
|
||||
use App\Services\PresupuestoService;
|
||||
use CodeIgniter\Shield\Entities\User;
|
||||
|
||||
@ -22,7 +23,8 @@ class Test extends BaseController
|
||||
{
|
||||
}
|
||||
|
||||
public function echo(){
|
||||
public function echo()
|
||||
{
|
||||
|
||||
echo "echo";
|
||||
|
||||
@ -30,25 +32,39 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$emailService = service('emailService');
|
||||
|
||||
return $emailService->send("Hola mundo", "Hola mundo", "imnavajas@coit.es");
|
||||
|
||||
$modelCL = new CatalogoLibroModel();
|
||||
$modelISK = new IdentificadorIskModel();
|
||||
|
||||
// Obtener todos los registros sin isk
|
||||
$registros = $modelCL->where('isk', null)->findAll();
|
||||
|
||||
$i = 0;
|
||||
foreach ($registros as $registro) {
|
||||
$isk = $modelISK->newIsk();
|
||||
|
||||
$modelCL->update($registro->id, ['isk' => $isk]);
|
||||
|
||||
echo "[" . $i++ . "]Asignado ISK {$isk} a ID {$registro->id}<br>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function clonar_tarifa_encuadernacion($teOrigen, $teDestino){
|
||||
|
||||
private function clonar_tarifa_encuadernacion($teOrigen, $teDestino)
|
||||
{
|
||||
|
||||
$tet_model = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel');
|
||||
$tel_model = model('App\Models\Tarifas\TarifaEncuadernacionLineaModel');
|
||||
|
||||
$tarifasTiradas = $tet_model->asObject()->where('tarifa_encuadernacion_id',$teOrigen)->findAll();
|
||||
$tarifasTiradas = $tet_model->asObject()->where('tarifa_encuadernacion_id', $teOrigen)->findAll();
|
||||
|
||||
foreach ($tarifasTiradas as $tarifasTirada){
|
||||
foreach ($tarifasTiradas as $tarifasTirada) {
|
||||
|
||||
echo "--->" . $tarifasTirada->id . "<br>";
|
||||
|
||||
$tarifasLineas = $tel_model->asObject()->where('tirada_encuadernacion_id',$tarifasTirada->id)->findAll();
|
||||
$tarifasLineas = $tel_model->asObject()->where('tirada_encuadernacion_id', $tarifasTirada->id)->findAll();
|
||||
|
||||
// Prepare the data
|
||||
unset($tarifasTirada->id);
|
||||
@ -61,7 +77,7 @@ class Test extends BaseController
|
||||
$tet_model->insert($tarifasTirada);
|
||||
$inserted_id = $tet_model->insertID();
|
||||
|
||||
foreach ($tarifasLineas as $tarifasLinea){
|
||||
foreach ($tarifasLineas as $tarifasLinea) {
|
||||
|
||||
echo "------>" . $tarifasLinea->id . "<br>";
|
||||
|
||||
@ -82,10 +98,20 @@ class Test extends BaseController
|
||||
|
||||
|
||||
|
||||
private function test_get_tirada_alt($tirada, $merma, $tipo_impresion_id,
|
||||
$json_data, $cliente_id, $ancho, $alto,
|
||||
$solapas_cubierta, $solapas_ancho_cubierta, $solapas_sobrecubierta, $solapas_ancho_sobrecubierta, $lomo)
|
||||
{
|
||||
private function test_get_tirada_alt(
|
||||
$tirada,
|
||||
$merma,
|
||||
$tipo_impresion_id,
|
||||
$json_data,
|
||||
$cliente_id,
|
||||
$ancho,
|
||||
$alto,
|
||||
$solapas_cubierta,
|
||||
$solapas_ancho_cubierta,
|
||||
$solapas_sobrecubierta,
|
||||
$solapas_ancho_sobrecubierta,
|
||||
$lomo
|
||||
) {
|
||||
$values = [];
|
||||
|
||||
if ($json_data) {
|
||||
@ -96,7 +122,7 @@ class Test extends BaseController
|
||||
echo '------------------------------------<br>';
|
||||
var_dump($linea);
|
||||
// Se obtienen los valores de cada linea para el calculo del precio
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => intval($linea['paginas']) ?? 0,
|
||||
'tirada' => intval($tirada) ?? 0,
|
||||
'merma' => intval($merma) ?? 0,
|
||||
@ -174,7 +200,7 @@ class Test extends BaseController
|
||||
$datosTipolog = $linea['gotaNegro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
$data = (object) array(
|
||||
'negro' => intval($linea['cobNegro']) ?? 0,
|
||||
'cyan' => intval($linea['cobCyan']) ?? 0,
|
||||
'magenta' => intval($linea['cobMagenta']) ?? 0,
|
||||
@ -193,7 +219,7 @@ class Test extends BaseController
|
||||
$data['papel'] = $papel;
|
||||
$data['opciones_papel'] = $opciones_papel;
|
||||
$data['maquina'] = $maquina;
|
||||
$data['papel_generico'] = (array)$papel_generico;
|
||||
$data['papel_generico'] = (array) $papel_generico;
|
||||
$data['isColor'] = $isColor;
|
||||
$data['a_favor_fibra'] = $linea['aFavorFibra'] ?? null;
|
||||
$data['datosTipolog'] = $datosTipolog;
|
||||
@ -222,7 +248,7 @@ class Test extends BaseController
|
||||
|
||||
// Previo a ejecutar, vaciar la tabla clientes_precios (ojo si hay customizaciones)
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('cliente_precios');
|
||||
|
||||
$plantillaDefectoId = 5;
|
||||
@ -394,14 +420,14 @@ class Test extends BaseController
|
||||
{
|
||||
$paginas = 240;
|
||||
|
||||
$papel_impresion = (object)array(
|
||||
$papel_impresion = (object) array(
|
||||
'id' => 198,
|
||||
'gramaje' => 90,
|
||||
'precio_tonelada' => 1600
|
||||
);
|
||||
|
||||
|
||||
$maquina = (object)array(
|
||||
$maquina = (object) array(
|
||||
//'id' => 48,
|
||||
'alto' => 800,
|
||||
'ancho' => 520,
|
||||
@ -430,7 +456,7 @@ class Test extends BaseController
|
||||
{
|
||||
$uso = 'interior';
|
||||
$tipo = 'negro';
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => 200,
|
||||
'tirada' => 500,
|
||||
'merma' => 10,
|
||||
@ -482,7 +508,7 @@ class Test extends BaseController
|
||||
echo '<pre>';
|
||||
$uso = 'cubierta';
|
||||
$tipo = 'color';
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => 200,
|
||||
'tirada' => 500,
|
||||
'merma' => 10,
|
||||
@ -542,7 +568,7 @@ class Test extends BaseController
|
||||
|
||||
|
||||
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => 240,
|
||||
'tirada' => 100,
|
||||
'merma' => 10,
|
||||
@ -552,10 +578,10 @@ class Test extends BaseController
|
||||
'isCosido' => true,
|
||||
);
|
||||
|
||||
$parametrosRotativa = (object)array(
|
||||
$parametrosRotativa = (object) array(
|
||||
'a_favor_fibra' => 0,
|
||||
'bnPages' => 240,
|
||||
'colorPages' => 0,
|
||||
'bnPages' => 240,
|
||||
'colorPages' => 0,
|
||||
'rotativa_gota_negro' => 0,
|
||||
'rotativa_gota_color' => 0,
|
||||
);
|
||||
@ -587,12 +613,12 @@ class Test extends BaseController
|
||||
var_dump($datosTipologias);
|
||||
echo '</pre>';
|
||||
|
||||
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
||||
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
||||
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
|
||||
$parametrosRotativa->rotativa_cyan = $datosTipologias[0]->cyan;
|
||||
$parametrosRotativa->rotativa_magenta = $datosTipologias[0]->magenta;
|
||||
$parametrosRotativa->rotativa_amarillo = $datosTipologias[0]->amarillo;
|
||||
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
||||
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
||||
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
|
||||
$parametrosRotativa->rotativa_cyan = $datosTipologias[0]->cyan;
|
||||
$parametrosRotativa->rotativa_magenta = $datosTipologias[0]->magenta;
|
||||
$parametrosRotativa->rotativa_amarillo = $datosTipologias[0]->amarillo;
|
||||
|
||||
echo '-------------------------------';
|
||||
$maquinas = $maquina_model->getMaquinaImpresionForPresupuesto(
|
||||
@ -624,7 +650,7 @@ class Test extends BaseController
|
||||
$uso = 'cubierta';
|
||||
$tipo = 'color';
|
||||
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => 240,
|
||||
'tirada' => 100,
|
||||
'merma' => 10,
|
||||
@ -714,7 +740,7 @@ class Test extends BaseController
|
||||
$uso = 'sobrecubierta';
|
||||
$tipo = 'colorhq';
|
||||
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => 240,
|
||||
'tirada' => 100,
|
||||
'merma' => 10,
|
||||
|
||||
@ -4,7 +4,7 @@ namespace App\Entities\Catalogo;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
use App\Models\Configuracion\PapelGenericoModel;
|
||||
|
||||
use App\Models\Tarifas\Acabados\ServicioAcabadoModel;
|
||||
class CatalogoLibroEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
@ -32,6 +32,7 @@ class CatalogoLibroEntity extends Entity
|
||||
'num_ilustr_color' => 0,
|
||||
'num_ilustr_bn' => 0,
|
||||
'coleccion' => '',
|
||||
'isk' => null,
|
||||
'isbn' => null,
|
||||
'ean' => null,
|
||||
'editorial' => '',
|
||||
@ -143,4 +144,24 @@ class CatalogoLibroEntity extends Entity
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->sobrecubierta_papel_id);
|
||||
return $papel?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getCubiertaAcabadoName()
|
||||
{
|
||||
if (!$this->cubierta_acabado_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$servicioAcabado = model(ServicioAcabadoModel::class)->asObject()->find($this->cubierta_acabado_id);
|
||||
return $servicioAcabado?->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getSobrecubiertaAcabadoName()
|
||||
{
|
||||
if (!$this->sobrecubierta_acabado_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$servicioAcabado = model(ServicioAcabadoModel::class)->asObject()->find($this->sobrecubierta_acabado_id);
|
||||
return $servicioAcabado?->nombre ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
10
ci4/app/Entities/Catalogo/IdentificadorIsk.php
Normal file
10
ci4/app/Entities/Catalogo/IdentificadorIsk.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Catalogo;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class IdentificadorIsk extends Entity
|
||||
{
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
}
|
||||
@ -39,6 +39,7 @@ class CatalogoLibroModel extends Model
|
||||
'num_ilustr_color',
|
||||
'num_ilustr_bn',
|
||||
'coleccion',
|
||||
'isk',
|
||||
'isbn',
|
||||
'ean',
|
||||
'editorial',
|
||||
|
||||
79
ci4/app/Models/Catalogo/IdentificadorIskModel.php
Normal file
79
ci4/app/Models/Catalogo/IdentificadorIskModel.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Catalogo;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use RuntimeException;
|
||||
|
||||
class IdentificadorIskModel extends Model
|
||||
{
|
||||
protected $table = 'identificadores_isk';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = \App\Entities\Catalogo\IdentificadorIsk::class;
|
||||
protected $useSoftDeletes = false; // No soft delete
|
||||
protected $useTimestamps = true;
|
||||
protected $allowedFields = ['isk'];
|
||||
|
||||
protected $beforeInsert = ['agregarIsk'];
|
||||
|
||||
/**
|
||||
* Crea un nuevo registro con un ISK único y lo devuelve.
|
||||
*/
|
||||
public function newIsk(string $contexto = 'libro'): string
|
||||
{
|
||||
$isk = $this->generarIskUnico($contexto);
|
||||
$this->insert(['isk' => $isk]);
|
||||
|
||||
return $isk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un ISK único validado contra la base de datos.
|
||||
*/
|
||||
private function generarIskUnico(string $contexto): string
|
||||
{
|
||||
do {
|
||||
$isk = $this->generarIsk($contexto);
|
||||
} while ($this->where('isk', $isk)->countAllResults() > 0);
|
||||
|
||||
return $isk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formato legible de ISK, ejemplo: isk_libro_20250419_ab12c
|
||||
*/
|
||||
private function generarIsk(string $contexto): string
|
||||
{
|
||||
$fecha = date('Ymd');
|
||||
$random = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'), 0, 5);
|
||||
return "isk_{$contexto}_{$fecha}_{$random}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook para generar el ISK automáticamente al insertar.
|
||||
*/
|
||||
protected function agregarIsk(array $data): array
|
||||
{
|
||||
if (!isset($data['data']['isk']) || empty($data['data']['isk'])) {
|
||||
$data['data']['isk'] = $this->generarIskUnico('registro');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Bloqueo total de eliminaciones
|
||||
public function delete($id = null, bool $purge = false)
|
||||
{
|
||||
throw new RuntimeException('La eliminación de registros está deshabilitada.');
|
||||
}
|
||||
|
||||
public function deleteWhere($where)
|
||||
{
|
||||
throw new RuntimeException('La eliminación de registros está deshabilitada.');
|
||||
}
|
||||
|
||||
public function deleteBatch($where)
|
||||
{
|
||||
throw new RuntimeException('La eliminación de registros está deshabilitada.');
|
||||
}
|
||||
}
|
||||
@ -242,15 +242,11 @@
|
||||
<div class="col-md-12 col-lg-1 px-4">
|
||||
<select id="compCarasCubierta" name="comp_paginas_cubierta"
|
||||
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
|
||||
<option value="2">
|
||||
<p>
|
||||
<?= lang('Presupuestos.unaCara') ?>
|
||||
</p>
|
||||
<option value="2" <?= $catalogoLibrosEntity->cubierta_paginas == 2 ? 'selected' : '' ?>>
|
||||
<?= lang('Presupuestos.unaCara') ?>
|
||||
</option>
|
||||
<option value="4">
|
||||
<p>
|
||||
<?= lang('Presupuestos.dosCaras') ?>
|
||||
</p>
|
||||
<option value="4" <?= $catalogoLibrosEntity->cubierta_paginas == 4 ? 'selected' : '' ?>>
|
||||
<?= lang('Presupuestos.dosCaras') ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -273,8 +269,19 @@
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4"></div>
|
||||
<div class="col-md-12 col-lg-2 px-4"></div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<input type="text" id="compSolapasCubierta" name="comp_solapas_cubierta" placeholder="0"
|
||||
maxLength="5" class="form-control comp_cubierta_items"
|
||||
value="<?= old('cubierta_solapas_ancho', $catalogoLibrosEntity->cubierta_solapas_ancho) ?>">
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<select id="compAcabadoCubierta" name="comp_acabado_cubierta"
|
||||
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
|
||||
<option value="<?= $catalogoLibrosEntity->cubierta_acabado_id ?>" selected>
|
||||
<?= $catalogoLibrosEntity->cubiertaAcabadoName ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<hr class="my-1">
|
||||
</div>
|
||||
@ -290,12 +297,12 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-1 px-4">
|
||||
<select id="compSobrecubierta" name="comp_sobrecubierta"
|
||||
class="form-control select2bs2 comp_sobrecubierta_items" style="width: 100%;">
|
||||
<option value="0">
|
||||
<select id="compSobrecubierta" name="comp_sobrecubierta" class="form-control select2bs2"
|
||||
style="width: 100%;">
|
||||
<option value="0" <?= $catalogoLibrosEntity->sobrecubierta_paginas != 1 ? 'selected' : '' ?>>
|
||||
<?= lang('Presupuestos.no') ?>
|
||||
</option>
|
||||
<option value="1">
|
||||
<option value="1" <?= $catalogoLibrosEntity->sobrecubierta_paginas == 1 ? 'selected' : '' ?>>
|
||||
<?= lang('Presupuestos.si') ?>
|
||||
</option>
|
||||
</select>
|
||||
@ -319,8 +326,19 @@
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4"></div>
|
||||
<div class="col-md-12 col-lg-2 px-4"></div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<input disabled type="text" id="compSolapasSobrecubierta" name="comp_solapas_sobrecubierta"
|
||||
placeholder="0" maxLength="5" class="form-control comp_sobrecubierta_items"
|
||||
value="<?= old('cubierta_solapas_ancho', $catalogoLibrosEntity->sobrecubierta_solapas_ancho) ?>">
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<select disabled id="compAcabadoSobrecubierta" name="comp_acabado_sobrecubierta"
|
||||
class="form-control select2bs2 comp_sobrecubierta_items" style="width: 100%;">
|
||||
<option value="<?= $catalogoLibrosEntity->sobrecubierta_acabado_id ?>" selected>
|
||||
<?= $catalogoLibrosEntity->sobrecubiertaAcabadoName ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<hr class="my-1">
|
||||
</div>
|
||||
@ -338,105 +356,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Configuración física -->
|
||||
<div class="table-responsive mb-4">
|
||||
<table class="table table-bordered align-middle text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nº Páginas</th>
|
||||
<th>Papel</th>
|
||||
<th>Gramaje</th>
|
||||
<th>Solapa</th>
|
||||
<th>Plastificado</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Interior B/N -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="number" name="negro_paginas" class="form-control"
|
||||
value="<?= old('negro_paginas', $catalogoLibrosEntity->negro_paginas) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="negro_papel" class="form-control"
|
||||
value="<?= old('negro_papel', $catalogoLibrosEntity->negro_papel) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" step="0.01" name="negro_gramaje" class="form-control"
|
||||
value="<?= old('negro_gramaje', $catalogoLibrosEntity->negro_gramaje) ?>">
|
||||
</td>
|
||||
<td>—</td>
|
||||
<td>—</td>
|
||||
</tr>
|
||||
|
||||
<!-- Interior Color -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="number" name="color_paginas" class="form-control"
|
||||
value="<?= old('color_paginas', $catalogoLibrosEntity->color_paginas) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="color_papel" class="form-control"
|
||||
value="<?= old('color_papel', $catalogoLibrosEntity->color_papel) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" step="0.01" name="color_gramaje" class="form-control"
|
||||
value="<?= old('color_gramaje', $catalogoLibrosEntity->color_gramaje) ?>">
|
||||
</td>
|
||||
<td>—</td>
|
||||
<td>—</td>
|
||||
</tr>
|
||||
|
||||
<!-- Portada -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="number" name="portada_paginas" class="form-control"
|
||||
value="<?= old('portada_paginas', $catalogoLibrosEntity->portada_paginas) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="portada_papel" class="form-control"
|
||||
value="<?= old('portada_papel', $catalogoLibrosEntity->portada_papel) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" step="0.01" name="portada_gramaje" class="form-control"
|
||||
value="<?= old('portada_gramaje', $catalogoLibrosEntity->portada_gramaje) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" step="0.01" name="solapas_ancho" class="form-control"
|
||||
value="<?= old('solapas_ancho', $catalogoLibrosEntity->solapas_ancho) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="portada_acabado" class="form-control"
|
||||
value="<?= old('portada_acabado', $catalogoLibrosEntity->portada_acabado) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Cubierta -->
|
||||
<tr>
|
||||
<td>
|
||||
<input type="number" name="cubierta_paginas" class="form-control"
|
||||
value="<?= old('cubierta_paginas', $catalogoLibrosEntity->cubierta_paginas) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="cubierta_papel" class="form-control"
|
||||
value="<?= old('cubierta_papel', $catalogoLibrosEntity->cubierta_papel) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" step="0.01" name="cubierta_gramaje" class="form-control"
|
||||
value="<?= old('cubierta_gramaje', $catalogoLibrosEntity->cubierta_gramaje) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" step="0.01" name="cubiertas_ancho" class="form-control"
|
||||
value="<?= old('cubiertas_ancho', $catalogoLibrosEntity->cubiertas_ancho) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="cubierta_acabado" class="form-control"
|
||||
value="<?= old('cubierta_acabado', $catalogoLibrosEntity->cubierta_acabado) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -71,6 +71,12 @@
|
||||
value="<?= old('sello', $catalogoLibrosEntity->sello) ?>" maxlength="255">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="isk" class="form-label">Identificador ISK</label>
|
||||
<input type="text" id="isk" name="isk" class="form-control"
|
||||
value="<?= old('isk', $catalogoLibrosEntity->isk) ?>" maxlength="64">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="isbn" class="form-label">ISBN</label>
|
||||
<input type="text" id="isbn" name="isbn" class="form-control"
|
||||
@ -83,7 +89,7 @@
|
||||
value="<?= old('num_edic', $catalogoLibrosEntity->num_edic ?? 1) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="ean" class="form-label">EAN</label>
|
||||
<input type="text" id="ean" name="ean" class="form-control" readonly
|
||||
style="background: #E8E8E8;" value="<?= old('ean', $catalogoLibrosEntity->ean) ?>">
|
||||
|
||||
@ -10,9 +10,10 @@ class Catalogo {
|
||||
|
||||
this.cliente = new ClassSelect($("#clienteId"), '/catalogo/libros/clientlist', "Seleccione un cliente");
|
||||
this.tipo_impresion = $("#tipoImpresion");
|
||||
this.caras_cubierta = $("#compCarasCubierta");
|
||||
|
||||
this.encuadernacion = new ClassSelect($("#encuadernacion"), '/importador/getencuadernacion', "Seleccione una encuadernación");
|
||||
|
||||
|
||||
this.compPapelNegro = new ClassSelect($("#compPapelNegro"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
|
||||
@ -91,10 +92,10 @@ class Catalogo {
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
this.compSobrecubierta = new ClassSelect($("#compPapelSobrecubierta"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
this.compPapelSobrecubierta = new ClassSelect($("#compPapelSobrecubierta"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => $('#tirada').val(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#compSolapasSobrecubierta').val(),
|
||||
@ -105,8 +106,8 @@ class Catalogo {
|
||||
this.compGramajeSobrecubierta = new ClassSelect($('#compGramajeSobrecubierta'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.compPapelCubierta.getVal(),
|
||||
tirada: () => $('#tirada').val(),
|
||||
papel_generico: () => this.compPapelSobrecubierta.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#compSolapasSobrecubierta').val(),
|
||||
@ -114,7 +115,7 @@ class Catalogo {
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
|
||||
this.acabadoCubierta = new ClassSelect($("#compAcabadoCubiertaSelected"),
|
||||
this.acabadoCubierta = new ClassSelect($("#compAcabadoCubierta"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
@ -122,7 +123,7 @@ class Catalogo {
|
||||
"cubierta": 1
|
||||
}
|
||||
);
|
||||
this.acabadosSobrecubierta = new ClassSelect($("#compAcabadoSobrecubiertaSelected"),
|
||||
this.acabadosSobrecubierta = new ClassSelect($("#compAcabadoSobrecubierta"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
@ -131,7 +132,8 @@ class Catalogo {
|
||||
}
|
||||
);
|
||||
|
||||
this.openBtn = $('#openOld');
|
||||
this.sobrecubiertaItems = $('.comp_sobrecubierta_items');
|
||||
this.compPaginasSobrecubierta = $('#compSobrecubierta');
|
||||
|
||||
}
|
||||
|
||||
@ -146,6 +148,9 @@ class Catalogo {
|
||||
|
||||
this.cliente.init();
|
||||
this.tipo_impresion.select2();
|
||||
this.caras_cubierta.select2();
|
||||
this.compPaginasSobrecubierta .select2();
|
||||
|
||||
this.encuadernacion.init();
|
||||
|
||||
this.compPapelNegro.init();
|
||||
@ -154,12 +159,15 @@ class Catalogo {
|
||||
this.compGramajeColor.init();
|
||||
this.compPapelCubierta.init();
|
||||
this.compGramajeCubierta.init();
|
||||
this.compSobrecubierta.init();
|
||||
this.compPapelSobrecubierta.init();
|
||||
this.compGramajeSobrecubierta.init();
|
||||
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadosSobrecubierta.init();
|
||||
|
||||
|
||||
// Al cargar la página
|
||||
this.toggleSobrecubiertaFields();
|
||||
|
||||
this.compPapelNegro.item.on('select2:select', function () {
|
||||
self.compGramajeNegro.empty();
|
||||
@ -173,6 +181,9 @@ class Catalogo {
|
||||
// Inicializacino de eventos
|
||||
this.tipo_impresion.on("change", this.updateOpcionesComparador.bind(this));
|
||||
|
||||
// Al cambiar el selector de paginas de sobrecubierta
|
||||
this.compPaginasSobrecubierta.on('change', this.toggleSobrecubiertaFields.bind(this));
|
||||
|
||||
this.updateOpcionesComparador();
|
||||
|
||||
$(document).on('change', '.warning-change', function () {
|
||||
@ -181,7 +192,7 @@ class Catalogo {
|
||||
select2Container.addClass('bg-warning');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateOpcionesComparador() {
|
||||
|
||||
@ -241,144 +252,22 @@ class Catalogo {
|
||||
}
|
||||
|
||||
|
||||
|
||||
getDimensionLibro() {
|
||||
let ancho = $('#ancho').val();
|
||||
let alto = $('#alto').val();;
|
||||
return { ancho, alto };
|
||||
}
|
||||
|
||||
|
||||
fillInitialData(data) {
|
||||
|
||||
$('#paginas').val(data.datosGenerales.paginas);
|
||||
$('#tirada').val(data.datosGenerales.tirada);
|
||||
if (data.datosGenerales.papel_formato_personalizado) {
|
||||
$('#papelFormatoPersonalizado').prop('checked', true);
|
||||
$('#tamanio').addClass('d-none');
|
||||
$('#formatoPersonalizado').removeClass('d-none');
|
||||
$('#papelFormatoAncho').val(data.datosGenerales.papel_formato_ancho);
|
||||
$('#papelFormatoAlto').val(data.datosGenerales.papel_formato_alto);
|
||||
}
|
||||
else {
|
||||
$('#tamanio').removeClass('d-none');
|
||||
$('#formatoPersonalizado').addClass('d-none');
|
||||
$('#papelFormatoPersonalizado').prop('checked', false);
|
||||
$('#tamanio').append('<option value="' + data.datosGenerales.papel_formato_id + '" selected>' + data.datosGenerales.papel_formato_texto + '</option>');
|
||||
$('#tamanio').val(data.datosGenerales.papel_formato_id).trigger('change');
|
||||
}
|
||||
|
||||
if (data.encuadernacion) {
|
||||
$('#encuadernacion_old').val(data.encuadernacion.encuadernacionOld);
|
||||
// check if data.encuadernacion.encuadernacion exists and is not empty
|
||||
if (data.encuadernacion.encuadernacion) {
|
||||
this.encuadernacion.setOption(data.encuadernacion.encuadernacion.id, data.encuadernacion.encuadernacion.encuadernacion);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.lineas) {
|
||||
if (data.lineas.isHq) {
|
||||
$('#isHq').val(data.lineas.isHq);
|
||||
}
|
||||
else {
|
||||
$('#isHq').val(0);
|
||||
}
|
||||
|
||||
if (data.lineas.bn && data.lineas.bn.paginas) {
|
||||
$('#compPaginasNegro').val(data.lineas.bn.paginas);
|
||||
$('#compPapelNegroOrigen').val(data.lineas.bn.papel_nombre);
|
||||
this.compGramajeNegro.setOption(parseFloat(data.lineas.bn.gramaje).toFixed(0), parseFloat(data.lineas.bn.gramaje).toFixed(0));
|
||||
this.compPapelNegro.item.prop('disabled', false);
|
||||
this.compPapelNegro.setOption(data.lineas.bn.new_papel_id, data.lineas.bn.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compPaginasNegro').val(0);
|
||||
$('#compPapelNegroOrigen').val("");
|
||||
this.compGramajeNegro.empty();
|
||||
this.compPapelNegro.empty();
|
||||
this.compPapelNegro.item.prop('disabled', true);
|
||||
this.compGramajeNegro.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.lineas.color && data.lineas.color.paginas) {
|
||||
$('#compPaginasColor').val(data.lineas.color.paginas);
|
||||
$('#compPapelColorOrigen').val(data.lineas.color.papel_nombre);
|
||||
this.compGramajeColor.setOption(parseFloat(data.lineas.color.gramaje).toFixed(0), parseFloat(data.lineas.color.gramaje).toFixed(0));
|
||||
this.compPapelColor.item.prop('disabled', false);
|
||||
this.compPapelColor.setOption(data.lineas.color.new_papel_id, data.lineas.color.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compPaginasColor').val(0);
|
||||
$('#compPapelColorOrigen').val("");
|
||||
this.compGramajeColor.empty();
|
||||
this.compPapelColor.empty();
|
||||
this.compPapelColor.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.lineas.cubierta && data.lineas.cubierta.paginas) {
|
||||
$('#compPaginasCubierta').val(data.lineas.cubierta.paginas);
|
||||
$('#compPapelCubiertaOrigen').val(data.lineas.cubierta.papel_nombre);
|
||||
this.compGramajeCubierta.setOption(parseFloat(data.lineas.cubierta.gramaje).toFixed(0), parseFloat(data.lineas.cubierta.gramaje).toFixed(0));
|
||||
$('#compSolapasCubierta').val(parseFloat(data.lineas.cubierta.solapas).toFixed(0));
|
||||
this.compPapelCubierta.item.prop('disabled', false);
|
||||
this.compPapelCubierta.setOption(data.lineas.cubierta.new_papel_id, data.lineas.cubierta.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compPaginasCubierta').val(0);
|
||||
$('#compPapelCubiertaOrigen').val("");
|
||||
this.compGramajeCubierta.empty();
|
||||
$('#compSolapasCubierta').val("");
|
||||
this.compPapelCubierta.empty();
|
||||
this.compPapelCubierta.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.lineas.sobrecubierta && data.lineas.sobrecubierta.paginas) {
|
||||
$('#compSobrecubierta').val(1);
|
||||
$('#compPapelSobrecubiertaOrigen').val(data.lineas.sobrecubierta.papel_nombre);
|
||||
this.compGramajeSobrecubierta.setOption(parseFloat(data.lineas.sobrecubierta.gramaje).toFixed(0), parseFloat(data.lineas.sobrecubierta.gramaje).toFixed(0));
|
||||
$('#compSolapasSobrecubierta').val(parseFloat(data.lineas.sobrecubierta.solapas).toFixed(0));
|
||||
this.compSobrecubierta.item.prop('disabled', false);
|
||||
this.compSobrecubierta.setOption(data.lineas.sobrecubierta.new_papel_id, data.lineas.sobrecubierta.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compSobrecubierta').val(0);
|
||||
$('#compPapelSobrecubiertaOrigen').val("");
|
||||
this.compGramajeSobrecubierta.empty();
|
||||
$('#compSolapasSobrecubierta').val("");
|
||||
this.compSobrecubierta.empty();
|
||||
this.compSobrecubierta.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.acabados) {
|
||||
if (data.acabados.cubierta && data.acabados.cubierta.acabadoOld) {
|
||||
$('#compAcabadoCubiertaOrigen').val(data.acabados.cubierta.acabadoOld);
|
||||
this.acabadoCubierta.setOption(data.acabados.cubierta.acabado.id, data.acabados.cubierta.acabado.name);
|
||||
this.acabadoCubierta.item.prop('disabled', false);
|
||||
}
|
||||
else {
|
||||
$('#compAcabadoCubiertaOrigen').val("");
|
||||
this.acabadoCubierta.empty();
|
||||
this.acabadoCubierta.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.acabados.sobrecubierta && data.acabados.sobrecubierta.acabadoOld) {
|
||||
$('#compAcabadoSobrecubiertaOrigen').val(data.acabados.sobrecubierta.acabadoOld);
|
||||
this.acabadosSobrecubierta.setOption(data.acabados.sobrecubierta.acabado.id, data.acabados.sobrecubierta.acabado.name);
|
||||
this.acabadosSobrecubierta.item.prop('disabled', false);
|
||||
}
|
||||
else {
|
||||
$('#compAcabadoSobrecubiertaOrigen').val("");
|
||||
this.acabadosSobrecubierta.empty();
|
||||
this.acabadosSobrecubierta.item.prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this.makeImport.prop('disabled', false);
|
||||
toggleSobrecubiertaFields() {
|
||||
if (this.compPaginasSobrecubierta.val() === '1') {
|
||||
this.sobrecubiertaItems.prop('disabled', false).trigger('change.select2');
|
||||
} else {
|
||||
this.sobrecubiertaItems.prop('disabled', true).trigger('change.select2');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
let catalogo = new Catalogo();
|
||||
|
||||
Reference in New Issue
Block a user