|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright (C) 2019 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\Base\DataBase\DataBaseWhere; |
|
|
|
|
|
|
25
|
|
|
use FacturaScripts\Core\Lib\ExtendedController\ListController; |
|
|
|
|
|
|
26
|
|
|
use FacturaScripts\Core\Tools; |
|
27
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFRango; |
|
28
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipo; |
|
29
|
|
|
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFTipoMovimiento; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Description of ListNCFRango |
|
33
|
|
|
* |
|
34
|
|
|
* @author joenilson |
|
35
|
|
|
*/ |
|
36
|
|
|
class ListNCFRango extends ListController |
|
37
|
|
|
{ |
|
38
|
|
|
public function getPageData(): array |
|
39
|
|
|
{ |
|
40
|
|
|
$pageData = parent::getPageData(); |
|
41
|
|
|
$pageData['menu'] = 'accounting'; |
|
42
|
|
|
$pageData['submenu'] = 'Republica Dominicana'; |
|
43
|
|
|
$pageData['title'] = 'ncf-master'; |
|
44
|
|
|
$pageData['icon'] = 'fa-solid fa-list'; |
|
45
|
|
|
|
|
46
|
|
|
return $pageData; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function createViews() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->addView('ListNCFRango', 'NCFRango'); |
|
52
|
|
|
$this->addSearchFields('ListNCFRango', ['tipocomprobante']); |
|
53
|
|
|
$this->addOrderBy('ListNCFRango', ['tipocomprobante','correlativo'], 'tipocomprobante'); |
|
54
|
|
|
|
|
55
|
|
|
$this->setSettings('ListNCFRango', 'modalInsert', 'ncf-rango-insert'); |
|
56
|
|
|
$this->setCustomWidgetValues('ListNCFRango'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setCustomWidgetValues($viewName) |
|
60
|
|
|
{ |
|
61
|
|
|
$customValues = []; |
|
62
|
|
|
$customValues[] = ['value'=>'', 'title'=>'-----------']; |
|
63
|
|
|
foreach (\range('A', 'Z') as $i) { |
|
64
|
|
|
$customValues[] = ['value'=>$i, 'title'=>$i]; |
|
65
|
|
|
} |
|
66
|
|
|
$columnToModify = $this->views[$viewName]->columnModalForName('serie_nueva'); |
|
67
|
|
|
if ($columnToModify) { |
|
68
|
|
|
$columnToModify->widget->setValuesFromArray($customValues); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @throws \JsonException |
|
74
|
|
|
*/ |
|
75
|
|
|
public function execPreviousAction($action) |
|
76
|
|
|
{ |
|
77
|
|
|
switch ($action) { |
|
78
|
|
|
case 'ncf-rango-insert': |
|
79
|
|
|
$valueIdEmpresa = $this->request->request->get('idempresa'); |
|
80
|
|
|
$valueSerie = $this->request->request->get('serie_nueva'); |
|
81
|
|
|
$valueUsuarioCreacion = $this->request->request->get('usuariocreacion'); |
|
82
|
|
|
$valueFechaCreacion = $this->request->request->get('fechacreacion'); |
|
83
|
|
|
$data = $this->request->request->all(); |
|
84
|
|
|
$data['serie']=($this->inputExists($valueSerie))?$valueSerie:$data['serie']; |
|
85
|
|
|
$data['idempresa']=($this->inputExists($valueIdEmpresa))?$valueIdEmpresa:$this->empresa->idempresa; |
|
86
|
|
|
$data['usuariomodificacion']=($this->inputExists($valueFechaCreacion))?$this->user->nick:null; |
|
87
|
|
|
$data['usuariocreacion']=($this->inputExists($valueUsuarioCreacion)) |
|
88
|
|
|
?$valueUsuarioCreacion |
|
89
|
|
|
:$this->user->nick; |
|
90
|
|
|
$data['fechacreacion']=($this->inputExists($valueFechaCreacion)) |
|
91
|
|
|
?$valueFechaCreacion |
|
92
|
|
|
:\date('Y-m-d'); |
|
93
|
|
|
$rangoNuevo = new NCFRango(); |
|
94
|
|
|
$rangoNuevo->loadFromData($data); |
|
95
|
|
|
$rangoNuevo->save(); |
|
96
|
|
|
Tools::log()->notice('Rango nuevo guardado exitosamente'); |
|
97
|
|
|
break; |
|
98
|
|
|
case 'busca_correlativo': |
|
99
|
|
|
$this->setTemplate(false); |
|
100
|
|
|
$tipocomprobante = new NCFRango(); |
|
101
|
|
|
$where = [ |
|
102
|
|
|
new DatabaseWhere('tipocomprobante', $_REQUEST['tipocomprobante']), |
|
103
|
|
|
new DatabaseWhere('idempresa', $this->empresa->idempresa), |
|
104
|
|
|
new DatabaseWhere('estado', 1) |
|
105
|
|
|
]; |
|
106
|
|
|
$comprobante = $tipocomprobante->all($where); |
|
107
|
|
|
if ($comprobante) { |
|
108
|
|
|
echo json_encode(['existe' => $comprobante], JSON_THROW_ON_ERROR); |
|
109
|
|
|
} else { |
|
110
|
|
|
echo json_encode(['existe' => false], JSON_THROW_ON_ERROR); |
|
111
|
|
|
} |
|
112
|
|
|
break; |
|
113
|
|
|
} |
|
114
|
|
|
return parent::execPreviousAction($action); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
private function inputExists($input): bool |
|
118
|
|
|
{ |
|
119
|
|
|
return isset($input) and $input !== ''; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
} |
|
123
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths