|
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\model; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Description of residentes_facturacion_programada_edificaciones |
|
26
|
|
|
* |
|
27
|
|
|
* @author joenilson |
|
28
|
|
|
*/ |
|
29
|
|
|
class residentes_facturacion_programada_edificaciones extends \fs_model |
|
30
|
|
|
{ |
|
31
|
|
|
public $id; |
|
32
|
|
|
public $idprogramacion; |
|
33
|
|
|
public $id_edificacion; |
|
34
|
|
|
public $codcliente; |
|
35
|
|
|
public $idfactura; |
|
36
|
|
|
public $procesado; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct($t = FALSE) { |
|
39
|
|
|
parent::__construct('residentes_fact_prog_edificaciones','plugins/residentes'); |
|
40
|
|
|
if($t){ |
|
41
|
|
|
$this->id = $t['id']; |
|
42
|
|
|
$this->idprogramacion = $t['idprogramacion']; |
|
43
|
|
|
$this->id_edificacion = $t['id_edificacion']; |
|
44
|
|
|
$this->codcliente = $t['codcliente']; |
|
45
|
|
|
$this->idfactura = $t['idfactura']; |
|
46
|
|
|
$this->procesado = $this->str2bool($t['procesado']); |
|
47
|
|
|
}else{ |
|
48
|
|
|
$this->id = null; |
|
49
|
|
|
$this->idprogramacion = null; |
|
50
|
|
|
$this->id_edificacion = null; |
|
51
|
|
|
$this->codcliente = ''; |
|
52
|
|
|
$this->idfactura = null; |
|
53
|
|
|
$this->procesado = false; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function install(){ |
|
58
|
|
|
return ""; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function exists() |
|
62
|
|
|
{ |
|
63
|
|
|
if(is_null($this->id)) { |
|
64
|
|
|
return false; |
|
65
|
|
|
} |
|
66
|
|
|
return true; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function save() |
|
70
|
|
|
{ |
|
71
|
|
|
if($this->exists()){ |
|
72
|
|
|
$sql = "UPDATE ".$this->table_name." SET ". |
|
73
|
|
|
"idfactura = ".$this->intval($this->idfactura).", ". |
|
74
|
|
|
"codcliente = ".$this->var2str($this->codcliente).", ". |
|
75
|
|
|
"id_edificacion = ".$this->intval($this->id_edificacion).", ". |
|
76
|
|
|
"idprogramacion = ".$this->intval($this->idprogramacion).", ". |
|
77
|
|
|
"procesado = ".$this->var2str($this->procesado)." ". |
|
78
|
|
|
"WHERE id = ".$this->intval($this->id).";"; |
|
79
|
|
|
$data = $this->db->exec($sql); |
|
80
|
|
|
return $data; |
|
81
|
|
|
} else { |
|
82
|
|
|
$sql = "INSERT INTO ".$this->table_name. |
|
83
|
|
|
" (idprogramacion, id_edificacion, codcliente, procesado) VALUES (". |
|
84
|
|
|
$this->intval($this->idprogramacion).", ". |
|
85
|
|
|
$this->intval($this->id_edificacion).", ". |
|
86
|
|
|
$this->var2str($this->codcliente).", ". |
|
87
|
|
|
$this->var2str($this->procesado).");"; |
|
88
|
|
|
if($this->db->exec($sql)){ |
|
89
|
|
|
return true; |
|
90
|
|
|
}else{ |
|
91
|
|
|
return false; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function get($id) |
|
98
|
|
|
{ |
|
99
|
|
|
$sql = "select * from ".$this->table_name." WHERE id = ".$this->intval($id); |
|
100
|
|
|
$this->new_advice($sql); |
|
101
|
|
|
$data = $this->db->select($sql); |
|
102
|
|
|
if($data) { |
|
103
|
|
|
return new residentes_facturacion_programada_edificaciones($data[0]); |
|
104
|
|
|
} |
|
105
|
|
|
return false; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function getByIdProgramacion($idProg) |
|
109
|
|
|
{ |
|
110
|
|
|
$sql = "select * from ".$this->table_name." WHERE idprogramacion = ".$this->intval($idProg)." ORDER BY id"; |
|
111
|
|
|
$data = $this->db->select($sql); |
|
112
|
|
|
$lista = array(); |
|
113
|
|
|
if($data) { |
|
114
|
|
|
foreach($data as $d) { |
|
115
|
|
|
$lista[] = new residentes_facturacion_programada_edificaciones($d); |
|
116
|
|
|
} |
|
117
|
|
|
return $lista; |
|
118
|
|
|
} |
|
119
|
|
|
return false; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function getByIdProgramacionPendientes($idProg) |
|
123
|
|
|
{ |
|
124
|
|
|
$sql = "select * from ".$this->table_name." WHERE idprogramacion = ".$this->intval($idProg). |
|
125
|
|
|
" AND procesado = FALSE ORDER BY id"; |
|
126
|
|
|
$data = $this->db->select($sql); |
|
127
|
|
|
$lista = array(); |
|
128
|
|
|
if($data) { |
|
129
|
|
|
foreach($data as $d) { |
|
130
|
|
|
$lista[] = new residentes_facturacion_programada_edificaciones($d); |
|
131
|
|
|
} |
|
132
|
|
|
return $lista; |
|
133
|
|
|
} |
|
134
|
|
|
return false; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function get_lista_edificaciones($idProg) |
|
138
|
|
|
{ |
|
139
|
|
|
$sql = "select * from ".$this->table_name." WHERE idprogramacion = ".$this->intval($idProg)." ORDER BY id"; |
|
140
|
|
|
$data = $this->db->select($sql); |
|
141
|
|
|
$lista = array(); |
|
142
|
|
|
if ($data) { |
|
143
|
|
|
foreach ($data as $d) { |
|
144
|
|
|
$item = new residentes_facturacion_programada_edificaciones($d); |
|
145
|
|
|
$this->infoAdicional($item); |
|
146
|
|
|
$lista[] = $item; |
|
147
|
|
|
} |
|
148
|
|
|
return $lista; |
|
149
|
|
|
} |
|
150
|
|
|
return false; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
public function infoAdicional(&$item) |
|
154
|
|
|
{ |
|
155
|
|
|
$cli = new cliente(); |
|
|
|
|
|
|
156
|
|
|
$infoCli = $cli->get($item->codcliente); |
|
157
|
|
|
$item->nombre_residente = $infoCli->nombre; |
|
158
|
|
|
$redif = new residentes_edificaciones(); |
|
159
|
|
|
$infoEdif = $redif->get($item->id_edificacion); |
|
160
|
|
|
$item->codigo = $infoEdif->codigo; |
|
161
|
|
|
$item->numero = $infoEdif->numero; |
|
162
|
|
|
$item->email = $infoCli->email; |
|
163
|
|
|
$item->numero2 = ''; |
|
164
|
|
|
$item->femail = ''; |
|
165
|
|
|
$item->fecha = ''; |
|
166
|
|
|
$item->importe = 0; |
|
167
|
|
|
$item->forma_pago = ''; |
|
168
|
|
|
if ($item->idfactura) { |
|
169
|
|
|
$fact = new factura_cliente(); |
|
170
|
|
|
$infoFact = $fact->get($item->idfactura); |
|
171
|
|
|
if ($infoFact) { |
|
172
|
|
|
$item->numero2 = $infoFact->numero2; |
|
173
|
|
|
$item->femail = $infoFact->femail; |
|
174
|
|
|
$item->fecha = $infoFact->fecha; |
|
175
|
|
|
$item->importe = $infoFact->total; |
|
176
|
|
|
$fp = new forma_pago(); |
|
|
|
|
|
|
177
|
|
|
$infoFP = $fp->get($fact->codpago); |
|
178
|
|
|
$item->forma_pago = $infoFP->descripcion; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public function get_by_date_status($date, $status) |
|
184
|
|
|
{ |
|
185
|
|
|
$sql = "select * from ".$this->table_name." WHERE fecha_envio = ".$this->var2str($date) |
|
186
|
|
|
." AND "."estado = ".$this->var2str($status)." ORDER BY idprogramacion, id"; |
|
187
|
|
|
$data = $this->db->select($sql); |
|
188
|
|
|
$lista = array(); |
|
189
|
|
|
if ($data) { |
|
190
|
|
|
foreach ($data as $d) { |
|
191
|
|
|
$lista[] = new residentes_facturacion_programada_edificaciones($d); |
|
192
|
|
|
} |
|
193
|
|
|
return $lista; |
|
194
|
|
|
} |
|
195
|
|
|
return false; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* @param int $idProgramacion |
|
200
|
|
|
* @param int $limit |
|
201
|
|
|
* @return array|false |
|
202
|
|
|
*/ |
|
203
|
|
|
public function getFacturasPorEnviar(int $idProgramacion, int $limit = 0) |
|
204
|
|
|
{ |
|
205
|
|
|
$sql = "SELECT t1.*, t2.femail FROM ".$this->table_name." as t1, facturascli as t2 ". |
|
206
|
|
|
"WHERE idprogramacion = ".$this->intval($idProgramacion) . |
|
207
|
|
|
" AND t2.femail = ".$this->str2bool("FALSE") . |
|
208
|
|
|
" AND t1.idfactura = t2.idfactura " |
|
209
|
|
|
." AND "."estado = ".$this->var2str($status)." ORDER BY id, idfactura" . |
|
|
|
|
|
|
210
|
|
|
" LIMIT " . $limit; |
|
211
|
|
|
$data = $this->db->select($sql); |
|
212
|
|
|
$lista = array(); |
|
213
|
|
|
if ($data) { |
|
214
|
|
|
foreach ($data as $d) { |
|
215
|
|
|
$lista[] = new residentes_facturacion_programada_edificaciones($d); |
|
216
|
|
|
} |
|
217
|
|
|
return $lista; |
|
218
|
|
|
} |
|
219
|
|
|
return false; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
public function all() |
|
223
|
|
|
{ |
|
224
|
|
|
$sql = "select * from ".$this->table_name." ORDER BY idprogramacion, id"; |
|
225
|
|
|
$data = $this->db->select($sql); |
|
226
|
|
|
$lista = array(); |
|
227
|
|
|
if ($data) { |
|
228
|
|
|
foreach ($data as $d) { |
|
229
|
|
|
$lista[] = new residentes_facturacion_programada_edificaciones($d); |
|
230
|
|
|
} |
|
231
|
|
|
return $lista; |
|
232
|
|
|
} |
|
233
|
|
|
return false; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
public function delete() |
|
237
|
|
|
{ |
|
238
|
|
|
$sql = "DELETE from ".$this->table_name." WHERE id = ".$this->intval($this->id); |
|
239
|
|
|
$data = $this->db->exec($sql); |
|
240
|
|
|
if ($data) { |
|
241
|
|
|
return true; |
|
242
|
|
|
} |
|
243
|
|
|
return false; |
|
244
|
|
|
} |
|
245
|
|
|
} |
|
246
|
|
|
|
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