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

ListNCFTipoMovimiento::getPageData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
/**
4
 * Copyright (C) 2019 Joe Zegarra.
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\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...
25
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...
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\Plugins\fsRepublicaDominicana\Model\NCFTipoMovimiento;
28
29
/**
30
 * Description of ListNCFTipoMovimiento
31
 *
32
 * @author Joe Zegarra
33
 */
34
class ListNCFTipoMovimiento extends ListController
35
{
36
    public function getPageData(): array
37
    {
38
        $pageData = parent::getPageData();
39
        $pageData['menu'] = 'accounting';
40
        $pageData['submenu'] = 'Republica Dominicana';
41
        $pageData['title'] = 'ncf-movement-types';
42
        $pageData['icon'] = 'fas fa-list';
43
        
44
        return $pageData;
45
    }
46
    
47
    public function addRestoreButton($viewName)
48
    {
49
        $restoreButton = [
50
            'color' => 'danger',
51
            'icon' => 'fas fa-undo',
52
            'label' => 'restore-original-data',
53
            'title' => 'restore-original-data',
54
            'type' => 'action',
55
            'action' => 'restore-data',
56
            'hint' => 'restore-original-data',
57
            'confirm' => true
58
        ];
59
        $this->addButton($viewName, $restoreButton);
60
    }
61
    
62
    protected function createViews()
63
    {
64
        
65
        $this->addView('ListNCFTipoMovimiento-1', 'NCFTipoMovimiento', 'sales', 'fas fa-store');
66
        $this->addSearchFields('ListNCFTipoMovimiento-1', ['tipomovimiento','codigo','descripcion']);
67
        $this->addOrderBy('ListNCFTipoMovimiento-1', ['id'], 'code');
68
        $this->addOrderBy('ListNCFTipoMovimiento-1', ['descripcion'], 'description');
69
        $this->addRestoreButton('ListNCFTipoMovimiento-1');
70
        
71
        $this->addView('ListNCFTipoMovimiento-2', 'NCFTipoMovimiento', 'purchases', 'fas fa-credit-card');
72
        $this->addSearchFields('ListNCFTipoMovimiento-2', ['tipomovimiento','codigo','descripcion']);
73
        $this->addOrderBy('ListNCFTipoMovimiento-2', ['id'], 'code');
74
        $this->addOrderBy('ListNCFTipoMovimiento-2', ['descripcion'], 'description');
75
        $this->addRestoreButton('ListNCFTipoMovimiento-2');
76
    }
77
    
78
    protected function execPreviousAction($action)
79
    {
80
        switch ($action) {
81
            case 'restore-data':
82
                $this->views['ListNCFTipoMovimiento-1']->model->restoreData();
83
                $this->toolBox()->i18nLog()->notice('restored-original-data');
84
                break;
85
            case 'busca_movimiento':
86
                $this->setTemplate(FALSE);
87
                $tipomovimiento = new NCFTipoMovimiento();
88
                $where = [new DatabaseWhere('tipomovimiento', $_REQUEST['tipomovimiento'])];
89
                $movimientos = $tipomovimiento->all($where);
90
                if ($movimientos) {
91
                    //header('Content-Type: application/json');
92
                    echo json_encode(['movimientos' => $movimientos]);
93
                } else {
94
                    echo '';
95
                }
96
                break;
97
            default:
98
                parent::execPreviousAction($action);
99
        }
100
    }
101
    
102
    protected function loadData($viewName, $view)
103
    {
104
        switch ($viewName) {
105
            case 'ListNCFTipoMovimiento-1':
106
//                $tipoMovimiento = $this->getViewModelValue('ListNCFTipoMovimientoSales', 'tipomovimiento');
107
                $where = [new DataBaseWhere('tipomovimiento', 'VEN')];
108
                $view->loadData('', $where);
109
                break;
110
111
            case 'ListNCFTipoMovimiento-2':
112
//                $tipoMovimiento = $this->getViewModelValue('ListNCFTipoMovimientoPurchases', 'tipomovimiento');
113
                $where = [new DataBaseWhere('tipomovimiento', 'COM')];
114
                $view->loadData('', $where);
115
                break;
116
        }
117
    }
118
}
119