Issues (232)

Extension/Controller/EditCliente.php (6 issues)

1
<?php
2
/**
3
 * Copyright (C) 2020 Joe Nilson <joenilson at gmail dot com>
4
 * 
5
 * fsRepublicaDominicana is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 * 
10
 * fsRepublicaDominicana 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
 * 
15
 * You should have received a copy of the GNU Lesser General Public License
16
 * along with fsRepublicaDominicana. If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Extension\Controller;
20
21
use Closure;
22
use FacturaScripts\Core\Tools;
23
use FacturaScripts\Dinamic\Lib\AssetManager;
0 ignored issues
show
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...
24
use FacturaScripts\Dinamic\Model\NCFTipo;
0 ignored issues
show
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...
25
use FacturaScripts\Dinamic\Model\NCFTipoPago;
0 ignored issues
show
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...
26
use FacturaScripts\Plugins\fsRepublicaDominicana\Lib\WebserviceDgii;
27
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoMovimiento;
28
29
class EditCliente
30
{
31
    public function createViews(): Closure
32
    {
33
        return function () {
34
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonModals.js');
0 ignored issues
show
The constant FS_ROUTE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.js');
36
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/BusquedaRNCDGII.js');
37
            $ncfTipo = new NCFTipo();
38
            $ncfTipos = $ncfTipo->allFor('ventas', 'suma');
39
            $customValues = [];
40
            $customValues[] = ['value'=>'', 'title'=>'-----------'];
41
            foreach ($ncfTipos as $tipo) {
42
                $customValues[] = ['value'=>$tipo->tipocomprobante, 'title'=>$tipo->descripcion];
43
            }
44
            $columnToModify = $this->views['EditCliente']->columnForName('tipocomprobante');
0 ignored issues
show
Bug Best Practice introduced by
The property views does not exist on FacturaScripts\Plugins\f...\Controller\EditCliente. Did you maybe forget to declare it?
Loading history...
45
            if ($columnToModify) {
46
                $columnToModify->widget->setValuesFromArray($customValues);
47
            }
48
49
            $ncfTipoPago = new NCFTipoPago();
50
            $ncfTiposPago = $ncfTipoPago->findAllByTipopago('01');
51
            $customValuesNTP = [];
52
            $customValuesNTP[] = ['value'=>'', 'title'=>'-----------'];
53
            foreach ($ncfTiposPago as $tipopago) {
54
                $customValuesNTP[] = ['value'=>$tipopago->codigo, 'title'=>$tipopago->descripcion];
55
            }
56
            $columnToModifyNTP = $this->views['EditCliente']->columnForName('ncf-payment-types');
57
            if ($columnToModifyNTP) {
58
                $columnToModifyNTP->widget->setValuesFromArray($customValuesNTP);
59
            }
60
        };
61
    }
62
63
    public function execPreviousAction(): Closure
64
    {
65
        return function ($action) {
66
            switch ($action) {
67
                case 'busca_rnc':
68
                    $this->setTemplate(false);
0 ignored issues
show
The method setTemplate() does not exist on FacturaScripts\Plugins\f...\Controller\EditCliente. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
                    $this->/** @scrutinizer ignore-call */ 
69
                           setTemplate(false);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
                    $consulta = new WebserviceDgii();
70
                    $rncNotFound = Tools::lang()->trans('rnc-not-found');
71
                    $respuesta = $consulta->getExternalAPI($_REQUEST['cifnif']);
72
                    $registros = $respuesta->totalResults;
73
                    if ($registros !== 0) {
74
                        $resultado = $respuesta->entry[0];
75
                        if ($resultado) {
76
                            $arrayResultado = [];
77
                            $arrayResultado["RGE_RUC"] = $resultado->rnc;
78
                            $arrayResultado["RGE_NOMBRE"] = $resultado->nombre;
79
                            $arrayResultado["NOMBRE_COMERCIAL"] = $resultado->razonsocial;
80
                            $arrayResultado["ESTATUS"] = $resultado->estado;
81
                            echo json_encode($arrayResultado);
82
                        } else {
83
                            echo '{"RGE_ERROR": "true", "message": "'.$rncNotFound.'"}';
84
                        }
85
                    } else {
86
                        echo '{"RGE_ERROR": "true", "message": "'.$rncNotFound.'"}';
87
                    }
88
                    break;
89
                default:
90
                    break;
91
            }
92
        };
93
    }
94
}
95