mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'feat/catalogo' into 'main'
Feat/catalogo See merge request jjimenez/safekat!727
This commit is contained in:
29
ci4/app/Config/Routes/CatalogoRoutes.php
Normal file
29
ci4/app/Config/Routes/CatalogoRoutes.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\Router\RouteCollection;
|
||||
|
||||
/** @var RouteCollection $routes */
|
||||
|
||||
/* Rutas para tarifas */
|
||||
$routes->group('catalogo', ['namespace' => 'App\Controllers\Catalogo'], function ($routes) {
|
||||
/* Libros */
|
||||
$routes->group('libros', ['namespace' => 'App\Controllers\Catalogo'], function ($routes) {
|
||||
/**======================
|
||||
* CRUD
|
||||
*========================**/
|
||||
$routes->get('', 'CatalogoLibros::index', ['as' => 'CatalogoLibrosList']);
|
||||
$routes->get('gettarifas', 'CatalogoLibros::getSelect2');
|
||||
$routes->match(['get', 'post'], 'add', 'CatalogoLibros::add', ['as' => 'CatalogoLibrosAdd']);
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'CatalogoLibros::edit/$1', ['as' => 'CatalogoLibrosEdit']);
|
||||
$routes->get('delete/(:num)', 'CatalogoLibros::delete/$1', ['as' => 'CatalogoLibrosDelete']);
|
||||
$routes->get('datatable', 'CatalogoLibros::datatable', ['as' => 'CatalogoLibrosDT']);
|
||||
|
||||
|
||||
/**======================
|
||||
* AJAX
|
||||
*========================**/
|
||||
$routes->get('clientlist', 'CatalogoLibros::getClientList', ['as' => 'clientList']);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
239
ci4/app/Controllers/Catalogo/CatalogoLibros.php
Normal file
239
ci4/app/Controllers/Catalogo/CatalogoLibros.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
namespace App\Controllers\Catalogo;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Entities\Catalogo\CatalogoLibroEntity;
|
||||
use App\Models\Catalogo\CatalogoLibroModel;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
|
||||
class CatalogoLibros extends BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = CatalogoLibroModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Catalogo';
|
||||
protected static $singularObjectNameCc = 'CatalogoLibros';
|
||||
protected static $pluralObjectName = 'Catalogos';
|
||||
protected static $pluralObjectNameCc = 'catalogos';
|
||||
|
||||
protected static $controllerSlug = 'catalogo';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/catalogo/';
|
||||
|
||||
protected $indexRoute = 'CatalogoLibrosList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Catalogo.listingPage');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_catalogo"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_catalogo_libros"), 'route' => route_to('CatalogoLibrosList'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Catalogo.catalogo')]),
|
||||
'catalogoLibrosEntity' => new CatalogoLibroEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewCatalogoLibrosList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$sanitizedData['user_created_id'] = auth()->user()->id;
|
||||
unset($sanitizedData['isk']);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()):
|
||||
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['catalogoLibrosEntity'] = isset($sanitizedData) ? new CatalogoLibroEntity($sanitizedData) : new CatalogoLibroEntity();
|
||||
$this->viewData['formAction'] = route_to('CatalogoLibrosAdd');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Catalogo.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$catalogoLibrosEntity = $this->model->find($id);
|
||||
|
||||
if ($catalogoLibrosEntity == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Catalogo.pais')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
unset($sanitizedData['isk']);
|
||||
$sanitizedData['user_update_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Catalogo.catalogo'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$catalogoLibrosEntity->fill($sanitizedData);
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
|
||||
if ($noException && $successfulResult):
|
||||
$id = $catalogoLibrosEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
|
||||
$this->viewData['catalogoLibrosEntity'] = $catalogoLibrosEntity;
|
||||
$this->viewData['formAction'] = route_to('CatalogoLibrosEdit', $id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Catalogo.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$reqData = $this->request->getGet();
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
|
||||
$q = $this->model->getDatatableQuery()->limit($length, $start);
|
||||
|
||||
$result = DataTable::of($q)
|
||||
->edit(
|
||||
"portada",
|
||||
function ($row, $meta) {
|
||||
if (is_null($row->cubierta_archivo)) {
|
||||
return '<img class="img-thumbnail" src="' . $row->portada . '" alt="Portada" style="max-height: 80px;">';
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
)
|
||||
->add("actionBtns", callback: function ($q) {
|
||||
$actions = '';
|
||||
if (auth()->user()->can('catalogo.edit')) {
|
||||
$actions .= '
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
|
||||
</div>';
|
||||
}
|
||||
if (auth()->user()->can('catalogo.delete')) {
|
||||
$actions .= '
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="' . $q->id . '"></i></a>
|
||||
</div>';
|
||||
}
|
||||
return $actions;
|
||||
});
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* IMN */
|
||||
public function getClientList()
|
||||
{
|
||||
$search = $this->request->getGet("q") ?? "";
|
||||
$data = (new ClienteModel())->getIdName($search);
|
||||
return $this->response->setJSON($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
ci4/app/Controllers/Catalogo/notas.txt
Normal file
2
ci4/app/Controllers/Catalogo/notas.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Portada Id Cliente Título Edición Autor Archivo ISBN EAN Páginas Acciones
|
||||
Lo que hay que listar
|
||||
@ -56,10 +56,33 @@ class Intranet extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
function orden_trabajo($ot_id,$resource_name)
|
||||
function orden_trabajo($ot_id, $resource_name)
|
||||
{
|
||||
helper('file');
|
||||
$resource_path = WRITEPATH . 'uploads/orden_trabajo/'.$ot_id. '/' . $resource_name;
|
||||
$resource_path = WRITEPATH . 'uploads/orden_trabajo/' . $ot_id . '/' . $resource_name;
|
||||
if (file_exists($resource_path)) {
|
||||
// Get the mime type of the file
|
||||
$mime_type = mime_content_type($resource_path);
|
||||
|
||||
// Get an instance of the Response class
|
||||
$response = service('response');
|
||||
|
||||
// Set the content type
|
||||
$response->setContentType($mime_type);
|
||||
|
||||
// Set the output
|
||||
$response->setBody(file_get_contents($resource_path));
|
||||
|
||||
// Send the response to the browser
|
||||
$response->send();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function catalogo($catalogo_id, $resource_name)
|
||||
{
|
||||
helper('file');
|
||||
$resource_path = WRITEPATH . 'uploads/catalogo/' . $catalogo_id . '/' . $resource_name;
|
||||
if (file_exists($resource_path)) {
|
||||
// Get the mime type of the file
|
||||
$mime_type = mime_content_type($resource_path);
|
||||
|
||||
@ -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,33 +23,48 @@ class Test extends BaseController
|
||||
{
|
||||
}
|
||||
|
||||
public function echo(){
|
||||
public function echo()
|
||||
{
|
||||
|
||||
echo "echo";
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
private 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,
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateIdentificadoresIskTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => 10,
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'isk' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 64,
|
||||
'null' => false,
|
||||
],
|
||||
'created_at' => [
|
||||
'type' => 'DATETIME',
|
||||
'null' => true,
|
||||
'default' => 'current_timestamp()',
|
||||
],
|
||||
'updated_at' => [
|
||||
'type' => 'DATETIME',
|
||||
'null' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true); // primary key
|
||||
$this->forge->addUniqueKey('isk'); // unique index
|
||||
|
||||
$this->forge->createTable('identificadores_isk', true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('identificadores_isk', true);
|
||||
}
|
||||
}
|
||||
@ -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
265
ci4/app/Entities/Catalogo/CatalogoLibroEntity.php
Normal file
265
ci4/app/Entities/Catalogo/CatalogoLibroEntity.php
Normal file
@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Catalogo;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
use App\Models\Configuracion\PapelGenericoModel;
|
||||
use App\Models\Configuracion\TipoPresupuestoModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Models\Tarifas\Acabados\ServicioAcabadoModel;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
class CatalogoLibroEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
'cliente_id' => null,
|
||||
'proveedor_id' => null,
|
||||
'user_created_id' => 1,
|
||||
'user_update_id' => 1,
|
||||
'cubierta_archivo' => null,
|
||||
'cubierta_url' => null,
|
||||
'ancho' => 0.00,
|
||||
'alto' => 0.00,
|
||||
'peso' => null,
|
||||
'titulo' => '',
|
||||
'autor' => '',
|
||||
'autor_entidad' => null,
|
||||
'traductor' => null,
|
||||
'ilustrador' => null,
|
||||
'idioma' => 'spa',
|
||||
'num_edic' => 1,
|
||||
'fecha_disponibilidad' => null,
|
||||
'fecha_public' => null,
|
||||
'num_fotos' => 0,
|
||||
'num_ilustr' => 0,
|
||||
'num_ilustr_color' => 0,
|
||||
'num_ilustr_bn' => 0,
|
||||
'coleccion' => '',
|
||||
'isk' => null,
|
||||
'isbn' => null,
|
||||
'ean' => null,
|
||||
'editorial' => '',
|
||||
'resumen' => null,
|
||||
'resumen_breve' => null,
|
||||
'sello' => null,
|
||||
'paginas' => 0,
|
||||
'tipo_impresion' => null,
|
||||
'solapas_ancho' => 0.00,
|
||||
'cubiertas_ancho' => 0.00,
|
||||
'comentarios' => '',
|
||||
'negro_paginas' => null,
|
||||
'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,
|
||||
'sobrecubierta_pod_papel_id' => null,
|
||||
'sobrecubierta_pod_gramaje' => null,
|
||||
'encuardenacion_id' => 'null',
|
||||
'ubicacion' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
];
|
||||
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'fecha_disponibilidad', 'fecha_public'];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'int',
|
||||
'cliente_id' => '?int',
|
||||
'proveedor_id' => '?int',
|
||||
'user_created_id' => 'int',
|
||||
'user_update_id' => 'int',
|
||||
'ancho' => 'float',
|
||||
'alto' => 'float',
|
||||
'peso' => '?float',
|
||||
'num_edic' => '?int',
|
||||
'num_fotos' => '?int',
|
||||
'num_ilustr' => '?int',
|
||||
'num_ilustr_color' => '?int',
|
||||
'num_ilustr_bn' => '?int',
|
||||
'paginas' => 'int',
|
||||
'solapas_ancho' => 'float',
|
||||
'cubiertas_ancho' => 'float',
|
||||
'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()
|
||||
{
|
||||
if (!$this->cliente_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$cliente = model(ClienteModel::class)->find($this->cliente_id);
|
||||
return $cliente->nombre ?? null;
|
||||
}
|
||||
|
||||
public function getEncuadernacionName()
|
||||
{
|
||||
if (!$this->encuadernacion_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$enc = model(TipoPresupuestoModel::class)->find($this->encuadernacion_id);
|
||||
return $enc->encuadernacion ?? null;
|
||||
}
|
||||
|
||||
public function getCreatedUser()
|
||||
{
|
||||
if (!$this->user_created_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return model(UserModel::class)->getFullName($this->user_created_id);
|
||||
}
|
||||
|
||||
public function getUpdatedUser()
|
||||
{
|
||||
if (!$this->user_update_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return model(UserModel::class)->getFullName($this->user_update_id);
|
||||
}
|
||||
|
||||
|
||||
public function getNegroPapelName()
|
||||
{
|
||||
if (!$this->negro_papel_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->negro_papel_id);
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->color_papel_id);
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->cubierta_papel_id);
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$papel = model(PapelGenericoModel::class)->asObject()->find($this->sobrecubierta_papel_id);
|
||||
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) {
|
||||
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'];
|
||||
}
|
||||
75
ci4/app/Language/es/Catalogo.php
Normal file
75
ci4/app/Language/es/Catalogo.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'moduleTitle' => 'Catálogo de libros',
|
||||
'listingPage' => 'Listado de libros',
|
||||
'catalogo' => 'catálogo',
|
||||
'libro' => 'libro',
|
||||
'id' => 'ID',
|
||||
'clienteId' => 'Cliente',
|
||||
'cliente' => 'Cliente',
|
||||
'proveedorId' => 'Proveedor',
|
||||
'userCreatedId' => 'Usuario Creador',
|
||||
'userUpdateId' => 'Usuario Actualizador',
|
||||
'cubiertaArchivo' => 'Archivo de Cubierta',
|
||||
'cubiertaUrl' => 'URL de Cubierta',
|
||||
'portada' => 'Portada',
|
||||
'ancho' => 'Ancho',
|
||||
'alto' => 'Alto',
|
||||
'peso' => 'Peso',
|
||||
'titulo' => 'Título',
|
||||
'autor' => 'Autor',
|
||||
'autorEntidad' => 'Entidad del Autor',
|
||||
'traductor' => 'Traductor',
|
||||
'ilustrador' => 'Ilustrador',
|
||||
'idioma' => 'Idioma',
|
||||
'numEdic' => 'Número de Edición',
|
||||
'edicion' => 'Edición',
|
||||
'fechaDisponibilidad' => 'Fecha de Disponibilidad',
|
||||
'fechaPublic' => 'Fecha de Publicación',
|
||||
'numFotos' => 'Número de Fotos',
|
||||
'numIlustr' => 'Número de Ilustraciones',
|
||||
'numIlustrColor' => 'Ilustraciones a Color',
|
||||
'numIlustrBn' => 'Ilustraciones en Blanco y Negro',
|
||||
'coleccion' => 'Colección',
|
||||
'isbn' => 'ISBN',
|
||||
'ean' => 'EAN',
|
||||
'editorial' => 'Editorial',
|
||||
'resumen' => 'Resumen',
|
||||
'resumenBreve' => 'Resumen Breve',
|
||||
'sello' => 'Sello',
|
||||
'paginas' => 'Páginas',
|
||||
'tipoImpresion' => 'Tipo de Impresión',
|
||||
'seleccionarTipoImpresion' => 'Seleccionar tipo de impresión',
|
||||
'solapasAncho' => 'Ancho de Solapas',
|
||||
'cubiertasAncho' => 'Ancho de Cubiertas',
|
||||
'comentarios' => 'Comentarios',
|
||||
'negroPaginas' => 'Páginas Negras',
|
||||
'negroPapel' => 'Papel Negro',
|
||||
'negroGramaje' => 'Gramaje Negro',
|
||||
'colorPaginas' => 'Páginas a Color',
|
||||
'colorPapel' => 'Papel a Color',
|
||||
'colorGramaje' => 'Gramaje Color',
|
||||
'portadaPaginas' => 'Páginas de Portada',
|
||||
'portadaPapel' => 'Papel de Portada',
|
||||
'portadaGramaje' => 'Gramaje Portada',
|
||||
'portadaAcabado' => 'Acabado Portada',
|
||||
'cubiertaPaginas' => 'Páginas de Cubierta',
|
||||
'cubiertaPapel' => 'Papel de Cubierta',
|
||||
'cubiertaGramaje' => 'Gramaje Cubierta',
|
||||
'cubiertaAcabado' => 'Acabado Cubierta',
|
||||
'encuardenacion' => 'Encuadernación',
|
||||
'ubicacion' => 'Ubicación',
|
||||
'createdAt' => 'Fecha de Creación',
|
||||
'updatedAt' => 'Fecha de Actualización',
|
||||
'deletedAt' => 'Fecha de Eliminación',
|
||||
|
||||
'catalogoLibro' => 'Libro',
|
||||
'catalogoLibroList' => 'Lista de Libros',
|
||||
'datosGenerales' => 'Datos generales del libro',
|
||||
'otrosDatosLibro' => 'Otros datos del libro',
|
||||
'configuracionLibro' => 'Configuración del libro',
|
||||
'ficherosLibro' => 'Ficheros',
|
||||
'created_by_at' => 'Creado:',
|
||||
'updated_by_at' => 'Actualizado:',
|
||||
];
|
||||
@ -23,9 +23,13 @@ return [
|
||||
'margen' => 'Margen',
|
||||
'interior' => 'Interior',
|
||||
'cubierta' => 'Cubierta',
|
||||
'cubierta_pod' => 'Cubierta (POD)',
|
||||
'sobrecubierta' => 'Sobrecubierta',
|
||||
'sobrecubierta_pod' => 'Sobrecubierta (POD)',
|
||||
'negro' => 'Negro',
|
||||
'negro_pod' => 'Negro (POD)',
|
||||
'color' => 'Color',
|
||||
'color_pod' => 'Color (POD)',
|
||||
'negrohq' => 'Negro HQ',
|
||||
'colorhq' => 'Color HQ',
|
||||
'bicolor' => 'Bicolor',
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -89,7 +89,11 @@ return [
|
||||
'colorPageInstructions' => 'Introduzca la posición de las páginas a color dentro del libro. Ej: 3,5,7 ó 4-10,20,155',
|
||||
'numeroPaginas' => 'Nº Páginas',
|
||||
'papel' => 'Papel',
|
||||
'papelPod' => 'Papel (POD)',
|
||||
'gramaje' => 'Gramaje',
|
||||
'gramajePod' => 'Gramaje (POD)',
|
||||
'solapas' => 'Solapas',
|
||||
'acabados' => 'Acabados',
|
||||
'opcionesPresupuesto' => 'Opciones presupuesto',
|
||||
'retractilado' => 'Retractilado individual',
|
||||
'retractilado5' => 'Retractilado de 5',
|
||||
|
||||
214
ci4/app/Models/Catalogo/CatalogoLibroModel.php
Normal file
214
ci4/app/Models/Catalogo/CatalogoLibroModel.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Catalogo;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Entities\Catalogo\CatalogoLibroEntity;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
|
||||
class CatalogoLibroModel extends Model
|
||||
{
|
||||
protected $table = 'catalogo_libros';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $returnType = CatalogoLibroEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
|
||||
protected $allowedFields = [
|
||||
'cliente_id',
|
||||
'proveedor_id',
|
||||
'cubierta_archivo',
|
||||
'ancho',
|
||||
'alto',
|
||||
'peso',
|
||||
'titulo',
|
||||
'autor',
|
||||
'autor_entidad',
|
||||
'traductor',
|
||||
'ilustrador',
|
||||
'idioma',
|
||||
'num_edic',
|
||||
'fecha_disponibilidad',
|
||||
'fecha_public',
|
||||
'num_fotos',
|
||||
'num_ilustr',
|
||||
'num_ilustr_color',
|
||||
'num_ilustr_bn',
|
||||
'coleccion',
|
||||
'isbn',
|
||||
'editorial',
|
||||
'resumen',
|
||||
'resumen_breve',
|
||||
'sello',
|
||||
'paginas',
|
||||
'tipo_impresion',
|
||||
'comentarios',
|
||||
'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',
|
||||
];
|
||||
|
||||
protected $useAutoIncrement = true;
|
||||
protected $protectFields = true;
|
||||
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Opcional: reglas de validación
|
||||
protected $validationRules = [
|
||||
'cliente_id' => 'required|is_natural_no_zero',
|
||||
'titulo' => 'required|string|min_length[2]|max_length[300]',
|
||||
'paginas' => 'required|integer|greater_than[0]',
|
||||
'ancho' => 'required|decimal|greater_than[0]',
|
||||
'alto' => 'required|decimal|greater_than[0]',
|
||||
'tipo_impresion' => 'required|in_list[negro,negrohq,color,colorhq]',
|
||||
'isbn' => 'required|regex_match[/^[\d-]+$/]',
|
||||
'encuadernacion_id' => 'required|is_natural_no_zero',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
protected $beforeInsert = ['asignarIsk', 'asignarEan', 'asignarCubiertaUrl'];
|
||||
protected $beforeUpdate = ['asignarEan', 'asignarCubiertaUrl'];
|
||||
|
||||
protected function asignarIsk(array $data): array
|
||||
{
|
||||
$data['data']['isk'] = model('App\Models\Catalogo\IdentificadorIskModel')->newIsk();
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function asignarEan(array $data): array
|
||||
{
|
||||
if (!empty($data['data']['isbn'])) {
|
||||
$ean = $this->generarEanDesdeIsbn($data['data']['isbn']);
|
||||
|
||||
if ($ean !== null) {
|
||||
$data['data']['ean'] = $ean;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function generarEanDesdeIsbn(string $isbn): ?string
|
||||
{
|
||||
// Elimina guiones o espacios y convierte a mayúsculas
|
||||
$isbn = preg_replace('/[^0-9X]/', '', strtoupper($isbn));
|
||||
|
||||
// Si ya es un ISBN-13 válido
|
||||
if (strlen($isbn) === 13 && preg_match('/^97[89][0-9]{10}$/', $isbn)) {
|
||||
return $isbn;
|
||||
}
|
||||
|
||||
// Si es un ISBN-10, lo convertimos a EAN-13
|
||||
if (strlen($isbn) === 10) {
|
||||
$isbnSinDigito = substr($isbn, 0, 9);
|
||||
$eanBase = '978' . $isbnSinDigito;
|
||||
$digitoControl = $this->calcularDigitoControlEan($eanBase);
|
||||
return $eanBase . $digitoControl;
|
||||
}
|
||||
|
||||
return null; // Formato inválido
|
||||
}
|
||||
|
||||
protected function asignarCubiertaUrl(array $data): array
|
||||
{
|
||||
// No sobreescribir si ya hay un archivo manual
|
||||
if (!empty($data['data']['cubierta_archivo'] ?? null)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Usamos el EAN generado
|
||||
$ean = $data['data']['ean'] ?? null;
|
||||
|
||||
if ($ean && preg_match('/^\d{13}$/', $ean)) {
|
||||
$ean0 = substr($ean, 0, 7);
|
||||
$ean12 = substr($ean, 0, 12);
|
||||
$data['data']['cubierta_url'] = "https://static.cegal.es/imagenes/marcadas/$ean0/$ean12.gif";
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function calcularDigitoControlEan(string $eanBase): int
|
||||
{
|
||||
$suma = 0;
|
||||
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
$digito = (int) $eanBase[$i];
|
||||
$suma += ($i % 2 === 0) ? $digito : $digito * 3;
|
||||
}
|
||||
|
||||
$modulo = $suma % 10;
|
||||
return ($modulo === 0) ? 0 : 10 - $modulo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getDatatableQuery()
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("
|
||||
t1.id AS id,
|
||||
t1.titulo AS titulo,
|
||||
t2.nombre AS cliente,
|
||||
t1.num_edic AS edicion,
|
||||
t1.autor AS autor,
|
||||
t1.isbn AS isbn,
|
||||
t1.ean AS ean,
|
||||
t1.paginas AS paginas,
|
||||
t1.cubierta_archivo AS cubierta_archivo,
|
||||
t1.cubierta_url AS portada
|
||||
")
|
||||
->join('clientes t2', 't1.cliente_id = t2.id')
|
||||
->where('t1.deleted_at', null);
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getClientList($search = "")
|
||||
{
|
||||
$clienteModel = new ClienteModel();
|
||||
|
||||
$query = $clienteModel->builder()
|
||||
->select('id, nombre as name') // O el campo que quieras usar como "name"
|
||||
->where('deleted_at', null);
|
||||
if ($search != "") {
|
||||
$query->groupStart()
|
||||
->orLike("nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
return $query->get()->getResultObject();
|
||||
}
|
||||
|
||||
}
|
||||
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.');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,146 @@
|
||||
<!-- File: app/Views/catalogo_configuracion_libro.php -->
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionConfiguracionLibro">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingConfiguracionLibro">
|
||||
<button class="accordion-button" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseConfiguracionLibro" aria-expanded="true"
|
||||
aria-controls="collapseConfiguracionLibro">
|
||||
<h5 class="mb-0"><?= lang('Catalogo.configuracionLibro') ?: 'Configuración del libro' ?></h5>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="collapseConfiguracionLibro" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#accordionConfiguracionLibro">
|
||||
<div class="accordion-body">
|
||||
|
||||
<?php
|
||||
// 1) TIPO DE IMPRESIÓN + ENCUADERNACIÓN
|
||||
$tipos = ['negro', 'negrohq', 'color', 'colorhq'];
|
||||
?>
|
||||
<div class="divider divider-dark text-start mb-1">
|
||||
<div class="divider-text">
|
||||
<h5><?= lang('Presupuestos.tipoImpresion') ?></h5>
|
||||
</div>
|
||||
</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 warning-change"
|
||||
style="width:100%" data-placeholder="<?= lang('Catalogo.seleccionarTipoImpresion') ?>">
|
||||
<option></option>
|
||||
<?php foreach ($tipos as $t): ?>
|
||||
<option value="<?= $t ?>" <?= $catalogoLibrosEntity->tipo_impresion === $t ? 'selected' : '' ?>>
|
||||
<?= lang("MaquinasTarifasImpresions.$t") ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-12">
|
||||
<select id="encuadernacion_id" name="encuadernacion_id"
|
||||
class="form-control select2bs2 warning-change" style="width:100%">
|
||||
<option value="<?= $catalogoLibrosEntity->encuadernacion_id ?>" selected>
|
||||
<?= esc($catalogoLibrosEntity->encuadernacionName) ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// 2) COLUMNAS Y ETIQUETAS COMPARTIDAS
|
||||
$cols = [2, 2, 2, 2, 2, 2];
|
||||
$labels = ['', 'numeroPaginas', 'papel', 'gramaje', 'solapas', 'acabados'];
|
||||
|
||||
// Función única para renderizar cualquier fila, con clase opcional
|
||||
$renderRow = function (array $cellsHtml, string $rowClass = '') use ($cols) {
|
||||
$classAttr = $rowClass ? " {$rowClass}-line" : '';
|
||||
echo "<div class=\"row{$classAttr} mb-0\">";
|
||||
foreach ($cellsHtml as $i => $cell) {
|
||||
$w = $cols[$i] ?? 2;
|
||||
echo "<div class=\"col-lg-{$w} col-md-12 px-4 mb-0\">{$cell}</div>";
|
||||
}
|
||||
echo '<div><hr class="my-1"></div></div>';
|
||||
};
|
||||
?>
|
||||
|
||||
<div class="divider divider-dark text-start mb-1">
|
||||
<div class="divider-text">
|
||||
<h5><?= lang('Presupuestos.papelesComparadorPresupuestoAdmin') ?></h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2a) Encabezado -->
|
||||
<?php
|
||||
$hdr = [];
|
||||
foreach ($labels as $lbl) {
|
||||
$hdr[] = '<p class="mb-0">' . ($lbl ? lang("Presupuestos.$lbl") : '') . '</p>';
|
||||
}
|
||||
echo '<div class="row mb-1">';
|
||||
foreach ($hdr as $i => $html) {
|
||||
echo '<div class="col-lg-' . $cols[$i] . ' col-md-12 px-4 mb-0">' . $html . '</div>';
|
||||
}
|
||||
echo '<div><hr class="my-1"><hr class="my-1"></div></div>';
|
||||
?>
|
||||
|
||||
<!-- 3) Filas dinámicas: negro y color -->
|
||||
<?php foreach (['negro', 'negro_pod', 'color', 'color_pod'] as $tipo):
|
||||
$pag = old("{$tipo}_paginas", $catalogoLibrosEntity->{"{$tipo}_paginas"});
|
||||
$papId = $catalogoLibrosEntity->{"{$tipo}_papel_id"};
|
||||
$papNm = $catalogoLibrosEntity->{"{$tipo}PapelName"};
|
||||
$gram = $catalogoLibrosEntity->{"{$tipo}_gramaje"};
|
||||
|
||||
$cells = [
|
||||
'<p>' . lang("MaquinasTarifasImpresions.$tipo") . '</p>',
|
||||
"<input type=\"text\" id=\"{$tipo}_paginas\" name=\"{$tipo}_paginas\" placeholder=\"0\" maxlength=\"5\" class=\"form-control {$tipo}_items\" value=\"" . esc($pag) . "\">",
|
||||
"<select id=\"{$tipo}_papel_id\" name=\"{$tipo}_papel_id\" class=\"form-control select2bs2 {$tipo}_items\" style=\"width:100%\">"
|
||||
. ($papNm ? "<option value=\"" . esc($papId) . "\" selected>" . esc($papNm) . "</option>" : "")
|
||||
. "</select>",
|
||||
"<select id=\"{$tipo}_gramaje\" name=\"{$tipo}_gramaje\" class=\"form-control select2bs2 {$tipo}_items\" style=\"width:100%\">"
|
||||
. "<option value=\"" . esc($gram) . "\" selected>" . esc($gram) . "</option></select>",
|
||||
'', // solapas
|
||||
'' // acabados
|
||||
];
|
||||
$renderRow($cells, $tipo);
|
||||
endforeach; ?>
|
||||
|
||||
<!-- 4) Cubierta y Sobrecubierta -->
|
||||
<?php
|
||||
$especiales = [
|
||||
'cubierta' => ['faces' => [2 => 'unaCara', 4 => 'dosCaras'], 'disable' => false],
|
||||
'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}_ancho_solapas"});
|
||||
$acId = $catalogoLibrosEntity->{"{$tipo}_acabado_id"};
|
||||
$acNm = $catalogoLibrosEntity->{"{$tipo}AcabadoName"};
|
||||
|
||||
$optPag = '';
|
||||
foreach ($cfg['faces'] as $v => $lbl) {
|
||||
$sel = $pag == $v ? ' selected' : '';
|
||||
$optPag .= "<option value=\"$v\"$sel>" . lang("Presupuestos.$lbl") . "</option>";
|
||||
}
|
||||
|
||||
$cells = [
|
||||
'<p>' . lang("PapelImpresion.$tipo") . '</p>',
|
||||
"<select id=\"{$tipo}_paginas\" name=\"{$tipo}_paginas\" class=\"form-control select2bs2\" style=\"width:100%\"" . ($cfg['disable'] ? ' disabled' : '') . ">{$optPag}</select>",
|
||||
"<select id=\"{$tipo}_papel_id\" name=\"{$tipo}_papel_id\" class=\"form-control select2bs2 {$tipo}_items\" style=\"width:100%\"" . ($cfg['disable'] ? ' disabled' : '') . ">"
|
||||
. ($papNm ? "<option value=\"" . esc($papId) . "\" selected>" . esc($papNm) . "</option>" : "")
|
||||
. "</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}_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, $tipo);
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,127 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionLibro">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingLibroDatos">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseLibroDatos" aria-expanded="true" aria-controls="collapseLibroDatos">
|
||||
<h5 class="mb-0"><?= lang("Catalogo.datosGenerales") ?? 'Datos generales del libro' ?></h5>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="collapseLibroDatos" class="accordion-collapse collapse show" data-bs-parent="#accordionLibro">
|
||||
<div class="accordion-body">
|
||||
|
||||
<div class="row">
|
||||
<!-- COLUMNA IZQUIERDA: Imagen -->
|
||||
<div class="col-md-12 col-lg-2 px-4 d-flex flex-column justify-content-center align-items-center"
|
||||
style="min-height: 100%;">
|
||||
<div class="mb-3 text-center w-100">
|
||||
<?php if (!empty($catalogoLibrosEntity->cubierta_url)): ?>
|
||||
<img src="<?= esc($catalogoLibrosEntity->cubierta_url) ?>" class="img-fluid mb-2"
|
||||
alt="Portada">
|
||||
<?php else: ?>
|
||||
<img src="https://static.cegal.es/imagenes/marcadas/9788415/978841f45711.gif" class="img-fluid mb-2"
|
||||
alt="Sin portada">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- COLUMNA DERECHA: Datos -->
|
||||
<div class="col-md-12 col-lg-10 px-4">
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="cliente_id" class="form-label">Cliente *</label>
|
||||
<select id="cliente_id" name="cliente_id" class="form-select select2bs5">
|
||||
<option value="<?= $catalogoLibrosEntity->cliente_id ?>" selected>
|
||||
<?= $catalogoLibrosEntity->clienteName ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8 mb-3">
|
||||
<label for="titulo" class="form-label">Título *</label>
|
||||
<input type="text" id="titulo" name="titulo" class="form-control"
|
||||
value="<?= old('titulo', $catalogoLibrosEntity->titulo) ?>" required
|
||||
maxlength="300">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="autor" class="form-label">Autor</label>
|
||||
<input type="text" id="autor" name="autor" class="form-control"
|
||||
value="<?= old('autor', $catalogoLibrosEntity->autor) ?>" maxlength="255">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="coleccion" class="form-label">Colección</label>
|
||||
<input type="text" id="coleccion" name="coleccion" class="form-control"
|
||||
value="<?= old('coleccion', $catalogoLibrosEntity->coleccion) ?>" maxlength="255">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="editorial" class="form-label">Editorial</label>
|
||||
<input type="text" id="editorial" name="editorial" class="form-control"
|
||||
value="<?= old('editorial', $catalogoLibrosEntity->editorial) ?>" maxlength="255">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="sello" class="form-label">Sello</label>
|
||||
<input type="text" id="sello" name="sello" class="form-control"
|
||||
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" readonly
|
||||
value="<?= old('isk', $catalogoLibrosEntity->isk) ?>" maxlength="64"
|
||||
style="background: #E8E8E8;">
|
||||
</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"
|
||||
value="<?= old('isbn', $catalogoLibrosEntity->isbn) ?>" maxlength="255">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="num_edic" class="form-label">Edición</label>
|
||||
<input type="number" id="num_edic" name="num_edic" class="form-control"
|
||||
value="<?= old('num_edic', $catalogoLibrosEntity->num_edic ?? 1) ?>">
|
||||
</div>
|
||||
|
||||
<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) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<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">
|
||||
<label for="ancho" class="form-label">Ancho *</label>
|
||||
<input type="number" step="0.01" id="ancho" name="ancho" class="form-control"
|
||||
value="<?= old('ancho', $catalogoLibrosEntity->ancho) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="alto" class="form-label">Alto *</label>
|
||||
<input type="number" step="0.01" id="alto" name="alto" class="form-control"
|
||||
value="<?= old('alto', $catalogoLibrosEntity->alto) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="paginas" class="form-label">Nº Páginas *</label>
|
||||
<input type="number" id="paginas" name="paginas" class="form-control"
|
||||
value="<?= old('paginas', $catalogoLibrosEntity->paginas) ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.row -->
|
||||
|
||||
</div> <!-- //.accordion-body -->
|
||||
</div> <!-- //.collapse -->
|
||||
</div> <!-- //.accordion-item -->
|
||||
</div> <!-- //.accordion -->
|
||||
@ -0,0 +1,99 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="accordionLibroOtros">
|
||||
<div class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingOtrosDatos">
|
||||
<button type="button" class="accordion-button collapsed" data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseOtrosDatos" aria-expanded="false" aria-controls="collapseOtrosDatos">
|
||||
<h5 class="mb-0"><?= lang("Catalogo.otrosDatosLibro") ?? 'Otros datos del libro' ?></h5>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="collapseOtrosDatos" class="accordion-collapse collapse" data-bs-parent="#accordionLibroOtros">
|
||||
<div class="accordion-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="peso" class="form-label">Peso</label>
|
||||
<input type="number" step="0.01" id="peso" name="peso" class="form-control"
|
||||
value="<?= old('peso', $catalogoLibrosEntity->peso) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="autor_entidad" class="form-label">Autor entidad</label>
|
||||
<input type="text" id="autor_entidad" name="autor_entidad" class="form-control"
|
||||
value="<?= old('autor_entidad', $catalogoLibrosEntity->autor_entidad) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="traductor" class="form-label">Traductor</label>
|
||||
<input type="text" id="traductor" name="traductor" class="form-control"
|
||||
value="<?= old('traductor', $catalogoLibrosEntity->traductor) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="ilustrador" class="form-label">Ilustrador</label>
|
||||
<input type="text" id="ilustrador" name="ilustrador" class="form-control"
|
||||
value="<?= old('ilustrador', $catalogoLibrosEntity->ilustrador) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="idioma" class="form-label">Idioma</label>
|
||||
<input type="text" id="idioma" name="idioma" class="form-control"
|
||||
value="<?= old('idioma', $catalogoLibrosEntity->idioma ?? 'spa') ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="num_edic" class="form-label">Nº Edición</label>
|
||||
<input type="number" id="num_edic" name="num_edic" class="form-control"
|
||||
value="<?= old('num_edic', $catalogoLibrosEntity->num_edic ?? 1) ?>">
|
||||
</div>
|
||||
|
||||
<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?->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?->format('Y-m-d')) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="num_fotos" class="form-label">Nº Fotos</label>
|
||||
<input type="number" id="num_fotos" name="num_fotos" class="form-control"
|
||||
value="<?= old('num_fotos', $catalogoLibrosEntity->num_fotos ?? 0) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="num_ilustr" class="form-label">Nº Ilustraciones</label>
|
||||
<input type="number" id="num_ilustr" name="num_ilustr" class="form-control"
|
||||
value="<?= old('num_ilustr', $catalogoLibrosEntity->num_ilustr ?? 0) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="num_ilustr_color" class="form-label">Nº Ilustraciones Color</label>
|
||||
<input type="number" id="num_ilustr_color" name="num_ilustr_color" class="form-control"
|
||||
value="<?= old('num_ilustr_color', $catalogoLibrosEntity->num_ilustr_color ?? 0) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mb-3">
|
||||
<label for="num_ilustr_bn" class="form-label">Nº Ilustraciones B/N</label>
|
||||
<input type="number" id="num_ilustr_bn" name="num_ilustr_bn" class="form-control"
|
||||
value="<?= old('num_ilustr_bn', $catalogoLibrosEntity->num_ilustr_bn ?? 0) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="resumen" class="form-label">Resumen</label>
|
||||
<textarea id="resumen" name="resumen" rows="4" class="form-control"><?= old('resumen', $catalogoLibrosEntity->resumen) ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="resumen_breve" class="form-label">Resumen breve</label>
|
||||
<textarea id="resumen_breve" name="resumen_breve" rows="4" class="form-control"><?= old('resumen_breve', $catalogoLibrosEntity->resumen_breve) ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,20 @@
|
||||
<?php if (!empty($catalogoLibrosEntity->user_created_id)): ?>
|
||||
<div
|
||||
class="container-fluid d-flex flex-md-row flex-column justify-content-between align-items-md-center gap-1 container-p-x py-3">
|
||||
<div class="col-md-6">
|
||||
<p>
|
||||
<strong><?= lang("Catalogo.created_by_at") ?></strong>
|
||||
<span id="created_by"><?= $catalogoLibrosEntity->createdUser ?></span>,
|
||||
<span id="created_at"><?= $catalogoLibrosEntity->created_at ?></span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p>
|
||||
<strong><?= lang("Catalogo.updated_by_at") ?></strong>
|
||||
<span id="updated_by"><?= $catalogoLibrosEntity->updatedUser ?></span>,
|
||||
<span id="updated_at_footer"><?= $catalogoLibrosEntity->updated_at ?></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
@ -0,0 +1,48 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
|
||||
<form id="catalogoLibroForm" class="card-body" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<!-- card-body -->
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/vuexy/form/catalogo/_datosGeneralesFormItems") ?>
|
||||
<?= view("themes/vuexy/form/catalogo/_otrosDatosFormItems") ?>
|
||||
<?= view("themes/vuexy/form/catalogo/_configuracionLibroFormItems") ?>
|
||||
<?= view("themes/vuexy/form/catalogo/_trackingFormItems") ?>
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
<!-- card-footer -->
|
||||
<div class="pt-4">
|
||||
<?php if (auth()->user()->can('catalogo.edit')): ?>
|
||||
<input type="submit" class="btn btn-primary float-start me-sm-3 me-1" name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>" />
|
||||
<?php endif; ?>
|
||||
<?= anchor(route_to("CatalogoLibrosList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
</div>
|
||||
<!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/safekat.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script type="module" src="<?= site_url('assets/js/safekat/pages/catalogo/catalogo.js?' . 'token' . '=' . (csrf_token() ?? "token")) ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,80 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('Catalogo.listingPage') ?></h3>
|
||||
<?= anchor(route_to('CatalogoLibrosAdd'), lang('Basic.global.addNew') . ' ' . lang('Catalogo.libro'), ['class' => 'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfCatalogoLibros" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Catalogo.portada') ?></th>
|
||||
<th><?= lang('Catalogo.id') ?></th>
|
||||
<th><?= lang('Catalogo.titulo') ?></th>
|
||||
<th><?= lang('Catalogo.cliente') ?></th>
|
||||
<th><?= lang('Catalogo.edicion') ?></th>
|
||||
<th><?= lang('Catalogo.autor') ?></th>
|
||||
<th><?= lang('Catalogo.isbn') ?></th>
|
||||
<th><?= lang('Catalogo.ean') ?></th>
|
||||
<th><?= lang('Catalogo.paginas') ?></th>
|
||||
<th class="text-nowrap" style="min-width: 85px;"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th><input type="text" class="form-control filtro_catalogo" name="titulo"></th>
|
||||
<th><input type="text" class="form-control filtro_catalogo" name="cliente"></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet"
|
||||
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script
|
||||
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
|
||||
<script
|
||||
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/catalogo/list.js") ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,35 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MENU CATALOGO
|
||||
*/
|
||||
if (auth()->user()->inGroup('beta')) {
|
||||
?>
|
||||
if (auth()->user()->can('catalogo.menu')) {
|
||||
?>
|
||||
<!-- Catalogue -->
|
||||
<li class="menu-item">
|
||||
<a href="javascript:void(0);" class="menu-link menu-toggle beta">
|
||||
<a href="javascript:void(0);" class="menu-link menu-toggle">
|
||||
<i class="menu-icon tf-icons ti ti-book"></i>
|
||||
<div><?= lang("App.menu_catalogo") ?></div>
|
||||
<?= lang("App.menu_catalogo") ?>
|
||||
</a>
|
||||
<ul class="menu-sub">
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo") ?>" class="menu-link beta">
|
||||
<div><?= lang("App.menu_catalogo_libros") ?></div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo/nuevo") ?>" class="menu-link beta">
|
||||
<div><?= lang("App.menu_catalogo_nuevo") ?></div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo/categorias") ?>" class="menu-link beta">
|
||||
<div><?= lang("App.menu_catalogo_categorias") ?></div>
|
||||
</a>
|
||||
</li>
|
||||
<?php if (auth()->user()->can('catalogo.menu')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to("CatalogoLibrosList") ?>" class="menu-link">
|
||||
<?= lang("App.menu_catalogo_libros") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->can('catalogo.create')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to("CatalogoLibrosAdd") ?>" class="menu-link">
|
||||
<?= lang("App.menu_catalogo_nuevo") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo/importar") ?>" class="menu-link beta">
|
||||
<div> <?= lang("App.menu_catalogo_importar") ?></div>
|
||||
<?= lang("App.menu_catalogo_importar") ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
418
httpdocs/assets/js/safekat/pages/catalogo/catalogo.js
Normal file
418
httpdocs/assets/js/safekat/pages/catalogo/catalogo.js
Normal file
@ -0,0 +1,418 @@
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
class Catalogo {
|
||||
|
||||
constructor() {
|
||||
|
||||
/* Definiciones */
|
||||
this.tirada_no_pod = 100;
|
||||
this.tirada_pod = 1;
|
||||
|
||||
/* 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");
|
||||
|
||||
/* 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,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
this.selectPapelNegroPod = new ClassSelect($("#negro_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: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
this.selectGramajeNegro = new ClassSelect($('#negro_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelNegro.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
|
||||
});
|
||||
|
||||
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,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
|
||||
});
|
||||
|
||||
this.selectPapelColorPod = new ClassSelect($("#color_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: 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,
|
||||
sopalas: 0,
|
||||
lomo: 0,
|
||||
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
|
||||
});
|
||||
|
||||
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_ancho_solapas').val(),
|
||||
lomo: () => 0,
|
||||
tipo: 'colorhq',
|
||||
uso: 'cubierta',
|
||||
});
|
||||
|
||||
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.selectPapelCubierta.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#cubierta_ancho_solapas').val(),
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
|
||||
this.selectGramajeCubiertaPod = new ClassSelect($('#cubierta_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.selectPapelCubiertaPod.getVal(),
|
||||
tirada: () => this.tirada_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#cubierta_ancho_solapas').val(),
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
|
||||
this.acabadoCubierta = new ClassSelect($("#cubierta_acabado_id"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'Seleccione acabado',
|
||||
false,
|
||||
{
|
||||
"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',
|
||||
false,
|
||||
{
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
this.cliente.init();
|
||||
this.tipo_impresion.select2();
|
||||
this.paginas_cubierta.select2();
|
||||
this.paginasSobrecubierta.select2();
|
||||
|
||||
this.encuadernacion.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();
|
||||
|
||||
// Inicializacino de eventos
|
||||
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));
|
||||
|
||||
// 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');
|
||||
let select2Container = $(this).next('.select2').find('.select2-selection');
|
||||
select2Container.addClass('bg-warning');
|
||||
});
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// 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();;
|
||||
return { ancho, alto };
|
||||
}
|
||||
|
||||
toggleSobrecubiertaFields() {
|
||||
if (this.paginasSobrecubierta.val() === '1') {
|
||||
this.sobrecubiertaItems.prop('disabled', false).trigger('change.select2');
|
||||
} else {
|
||||
this.sobrecubiertaItems.prop('disabled', true).trigger('change.select2');
|
||||
}
|
||||
}
|
||||
|
||||
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 () {
|
||||
|
||||
let catalogo = new Catalogo();
|
||||
catalogo.init();
|
||||
});
|
||||
|
||||
export default Catalogo;
|
||||
114
httpdocs/assets/js/safekat/pages/catalogo/list.js
Normal file
114
httpdocs/assets/js/safekat/pages/catalogo/list.js
Normal file
@ -0,0 +1,114 @@
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const lastColNr = $('#tableOfCatalogoLibros').find("tr:first th").length - 1;
|
||||
|
||||
const theTable = $('#tableOfCatalogoLibros').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
orderCellsTop: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
dom: 'lfBrtip',
|
||||
buttons: [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
order: [[1, 'asc']],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
ajax: {
|
||||
url: '/catalogo/libros/datatable',
|
||||
method: 'GET'
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
{ data: 'portada' },
|
||||
{ data: 'id' },
|
||||
{ data: 'titulo' },
|
||||
{ data: 'cliente' },
|
||||
{
|
||||
data: 'edicion',
|
||||
className: "text-center"
|
||||
},
|
||||
{ data: 'autor' },
|
||||
{ data: 'isbn' },
|
||||
{ data: 'ean' },
|
||||
{
|
||||
data: 'paginas',
|
||||
className: "text-center"
|
||||
},
|
||||
{ data: 'actionBtns' }
|
||||
]
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function (e) {
|
||||
window.location.href = '/catalogo/libros/edit/' + $(this).attr('data-id');
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function (e) {
|
||||
e.preventDefault();
|
||||
const row = $(this).closest('tr')[0]._DT_RowIndex;
|
||||
const dataId = $(this).attr('data-id');
|
||||
|
||||
Swal.fire({
|
||||
title: '¿Estás seguro?',
|
||||
text: 'Esta acción no se puede deshacer.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí',
|
||||
cancelButtonText: 'No',
|
||||
reverseButtons: false,
|
||||
buttonsStyling: true,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-danger', // rojo para "Sí"
|
||||
cancelButton: 'btn btn-secondary' // gris para "No"
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
new Ajax(
|
||||
'/catalogo/libros/delete/' + dataId,
|
||||
{},
|
||||
{},
|
||||
(data, textStatus, jqXHR) => {
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
},
|
||||
(error) => {
|
||||
console.error(error);
|
||||
Swal.fire('Error', 'No se pudo eliminar el libro.', 'error');
|
||||
}
|
||||
).get();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(document).on("keyup", ".filtro_catalogo", (event) => {
|
||||
let columnName = $(event.currentTarget).attr("name");
|
||||
let columnIndex = $('#tableOfCatalogoLibros').DataTable().columns().eq(0).filter(function (index) {
|
||||
return $('#tableOfCatalogoLibros').DataTable().column(index).dataSrc() === columnName;
|
||||
})[0];
|
||||
$('#tableOfCatalogoLibros').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user