Skip to content

Commit 43eca13

Browse files
refactor: hide CategoriaAT tab, when no category exists.
1 parent db31abf commit 43eca13

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Controller/EditServicioAT.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* 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>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as
@@ -26,6 +26,7 @@
2626
use FacturaScripts\Core\Tools;
2727
use FacturaScripts\Core\Where;
2828
use FacturaScripts\Dinamic\Lib\ServiceToInvoice;
29+
use FacturaScripts\Dinamic\Model\CategoriaAT;
2930
use FacturaScripts\Dinamic\Model\ServicioAT;
3031
use FacturaScripts\Dinamic\Model\TipoAT;
3132
use FacturaScripts\Dinamic\Model\TrabajoAT;
@@ -113,6 +114,11 @@ protected function createViews()
113114
*/
114115
protected function createViewsCategories(string $viewName = 'EditServicioCategoriaAT'): void
115116
{
117+
$category = new CategoriaAT();
118+
if ($category->count() === 0) {
119+
return;
120+
}
121+
116122
$this->addEditListView($viewName, 'ServicioCategoriaAT', 'categories', 'fa-solid fa-tags')
117123
->setInLine(true);
118124
}
@@ -197,7 +203,7 @@ protected function createViewsInvoices(string $viewName = 'ListFacturaCliente'):
197203
'label' => 'make-invoice'
198204
]);
199205
}
200-
206+
201207
public function createViewLogs(string $viewName = 'ListServicioATLog'): void
202208
{
203209
$this->addListView($viewName, 'ServicioATLog', 'history', 'fa-solid fa-history')
@@ -340,6 +346,7 @@ protected function loadData($viewName, $view)
340346
$view->loadData('', $where);
341347
// Remove checks if the service has no categories and checks.
342348
if ($viewName === 'EditServicioCheckAT'
349+
&& isset($this->views['EditServicioCategoriaAT'])
343350
&& $this->views['EditServicioCategoriaAT']->count === 0
344351
&& $this->views['EditServicioCheckAT']->count === 0
345352
) {

0 commit comments

Comments
 (0)