Revisados formularios de crear y editar, con su validacion

This commit is contained in:
unknown
2025-04-20 21:35:24 +02:00
parent f93ecda648
commit 14b5f4bf95
12 changed files with 310 additions and 286 deletions

View File

@ -66,10 +66,12 @@ class CatalogoLibros extends BaseResourceController
$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);
@ -84,6 +86,7 @@ class CatalogoLibros extends BaseResourceController
$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();
@ -105,10 +108,9 @@ class CatalogoLibros extends BaseResourceController
endif; // ($requestMethod === 'post')
$this->viewData['catalogoLibrosEntity'] = isset($sanitizedData) ? new CatalogoLibroEntity($sanitizedData) : new CatalogoLibroEntity();
$this->viewData['formAction'] = route_to('createPais');
$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()
@ -126,21 +128,15 @@ class CatalogoLibros extends BaseResourceController
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;
}
$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) ) :
@ -158,9 +154,9 @@ class CatalogoLibros extends BaseResourceController
endif;
$catalogoLibrosEntity->fill($sanitizedData);
$thenRedirect = false;
endif;
if ($noException && $successfulResult):
$id = $catalogoLibrosEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
@ -178,15 +174,9 @@ class CatalogoLibros extends BaseResourceController
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$catalogoLibrosEntity->clienteName = model('App\Models\Clientes\ClienteModel')->find($catalogoLibrosEntity->cliente_id)->nombre;
$catalogoLibrosEntity->encuadernacionName = model('App\Models\Configuracion\TipoPresupuestoModel')->find($catalogoLibrosEntity->encuadernacion_id)->encuadernacion;
$catalogoLibrosEntity->createdUser = model('App\Models\Usuarios\UserModel')->getFullName($catalogoLibrosEntity->user_created_id);
$catalogoLibrosEntity->updatedUser = model('App\Models\Usuarios\UserModel')->getFullName($catalogoLibrosEntity->user_update_id);
$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');
@ -235,77 +225,6 @@ class CatalogoLibros extends BaseResourceController
}
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);
}
}
/* IMN */
public function getClientList()
@ -316,92 +235,5 @@ class CatalogoLibros extends BaseResourceController
}
public function get_files()
{
// Check if the request is a POST request
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$presupuesto_id = $this->request->getPost()['presupuesto_id'] ?? 0;
$model = model('App\Models\Presupuestos\PresupuestoFicheroModel');
$files = $model->getFiles($presupuesto_id);
$result = [];
foreach ($files as $file) {
$size = filesize($file->file_path);
$splitPath = explode("presupuestos/", $file->file_path);
// se crea un objeto con el nombre del fichero y el tamaño
$obj = (object) array(
'name' => $file->nombre,
'size' => $size,
'hash' => $splitPath[1] ?? $file->file_path
);
// se añade el objeto al array
array_push($result, $obj);
}
return json_encode($result);
}
}
public function upload_files()
{
$model = model('App\Models\Presupuestos\PresupuestoFicheroModel');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$presupuesto_id = $_POST['presupuesto_id'];
$old_files = json_decode($_POST['oldFiles']);
$ftp = new SafekatFtpClient();
// Comprobar si se han subido archivos
if (!empty($_FILES['file']) || !empty($old_files)) {
// Borrar los archivos existentes del presupuesto
$ftp->removeFiles($presupuesto_id);
$model->deleteFiles($presupuesto_id, $old_files);
if (!empty($_FILES['file'])) {
$files = $_FILES['file'];
// Iterar sobre los archivos
for ($i = 0; $i < count($files['name']); $i++) {
// Aquí puedes acceder a las propiedades del archivo
$name = $files['name'][$i];
$extension = explode('.', $files['name'][$i])[1];
$tmp_name = $files['tmp_name'][$i];
$new_name = $model->saveFileInBBDD($presupuesto_id, $name, $extension, auth()->id());
// Se sube el fichero
// Pero primero se comprueba que la carpeta presupuestos exista
if (!is_dir(WRITEPATH . 'uploads/presupuestos')) {
mkdir(WRITEPATH . 'uploads/presupuestos', 0777, true);
}
if (!is_null($new_name)) {
$path = WRITEPATH . 'uploads/presupuestos/' . $new_name;
move_uploaded_file($tmp_name, $path);
}
}
$ftp->uploadFilePresupuesto($presupuesto_id);
}
} else {
// Borrar los archivos existentes del presupuesto
$ftp->removeFiles($presupuesto_id);
$model->deleteFiles($presupuesto_id);
}
}
return json_encode(['message' => 'Archivos subidos correctamente']);
}
}

