Completed
Push — master ( 8ee8e5...542744 )
by Joe Nilson
03:39 queued 03:39
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\Base\DataBase\DataBaseWhere;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\DataBase\DataBaseWhere 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\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...
25
use FacturaScripts\Core\Lib\ExtendedController\BaseView;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Lib\...ndedController\BaseView 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
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...
27
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...
28
29
/**
30
 * Description of FiscalReports
31
 *
32
 * @author joenilson
33
 */
34
class FiscalReports extends ListController
35
{
36
    /**
37
     * @return array
38
     */
39
    public function getPageData(): array
40
    {
41
        $data = parent::getPageData();
42
        $data['menu'] = 'reports';
43
        $data['submenu'] = 'dominican-republic';
44
        $data['icon'] = 'fas fa-hand-holding-usd';
45
        $data['title'] = 'rd-fiscal-reports';
46
        return $data;
47
    }
48
49
    protected function createViews(): void
50
    {
51
        // needed dependencies
52
        new LineaFacturaCliente();
53
54
        $this->createViewsFiscalReportsConsolidated();
55
        $this->createViewsFiscalReports606();
56
        $this->createViewsFiscalReports607();
57
        $this->createViewsFiscalReports608();
58
    }
59
60
    /**
61
     * @param string $viewName
62
     */
63
    protected function createViewsFiscalReportsConsolidated(string $viewName = 'FiscalReports-consolidated')
64
    {
65
        $this->addView(
66
            $viewName,
67
            'Join\FiscalReports',
68
            'rd-fiscal-reports-consolidated',
69
            'fas fa-shipping-fast'
70
        );
71
        $this->addOrderBy($viewName, ['ncf'], 'ncf');
72
        $this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
73
        $this->addCommonSearchFields($viewName);
74
        $this->disableButtons($viewName);
75
    }
76
77
    /**
78
     * @param string $viewName
79
     */
80
    protected function createViewsFiscalReports608(string $viewName = 'FiscalReport608')
81
    {
82
        $this->addView($viewName,
83
            'Join\FiscalReport608',
84
            'rd-fiscal-reports-608',
85
            'fas fa-shopping-cart');
86
        $this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
87
        $this->addCommonSearchFields($viewName);
88
        $this->disableButtons($viewName);
89
    }
90
91
    /**
92
     * @param string $viewName
93
     */
94
    protected function createViewsFiscalReports607(string $viewName = 'FiscalReport607')
95
    {
96
        $this->addView($viewName, 'Join\FiscalReport607', 'rd-fiscal-reports-607', 'fas fa-copy');
97
        $this->addFilterPeriod($viewName, 'fecha', 'date', 'facturascli.fecha');
98
        $this->addCommonSearchFields($viewName);
99
        $this->disableButtons($viewName);
100
    }
101
102
    /**
103
     * @param string $viewName
104
     */
105
    protected function createViewsFiscalReports606(string $viewName = 'FiscalReport606')
106
    {
107
        $this->addView($viewName, 'Join\FiscalReport606', 'rd-fiscal-reports-606', 'fas fa-copy');
108
        $this->addFilterPeriod($viewName, 'fecha', 'date', 'facturasprov.fecha');
109
        $this->addSearchFields($viewName, ['numero2', 'cifnif', 'fecha', 'estado'], 'fecha');
110
        $this->addOrderBy($viewName, ['facturasprov.fecha'], 'fecha');
111
        $this->addOrderBy($viewName, ['facturasprov.numproveedor'], 'ncf');
112
        $this->addOrderBy($viewName, ['cifnif'], 'cifnif');
113
        $this->disableButtons($viewName);
114
    }
115
116
    /**
117
     * @param string $viewName
118
     */
119
    private function addCommonSearchFields(string $viewName)
120
    {
121
        $this->addSearchFields($viewName, ['numero2', 'cifnif', 'fecha', 'estado'], 'fecha');
122
        $this->addOrderBy($viewName, ['facturascli.fecha'], 'fecha');
123
        $this->addOrderBy($viewName, ['facturascli.numero2'], 'ncf');
124
        $this->addOrderBy($viewName, ['cifnif'], 'cifnif');
125
    }
126
127
    /**
128
     * @param string $viewName
129
     */
130
    private function disableButtons(string $viewName)
131
    {
132
        $this->setSettings($viewName, 'btnDelete', false);
133
        $this->setSettings($viewName, 'btnNew', false);
134
        $this->setSettings($viewName, 'checkBoxes', false);
135
        $this->setSettings($viewName, 'clickable', false);
136
    }
137
138
    /**
139
     *
140
     * @param string   $viewName
141
     * @param BaseView $view
142
     */
143
//    protected function loadData($viewName, $view)
144
//    {
145
//        $startDate = \date('Y-m-01');
146
//        $endDate = \date('Y-m-d');
147
//        switch ($viewName) {
148
//            case 'FiscalReport606':
149
//                $where = [
150
//                    new DataBaseWhere('facturasprov.fecha', $startDate, '>='),
151
//                    new DataBaseWhere('facturasprov.fecha', $endDate, '<='),
152
//                ];
153
//                $view->loadData('', $where);
154
//                break;
155
//            case 'FiscalReport607':
156
//            case 'FiscalReport608':
157
//            case 'FiscalReports-consolidated':
158
//                $where = [
159
//                    new DataBaseWhere('facturascli.fecha', $startDate, '>='),
160
//                    new DataBaseWhere('facturascli.fecha', $endDate, '<='),
161
//                ];
162
//                $view->loadData('', $where);
163
//                break;
164
//            default:
165
//                parent::loadData($viewName, $view);
166
//                break;
167
//        }
168
//    }
169
}
170