Passed
Push — master ( 8e49de...855750 )
by Joe Nilson
03:05
created

ListFacturaCliente::createViewSales()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * This file is part of FacturaScripts
4
 * Copyright (C) 2017-2020 Carlos Garcia Gomez <[email protected]>
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, either version 3 of the
9
 * License, or (at your option) any later version.
10
 *
11
 * This program 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
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
 */
19
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Controller;
20
21
use FacturaScripts\Core\Controller\ListFacturaCliente as ParentClass;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Controller\ListFacturaCliente 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
/**
23
 * Controller to list the items in the FacturaCliente model
24
 *
25
 * @author Carlos García Gómez          <[email protected]>
26
 * @author Artex Trading sa             <[email protected]>
27
 * @author Raul Jimenez                 <[email protected]>
28
 * @author Cristo M. Estévez Hernández  <[email protected]>
29
 */
30
class ListFacturaCliente extends ParentClass
31
{
32
33
    /**
34
     * Returns basic page attributes
35
     *
36
     * @return array
37
     */
38
    public function getPageData()
39
    {
40
        $data = parent::getPageData();
41
        $data['menu'] = 'sales';
42
        $data['title'] = 'invoices';
43
        $data['icon'] = 'fas fa-copy';
44
        return $data;
45
    }
46
47
    /**
48
     * Load views
49
     */
50
    protected function createViews()
51
    {
52
        $this->createViewSales('ListFacturaCliente', 'FacturaCliente', 'invoices');
53
        $this->createViewLines('ListLineaFacturaCliente', 'LineaFacturaCliente');
54
        $this->createViewReceipts();
55
    }
56
57
    /**
58
     * @param string $viewName
59
     * @param string $modelName
60
     * @param string $label
61
     */
62
    protected function createViewSales(string $viewName, $modelName, $label)
63
    {
64
        //$modelName->loadFromData(['facturarectnumero2'=>'QEPD']);
65
66
        parent::createViewSales($viewName, $modelName, $label);
67
        $this->views[$viewName]->model->loadFromData(['facturarectnumero2'=>'QEPD']);
68
        $this->addFilterCheckbox('ListFacturaCliente', 'pagada', 'unpaid', 'pagada', '=', false);
69
        $this->addFilterCheckbox('ListFacturaCliente', 'idasiento', 'invoice-without-acc-entry', 'idasiento', 'IS', null);
70
        $this->addButtonLockInvoice('ListFacturaCliente');
71
    }
72
73
    /**
74
     *
75
     * @param string $viewName
76
     */
77
    protected function createViewReceipts(string $viewName = 'ListReciboCliente')
78
    {
79
        $this->addView($viewName, 'ReciboCliente', 'receipts', 'fas fa-dollar-sign');
80
        $this->addOrderBy($viewName, ['fecha', 'idrecibo'], 'date', 2);
81
        $this->addOrderBy($viewName, ['fechapago'], 'payment-date');
82
        $this->addOrderBy($viewName, ['vencimiento'], 'expiration');
83
        $this->addOrderBy($viewName, ['importe'], 'amount');
84
        $this->addSearchFields($viewName, ['codigofactura', 'observaciones']);
85
86
        /// filters
87
        $this->addFilterPeriod($viewName, 'date', 'period', 'fecha');
88
        $this->addFilterAutocomplete($viewName, 'codcliente', 'customer', 'codcliente', 'Cliente');
89
        $this->addFilterNumber($viewName, 'min-total', 'amount', 'importe', '>=');
90
        $this->addFilterNumber($viewName, 'max-total', 'amount', 'importe', '<=');
91
92
        $currencies = $this->codeModel->all('divisas', 'coddivisa', 'descripcion');
93
        if (\count($currencies) > 2) {
94
            $this->addFilterSelect($viewName, 'coddivisa', 'currency', 'coddivisa', $currencies);
95
        }
96
97
        $paymethods = $this->codeModel->all('formaspago', 'codpago', 'descripcion');
98
        if (\count($paymethods) > 2) {
99
            $this->addFilterSelect($viewName, 'codpago', 'payment-method', 'codpago', $paymethods);
100
        }
101
102
        $this->addFilterCheckbox($viewName, 'pagado', 'unpaid', '', '!=');
103
104
        /// buttons
105
        $this->addButtonPayReceipt($viewName);
106
107
        /// settings
108
        $this->setSettings($viewName, 'btnNew', false);
109
    }
110
}
111