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

EditFacturaProveedor::subjectChangedAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 18
rs 9.9332
c 1
b 0
f 0
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\Core\Controller\EditFacturaProveedor as ParentClass;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Cont...er\EditFacturaProveedor 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
/**
27
 * Description of EditFacturaCliente
28
 *
29
 * @author joenilson
30
 */
31
class EditFacturaProveedor extends ParentClass
32
{
33
    /**
34
     * Shows the document opertation type selector.
35
     *
36
     * @var bool
37
     */
38
    public $showDocOperation = false;
39
    /**
40
     * Shows the document sub-type selector.
41
     *
42
     * @var bool
43
     */
44
    public $showDocSubType = true;
45
    
46
    protected function createViews()
47
    {
48
        parent::createViews();
49
        $this->customWidgetValues();
50
    }
51
    
52
    public function customWidgetValues()
53
    {
54
        //var_dump($this->views[$this->active]->model);
55
//        if($this->views[$this->active]->model->codcliente !== null) {
56
//            $columnToModify = $this->views[$this->active]->columnForName('codsubtipodoc');
57
//            if($columnToModify) {
58
//                $columnToModify->widget->setCustomValue('02');
59
//            }
60
//        }
61
    }
62
    
63
    protected function subjectChangedAction()
64
    {
65
        $this->setTemplate(false);
66
67
        /// loads model
68
        $data = $this->getBusinessFormData();
69
        $data['form']['codsubtipodoc'] = "02";
70
        $data['form']['codoperaciondoc'] = "11";
71
        $merged = array_merge($data['custom'], $data['final'], $data['form'], $data['subject']);
72
        $this->views[$this->active]->loadFromData($merged);
73
74
        /// update subject data?
75
        if (!$this->views[$this->active]->model->exists()) {
76
            $this->views[$this->active]->model->updateSubject();
77
        }
78
79
        $this->response->setContent(json_encode($this->views[$this->active]->model));
80
        return false;
81
    }
82
}
83