View File

@ -30,7 +30,7 @@ class Test extends BaseController
}
public function index()
private function index()
{
$modelCL = new CatalogoLibroModel();

View File

@ -4,7 +4,10 @@ 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 = [
@ -104,6 +107,44 @@ class CatalogoLibroEntity extends Entity
];
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()
{

View File

@ -1,4 +1,59 @@
<?php
// override core en language system validation or define your own en language validation message
return [];
return [
// General rules
'required' => 'The {field} field is required.',
'matches' => 'The {field} field does not match the {param} field.',
'differs' => 'The {field} field must differ from the {param} field.',
'isUnique' => 'The value of {field} is already in use.',
'is_natural' => 'The {field} field must only contain positive numbers.',
'is_natural_no_zero' => 'The {field} field must be greater than zero.',
'valid_url' => 'The {field} field must contain a valid URL.',
'valid_email' => 'The {field} field must contain a valid email address.',
'valid_emails' => 'The {field} field must contain only valid email addresses.',
'valid_ip' => 'The {field} field must contain a valid IP address.',
'valid_base64' => 'The {field} field must contain a valid Base64 string.',
'valid_json' => 'The {field} field must contain a valid JSON string.',
'valid_datetime' => 'The {field} field must contain a valid date and time.',
'valid_date' => 'The {field} field must contain a valid date.',
'valid_time' => 'The {field} field must contain a valid time.',
// Comparison rules
'min_length' => 'The {field} field must be at least {param} characters long.',
'max_length' => 'The {field} field must not exceed {param} characters.',
'exact_length' => 'The {field} field must be exactly {param} characters long.',
'greater_than' => 'The {field} field must be greater than {param}.',
'greater_than_equal_to' => 'The {field} field must be greater than or equal to {param}.',
'less_than' => 'The {field} field must be less than {param}.',
'less_than_equal_to' => 'The {field} field must be less than or equal to {param}.',
// Type rules
'alpha' => 'The {field} field may only contain alphabetic characters.',
'alpha_space' => 'The {field} field may only contain letters and spaces.',
'alpha_numeric' => 'The {field} field may only contain letters and numbers.',
'alpha_numeric_space' => 'The {field} field may only contain letters, numbers, and spaces.',
'alpha_numeric_punct' => 'The {field} field may only contain letters, numbers, spaces, and the following characters: . , : ; - _ ! ?',
'alpha_numeric_dash' => 'The {field} field may only contain letters, numbers, underscores, and dashes.',
'numeric' => 'The {field} field must contain only numbers.',
'integer' => 'The {field} field must contain an integer.',
'decimal' => 'The {field} field must contain a decimal number.',
'natural' => 'The {field} field must contain only positive numbers.',
'natural_no_zero' => 'The {field} field must contain a number greater than zero.',
'in_list' => 'The {field} field must be one of the following: {param}.',
// File validation
'uploaded' => 'You must upload a file in the {field} field.',
'max_size' => 'The file in the {field} field must not exceed {param} kilobytes.',
'is_image' => 'The file in the {field} field must be a valid image.',
'mime_in' => 'The file in the {field} field must be of type: {param}.',
'ext_in' => 'The file in the {field} field must have one of the following extensions: {param}.',
'max_dims' => 'The image in the {field} field must not exceed the allowed dimensions: {param}.',
// Other
'permit_empty' => 'The {field} field may be left empty.',
'string' => 'The {field} field must be a text string.',
'is_unique' => 'The {field} value already exists in the system.',
'valid_cc_number' => 'The {field} field does not contain a valid credit card number.',
'regex_match' => 'The {field} field format is invalid.',
];

View File

@ -64,7 +64,6 @@ return [
'updatedAt' => 'Fecha de Actualización',
'deletedAt' => 'Fecha de Eliminación',
'moduleTitle' => 'Catálogo de Libros',
'catalogoLibro' => 'Libro',
'catalogoLibroList' => 'Lista de Libros',
'datosGenerales' => 'Datos generales del libro',
@ -72,31 +71,5 @@ return [
'configuracionLibro' => 'Configuración del libro',
'ficherosLibro' => 'Ficheros',
'created_by_at' => 'Creado:',
'updated_by_at' => 'Actualizado:',
'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.',
],
],
'updated_by_at' => 'Actualizado:',
];

View File

@ -1,4 +1,61 @@
<?php
// override core en language system validation or define your own en language validation message
return [];
return [
// Reglas generales
'required' => 'El campo {field} es obligatorio.',
'matches' => 'El campo {field} no coincide con el campo {param}.',
'differs' => 'El campo {field} debe ser diferente al campo {param}.',
'isUnique' => 'El valor del campo {field} ya está registrado.',
'is_natural' => 'El campo {field} debe contener solo números positivos.',
'is_natural_no_zero' => 'El campo {field} debe contener un número mayor que cero.',
'valid_url' => 'El campo {field} debe contener una URL válida.',
'valid_email' => 'El campo {field} debe contener un email válido.',
'valid_emails' => 'Todos los valores del campo {field} deben ser emails válidos.',
'valid_ip' => 'El campo {field} debe contener una IP válida.',
'valid_base64' => 'El campo {field} debe contener una cadena Base64 válida.',
'valid_json' => 'El campo {field} debe contener una cadena JSON válida.',
'valid_datetime' => 'El campo {field} debe contener una fecha y hora válida.',
'valid_date' => 'El campo {field} debe contener una fecha válida.',
'valid_time' => 'El campo {field} debe contener una hora válida.',
// Reglas de comparación
'min_length' => 'El campo {field} debe tener al menos {param} caracteres.',
'max_length' => 'El campo {field} no puede exceder los {param} caracteres.',
'exact_length' => 'El campo {field} debe tener exactamente {param} caracteres.',
'greater_than' => 'El campo {field} debe ser mayor que {param}.',
'greater_than_equal_to' => 'El campo {field} debe ser mayor o igual que {param}.',
'less_than' => 'El campo {field} debe ser menor que {param}.',
'less_than_equal_to' => 'El campo {field} debe ser menor o igual que {param}.',
// Reglas de tipo
'alpha' => 'El campo {field} solo puede contener letras.',
'alpha_space' => 'El campo {field} solo puede contener letras y espacios.',
'alpha_numeric' => 'El campo {field} solo puede contener letras y números.',
'alpha_numeric_space' => 'El campo {field} solo puede contener letras, números y espacios.',
'alpha_numeric_punct' => 'El campo {field} solo puede contener letras, números, espacios y los siguientes caracteres: . , : ; - _ ! ?',
'alpha_numeric_dash' => 'El campo {field} solo puede contener letras, números, guiones y guiones bajos.',
'numeric' => 'El campo {field} debe contener solo números.',
'integer' => 'El campo {field} debe contener un número entero.',
'decimal' => 'El campo {field} debe contener un número decimal.',
'natural' => 'El campo {field} debe contener solo números positivos.',
'natural_no_zero' => 'El campo {field} debe contener un número mayor que cero.',
'in_list' => 'El campo {field} debe contener uno de los siguientes valores: {param}.',
// Archivos
'uploaded' => 'Debes subir un archivo en el campo {field}.',
'max_size' => 'El archivo en el campo {field} no debe superar los {param} kilobytes.',
'is_image' => 'El archivo en el campo {field} debe ser una imagen válida.',
'mime_in' => 'El archivo en el campo {field} debe tener uno de los siguientes tipos MIME: {param}.',
'ext_in' => 'El archivo en el campo {field} debe tener una de las siguientes extensiones: {param}.',
'max_dims' => 'La imagen en el campo {field} no puede exceder las dimensiones permitidas: {param}.',
// Unicidad y formato
'permit_empty' => 'El campo {field} puede estar vacío.',
'string' => 'El campo {field} debe ser una cadena de texto.',
'is_unique' => 'El valor del campo {field} ya existe en el sistema.',
'valid_cc_number' => 'El campo {field} no contiene un número de tarjeta válido.',
'regex_match' => 'El campo {field} no tiene el formato esperado.',
];

View File

@ -18,10 +18,7 @@ class CatalogoLibroModel extends Model
protected $allowedFields = [
'cliente_id',
'proveedor_id',
'user_created_id',
'user_update_id',
'cubierta_archivo',
'cubierta_url',
'ancho',
'alto',
'peso',
@ -39,33 +36,31 @@ class CatalogoLibroModel extends Model
'num_ilustr_color',
'num_ilustr_bn',
'coleccion',
'isk',
'isbn',
'ean',
'editorial',
'resumen',
'resumen_breve',
'sello',
'paginas',
'tipo_impresion',
'solapas_ancho',
'cubiertas_ancho',
'comentarios',
'negro_paginas',
'negro_papel',
'negro_papel_id',
'negro_gramaje',
'color_paginas',
'color_papel',
'color_papel_id',
'color_gramaje',
'portada_paginas',
'portada_papel',
'portada_gramaje',
'portada_acabado',
'cubierta_paginas',
'cubierta_papel',
'cubierta_papel_id',
'cubierta_gramaje',
'cubierta_acabado',
'encuardenacion',
'cubierta_acabado_id',
'cubierta_ancho_solapas',
'sobrecubierta_paginas',
'sobrecubierta_papel_id',
'sobrecubierta_gramaje',
'sobrecubierta_acabado_id',
'sobrecubierta_ancho_solapas',
'encuadernacion_id',
'ubicacion',
];
@ -77,10 +72,94 @@ class CatalogoLibroModel extends Model
protected $deletedField = 'deleted_at';
// Opcional: reglas de validación
protected $validationRules = [];
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;
}
/**
@ -92,21 +171,20 @@ class CatalogoLibroModel extends Model
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id,
t1.titulo AS titulo,
t2.nombre AS cliente,
t1.titulo AS titulo,
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');
->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;
}

View File

@ -28,7 +28,7 @@
<div class="row px-4 mt-1">
<div class="col-md-12 col-lg-3">
<select id="tipoImpresion" name="comp_tipo_impresion" class="form-control select2bs2"
<select id="tipo_impresion" name="tipo_impresion" class="form-control select2bs2"
style="width: 100%;" data-placeholder="<?= lang('Catalogo.seleccionarTipoImpresion') ?>">
<option></option>
<option value="negro" <?= ($catalogoLibrosEntity->tipo_impresion == 'negro') ? 'selected' : '' ?>>
@ -47,7 +47,7 @@
</div><!--//.col -->
<div class="col-md-12 col-lg-3">
<select id="encuadernacion" name="encuadernacion" class="form-control select2bs2 warning-change"
<select id="encuadernacion" name="encuadernacion_id" class="form-control select2bs2 warning-change"
style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->encuadernacion_id ?>" selected>
<?= $catalogoLibrosEntity->encuadernacionName ?>
@ -110,12 +110,12 @@
</p>
</div>
<div class="col-md-12 col-lg-1 px-4">
<input type="text" id="compPaginasNegro" name="comp_paginas_negro" placeholder="0" maxLength="5"
<input type="text" id="compPaginasNegro" name="negro_paginas" placeholder="0" maxLength="5"
class="form-control comp_negro_items"
value="<?= old('negro_paginas', $catalogoLibrosEntity->negro_paginas) ?>">
</div>
<div class="col-md-12 col-lg-3 px-4">
<select id="compPapelNegro" name="comp_papel_negro"
<select id="compPapelNegro" name="negro_papel_id"
class="form-control select2bs2 comp_negro_items" style="width: 100%;">
<?php if (!is_null($catalogoLibrosEntity->negroPapelName)): ?>
<option value="<?= $catalogoLibrosEntity->negro_papel_id ?>" selected>
@ -125,7 +125,7 @@
</select>
</div>
<div class="col-md-12 col-lg-2 px-4">
<select id="compGramajeNegro" name="comp_gramaje_negro"
<select id="compGramajeNegro" name="negro_gramaje"
class="form-control select2bs2 comp_negro_items" style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->negro_gramaje ?>" selected>
<?= $catalogoLibrosEntity->negro_gramaje ?>
@ -175,12 +175,12 @@
</p>
</div>
<div class="col-md-12 col-lg-1 px-4">
<input type="text" id="compPaginasColor" name="comp_paginas_color" placeholder="0" maxLength="5"
<input type="text" id="compPaginasColor" name="color_paginas" placeholder="0" maxLength="5"
class="form-control comp_color_items"
value="<?= old('negro_paginas', $catalogoLibrosEntity->color_paginas) ?>">
</div>
<div class="col-md-12 col-lg-3 px-4">
<select id="compPapelColor" name="comp_papel_color"
<select id="compPapelColor" name="color_papel_id"
class="form-control select2bs2 comp_color_items" style="width: 100%;">
<?php if (!is_null($catalogoLibrosEntity->colorPapelName)): ?>
<option value="<?= $catalogoLibrosEntity->color_papel_id ?>" selected>
@ -190,7 +190,7 @@
</select>
</div>
<div class="col-md-12 col-lg-2 px-4">
<select id="compGramajeColor" name="comp_gramaje_color"
<select id="compGramajeColor" name="color_gramaje"
class="form-control select2bs2 comp_color_items" style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->color_gramaje ?>" selected>
<?= $catalogoLibrosEntity->color_gramaje ?>
@ -240,7 +240,7 @@
</p>
</div>
<div class="col-md-12 col-lg-1 px-4">
<select id="compCarasCubierta" name="comp_paginas_cubierta"
<select id="compCarasCubierta" name="cubierta_paginas"
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
<option value="2" <?= $catalogoLibrosEntity->cubierta_paginas == 2 ? 'selected' : '' ?>>
<?= lang('Presupuestos.unaCara') ?>
@ -251,7 +251,7 @@
</select>
</div>
<div class="col-md-12 col-lg-3 px-4">
<select id="compPapelCubierta" name="comp_papel_cubierta"
<select id="compPapelCubierta" name="cubierta_papel_id"
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
<?php if (!is_null($catalogoLibrosEntity->cubiertaPapelName)): ?>
<option value="<?= $catalogoLibrosEntity->cubierta_papel_id ?>" selected>
@ -262,7 +262,7 @@
</div>
<div class="col-md-12 col-lg-2 px-4">
<select id="compGramajeCubierta" name="comp_gramaje_cubierta"
<select id="compGramajeCubierta" name="cubierta_gramaje"
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->cubierta_gramaje ?>" selected>
<?= $catalogoLibrosEntity->cubierta_gramaje ?>
@ -270,12 +270,12 @@
</select>
</div>
<div class="col-md-12 col-lg-2 px-4">
<input type="text" id="compSolapasCubierta" name="comp_solapas_cubierta" placeholder="0"
<input type="text" id="compSolapasCubierta" name="cubierta_solapas_ancho" placeholder="0"
maxLength="5" class="form-control comp_cubierta_items"
value="<?= old('cubierta_solapas_ancho', $catalogoLibrosEntity->cubierta_solapas_ancho) ?>">
</div>
<div class="col-md-12 col-lg-2 px-4">
<select id="compAcabadoCubierta" name="comp_acabado_cubierta"
<select id="compAcabadoCubierta" name="cubierta_acabado_id"
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->cubierta_acabado_id ?>" selected>
<?= $catalogoLibrosEntity->cubiertaAcabadoName ?>
@ -297,7 +297,7 @@
</p>
</div>
<div class="col-md-12 col-lg-1 px-4">
<select id="compSobrecubierta" name="comp_sobrecubierta" class="form-control select2bs2"
<select id="compSobrecubierta" name="sobrecubierta_paginas" class="form-control select2bs2"
style="width: 100%;">
<option value="0" <?= $catalogoLibrosEntity->sobrecubierta_paginas != 1 ? 'selected' : '' ?>>
<?= lang('Presupuestos.no') ?>
@ -308,7 +308,7 @@
</select>
</div>
<div class="col-md-12 col-lg-3 px-4">
<select disabled id="compPapelSobrecubierta" name="comp_papel_sobrecubierta"
<select disabled id="compPapelSobrecubierta" name="sobrecubierta_papel_id"
class="form-control select2bs2 comp_sobrecubierta_items" style="width: 100%;">
<?php if (!is_null($catalogoLibrosEntity->sobrecubiertaPapelName)): ?>
<option value="<?= $catalogoLibrosEntity->sobrecubierta_papel_id ?>" selected>
@ -319,7 +319,7 @@
</select>
</div>
<div class="col-md-12 col-lg-2 px-4">
<select disabled id="compGramajeSobrecubierta" name="comp_gramaje_sobrecubierta"
<select disabled id="compGramajeSobrecubierta" name="sobrecubierta_gramaje"
class="form-control select2bs2 comp_sobrecubierta_items" style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->sobrecubierta_gramaje ?>" selected>
<?= $catalogoLibrosEntity->sobrecubierta_gramaje ?>
@ -327,12 +327,12 @@
</select>
</div>
<div class="col-md-12 col-lg-2 px-4">
<input disabled type="text" id="compSolapasSobrecubierta" name="comp_solapas_sobrecubierta"
<input disabled type="text" id="compSolapasSobrecubierta" name="sobrecubierta_solapas_ancho"
placeholder="0" maxLength="5" class="form-control comp_sobrecubierta_items"
value="<?= old('cubierta_solapas_ancho', $catalogoLibrosEntity->sobrecubierta_solapas_ancho) ?>">
</div>
<div class="col-md-12 col-lg-2 px-4">
<select disabled id="compAcabadoSobrecubierta" name="comp_acabado_sobrecubierta"
<select disabled id="compAcabadoSobrecubierta" name="sobrecubierta_acabado_id"
class="form-control select2bs2 comp_sobrecubierta_items" style="width: 100%;">
<option value="<?= $catalogoLibrosEntity->sobrecubierta_acabado_id ?>" selected>
<?= $catalogoLibrosEntity->sobrecubiertaAcabadoName ?>
@ -345,19 +345,6 @@
</div>
<?php endif; ?>
<!--------------------------------------CAACACACA>CA--------------------------------------->
<div class="row mb-3">
</div>
</div>
</div>
</div>

View File

@ -32,8 +32,8 @@
<div class="col-md-12 col-lg-10 px-4">
<div class="row">
<div class="col-md-4 mb-3">
<label for="clienteId" class="form-label">Cliente</label>
<select id="clienteId" name="clienteId" class="form-select select2bs5">
<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>
@ -41,7 +41,7 @@
</div>
<div class="col-md-8 mb-3">
<label for="titulo" class="form-label">Título</label>
<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">
@ -73,12 +73,13 @@
<div class="col-md-3 mb-3">
<label for="isk" class="form-label">Identificador ISK</label>
<input type="text" id="isk" name="isk" class="form-control"
value="<?= old('isk', $catalogoLibrosEntity->isk) ?>" maxlength="64">
<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>
<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>
@ -102,19 +103,19 @@
</div>
<div class="col-md-3 mb-3">
<label for="ancho" class="form-label">Ancho</label>
<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>
<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>
<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>

View File

@ -10,7 +10,7 @@
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="paisForm" class="card-body" method="post" action="<?= $formAction ?>">
<form id="catalogoLibroForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<!-- card-body -->
<div class="card-body">

View File

@ -8,8 +8,8 @@ class Catalogo {
this.tirada_no_pod = 100;
this.tirada_pod = 1;
this.cliente = new ClassSelect($("#clienteId"), '/catalogo/libros/clientlist', "Seleccione un cliente");
this.tipo_impresion = $("#tipoImpresion");
this.cliente = new ClassSelect($("#cliente_id"), '/catalogo/libros/clientlist', "Seleccione un cliente");
this.tipo_impresion = $("#tipo_impresion");
this.caras_cubierta = $("#compCarasCubierta");
this.encuadernacion = new ClassSelect($("#encuadernacion"), '/importador/getencuadernacion', "Seleccione una encuadernación");

View File

@ -93,7 +93,7 @@ document.addEventListener('DOMContentLoaded', function () {
},
(error) => {
console.error(error);
Swal.fire('Error', 'No se pudo eliminar el país.', 'error');
Swal.fire('Error', 'No se pudo eliminar el libro.', 'error');
}
).get();
}