problema ruta papelformato

This commit is contained in:
2024-10-14 18:19:41 +02:00
parent 52303e9185
commit 668d0d79e6
5 changed files with 41 additions and 16 deletions

View File

@ -8,6 +8,7 @@ use CodeIgniter\Router\RouteCollection;
//service('auth')->routes($routes, ['except' => ['login', 'register']]); //service('auth')->routes($routes, ['except' => ['login', 'register']]);
service('auth')->routes($routes); service('auth')->routes($routes);
//WEB ROUTER ------------------------------------------------------ //WEB ROUTER ------------------------------------------------------
//------------------------------------------------------------------ //------------------------------------------------------------------
$routes->get('/', 'Home::index', ['as' => 'home']); $routes->get('/', 'Home::index', ['as' => 'home']);
@ -730,6 +731,7 @@ $routes->resource('buscadorpresupuestos', ['namespace' => 'App\Controllers\Presu
$routes->group('papel-formato', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->group('papel-formato', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->post('menuitems', 'Papelformato::menuitems', ['as' => 'menuitems']); $routes->post('menuitems', 'Papelformato::menuitems', ['as' => 'menuitems']);
$routes->get('getSelect2', 'Papelformato::getSelect2', ['as' => 'getSelect2']);
} }
); );
$routes->resource('papel-formato', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelformato', 'except' => 'show,new,create,update']); $routes->resource('papel-formato', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelformato', 'except' => 'show,new,create,update']);

View File

@ -1,4 +1,6 @@
<?php namespace App\Controllers\Clientes; <?php
namespace App\Controllers\Clientes;
@ -310,10 +312,9 @@ class Cliente extends \App\Controllers\BaseResourceController
$onlyActiveOnes = false; $onlyActiveOnes = false;
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
$onlyActiveOnes = false; $onlyActiveOnes = false;
try{ try {
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
} } catch (Exception $e) {
catch(Exception $e){
$menu = []; $menu = [];
} }
@ -339,7 +340,6 @@ class Cliente extends \App\Controllers\BaseResourceController
"nombre as name" "nombre as name"
] ]
)->where("deleted_at", null); )->where("deleted_at", null);
if ($this->request->getGet("q")) { if ($this->request->getGet("q")) {
$query->groupStart() $query->groupStart()
->orLike("clientes.nombre", $this->request->getGet("q")) ->orLike("clientes.nombre", $this->request->getGet("q"))
@ -347,7 +347,6 @@ class Cliente extends \App\Controllers\BaseResourceController
} }
return $this->response->setJSON($query->get()->getResultObject()); return $this->response->setJSON($query->get()->getResultObject());
// return $this->respond($menu);
} else { } else {
return $this->failUnauthorized('Invalid request', 403); return $this->failUnauthorized('Invalid request', 403);
} }
@ -447,24 +446,23 @@ class Cliente extends \App\Controllers\BaseResourceController
} }
protected function getPrecioTemplate($cliente_id){ protected function getPrecioTemplate($cliente_id)
{
$modelPreciosCliente = model('App\Models\Clientes\ClientePreciosModel'); $modelPreciosCliente = model('App\Models\Clientes\ClientePreciosModel');
$plantilla_id = $modelPreciosCliente->get_plantilla_precios($cliente_id); $plantilla_id = $modelPreciosCliente->get_plantilla_precios($cliente_id);
if (is_null($plantilla_id)){ if (is_null($plantilla_id)) {
return null; return null;
} }
$modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel'); $modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel');
$plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first(); $plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first();
if ($plantilla == false){ if ($plantilla == false) {
return null; return null;
} } else {
else{
return (object)array( return (object)array(
"value" => $plantilla_id, "value" => $plantilla_id,
"label" => $plantilla->nombre "label" => $plantilla->nombre
); );
} }
} }
} }

View File

@ -260,4 +260,25 @@ class Papelformato extends \App\Controllers\BaseResourceController {
} }
} }
public function getSelect2()
{
if ($this->request->isAJAX()) {
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("clientes.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
} }

View File

@ -18,7 +18,11 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param
return this.url; return this.url;
}, },
data: (params) => { data: (params) => {
let d = $.trim(params.term); let q = $.trim(params.term);
let d = {
q: q,
page: params.page || 1,
};
for (let key in this.params) { for (let key in this.params) {
d[key] = this.params[key]; d[key] = this.params[key];

View File

@ -9,7 +9,7 @@ class DatosGenerales {
this.wizardStep = wizardForm.querySelector('#datos-generales'); this.wizardStep = wizardForm.querySelector('#datos-generales');
this.validatorStepper = validatorStepper; this.validatorStepper = validatorStepper;
this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/menuitems', window.translations["formatoLibro"]); this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.translations["formatoLibro"]);
this.cliente = new ClassSelect($("#clienteId"), '/clientes/cliente/getSelect2', window.translations["selectCliente"]); this.cliente = new ClassSelect($("#clienteId"), '/clientes/cliente/getSelect2', window.translations["selectCliente"]);
this.titulo = this.domItem.find("#titulo"); this.titulo = this.domItem.find("#titulo");