mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Construyendo el formulario de edicion
This commit is contained in:
@ -14,7 +14,7 @@ class CatalogoLibros extends BaseResourceController
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Catalogo';
|
||||
protected static $singularObjectNameCc = 'catalogo';
|
||||
protected static $singularObjectNameCc = 'CatalogoLibros';
|
||||
protected static $pluralObjectName = 'Catalogos';
|
||||
protected static $pluralObjectNameCc = 'catalogos';
|
||||
|
||||
@ -194,6 +194,17 @@ class CatalogoLibros extends BaseResourceController
|
||||
$q = $this->model->getDatatableQuery();
|
||||
|
||||
$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')) {
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
namespace App\Models\Catalogo;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Entities\Catalogo\CatalogoLibro;
|
||||
use App\Entities\Catalogo\CatalogoLibroEntity;
|
||||
|
||||
class CatalogoLibroModel extends Model
|
||||
{
|
||||
protected $table = 'catalogo_libros';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $returnType = CatalogoLibro::class;
|
||||
protected $returnType = CatalogoLibroEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
|
||||
@ -100,6 +100,7 @@ class CatalogoLibroModel extends Model
|
||||
t1.isbn AS isbn,
|
||||
t1.ean AS ean,
|
||||
t1.paginas AS paginas,
|
||||
t1.cubierta_archivo AS cubierta_archivo,
|
||||
t1.cubierta_url AS portada"
|
||||
);
|
||||
|
||||
|
||||
@ -1,74 +1,112 @@
|
||||
<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="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 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 id="collapseLibroDatos" class="accordion-collapse collapse show" data-bs-parent="#accordionLibro">
|
||||
<div class="accordion-body">
|
||||
|
||||
<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="row">
|
||||
<!-- COLUMNA IZQUIERDA: Imagen -->
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
<div class="mb-3 text-center">
|
||||
<?php if (!empty($catalogoLibrosEntity->cubierta_url)) : ?>
|
||||
<img src="<?= esc($catalogoLibrosEntity->cubierta_url) ?>" class="img-fluid mb-2" alt="Portada">
|
||||
<?php else : ?>
|
||||
<img src="<?= base_url('assets/img/default_cover.png') ?>" class="img-fluid mb-2" alt="Sin portada">
|
||||
<?php endif; ?>
|
||||
<input type="file" name="cubierta_archivo" class="form-control" accept="image/*">
|
||||
<small class="form-text text-muted">Subir portada</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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 -->
|
||||
<!-- 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"></select>
|
||||
</div>
|
||||
|
||||
</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="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="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="col-md-4 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="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="col-md-4 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="mb-3">
|
||||
<div class="form-check">
|
||||
<div class="col-md-4 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>
|
||||
|
||||
<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 class="col-md-4 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><!--//.col -->
|
||||
<div class="col-md-4 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><!-- //.row -->
|
||||
<div class="col-md-2 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-6 mb-3">
|
||||
<label for="ean" class="form-label">EAN</label>
|
||||
<input type="text" id="ean" name="ean" class="form-control" readonly
|
||||
value="<?= old('ean', $catalogoLibrosEntity->ean) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="cubierta_archivo" class="form-label">Archivo</label>
|
||||
<input type="text" id="cubierta_archivo" name="cubierta_archivo" class="form-control"
|
||||
value="<?= old('cubierta_archivo', $catalogoLibrosEntity->cubierta_archivo) ?>">
|
||||
</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 -->
|
||||
|
||||
@ -1,26 +1,35 @@
|
||||
<?= $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="col-12">
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="paisForm" method="post" action="<?= $formAction ?>">
|
||||
|
||||
<form id="paisForm" class="card-body" 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 -->
|
||||
<!-- card-body -->
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/vuexy/form/catalogo/_catalogoLibrosFormItems") ?>
|
||||
</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><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->endSection() ?>
|
||||
Reference in New Issue
Block a user