|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * This file is part of Servicios plugin for FacturaScripts |
4 | | - * Copyright (C) 2020-2024 Carlos Garcia Gomez <carlos@facturascripts.com> |
| 4 | + * Copyright (C) 2020-2026 Carlos Garcia Gomez <carlos@facturascripts.com> |
5 | 5 | * |
6 | 6 | * This program is free software: you can redistribute it and/or modify |
7 | 7 | * it under the terms of the GNU Lesser General Public License as |
|
26 | 26 | use FacturaScripts\Core\Tools; |
27 | 27 | use FacturaScripts\Core\Where; |
28 | 28 | use FacturaScripts\Dinamic\Lib\ServiceToInvoice; |
| 29 | +use FacturaScripts\Dinamic\Model\CategoriaAT; |
29 | 30 | use FacturaScripts\Dinamic\Model\ServicioAT; |
30 | 31 | use FacturaScripts\Dinamic\Model\TipoAT; |
31 | 32 | use FacturaScripts\Dinamic\Model\TrabajoAT; |
@@ -113,6 +114,11 @@ protected function createViews() |
113 | 114 | */ |
114 | 115 | protected function createViewsCategories(string $viewName = 'EditServicioCategoriaAT'): void |
115 | 116 | { |
| 117 | + $category = new CategoriaAT(); |
| 118 | + if ($category->count() === 0) { |
| 119 | + return; |
| 120 | + } |
| 121 | + |
116 | 122 | $this->addEditListView($viewName, 'ServicioCategoriaAT', 'categories', 'fa-solid fa-tags') |
117 | 123 | ->setInLine(true); |
118 | 124 | } |
@@ -197,7 +203,7 @@ protected function createViewsInvoices(string $viewName = 'ListFacturaCliente'): |
197 | 203 | 'label' => 'make-invoice' |
198 | 204 | ]); |
199 | 205 | } |
200 | | - |
| 206 | + |
201 | 207 | public function createViewLogs(string $viewName = 'ListServicioATLog'): void |
202 | 208 | { |
203 | 209 | $this->addListView($viewName, 'ServicioATLog', 'history', 'fa-solid fa-history') |
@@ -340,6 +346,7 @@ protected function loadData($viewName, $view) |
340 | 346 | $view->loadData('', $where); |
341 | 347 | // Remove checks if the service has no categories and checks. |
342 | 348 | if ($viewName === 'EditServicioCheckAT' |
| 349 | + && isset($this->views['EditServicioCategoriaAT']) |
343 | 350 | && $this->views['EditServicioCategoriaAT']->count === 0 |
344 | 351 | && $this->views['EditServicioCheckAT']->count === 0 |
345 | 352 | ) { |
|
0 commit comments