Passed
Push — master ( 9c95d4...eee053 )
by Joe Nilson
03:19
created

EditFacturaCliente   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
c 1
b 0
f 0
dl 0
loc 51
rs 10
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B createViews() 0 49 7
1
<?php
2
/*
3
 * Copyright (C) 2020 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\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...
21
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...
22
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...
23
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...
24
25
class EditFacturaCliente
26
{
27
    public function createViews()
28
    {
29
        return function () {
30
//            $ncfTipo = new NCFTipo();
31
//            $ncfTipos = $ncfTipo->allFor('ventas', 'suma');
32
//            $customValues = [];
33
//            $customValues[] = ['value'=>'', 'title'=>'-----------'];
34
//            foreach($ncfTipos as $tipo) {
35
//                $customValues[] = ['value'=>$tipo->tipocomprobante, 'title'=>$tipo->descripcion];
36
//            }
37
//            $columnToModify = $this->views['EditFacturaCliente']->columnForName('codsubtipodoc');
38
//            if($columnToModify) {
39
//                $columnToModify->widget->setValuesFromArray($customValues);
40
//            }
41
42
            $ncfTipoPago = new NCFTipoPago();
43
            $ncfTiposPago = $ncfTipoPago->findAllByTipopago('01');
44
            $customValuesNTP = [];
45
            $customValuesNTP[] = ['value'=>'', 'title'=>'-----------'];
46
            foreach($ncfTiposPago as $tipopago) {
47
                $customValuesNTP[] = ['value'=>$tipopago->codigo, 'title'=>$tipopago->descripcion];
48
            }
49
            $columnToModifyNTP = $this->views['EditFacturaCliente']->columnForName('ncf-payment-type');
0 ignored issues
show
Bug Best Practice introduced by
The property views does not exist on FacturaScripts\Plugins\f...ller\EditFacturaCliente. Did you maybe forget to declare it?
Loading history...
50
            if($columnToModifyNTP) {
51
                $columnToModifyNTP->widget->setValuesFromArray($customValuesNTP);
52
            }
53
54
            $ncfTipoAnulacion = new NCFTipoAnulacion();
55
            $ncfTiposAnulacion = $ncfTipoAnulacion->all();
56
            $customValuesNTA = [];
57
            $customValuesNTA[] = ['value'=>'', 'title'=>'-----------'];
58
            foreach($ncfTiposAnulacion as $tipoanulacion) {
59
                $customValuesNTA[] = ['value'=>$tipoanulacion->codigo, 'title'=>$tipoanulacion->descripcion];
60
            }
61
            $columnToModifyNTA = $this->views['EditFacturaCliente']->columnForName('ncf-cancellation-type');
62
            if($columnToModifyNTA) {
63
                $columnToModifyNTA->widget->setValuesFromArray($customValuesNTA);
64
            }
65
66
            $ncfTipoMovimiento = new NCFTipoMovimiento();
67
            $ncfTiposMovimiento = $ncfTipoMovimiento->findAllByTipomovimiento('VEN');
68
            $customValuesNTM = [];
69
            $customValuesNTM[] = ['value'=>'', 'title'=>'-----------'];
70
            foreach($ncfTiposMovimiento as $tipomovimiento) {
71
                $customValuesNTM[] = ['value'=>$tipomovimiento->codigo, 'title'=>$tipomovimiento->descripcion];
72
            }
73
            $columnToModifyNTM = $this->views['EditFacturaCliente']->columnForName('ncf-movement-type');
74
            if($columnToModifyNTM) {
75
                $columnToModifyNTM->widget->setValuesFromArray($customValuesNTM);
76
            }
77
        };
78
    }
79
}