From b274c9e105846aa4e668104dcb864b04c000921c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez=20Mart=C3=ADnez?= Date: Fri, 17 Apr 2026 17:40:20 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=20Pesta=C3=B1a=20Proyectos=20cerrados=20a?= =?UTF-8?q?=C3=B1adida=20a=20Listproyect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/ListProyecto.php | 59 ++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/Controller/ListProyecto.php b/Controller/ListProyecto.php index 31b753e..b6f3b09 100644 --- a/Controller/ListProyecto.php +++ b/Controller/ListProyecto.php @@ -19,7 +19,7 @@ namespace FacturaScripts\Plugins\Proyectos\Controller; -use FacturaScripts\Core\Base\DataBase\DataBaseWhere; +use FacturaScripts\Core\Where; use FacturaScripts\Core\Lib\ExtendedController\ListController; use FacturaScripts\Core\Lib\ExtendedController\ListView; use FacturaScripts\Core\Tools; @@ -45,6 +45,7 @@ protected function createViews() { $this->createViewsProjects('ListProyecto', 'projects', 'fa-brands fa-stack-overflow'); $this->createViewsProjects('ListProyecto-private', 'private', 'fa-solid fa-unlock-alt'); + $this->createViewsProjectsClosed('Listproyecto-closed', 'projects', 'fa-solid fa-lock'); } protected function createViewsProjects(string $viewName, string $label, string $icon): void @@ -61,12 +62,12 @@ protected function createViewsProjects(string $viewName, string $label, string $ // filtros $users = $this->codeModel->all('users', 'nick', 'nick'); $where = [ - ['label' => Tools::lang()->trans('only-active'), 'where' => [new DataBaseWhere('editable', true)]], - ['label' => Tools::lang()->trans('only-closed'), 'where' => [new DataBaseWhere('editable', false)]], + ['label' => Tools::lang()->trans('only-active'), 'where' => [Where::column('editable', true)]], + ['label' => Tools::lang()->trans('only-closed'), 'where' => [Where::column('editable', false)]], ['label' => Tools::lang()->trans('all'), 'where' => []] ]; foreach ($this->codeModel->all('proyectos_estados', 'idestado', 'nombre') as $status) { - $where[] = ['label' => $status->description, 'where' => [new DataBaseWhere('idestado', $status->code)]]; + $where[] = ['label' => ($status->description ?? $status->nombre), 'where' => [Where::column('idestado', $status->code)]]; } $this->listView($viewName) @@ -95,8 +96,8 @@ protected function loadData($viewName, $view) break; } $where = [ - new DataBaseWhere('idempresa', $this->user->idempresa), - new DataBaseWhere('privado', false) + Where::column('idempresa', $this->user->idempresa), + Where::column('privado', false) ]; $view->loadData('', $where); break; @@ -105,8 +106,21 @@ protected function loadData($viewName, $view) $sql = 'SELECT idproyecto FROM proyectos WHERE nick = ' . $this->dataBase->var2str($this->user->nick) . ' UNION SELECT idproyecto FROM proyectos_users WHERE nick = ' . $this->dataBase->var2str($this->user->nick); $where = [ - new DataBaseWhere('privado', true), - new DataBaseWhere('idproyecto', $sql, 'IN') + Where::column('privado', true), + Where::in('idproyecto', $sql) + ]; + $view->loadData('', $where); + break; + + case 'Listproyecto-closed': + if ($this->user->admin) { + $view->loadData(); + break; + } + $where = [ + Where::column('idempresa', $this->user->idempresa), + Where::column('privado', false), + Where::column('editable', false), ]; $view->loadData('', $where); break; @@ -134,4 +148,33 @@ protected function setProjectColors(string $viewName): void ]; } } + + protected function createViewsProjectsClosed(string $viewName, string $label, string $icon): void + { + $this->addView($viewName, 'Proyecto', $label, $icon) + ->addOrderBy(['fecha', 'idproyecto'], 'date', 2) + ->addOrderBy(['fechainicio'], 'start-date') + ->addOrderBy(['fechafin'], 'end-date') + ->addOrderBy(['nombre'], 'name') + ->addOrderBy(['totalcompras'], 'total-purchases') + ->addOrderBy(['totalventas'], 'total-sales') + ->addSearchFields(['nombre', 'descripcion']); + // sólo estados no editables + $where = [ + ['label' => Tools::lang()->trans('only-closed'), 'where' => [Where::column('editable', false)]], + ['label' => '------', 'where' => [Where::column('editable', false)]], + ]; + + foreach (EstadoProyecto::all([], [], 0, 0) as $estado) { + if (false === $estado->editable) { + $where[] = [ + 'label' => $estado->nombre, + 'where' => [Where::column('idestado', $estado->idestado)] + ]; + } + } + + $this->listView($viewName)->addFilterSelectWhere('status', $where); + $this->setProjectColors($viewName); + } } From 3c1b94cc21f2700e40cc02d2db800823a542b991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez=20Mart=C3=ADnez?= Date: Fri, 17 Apr 2026 17:49:01 +0200 Subject: [PATCH 2/2] =?UTF-8?q?cambiado=20el=20nombre=20de=20la=20pesta?= =?UTF-8?q?=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/ListProyecto.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ListProyecto.php b/Controller/ListProyecto.php index b6f3b09..4fdf8ca 100644 --- a/Controller/ListProyecto.php +++ b/Controller/ListProyecto.php @@ -45,7 +45,7 @@ protected function createViews() { $this->createViewsProjects('ListProyecto', 'projects', 'fa-brands fa-stack-overflow'); $this->createViewsProjects('ListProyecto-private', 'private', 'fa-solid fa-unlock-alt'); - $this->createViewsProjectsClosed('Listproyecto-closed', 'projects', 'fa-solid fa-lock'); + $this->createViewsProjectsClosed('Listproyecto-closed', 'closed', 'fa-solid fa-lock'); } protected function createViewsProjects(string $viewName, string $label, string $icon): void