Passed
Push — master ( 8a423f...9c95d4 )
by Joe Nilson
01:52
created

EditFacturaCliente   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A customWidgetValues() 0 2 1
A subjectChangedAction() 0 25 4
A createViews() 0 4 1
1
<?php
2
3
/**
4
 * Copyright (C) 2020 joenilson.
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 3 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301  USA
20
 */
21
22
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Controller;
23
24
use FacturaScripts\Dinamic\Model\Cliente;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Dinamic\Model\Cliente 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\Controller\EditFacturaCliente as ParentClass;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Controller\EditFacturaCliente 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 EditFacturaCliente
29
 *
30
 * @author joenilson
31
 */
32
class EditFacturaCliente extends ParentClass
33
{
34
    /**
35
     * Shows the document opertation type selector.
36
     *
37
     * @var bool
38
     */
39
    public $showDocOperation = false;
40
    /**
41
     * Shows the document sub-type selector.
42
     *
43
     * @var bool
44
     */
45
    public $showDocSubType = true;
46
    
47
    protected function createViews()
48
    {
49
        parent::createViews();
50
        $this->customWidgetValues();
51
    }
52
    
53
    public function customWidgetValues()
54
    {
55
        //TODO
56
    }
57
    
58
    protected function subjectChangedAction()
59
    {
60
        $this->setTemplate(false);
61
62
        //Client data
63
        $cliente0 = new Cliente();
64
        
65
        
66
        /// loads model
67
        $data = $this->getBusinessFormData();
68
        $cliente = $cliente0->get($data['subject']['codcliente']);
69
        
70
        $data['form']['codsubtipodoc'] =(isset($data['form']['codsubtipodoc']))?$cliente->codsubtipodoc:"02";
71
        $data['form']['codoperaciondoc'] = (isset($data['form']['codoperaciondoc']))?"01":"LIMPIO";
72
        
73
        $merged = array_merge($data['custom'], $data['final'], $data['form'], $data['subject']);
74
        $this->views[$this->active]->loadFromData($merged);
75
76
        /// update subject data?
77
        if (!$this->views[$this->active]->model->exists()) {
78
            $this->views[$this->active]->model->updateSubject();
79
        }
80
81
        $this->response->setContent(json_encode($this->views[$this->active]->model));
82
        return false;
83
    }
84
}
85