Passed
Push — master ( d131f6...dda4d9 )
by Joe Nilson
03:14
created

FiscalReports::disableButtons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
/*
3
 * Copyright (C) 2019 joenilson.
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 3 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA 02110-1301  USA
19
 */
20
21
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Controller;
22
23
use FacturaScripts\Core\DataSrc\Almacenes;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\DataSrc\Almacenes was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use FacturaScripts\Core\Lib\ExtendedController\ListController;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Lib\...ntroller\ListController was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use FacturaScripts\Dinamic\Model\LineaFacturaCliente;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\LineaFacturaCliente was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
/**
28
 * Description of FiscalReports
29
 *
30
 * @author joenilson
31
 */
32
class FiscalReports extends ListController
33
{
34
    /**
35
     * @return array
36
     */
37
    public function getPageData(): array
38
    {
39
        $data = parent::getPageData();
40
        $data['menu'] = 'reports';
41
        $data['submenu'] = 'dominican-republic';
42
        $data['icon'] = 'fas fa-hand-holding-usd';
43
        $data['title'] = 'rd-fiscal-reports';
44
        return $data;
45
    }
46
47
    protected function createViews(): void
48
    {
49
        // needed dependencies
50
        new LineaFacturaCliente();
51
52
        $this->createViewsFiscalReportsConsolidated();
53
        $this->createViewsFiscalReports606();
54
        $this->createViewsFiscalReports607();
55
        $this->createViewsFiscalReports608();
56
    }
57
58
    /**
59
     * @param string $viewName
60
     */
61
    protected function createViewsFiscalReportsConsolidated(string $viewName = 'FiscalReports-consolidated')
62
    {
63
        $this->addView(
64
            $viewName,
65
            'Join\FiscalReports',
66
            'rd-fiscal-reports-consolidated',
67
            'fas fa-shipping-fast'
68
        );
69
        $this->addOrderBy($viewName, ['ncf'], 'ncf');
70
        $this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
71
        $this->addCommonFilters($viewName);
72
        $this->disableButtons($viewName);
73
    }
74
75
    /**
76
     * @param string $viewName
77
     */
78
    protected function createViewsFiscalReports608(string $viewName = 'FiscalReports-606')
79
    {
80
        $this->addView($viewName,
81
            'Join\FiscalReports',
82
            'rd-fiscal-reports-606',
83
            'fas fa-shopping-cart');
84
        //$this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
85
        $this->addCommonFilters($viewName);
86
        $this->disableButtons($viewName);
87
    }
88
89
    /**
90
     * @param string $viewName
91
     */
92
    protected function createViewsFiscalReports607(string $viewName = 'FiscalReports-607')
93
    {
94
        $this->addView($viewName, 'Join\FiscalReports', 'rd-fiscal-reports-607', 'fas fa-copy');
95
        //$this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
96
        $this->addCommonFilters($viewName);
97
        $this->disableButtons($viewName);
98
    }
99
100
    /**
101
     * @param string $viewName
102
     */
103
    protected function createViewsFiscalReports606(string $viewName = 'FiscalReports-608')
104
    {
105
        $this->addView($viewName, 'Join\FiscalReports', 'rd-fiscal-reports-608', 'fas fa-copy');
106
        //$this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
107
        $this->addCommonFilters($viewName);
108
        $this->disableButtons($viewName);
109
    }
110
111
    /**
112
     * @param string $viewName
113
     */
114
    private function addCommonFilters(string $viewName)
115
    {
116
        $warehouses = Almacenes::codeModel();
117
        if (count($warehouses) > 2) {
118
            $this->addFilterSelect($viewName, 'codalmacen', 'warehouse', 'codalmacen', $warehouses);
119
        } else {
120
            $this->views[$viewName]->disableColumn('warehouse');
121
        }
122
    }
123
124
    /**
125
     * @param string $viewName
126
     */
127
    private function disableButtons(string $viewName)
128
    {
129
        $this->setSettings($viewName, 'btnDelete', false);
130
        $this->setSettings($viewName, 'btnNew', false);
131
        $this->setSettings($viewName, 'checkBoxes', false);
132
        $this->setSettings($viewName, 'clickable', false);
133
    }
134
}
135