@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $this->nueva_factura(); |
86 | 86 | } |
87 | 87 | $this->informacionResidente(); |
88 | - } else { |
|
88 | + }else { |
|
89 | 89 | $this->new_error_msg('Residente no encontrado.'); |
90 | 90 | } |
91 | 91 | } |
@@ -100,26 +100,26 @@ discard block |
||
100 | 100 | |
101 | 101 | public function informacionResidente() |
102 | 102 | { |
103 | - $this->page->title = 'Residente ' . $this->residente->nombre; |
|
103 | + $this->page->title = 'Residente '.$this->residente->nombre; |
|
104 | 104 | $factura = new factura_cliente(); |
105 | 105 | $totalFacturas = $this->residente->totalFacturas(); |
106 | - $cantidadGrupos = ceil($totalFacturas/FS_ITEM_LIMIT); |
|
106 | + $cantidadGrupos = ceil($totalFacturas / FS_ITEM_LIMIT); |
|
107 | 107 | $facts = []; |
108 | - for($i = 0; $i < $cantidadGrupos; $i++ ) { |
|
108 | + for ($i = 0; $i < $cantidadGrupos; $i++) { |
|
109 | 109 | $documentos = $factura->all_from_cliente($this->residente->codcliente, FS_ITEM_LIMIT * $i); |
110 | 110 | $facts = array_merge($facts, $documentos); |
111 | 111 | } |
112 | 112 | $this->facturas = array(); |
113 | 113 | $articulosCobrados = array(); |
114 | 114 | foreach ($facts as $fac) { |
115 | - if(!$fac->anulada) { |
|
115 | + if (!$fac->anulada) { |
|
116 | 116 | $fac->referencias = ""; |
117 | 117 | foreach ($fac->get_lineas() as $linea) { |
118 | 118 | if ($linea->referencia) { |
119 | - $fac->referencias .= $linea->referencia . " "; |
|
119 | + $fac->referencias .= $linea->referencia." "; |
|
120 | 120 | $this->validarArticulos($articulosCobrados, $fac, $linea); |
121 | - } else { |
|
122 | - $fac->referencias .= $linea->descripcion . " "; |
|
121 | + }else { |
|
122 | + $fac->referencias .= $linea->descripcion." "; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | $this->facturas[] = $fac; |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | $this->lineasLibresFactura($factura, 'otro2'); |
183 | 183 | |
184 | 184 | $this->totalFactura($factura); |
185 | - } else { |
|
185 | + }else { |
|
186 | 186 | $this->new_error_msg('Imposible guardar la factura.'); |
187 | 187 | } |
188 | - } else { |
|
188 | + }else { |
|
189 | 189 | $this->new_error_msg('Cliente no encontrado.'); |
190 | 190 | } |
191 | 191 | } |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | $art0 = new articulo(); |
251 | 251 | $lineas = \filter_input(INPUT_POST, 'numlineas'); |
252 | 252 | for ($x = 0; $x < $lineas; $x++) { |
253 | - $referencia = \filter_input(INPUT_POST, 'referencia_' . $x); |
|
254 | - $importe = \filter_input(INPUT_POST, 'importe_' . $x); |
|
255 | - $impuesto = \filter_input(INPUT_POST, 'impuesto_' . $x); |
|
253 | + $referencia = \filter_input(INPUT_POST, 'referencia_'.$x); |
|
254 | + $importe = \filter_input(INPUT_POST, 'importe_'.$x); |
|
255 | + $impuesto = \filter_input(INPUT_POST, 'impuesto_'.$x); |
|
256 | 256 | $art = $art0->get($referencia); |
257 | - if ((float)$importe) { |
|
257 | + if ((float) $importe) { |
|
258 | 258 | $linea = new linea_factura_cliente(); |
259 | 259 | $linea->idfactura = $factura->idfactura; |
260 | 260 | $linea->referencia = $referencia; |
261 | - $linea->descripcion = ($art) ? $art->descripcion : $referencia . ' Articulo libre'; |
|
261 | + $linea->descripcion = ($art) ? $art->descripcion : $referencia.' Articulo libre'; |
|
262 | 262 | $linea->cantidad = 1; |
263 | 263 | $imp = $this->impuesto->get($impuesto); |
264 | 264 | if ($imp) { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $linea->codimpuesto = $imp->codimpuesto; |
290 | 290 | $linea->iva = $imp->iva; |
291 | 291 | $linea->pvpsindto = $linea->pvptotal = $linea->pvpunitario = |
292 | - (100 * (float)\filter_input(INPUT_POST, $linea_nombre)) / (100 + $imp->iva); |
|
292 | + (100 * (float) \filter_input(INPUT_POST, $linea_nombre)) / (100 + $imp->iva); |
|
293 | 293 | |
294 | 294 | $articulo = (\filter_input(INPUT_POST, 'ref_'.$linea_nombre)) |
295 | 295 | ? $art0->get(\filter_input(INPUT_POST, 'ref_'.$linea_nombre)) |
@@ -315,19 +315,19 @@ discard block |
||
315 | 315 | $factura->totalrecargo = round($factura->totalrecargo, FS_NF0); |
316 | 316 | $factura->total = $factura->neto + $factura->totaliva - $factura->totalirpf + $factura->totalrecargo; |
317 | 317 | |
318 | - if (abs((float)(\filter_input(INPUT_POST, 'total_importe')) - $factura->total) > .01) { |
|
319 | - $this->new_error_msg("El total difiere entre la vista y el controlador (" . |
|
320 | - \filter_input(INPUT_POST, 'total_importe') . |
|
321 | - " frente a " . $factura->total . "). Debes informar del error."); |
|
318 | + if (abs((float) (\filter_input(INPUT_POST, 'total_importe')) - $factura->total) > .01) { |
|
319 | + $this->new_error_msg("El total difiere entre la vista y el controlador (". |
|
320 | + \filter_input(INPUT_POST, 'total_importe'). |
|
321 | + " frente a ".$factura->total."). Debes informar del error."); |
|
322 | 322 | $factura->delete(); |
323 | 323 | } elseif ($factura->save()) { |
324 | 324 | $this->generar_asiento($factura); |
325 | 325 | /// Función de ejecución de tareas post guardado correcto de la factura |
326 | 326 | fs_documento_post_save($factura); |
327 | - $this->new_message("<a href='" . $factura->url() . "'>Factura</a> guardada correctamente."); |
|
328 | - $this->new_change('Factura Cliente ' . $factura->codigo, $factura->url(), true); |
|
329 | - } else { |
|
330 | - $this->new_error_msg("¡Imposible actualizar la <a href='" . $factura->url() . "'>Factura</a>!"); |
|
327 | + $this->new_message("<a href='".$factura->url()."'>Factura</a> guardada correctamente."); |
|
328 | + $this->new_change('Factura Cliente '.$factura->codigo, $factura->url(), true); |
|
329 | + }else { |
|
330 | + $this->new_error_msg("¡Imposible actualizar la <a href='".$factura->url()."'>Factura</a>!"); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | if ($this->empresa->contintegrada) { |
341 | 341 | $asiento_factura = new asiento_factura(); |
342 | 342 | $asiento_factura->generar_asiento_venta($factura); |
343 | - } else { |
|
343 | + }else { |
|
344 | 344 | /// de todas formas forzamos la generación de las líneas de iva |
345 | 345 | $factura->get_lineas_iva(); |
346 | 346 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | /// añadimos todas la página |
380 | 380 | while ($num < $this->total_facturas) { |
381 | 381 | $paginas[$i] = array( |
382 | - 'url' => $url . "&offset=" . ($i * FS_ITEM_LIMIT), |
|
382 | + 'url' => $url."&offset=".($i * FS_ITEM_LIMIT), |
|
383 | 383 | 'num' => $i + 1, |
384 | 384 | 'actual' => ($num == $this->offset) |
385 | 385 | ); |
@@ -394,20 +394,20 @@ discard block |
||
394 | 394 | |
395 | 395 | /// ahora descartamos |
396 | 396 | foreach ($paginas as $j => $value) { |
397 | - $enmedio = (int)($i / 2); |
|
397 | + $enmedio = (int) ($i / 2); |
|
398 | 398 | |
399 | 399 | /** |
400 | 400 | * descartamos todo excepto la primera, la última, la de enmedio, |
401 | 401 | * la actual, las 5 anteriores y las 5 siguientes |
402 | 402 | */ |
403 | - if (($j>1 && $j<$actual-5 && $j !== $enmedio) || ($j > $actual + 5 && $j < $i - 1 && $j !== $enmedio)) { |
|
403 | + if (($j > 1 && $j < $actual - 5 && $j !== $enmedio) || ($j > $actual + 5 && $j < $i - 1 && $j !== $enmedio)) { |
|
404 | 404 | unset($paginas[$j]); |
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | 408 | if (count($paginas) > 1) { |
409 | 409 | return $paginas; |
410 | - } else { |
|
410 | + }else { |
|
411 | 411 | return array(); |
412 | 412 | } |
413 | 413 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @author Joe Nilson <joenilson at gmail.com> |
23 | 23 | */ |
24 | -class residentes_edificaciones extends \fs_model{ |
|
24 | +class residentes_edificaciones extends \fs_model { |
|
25 | 25 | /** |
26 | 26 | * El Id de la de edificacion |
27 | 27 | * @var integer serial |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | public $cliente_info; |
96 | 96 | public $cliente_vehiculo; |
97 | 97 | public function __construct($t = FALSE) { |
98 | - parent::__construct('residentes_edificaciones','plugins/residentes'); |
|
99 | - if($t){ |
|
98 | + parent::__construct('residentes_edificaciones', 'plugins/residentes'); |
|
99 | + if ($t) { |
|
100 | 100 | $this->id = $t['id']; |
101 | 101 | $this->iddireccion = $t['iddireccion']; |
102 | 102 | $this->id_edificacion = $t['id_edificacion']; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $this->ocupado = $this->str2bool($t['ocupado']); |
110 | 110 | $this->fecha_ocupacion = $t['fecha_ocupacion']; |
111 | 111 | $this->fecha_disponibilidad = $t['fecha_disponibilidad']; |
112 | - }else{ |
|
112 | + }else { |
|
113 | 113 | $this->id = null; |
114 | 114 | $this->iddireccion = 0; |
115 | 115 | $this->id_edificacion = null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | if (!is_null($this->id)) { |
149 | 149 | return FS_PATH.'index.php?page=ver_residente&id='.$this->id; |
150 | - } else { |
|
150 | + }else { |
|
151 | 151 | return FS_PATH.'index.php?page=residentes'; |
152 | 152 | } |
153 | 153 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $lista[] = $item; |
178 | 178 | } |
179 | 179 | return $lista; |
180 | - } else { |
|
180 | + }else { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | } |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | return $this->listaInfo($data); |
199 | 199 | } |
200 | 200 | |
201 | - public function get($id){ |
|
201 | + public function get($id) { |
|
202 | 202 | $sql = "SELECT * FROM ".$this->table_name." WHERE id = ".$this->intval($id).";"; |
203 | 203 | $data = $this->db->select($sql); |
204 | - if($data){ |
|
204 | + if ($data) { |
|
205 | 205 | $item = new residentes_edificaciones($data[0]); |
206 | 206 | $item->pertenencia = $this->pertenencia($item); |
207 | 207 | $this->info($item); |
208 | 208 | return $item; |
209 | - }else{ |
|
209 | + }else { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | } |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | * @param string $value |
218 | 218 | * @return boolean|\FacturaScripts\model\residentes_edificaciones |
219 | 219 | */ |
220 | - public function get_by_field($field,$value){ |
|
221 | - $query = (is_string($value))?$this->var2str($value):$this->intval($value); |
|
220 | + public function get_by_field($field, $value) { |
|
221 | + $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value); |
|
222 | 222 | $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query. |
223 | 223 | " ORDER BY codigo_interno,numero;"; |
224 | 224 | $data = $this->db->select($sql); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | if (is_null($this->id)) { |
231 | 231 | return false; |
232 | - } else { |
|
232 | + }else { |
|
233 | 233 | return $this->get($this->id); |
234 | 234 | } |
235 | 235 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | "ocupado = ".$this->var2str($this->ocupado)." ". |
252 | 252 | "WHERE id = ".$this->intval($this->id).";"; |
253 | 253 | return $this->db->exec($sql); |
254 | - } else { |
|
254 | + }else { |
|
255 | 255 | $sql = "INSERT INTO ".$this->table_name." (id_edificacion, iddireccion, codigo, codigo_interno, numero, ubicacion, coordenadas,codcliente, ocupado, fecha_ocupacion, fecha_disponibilidad) VALUES (". |
256 | 256 | $this->intval($this->id_edificacion).", ". |
257 | 257 | $this->intval($this->iddireccion).", ". |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $this->var2str($this->fecha_disponibilidad).");"; |
267 | 267 | if ($this->db->exec($sql)) { |
268 | 268 | return $this->db->lastval(); |
269 | - } else { |
|
269 | + }else { |
|
270 | 270 | return false; |
271 | 271 | } |
272 | 272 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | public function buscar_ubicacion_inmueble($id, $linea) |
310 | 310 | { |
311 | - $inicio_busqueda = ($linea===0)?"{\"":"{%\""; |
|
311 | + $inicio_busqueda = ($linea === 0) ? "{\"" : "{%\""; |
|
312 | 312 | $sql = "SELECT * FROM ".$this->table_name." WHERE codigo_interno LIKE '". |
313 | 313 | $inicio_busqueda.$id."\":%}' ORDER BY codigo;"; |
314 | 314 | $data = $this->db->select($sql); |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | $lista[] = $this->pertenencia($l); |
320 | 320 | } |
321 | 321 | return $lista; |
322 | - } else { |
|
322 | + }else { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | - public function buscar_cantidad_inmuebles($id,$linea) |
|
327 | + public function buscar_cantidad_inmuebles($id, $linea) |
|
328 | 328 | { |
329 | - $inicio_busqueda = ($linea===0)?"{\"":"{%\""; |
|
329 | + $inicio_busqueda = ($linea === 0) ? "{\"" : "{%\""; |
|
330 | 330 | $sql = "SELECT DISTINCT codigo FROM ".$this->table_name." WHERE codigo_interno LIKE '". |
331 | 331 | $inicio_busqueda.$id."\":%}' ORDER BY codigo;"; |
332 | 332 | $data = $this->db->select($sql); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $lista[] = $l; |
338 | 338 | } |
339 | 339 | return $lista; |
340 | - } else { |
|
340 | + }else { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $data = $this->db->select($sql); |
350 | 350 | if ($data) { |
351 | 351 | return $data[0]['cantidad']; |
352 | - } else { |
|
352 | + }else { |
|
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $mapa = array(); |
361 | 361 | $linea = 0; |
362 | 362 | foreach ($edificaciones_tipo->all() as $data) { |
363 | - if ($linea===1) { |
|
363 | + if ($linea === 1) { |
|
364 | 364 | break; |
365 | 365 | } |
366 | 366 | $items = $this->buscar_cantidad_inmuebles($data->id, $data->padre); |
@@ -376,19 +376,19 @@ discard block |
||
376 | 376 | { |
377 | 377 | $sql = "SELECT * FROM ".$this->table_name." WHERE "; |
378 | 378 | $OR = ""; |
379 | - if ($type=='inmueble') { |
|
380 | - $sql.=" numero LIKE '%".strtoupper($query)."%' "; |
|
381 | - $sql.=" OR codigo LIKE '%".strtoupper($query)."%' "; |
|
382 | - } else { |
|
379 | + if ($type == 'inmueble') { |
|
380 | + $sql .= " numero LIKE '%".strtoupper($query)."%' "; |
|
381 | + $sql .= " OR codigo LIKE '%".strtoupper($query)."%' "; |
|
382 | + }else { |
|
383 | 383 | if (is_int($query)) { |
384 | - $sql.=" id_edificacion LIKE '%".$query."%' "; |
|
385 | - $sql.=" id LIKE '%".$query."%' "; |
|
384 | + $sql .= " id_edificacion LIKE '%".$query."%' "; |
|
385 | + $sql .= " id LIKE '%".$query."%' "; |
|
386 | 386 | $OR = "OR"; |
387 | 387 | } |
388 | - $sql.=" $OR numero LIKE '%".strtoupper($query)."%' "; |
|
389 | - $sql.=" OR codigo LIKE '%".strtoupper($query)."%' "; |
|
388 | + $sql .= " $OR numero LIKE '%".strtoupper($query)."%' "; |
|
389 | + $sql .= " OR codigo LIKE '%".strtoupper($query)."%' "; |
|
390 | 390 | } |
391 | - $sql.=" ORDER BY codigo,numero"; |
|
391 | + $sql .= " ORDER BY codigo,numero"; |
|
392 | 392 | $data = $this->db->select($sql); |
393 | 393 | $lista = array(); |
394 | 394 | if ($data) { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | " order by ".$sort." ".$order; |
469 | 469 | if ($todo) { |
470 | 470 | $data = $this->db->select($sql); |
471 | - } else { |
|
471 | + }else { |
|
472 | 472 | $data = $this->db->select_limit($sql, $limit, $offset); |
473 | 473 | } |
474 | 474 | $sql_cantidad = "select count(r.id) as total from residentes_edificaciones as r ". |
@@ -506,13 +506,13 @@ discard block |
||
506 | 506 | " order by ".$sort." ".$order; |
507 | 507 | if ($todo) { |
508 | 508 | $data = $this->db->select($sql); |
509 | - } else { |
|
509 | + }else { |
|
510 | 510 | $data = $this->db->select_limit($sql, $limit, $offset); |
511 | 511 | } |
512 | 512 | |
513 | 513 | $sql_cantidad = "select count(r.id) as total from residentes_edificaciones as r"; |
514 | 514 | if ($whereSQL) { |
515 | - $sql_cantidad.=" WHERE r.codigo!='' ".$whereSQL; |
|
515 | + $sql_cantidad .= " WHERE r.codigo!='' ".$whereSQL; |
|
516 | 516 | } |
517 | 517 | $data_cantidad = $this->db->select($sql_cantidad); |
518 | 518 | return array($data, $data_cantidad[0]['total']); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | " order by ".$sort." ".$order; |
551 | 551 | if ($todo) { |
552 | 552 | $data = $this->db->select($sql); |
553 | - } else { |
|
553 | + }else { |
|
554 | 554 | $data = $this->db->select_limit($sql, $limit, $offset); |
555 | 555 | } |
556 | 556 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | |
564 | 564 | public function totalFacturas() |
565 | 565 | { |
566 | - $sql = "SELECT count(idfactura) as total from facturascli where codcliente = ". $this->codcliente .";"; |
|
566 | + $sql = "SELECT count(idfactura) as total from facturascli where codcliente = ".$this->codcliente.";"; |
|
567 | 567 | $data = $this->db->select($sql); |
568 | 568 | |
569 | 569 | return $data[0]['total']; |