mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Listado de libros de catalogo
This commit is contained in:
19
ci4/app/Config/Routes/CatalogoRoutes.php
Normal file
19
ci4/app/Config/Routes/CatalogoRoutes.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?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) {
|
||||
$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']);
|
||||
$routes->get('select', 'CatalogoLibros::show_select', ["as" => "CatalogoLibrosShow"]);
|
||||
});
|
||||
});
|
||||
289
ci4/app/Controllers/Catalogo/CatalogoLibros.php
Normal file
289
ci4/app/Controllers/Catalogo/CatalogoLibros.php
Normal file
@ -0,0 +1,289 @@
|
||||
<?php
|
||||
namespace App\Controllers\Catalogo;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Entities\Catalogo\CatalogoLibroEntity;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Catalogo\CatalogoLibroModel;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
|
||||
class CatalogoLibros extends BaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = CatalogoLibroModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Catalogo';
|
||||
protected static $singularObjectNameCc = 'catalogo';
|
||||
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);
|
||||
|
||||
$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('createPais');
|
||||
$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()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
if ($this->request->getPost('show_erp') == null) {
|
||||
$sanitizedData['show_erp'] = false;
|
||||
}
|
||||
|
||||
|
||||
$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()
|
||||
{
|
||||
$q = $this->model->getDatatableQuery();
|
||||
|
||||
$result = DataTable::of($q)
|
||||
->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);
|
||||
|
||||
}
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->orderBy("nombre", "asc");
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_paises.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,7 +4,7 @@ namespace App\Entities\Catalogo;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class CatalogoLibro extends Entity
|
||||
class CatalogoLibroEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
'id' => null,
|
||||
92
ci4/app/Language/es/Catalogo.php
Normal file
92
ci4/app/Language/es/Catalogo.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'moduleTitle' => 'Catálogo de libros',
|
||||
'listingPage' => 'Listado de libros',
|
||||
'catalogo' => 'catálogo',
|
||||
'libro' => 'libro',
|
||||
'id' => 'ID',
|
||||
'clienteId' => 'Cliente',
|
||||
'proveedorId' => 'Proveedor',
|
||||
'userCreatedId' => 'Usuario Creador',
|
||||
'userUpdateId' => 'Usuario Actualizador',
|
||||
'cubiertaArchivo' => 'Archivo de Cubierta',
|
||||
'cubiertaUrl' => 'URL de Cubierta',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
|
||||
'moduleTitle' => 'Catálogo de Libros',
|
||||
'catalogoLibro' => 'Libro',
|
||||
'catalogoLibroList' => 'Lista de Libros',
|
||||
|
||||
'validation' => [
|
||||
'titulo' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
'max_length' => 'El campo {field} no puede exceder {param} caracteres.',
|
||||
],
|
||||
'autor' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
'editorial' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
'coleccion' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
'paginas' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
'integer' => 'El campo {field} debe ser un número entero.',
|
||||
],
|
||||
'ancho' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
'alto' => [
|
||||
'required' => 'El campo {field} es obligatorio.',
|
||||
],
|
||||
],
|
||||
];
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Catalogo;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Entities\Catalogo\CatalogoLibro;
|
||||
@ -92,10 +92,10 @@ class CatalogoLibroModel extends Model
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id,
|
||||
t1.nombre AS nombre,
|
||||
t1.code AS cliente,
|
||||
t1.titulo AS titulo,
|
||||
t1.edicion AS edicion,
|
||||
t1.cliente_id AS cliente,
|
||||
t1.titulo AS titulo,
|
||||
t1.num_edic AS edicion,
|
||||
t1.autor AS autor,
|
||||
t1.isbn AS isbn,
|
||||
t1.ean AS ean,
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?= lang('Paises.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control"
|
||||
value="<?= old('nombre', $paisEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="code" class="form-label">
|
||||
<?= lang('Paises.code') ?>*
|
||||
</label>
|
||||
<input type="text" id="code" name="code" required maxLength="2" class="form-control"
|
||||
value="<?= old('code', $paisEntity->code) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="code3" class="form-label">
|
||||
<?= lang('Paises.code3') ?>
|
||||
</label>
|
||||
<input type="text" id="code3" name="code3" maxLength="3" class="form-control"
|
||||
value="<?= old('code3', $paisEntity->code3) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="moneda" class="form-label">
|
||||
<?= lang('Paises.moneda') ?>*
|
||||
</label>
|
||||
<input type="text" id="moneda" name="moneda" required maxLength="3" class="form-control"
|
||||
value="<?= old('moneda', $paisEntity->moneda) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="urlErp" class="form-label">
|
||||
<?= lang('Paises.urlErp') ?>
|
||||
</label>
|
||||
<input type="url" id="urlErp" name="url_erp" maxLength="255" class="form-control"
|
||||
value="<?= old('url_erp', $paisEntity->url_erp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="userErp" class="form-label">
|
||||
<?= lang('Paises.userErp') ?>
|
||||
</label>
|
||||
<input type="text" id="userErp" name="user_erp" maxLength="255" class="form-control"
|
||||
value="<?= old('user_erp', $paisEntity->user_erp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="keyErp" class="form-label">
|
||||
<?= lang('Paises.keyErp') ?>
|
||||
</label>
|
||||
<input type="text" id="keyErp" name="key_erp" maxLength="255" class="form-control"
|
||||
value="<?= old('key_erp', $paisEntity->key_erp) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
|
||||
<label for="showErp" class="form-check-label">
|
||||
<input type="checkbox" id="showErp" name="show_erp" value="1" class="form-check-input"
|
||||
<?= $paisEntity->show_erp == true ? 'checked' : ''; ?>>
|
||||
<?= lang('Paises.showErp') ?>
|
||||
</label>
|
||||
</div><!--//.form-check -->
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -0,0 +1,26 @@
|
||||
<?= $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="paisForm" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/vuexy/form/configuracion/paises/_paisFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("paisList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,68 @@
|
||||
<?= $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>
|
||||
</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() ?>
|
||||
@ -12,20 +12,15 @@ if (auth()->user()->inGroup('beta')) {
|
||||
</a>
|
||||
<ul class="menu-sub">
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo") ?>" class="menu-link beta">
|
||||
<a href="<?= route_to("CatalogoLibrosList") ?>" class="menu-link beta">
|
||||
<?= lang("App.menu_catalogo_libros") ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo/nuevo") ?>" class="menu-link beta">
|
||||
<a href="<?= route_to("CatalogoLibrosAdd") ?>" class="menu-link beta">
|
||||
<?= lang("App.menu_catalogo_nuevo") ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo/categorias") ?>" class="menu-link beta">
|
||||
<?= lang("App.menu_catalogo_categorias") ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("catalogo/catalogo/importar") ?>" class="menu-link beta">
|
||||
<?= lang("App.menu_catalogo_importar") ?>
|
||||
|
||||
98
httpdocs/assets/js/safekat/pages/catalogo/list.js
Normal file
98
httpdocs/assets/js/safekat/pages/catalogo/list.js
Normal file
@ -0,0 +1,98 @@
|
||||
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,
|
||||
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'
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
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' },
|
||||
{ data: 'autor' },
|
||||
{ data: 'isbn' },
|
||||
{ data: 'ean' },
|
||||
{ data: 'paginas' },
|
||||
{ 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 país.', 'error');
|
||||
}
|
||||
).get();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user