diff --git a/ci4/app/Controllers/Catalogo/CatalogoLibros.php b/ci4/app/Controllers/Catalogo/CatalogoLibros.php index b495f614..6cf4aec0 100644 --- a/ci4/app/Controllers/Catalogo/CatalogoLibros.php +++ b/ci4/app/Controllers/Catalogo/CatalogoLibros.php @@ -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']); - } - } diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 372d2da8..f7ccf76f 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -30,7 +30,7 @@ class Test extends BaseController } - public function index() + private function index() { $modelCL = new CatalogoLibroModel(); diff --git a/ci4/app/Entities/Catalogo/CatalogoLibroEntity.php b/ci4/app/Entities/Catalogo/CatalogoLibroEntity.php index 25a166cb..43d5a681 100644 --- a/ci4/app/Entities/Catalogo/CatalogoLibroEntity.php +++ b/ci4/app/Entities/Catalogo/CatalogoLibroEntity.php @@ -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() { diff --git a/ci4/app/Language/en/Validation.php b/ci4/app/Language/en/Validation.php index 54d1e7a4..0a833889 100755 --- a/ci4/app/Language/en/Validation.php +++ b/ci4/app/Language/en/Validation.php @@ -1,4 +1,59 @@ '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.', +]; diff --git a/ci4/app/Language/es/Catalogo.php b/ci4/app/Language/es/Catalogo.php index feb14e0b..cc6ae34e 100644 --- a/ci4/app/Language/es/Catalogo.php +++ b/ci4/app/Language/es/Catalogo.php @@ -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:', ]; diff --git a/ci4/app/Language/es/Validation.php b/ci4/app/Language/es/Validation.php index 54d1e7a4..ccea2d89 100755 --- a/ci4/app/Language/es/Validation.php +++ b/ci4/app/Language/es/Validation.php @@ -1,4 +1,61 @@ '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.', + +]; diff --git a/ci4/app/Models/Catalogo/CatalogoLibroModel.php b/ci4/app/Models/Catalogo/CatalogoLibroModel.php index af6b152a..78f3f119 100644 --- a/ci4/app/Models/Catalogo/CatalogoLibroModel.php +++ b/ci4/app/Models/Catalogo/CatalogoLibroModel.php @@ -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; } diff --git a/ci4/app/Views/themes/vuexy/form/catalogo/_configuracionLibroFormItems.php b/ci4/app/Views/themes/vuexy/form/catalogo/_configuracionLibroFormItems.php index 1b150622..e6f003db 100644 --- a/ci4/app/Views/themes/vuexy/form/catalogo/_configuracionLibroFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/catalogo/_configuracionLibroFormItems.php @@ -28,7 +28,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
- + + @@ -73,12 +73,13 @@
- +
- +
@@ -102,19 +103,19 @@
- +
- +
- +
diff --git a/ci4/app/Views/themes/vuexy/form/catalogo/viewCatalogoLibrosForm.php b/ci4/app/Views/themes/vuexy/form/catalogo/viewCatalogoLibrosForm.php index 8a2e4e3a..74b01fa2 100644 --- a/ci4/app/Views/themes/vuexy/form/catalogo/viewCatalogoLibrosForm.php +++ b/ci4/app/Views/themes/vuexy/form/catalogo/viewCatalogoLibrosForm.php @@ -10,7 +10,7 @@

-
+
diff --git a/httpdocs/assets/js/safekat/pages/catalogo/catalogo.js b/httpdocs/assets/js/safekat/pages/catalogo/catalogo.js index 27619de4..297dc533 100644 --- a/httpdocs/assets/js/safekat/pages/catalogo/catalogo.js +++ b/httpdocs/assets/js/safekat/pages/catalogo/catalogo.js @@ -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"); diff --git a/httpdocs/assets/js/safekat/pages/catalogo/list.js b/httpdocs/assets/js/safekat/pages/catalogo/list.js index 1aee8162..d8c718e5 100644 --- a/httpdocs/assets/js/safekat/pages/catalogo/list.js +++ b/httpdocs/assets/js/safekat/pages/catalogo/list.js @@ -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(); }