1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (C) 2016 Joe Nilson <joenilson at gmail.com> |
4
|
|
|
* |
5
|
|
|
* This program 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
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
namespace FacturaScripts\model; |
19
|
|
|
/** |
20
|
|
|
* Description of residentes_edificaciones |
21
|
|
|
* |
22
|
|
|
* @author Joe Nilson <joenilson at gmail.com> |
23
|
|
|
*/ |
24
|
|
|
class residentes_edificaciones extends \fs_model{ |
25
|
|
|
/** |
26
|
|
|
* El Id de la de edificacion |
27
|
|
|
* @var integer serial |
28
|
|
|
*/ |
29
|
|
|
public $id; |
30
|
|
|
/** |
31
|
|
|
* El id de la dirección almacenada en la tabla del cliente |
32
|
|
|
* @var integer |
33
|
|
|
*/ |
34
|
|
|
public $iddireccion; |
35
|
|
|
/** |
36
|
|
|
* Este es el id de la edificacion en el mapa de Edificaciones |
37
|
|
|
* @var integer |
38
|
|
|
*/ |
39
|
|
|
public $id_edificacion; |
40
|
|
|
/** |
41
|
|
|
* De cara al usuario se mostrará y buscara este código |
42
|
|
|
* pero esto se generará de los valores que ingrese de |
43
|
|
|
* los tipos de edificaciones |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
public $codigo; |
47
|
|
|
/** |
48
|
|
|
* Este codigo es en realidad una cadena para saber donde buscar |
49
|
|
|
* los datos de las edificaciones, si solo manejan el tipo de edificación |
50
|
|
|
* principal que es Bloque con código 1, entonces el codigo interno |
51
|
|
|
* será 1:LETRA_O_NUMERO del Bloque, si por el contrario tiene Bloque y Edificio |
52
|
|
|
* entonces el valor guardado será 1:1_2:1 que indicara que esta en el Bloque 1 Edificio 1 |
53
|
|
|
* siendo el id de Edificio el 2. |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
public $codigo_interno; |
57
|
|
|
/** |
58
|
|
|
* Este es el número del Inmueble |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
public $numero; |
62
|
|
|
/** |
63
|
|
|
* @todo En un futuro si se necesita colocar la ubicación del edificio, como la calle o avenida interna |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
public $ubicacion; |
67
|
|
|
/** |
68
|
|
|
* Si se van a agregar las coordenadas del inmueble pueden colocarse aquí |
69
|
|
|
* @var varchar(64) |
|
|
|
|
70
|
|
|
*/ |
71
|
|
|
public $coordenadas; |
72
|
|
|
/** |
73
|
|
|
* Si la edificación esta ocupada entonces se coloca aquí el código del Residente o Cliente |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
public $codcliente; |
77
|
|
|
/** |
78
|
|
|
* Con esto sabremos si un edificio está o no ocupado en el listado de edificios |
79
|
|
|
* @var boolean |
80
|
|
|
*/ |
81
|
|
|
public $ocupado; |
82
|
|
|
/** |
83
|
|
|
* |
84
|
|
|
* @var string |
85
|
|
|
*/ |
86
|
|
|
public $fecha_ocupacion; |
87
|
|
|
/** |
88
|
|
|
* |
89
|
|
|
* @var string |
90
|
|
|
*/ |
91
|
|
|
public $fecha_disponibilidad; |
92
|
|
|
//Datos auxiliares |
93
|
|
|
public $edificaciones_tipo; |
94
|
|
|
public $cliente; |
95
|
|
|
public $cliente_info; |
96
|
|
|
public $cliente_vehiculo; |
97
|
|
|
public function __construct($t = FALSE) { |
98
|
|
|
parent::__construct('residentes_edificaciones','plugins/residentes'); |
99
|
|
|
if($t){ |
100
|
|
|
$this->id = $t['id']; |
101
|
|
|
$this->iddireccion = $t['iddireccion']; |
102
|
|
|
$this->id_edificacion = $t['id_edificacion']; |
103
|
|
|
$this->codigo = $t['codigo']; |
104
|
|
|
$this->codigo_interno = $t['codigo_interno']; |
105
|
|
|
$this->numero = $t['numero']; |
106
|
|
|
$this->ubicacion = $t['ubicacion']; |
107
|
|
|
$this->coordenadas = $t['coordenadas']; |
108
|
|
|
$this->codcliente = $t['codcliente']; |
109
|
|
|
$this->ocupado = $this->str2bool($t['ocupado']); |
110
|
|
|
$this->fecha_ocupacion = $t['fecha_ocupacion']; |
111
|
|
|
$this->fecha_disponibilidad = $t['fecha_disponibilidad']; |
112
|
|
|
}else{ |
113
|
|
|
$this->id = null; |
114
|
|
|
$this->iddireccion = 0; |
115
|
|
|
$this->id_edificacion = null; |
116
|
|
|
$this->codigo = null; |
117
|
|
|
$this->codigo_interno = null; |
118
|
|
|
$this->numero = null; |
119
|
|
|
$this->ubicacion = null; |
120
|
|
|
$this->coordenadas = null; |
121
|
|
|
$this->codcliente = null; |
122
|
|
|
$this->ocupado = false; |
123
|
|
|
$this->fecha_ocupacion = null; |
124
|
|
|
$this->fecha_disponibilidad = null; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function install() |
130
|
|
|
{ |
131
|
|
|
new cliente(); |
|
|
|
|
132
|
|
|
new residentes_edificaciones_tipo(); |
133
|
|
|
new residentes_informacion(); |
134
|
|
|
new residentes_vehiculos(); |
135
|
|
|
$familias_sql = "INSERT INTO familias (descripcion,codfamilia) VALUES ('Servicios Residentes','RESIDENT');"; |
136
|
|
|
$articulos_sql = "INSERT INTO articulos (referencia, descripcion, codfamilia, nostock, controlstock, secompra, sevende, bloqueado) VALUES ". |
137
|
|
|
"('RES_CUOTA','Cuota Mensual','RESIDENT',TRUE,TRUE,FALSE, TRUE, FALSE),". |
138
|
|
|
"('RES_SEGURIDAD','Pago de Seguridad común','RESIDENT',TRUE,TRUE,FALSE, TRUE, FALSE),". |
139
|
|
|
"('RES_ILUMINACION','Pago Iluminación de Parques','RESIDENT',TRUE,TRUE,FALSE, TRUE, FALSE),". |
140
|
|
|
"('RES_AGUA','Pago de Agua','RESIDENT',TRUE,TRUE,FALSE, TRUE, FALSE),". |
141
|
|
|
"('RES_GAS','Pago de Gas Común','RESIDENT',TRUE,TRUE,FALSE, TRUE, FALSE),". |
142
|
|
|
"('RES_SERVICIOS','Pago de Servicios Municipales','RESIDENT',TRUE,TRUE,FALSE, TRUE, FALSE);"; |
143
|
|
|
return "$familias_sql $articulos_sql"; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function url() |
147
|
|
|
{ |
148
|
|
|
if (!is_null($this->id)) { |
|
|
|
|
149
|
|
|
return FS_PATH.'index.php?page=ver_residente&id='.$this->id; |
|
|
|
|
150
|
|
|
} else { |
151
|
|
|
return FS_PATH.'index.php?page=residentes'; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function info($item) |
156
|
|
|
{ |
157
|
|
|
$cliente = new cliente(); |
158
|
|
|
$cliente_info = new residentes_informacion(); |
159
|
|
|
$cliente_vehiculo = new residentes_vehiculos(); |
160
|
|
|
if ($item->codcliente) { |
161
|
|
|
$item->nombre = $cliente->get($item->codcliente)->nombre; |
162
|
|
|
$item->telefono = $cliente->get($item->codcliente)->telefono1; |
163
|
|
|
$item->email = $cliente->get($item->codcliente)->email; |
164
|
|
|
$item->info = $cliente_info->get($item->codcliente); |
165
|
|
|
$item->vehiculos = $cliente_vehiculo->get_by_field('codcliente', $item->codcliente); |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function listaInfo($data) |
170
|
|
|
{ |
171
|
|
|
if ($data) { |
172
|
|
|
$lista = array(); |
173
|
|
|
foreach ($data as $d) { |
174
|
|
|
$item = new residentes_edificaciones($d); |
175
|
|
|
$item->pertenencia = $this->pertenencia($item); |
|
|
|
|
176
|
|
|
$this->info($item); |
177
|
|
|
$lista[] = $item; |
178
|
|
|
} |
179
|
|
|
return $lista; |
180
|
|
|
} else { |
181
|
|
|
return false; |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
public function all() |
186
|
|
|
{ |
187
|
|
|
$sql = "SELECT * FROM ".$this->table_name." ORDER BY codigo_interno,numero"; |
188
|
|
|
$data = $this->db->select($sql); |
189
|
|
|
return $this->listaInfo($data); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function all_ocupados() |
193
|
|
|
{ |
194
|
|
|
$sql = "SELECT re.*, c.nombre FROM ".$this->table_name." as re, clientes as c ". |
195
|
|
|
" WHERE ocupado = TRUE and re.codcliente != '' and re.codcliente = c.codcliente ". |
196
|
|
|
" ORDER BY re.codigo_interno, re.numero"; |
197
|
|
|
$data = $this->db->select($sql); |
198
|
|
|
return $this->listaInfo($data); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function get($id){ |
202
|
|
|
$sql = "SELECT * FROM ".$this->table_name." WHERE id = ".$this->intval($id).";"; |
203
|
|
|
$data = $this->db->select($sql); |
204
|
|
|
if($data){ |
205
|
|
|
$item = new residentes_edificaciones($data[0]); |
206
|
|
|
$item->pertenencia = $this->pertenencia($item); |
|
|
|
|
207
|
|
|
$this->info($item); |
208
|
|
|
return $item; |
209
|
|
|
}else{ |
210
|
|
|
return false; |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Si queremos buscar por codigo o codigo_interno o codcliente o numero |
216
|
|
|
* @param string $field |
217
|
|
|
* @param string $value |
218
|
|
|
* @return boolean|\FacturaScripts\model\residentes_edificaciones |
219
|
|
|
*/ |
220
|
|
|
public function get_by_field($field,$value){ |
221
|
|
|
$query = (is_string($value))?$this->var2str($value):$this->intval($value); |
|
|
|
|
222
|
|
|
$sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query. |
223
|
|
|
" ORDER BY codigo_interno,numero;"; |
224
|
|
|
$data = $this->db->select($sql); |
225
|
|
|
return $this->listaInfo($data); |
|
|
|
|
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function exists() |
229
|
|
|
{ |
230
|
|
|
if (is_null($this->id)) { |
|
|
|
|
231
|
|
|
return false; |
232
|
|
|
} else { |
233
|
|
|
return $this->get($this->id); |
234
|
|
|
} |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function save() |
238
|
|
|
{ |
239
|
|
|
if ($this->exists()) { |
240
|
|
|
$sql = "UPDATE ".$this->table_name." SET ". |
241
|
|
|
"fecha_ocupacion = ".$this->var2str($this->fecha_ocupacion).", ". |
242
|
|
|
"fecha_disponibilidad = ".$this->var2str($this->fecha_disponibilidad).", ". |
243
|
|
|
"iddireccion = ".$this->intval($this->iddireccion).", ". |
244
|
|
|
"id_edificacion = ".$this->intval($this->id_edificacion).", ". |
245
|
|
|
"codigo = ".$this->var2str($this->codigo).", ". |
246
|
|
|
"codigo_interno = ".$this->var2str($this->codigo_interno).", ". |
247
|
|
|
"numero = ".$this->var2str($this->numero).", ". |
248
|
|
|
"ubicacion = ".$this->var2str($this->ubicacion).", ". |
249
|
|
|
"codcliente = ".$this->var2str($this->codcliente).", ". |
250
|
|
|
"coordenadas = ".$this->var2str($this->coordenadas).", ". |
251
|
|
|
"ocupado = ".$this->var2str($this->ocupado)." ". |
252
|
|
|
"WHERE id = ".$this->intval($this->id).";"; |
253
|
|
|
return $this->db->exec($sql); |
254
|
|
|
} else { |
255
|
|
|
$sql = "INSERT INTO ".$this->table_name." (id_edificacion, iddireccion, codigo, codigo_interno, numero, ubicacion, coordenadas,codcliente, ocupado, fecha_ocupacion, fecha_disponibilidad) VALUES (". |
256
|
|
|
$this->intval($this->id_edificacion).", ". |
257
|
|
|
$this->intval($this->iddireccion).", ". |
258
|
|
|
$this->var2str($this->codigo).", ". |
259
|
|
|
$this->var2str($this->codigo_interno).", ". |
260
|
|
|
$this->var2str($this->numero).", ". |
261
|
|
|
$this->var2str($this->ubicacion).", ". |
262
|
|
|
$this->var2str($this->coordenadas).", ". |
263
|
|
|
$this->var2str($this->codcliente).", ". |
264
|
|
|
$this->var2str($this->ocupado).", ". |
265
|
|
|
$this->var2str($this->fecha_ocupacion).", ". |
266
|
|
|
$this->var2str($this->fecha_disponibilidad).");"; |
267
|
|
|
if ($this->db->exec($sql)) { |
268
|
|
|
return $this->db->lastval(); |
269
|
|
|
} else { |
270
|
|
|
return false; |
271
|
|
|
} |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
public function delete() |
276
|
|
|
{ |
277
|
|
|
$sql = "DELETE FROM ".$this->table_name." WHERE id = ".$this->intval($this->id).";"; |
278
|
|
|
return $this->db->exec($sql); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
private function pertenencia($d) |
282
|
|
|
{ |
283
|
|
|
$edificaciones_tipo = new residentes_edificaciones_tipo(); |
284
|
|
|
$codigo_interno = $d->codigo_interno; |
285
|
|
|
$piezas = \json_decode($codigo_interno, true); |
286
|
|
|
$lista = array(); |
287
|
|
|
foreach ($piezas as $id => $data) { |
288
|
|
|
$pertenencia = new \stdClass(); |
289
|
|
|
$pertenencia->id = $id; |
290
|
|
|
$pertenencia->desc_id = $edificaciones_tipo->get($id)->descripcion; |
291
|
|
|
$pertenencia->padre = $edificaciones_tipo->get($id)->padre; |
292
|
|
|
$pertenencia->valor = $data; |
293
|
|
|
$lista[] = $pertenencia; |
294
|
|
|
} |
295
|
|
|
return $lista; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
public function codigo_externo() |
299
|
|
|
{ |
300
|
|
|
$edificaciones_tipo = new residentes_edificaciones_tipo(); |
301
|
|
|
$piezas = \json_decode($this->codigo_interno, true); |
302
|
|
|
$codigo_externo = ''; |
303
|
|
|
foreach ($piezas as $id => $data) { |
304
|
|
|
$codigo_externo .= $edificaciones_tipo->get($id)->descripcion.' '.$data.' '; |
305
|
|
|
} |
306
|
|
|
return $codigo_externo; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
public function buscar_ubicacion_inmueble($id, $linea) |
310
|
|
|
{ |
311
|
|
|
$inicio_busqueda = ($linea===0)?"{\"":"{%\""; |
312
|
|
|
$sql = "SELECT * FROM ".$this->table_name." WHERE codigo_interno LIKE '". |
313
|
|
|
$inicio_busqueda.$id."\":%}' ORDER BY codigo;"; |
314
|
|
|
$data = $this->db->select($sql); |
315
|
|
|
if ($data) { |
316
|
|
|
$lista = array(); |
317
|
|
|
foreach ($data as $d) { |
318
|
|
|
$l = new residentes_edificaciones($d); |
319
|
|
|
$lista[] = $this->pertenencia($l); |
320
|
|
|
} |
321
|
|
|
return $lista; |
322
|
|
|
} else { |
323
|
|
|
return false; |
324
|
|
|
} |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
public function buscar_cantidad_inmuebles($id,$linea) |
328
|
|
|
{ |
329
|
|
|
$inicio_busqueda = ($linea===0)?"{\"":"{%\""; |
330
|
|
|
$sql = "SELECT DISTINCT codigo FROM ".$this->table_name." WHERE codigo_interno LIKE '". |
331
|
|
|
$inicio_busqueda.$id."\":%}' ORDER BY codigo;"; |
332
|
|
|
$data = $this->db->select($sql); |
333
|
|
|
if ($data) { |
334
|
|
|
$lista = array(); |
335
|
|
|
foreach ($data as $d) { |
336
|
|
|
$l = $this->get_by_field('codigo', $d['codigo']); |
337
|
|
|
$lista[] = $l; |
338
|
|
|
} |
339
|
|
|
return $lista; |
340
|
|
|
} else { |
341
|
|
|
return false; |
342
|
|
|
} |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
public function cantidad_inmuebles($id_edificacion) |
346
|
|
|
{ |
347
|
|
|
$sql = "SELECT count(*) as cantidad FROM ".$this->table_name." WHERE id_edificacion = ". |
348
|
|
|
$this->intval($id_edificacion).";"; |
349
|
|
|
$data = $this->db->select($sql); |
350
|
|
|
if ($data) { |
351
|
|
|
return $data[0]['cantidad']; |
352
|
|
|
} else { |
353
|
|
|
return false; |
354
|
|
|
} |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
public function generar_mapa() |
358
|
|
|
{ |
359
|
|
|
$edificaciones_tipo = new residentes_edificaciones_tipo(); |
360
|
|
|
$mapa = array(); |
361
|
|
|
$linea = 0; |
362
|
|
|
foreach ($edificaciones_tipo->all() as $data) { |
363
|
|
|
if ($linea===1) { |
364
|
|
|
break; |
365
|
|
|
} |
366
|
|
|
$items = $this->buscar_cantidad_inmuebles($data->id, $data->padre); |
367
|
|
|
foreach ($items as $inmueble) { |
368
|
|
|
$mapa[$data->id][] = $inmueble; |
369
|
|
|
} |
370
|
|
|
$linea++; |
371
|
|
|
} |
372
|
|
|
return $mapa; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
public function search($query, $type = "") |
376
|
|
|
{ |
377
|
|
|
$sql = "SELECT * FROM ".$this->table_name." WHERE "; |
378
|
|
|
$OR = ""; |
379
|
|
|
if ($type=='inmueble') { |
380
|
|
|
$sql.=" numero LIKE '%".strtoupper($query)."%' "; |
381
|
|
|
$sql.=" OR codigo LIKE '%".strtoupper($query)."%' "; |
382
|
|
|
} else { |
383
|
|
|
if (is_int($query)) { |
384
|
|
|
$sql.=" id_edificacion LIKE '%".$query."%' "; |
385
|
|
|
$sql.=" id LIKE '%".$query."%' "; |
386
|
|
|
$OR = "OR"; |
387
|
|
|
} |
388
|
|
|
$sql.=" $OR numero LIKE '%".strtoupper($query)."%' "; |
389
|
|
|
$sql.=" OR codigo LIKE '%".strtoupper($query)."%' "; |
390
|
|
|
} |
391
|
|
|
$sql.=" ORDER BY codigo,numero"; |
392
|
|
|
$data = $this->db->select($sql); |
393
|
|
|
$lista = array(); |
394
|
|
|
if ($data) { |
395
|
|
|
foreach ($data as $d) { |
396
|
|
|
$item = new residentes_edificaciones($d); |
397
|
|
|
$item->pertenencia = $this->pertenencia($item); |
|
|
|
|
398
|
|
|
$item->nombre = 'Libre'; |
|
|
|
|
399
|
|
|
$item->info = ''; |
|
|
|
|
400
|
|
|
$item->vehiculos = ''; |
|
|
|
|
401
|
|
|
$this->info($item); |
402
|
|
|
$lista[] = $item; |
403
|
|
|
} |
404
|
|
|
} |
405
|
|
|
return $lista; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
public function lista_residentes($where = "", $order = "", $sort = "", $limit = FS_ITEM_LIMIT, $offset = 0) |
|
|
|
|
409
|
|
|
{ |
410
|
|
|
$sql = "select ". |
411
|
|
|
"r.id, r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero ". |
412
|
|
|
",i.propietario, i.ca_nombres, i.ca_apellidos, r.fecha_ocupacion ". |
413
|
|
|
", f1.total as pagado ". |
414
|
|
|
", f2.total as pendiente ". |
415
|
|
|
", count(v.idvehiculo) as cantidad_vehiculos ". |
416
|
|
|
"from residentes_edificaciones as r ". |
417
|
|
|
"left join clientes as c on (r.codcliente = c.codcliente ) ". |
418
|
|
|
"left join residentes_informacion as i ON (r.codcliente = i.codcliente) ". |
419
|
|
|
"left join residentes_vehiculos as v ON (r.codcliente = v.codcliente) ". |
420
|
|
|
"left join (select codcliente,sum(total) as total from facturascli where anulada = false and pagada = true ". |
421
|
|
|
"group by codcliente) as f1 on (r.codcliente = f1.codcliente) ". |
422
|
|
|
"left join (select codcliente,sum(total) as total from facturascli where anulada = false and pagada = false ". |
423
|
|
|
"group by codcliente) as f2 on (r.codcliente = f2.codcliente) ". |
424
|
|
|
$where. |
425
|
|
|
" group by ". |
426
|
|
|
"r.id, r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero, ". |
427
|
|
|
"i.propietario, i.ca_nombres, i.ca_apellidos, r.fecha_ocupacion, pagado, pendiente ". |
428
|
|
|
"order by ".trim($order)." ".$sort; |
429
|
|
|
|
430
|
|
|
$sql_count = "SELECT count(r.id) as total ". |
431
|
|
|
"from residentes_edificaciones as r ". |
432
|
|
|
"left join clientes as c on (r.codcliente = c.codcliente ) ". |
433
|
|
|
"left join residentes_informacion as i ON (r.codcliente = i.codcliente) ". |
434
|
|
|
"left join residentes_vehiculos as v ON (r.codcliente = v.codcliente) ". |
435
|
|
|
$where; |
436
|
|
|
$data_total = $this->db->select($sql_count); |
437
|
|
|
$data = $this->db->select_limit($sql, $limit, $offset); |
438
|
|
|
$lista = array(); |
439
|
|
|
if ($data) { |
440
|
|
|
foreach ($data as $item) { |
441
|
|
|
$lista[] = (object) $item; |
442
|
|
|
} |
443
|
|
|
} |
444
|
|
|
return array($lista, $data_total[0]['total']); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* @param false $todo |
449
|
|
|
* @param string $whereSQL |
450
|
|
|
* @param string $sort |
451
|
|
|
* @param string $order |
452
|
|
|
* @param integer $limit |
453
|
|
|
* @param integer $offset |
454
|
|
|
* @return array |
455
|
|
|
*/ |
456
|
|
|
public function listaResidentes( |
457
|
|
|
$todo = false, |
458
|
|
|
$whereSQL = '', |
459
|
|
|
$sort = 'r.codigo, r.numero', |
460
|
|
|
$order = 'ASC', |
461
|
|
|
$limit = FS_ITEM_LIMIT, |
|
|
|
|
462
|
|
|
$offset = 0 |
463
|
|
|
) |
464
|
|
|
{ |
465
|
|
|
$sql = " select r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, codigo, numero, fecha_ocupacion ". |
466
|
|
|
" from residentes_edificaciones as r, clientes as c ". |
467
|
|
|
" where r.codcliente = c.codcliente ".$whereSQL. |
468
|
|
|
" order by ".$sort." ".$order; |
469
|
|
|
if ($todo) { |
|
|
|
|
470
|
|
|
$data = $this->db->select($sql); |
471
|
|
|
} else { |
472
|
|
|
$data = $this->db->select_limit($sql, $limit, $offset); |
473
|
|
|
} |
474
|
|
|
$sql_cantidad = "select count(r.id) as total from residentes_edificaciones as r ". |
475
|
|
|
" where r.codcliente != '' ".$whereSQL; |
476
|
|
|
$data_cantidad = $this->db->select($sql_cantidad); |
477
|
|
|
return array($data, $data_cantidad[0]['total']); |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
/** |
481
|
|
|
* @param false $todo |
482
|
|
|
* @param string $whereSQL |
483
|
|
|
* @param string $sort |
484
|
|
|
* @param string $order |
485
|
|
|
* @param integer $limit |
486
|
|
|
* @param integer $offset |
487
|
|
|
* @return array |
488
|
|
|
*/ |
489
|
|
|
public function listaInmuebles( |
490
|
|
|
$todo = false, |
491
|
|
|
$whereSQL = '', |
492
|
|
|
$sort = 'r.codigo, r.numero', |
493
|
|
|
$order = 'ASC', |
494
|
|
|
$limit = FS_ITEM_LIMIT, |
|
|
|
|
495
|
|
|
$offset = 0 |
496
|
|
|
) |
497
|
|
|
{ |
498
|
|
|
$sql = "select r.id, r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero, ". |
499
|
|
|
"case when r.ocupado then 'Si' else 'NO' end as ocupado, r.fecha_ocupacion, rme.padre_id, ". |
500
|
|
|
"ret.descripcion as padre_desc, rme.codigo_padre, ret2.descripcion as edif_desc, codigo_edificacion ". |
501
|
|
|
" from residentes_edificaciones as r ". |
502
|
|
|
" join residentes_mapa_edificaciones as rme on (r.id_edificacion = rme.id ".$whereSQL.") ". |
503
|
|
|
" join residentes_edificaciones_tipo as ret on (rme.padre_tipo = ret.id) ". |
504
|
|
|
" join residentes_edificaciones_tipo as ret2 on (rme.id_tipo = ret2.id) ". |
505
|
|
|
" left join clientes as c on (r.codcliente = c.codcliente) ". |
506
|
|
|
" order by ".$sort." ".$order; |
507
|
|
|
if ($todo) { |
|
|
|
|
508
|
|
|
$data = $this->db->select($sql); |
509
|
|
|
} else { |
510
|
|
|
$data = $this->db->select_limit($sql, $limit, $offset); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
$sql_cantidad = "select count(r.id) as total from residentes_edificaciones as r"; |
514
|
|
|
if ($whereSQL) { |
515
|
|
|
$sql_cantidad.=" WHERE r.codigo!='' ".$whereSQL; |
516
|
|
|
} |
517
|
|
|
$data_cantidad = $this->db->select($sql_cantidad); |
518
|
|
|
return array($data, $data_cantidad[0]['total']); |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* @param false $todo |
523
|
|
|
* @param string $whereSQL |
524
|
|
|
* @param string $sort |
525
|
|
|
* @param string $order |
526
|
|
|
* @param integer $limit |
527
|
|
|
* @param integer $offset |
528
|
|
|
* @return array |
529
|
|
|
*/ |
530
|
|
|
public function listaCobros( |
531
|
|
|
$todo = false, |
532
|
|
|
$whereSQL = '', |
533
|
|
|
$sort = 'r.codigo, r.numero', |
534
|
|
|
$order = 'ASC', |
535
|
|
|
$limit = FS_ITEM_LIMIT, |
|
|
|
|
536
|
|
|
$offset = 0 |
537
|
|
|
) |
538
|
|
|
{ |
539
|
|
|
$sql = "select r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero, ". |
540
|
|
|
"sum(f1.total) as pagado, sum(f2.total) as pendiente ". |
541
|
|
|
" from residentes_edificaciones as r ". |
542
|
|
|
" join clientes as c on (r.codcliente = c.codcliente ".$whereSQL.") ". |
543
|
|
|
" left join (select codcliente,anulada,pagada, sum(total) as total ". |
544
|
|
|
"from facturascli group by codcliente,anulada, pagada ) as f1 on ". |
545
|
|
|
"(r.codcliente = f1.codcliente and f1.anulada = false and f1.pagada = true) ". |
546
|
|
|
" left join (select codcliente,anulada,pagada, sum(total) as total ". |
547
|
|
|
"from facturascli group by codcliente,anulada, pagada ) as f2 on ". |
548
|
|
|
"(r.codcliente = f2.codcliente and f2.anulada = false and f2.pagada = false) ". |
549
|
|
|
" group by r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero ". |
550
|
|
|
" order by ".$sort." ".$order; |
551
|
|
|
if ($todo) { |
|
|
|
|
552
|
|
|
$data = $this->db->select($sql); |
553
|
|
|
} else { |
554
|
|
|
$data = $this->db->select_limit($sql, $limit, $offset); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
$sql_cantidad = "select count(r.id) as total ". |
558
|
|
|
" from residentes_edificaciones as r". |
559
|
|
|
" where r.codcliente != '' ".$whereSQL; |
560
|
|
|
$data_cantidad = $this->db->select($sql_cantidad); |
561
|
|
|
return array($data, $data_cantidad[0]['total']); |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
public function totalFacturas() |
565
|
|
|
{ |
566
|
|
|
$sql = "SELECT count(idfactura) as total from facturascli where codcliente = ". $this->codcliente .";"; |
567
|
|
|
$data = $this->db->select($sql); |
568
|
|
|
|
569
|
|
|
return $data[0]['total']; |
570
|
|
|
} |
571
|
|
|
} |
572
|
|
|
|
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