Passed
Push — master ( eee053...2b5061 )
by Joe Nilson
04:47
created

EditFacturaProveedor::createViews()   B

Complexity

Conditions 7
Paths 1

Size

Total Lines 40
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 31
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 40
rs 8.4906
1
<?php
2
/*
3
 * Copyright (C) 2021 Joe Nilson <[email protected]>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as
7
 * published by the Free Software Foundation, either version 3 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program 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
13
 * GNU Lesser General Public License for more details.
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Extension\Controller;
19
20
use FacturaScripts\Dinamic\Lib\AssetManager;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Lib\AssetManager 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...
21
use FacturaScripts\Dinamic\Model\NCFTipo;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipo 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...
22
use FacturaScripts\Dinamic\Model\NCFTipoAnulacion;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipoAnulacion 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...
23
use FacturaScripts\Dinamic\Model\NCFTipoPago;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipoPago 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\Dinamic\Model\NCFTipoMovimiento;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\NCFTipoMovimiento 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
26
class EditFacturaProveedor
27
{
28
    public function createViews(): \Closure
29
    {
30
        return function () {
31
            parent::createViews();
32
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonModals.js');
0 ignored issues
show
Bug introduced by
The constant FS_ROUTE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.js');
34
            $ncfTipoPago = new NCFTipoPago();
35
            $ncfTiposPago = $ncfTipoPago->findAllByTipopago('02');
36
            $customValuesNTP = [];
37
            $customValuesNTP[] = ['value' => '', 'title' => '-----------'];
38
            foreach ($ncfTiposPago as $tipopago) {
39
                $customValuesNTP[] = ['value' => $tipopago->codigo, 'title' => $tipopago->descripcion];
40
            }
41
            $columnToModifyNTP = $this->views['EditFacturaProveedor']->columnForName('ncf-payment-type');
0 ignored issues
show
Bug Best Practice introduced by
The property views does not exist on FacturaScripts\Plugins\f...er\EditFacturaProveedor. Did you maybe forget to declare it?
Loading history...
42
            if ($columnToModifyNTP) {
43
                $columnToModifyNTP->widget->setValuesFromArray($customValuesNTP);
44
            }
45
46
            $ncfTipoAnulacion = new NCFTipoAnulacion();
47
            $ncfTiposAnulacion = $ncfTipoAnulacion->all();
48
            $customValuesNTA = [];
49
            $customValuesNTA[] = ['value' => '', 'title' => '-----------'];
50
            foreach ($ncfTiposAnulacion as $tipoanulacion) {
51
                $customValuesNTA[] = ['value' => $tipoanulacion->codigo, 'title' => $tipoanulacion->descripcion];
52
            }
53
            $columnToModifyNTA1 = $this->views['EditFacturaProveedor']->columnForName('ncf-cancellation-type');
54
            if ($columnToModifyNTA1) {
55
                $columnToModifyNTA1->widget->setValuesFromArray($customValuesNTA);
56
            }
57
58
            $ncfTipoMovimiento = new NCFTipoMovimiento();
59
            $ncfTiposMovimiento = $ncfTipoMovimiento->findAllByTipomovimiento('COM');
60
            $customValuesNTM = [];
61
            $customValuesNTM[] = ['value' => '', 'title' => '-----------'];
62
            foreach ($ncfTiposMovimiento as $tipomovimiento) {
63
                $customValuesNTM[] = ['value' => $tipomovimiento->codigo, 'title' => $tipomovimiento->descripcion];
64
            }
65
            $columnToModifyNTM = $this->views['EditFacturaProveedor']->columnForName('ncf-movement-type');
66
            if ($columnToModifyNTM) {
67
                $columnToModifyNTM->widget->setValuesFromArray($customValuesNTM);
68
            }
69
        };
70
    }
71
}