Issues (232)

Extension/Controller/EditProveedor.php (5 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\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...
25
use FacturaScripts\Plugins\fsRepublicaDominicana\Lib\WebserviceDgii;
26
27
class EditProveedor
28
{
29
30
    public function createViews(): Closure
31
    {
32
        return function () {
33
            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...
34
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/CommonDomFunctions.js');
35
            AssetManager::add('js', \FS_ROUTE . '/Plugins/fsRepublicaDominicana/Assets/JS/BusquedaRNCDGII.js');
36
            $ncfTipoPago = new NCFTipoPago();
37
            $ncfTiposPago = $ncfTipoPago->findAllByTipopago('02');
38
            $customValuesNTP = [];
39
            $customValuesNTP[] = ['value'=>'', 'title'=>'-----------'];
40
            foreach ($ncfTiposPago as $tipopago) {
41
                $customValuesNTP[] = ['value'=>$tipopago->codigo, 'title'=>$tipopago->descripcion];
42
            }
43
            $columnToModifyNTP = $this->views['EditProveedor']->columnForName('ncf-payment-types');
0 ignored issues
show
Bug Best Practice introduced by
The property views does not exist on FacturaScripts\Plugins\f...ontroller\EditProveedor. Did you maybe forget to declare it?
Loading history...
44
            if ($columnToModifyNTP) {
45
                $columnToModifyNTP->widget->setValuesFromArray($customValuesNTP);
46
            }
47
        };
48
    }
49
50
    public function execPreviousAction()
51
    {
52
        return function ($action) {
53
            switch ($action) {
54
                case 'busca_rnc':
55
                    $this->setTemplate(false);
0 ignored issues
show
The method setTemplate() does not exist on FacturaScripts\Plugins\f...ontroller\EditProveedor. ( Ignorable by Annotation )

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

55
                    $this->/** @scrutinizer ignore-call */ 
56
                           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...
56
                    $consulta = new WebserviceDgii();
57
                    $rncNotFound = Tools::lang()->trans('rnc-not-found');
58
                    $respuesta = $consulta->getExternalAPI($_REQUEST['cifnif']);
59
                    $registros = $respuesta->totalResults;
60
                    if ($registros !== 0) {
61
                        $resultado = $respuesta->entry[0];
62
                        if ($resultado) {
63
                            $arrayResultado = [];
64
                            $arrayResultado["RGE_RUC"] = $resultado->rnc;
65
                            $arrayResultado["RGE_NOMBRE"] = $resultado->nombre;
66
                            $arrayResultado["NOMBRE_COMERCIAL"] = $resultado->razonsocial;
67
                            $arrayResultado["ESTATUS"] = $resultado->estado;
68
                            echo json_encode($arrayResultado);
69
                        } else {
70
                            echo '{"RGE_ERROR": "true", "message": "'.$rncNotFound.'"}';
71
                        }
72
                    } else {
73
                        echo '{"RGE_ERROR": "true", "message": "'.$rncNotFound.'"}';
74
                    }
75
                    break;
76
                default:
77
                    break;
78
            }
79
        };
80
    }
81
}
82