Passed
Push — master ( f5cc14...b18210 )
by Joe Nilson
02:17
created
controller/lista_residentes.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
                 $inq->fecha_ocupacion = null;
76 76
                 if ($inq->save()) {
77 77
                     $this->new_message('Inquilino removido correctamente.');
78
-                } else {
78
+                }else {
79 79
                     $this->new_error_msg('Error al remover el inquilino.');
80 80
                 }
81
-            } else {
81
+            }else {
82 82
                 $this->new_error_msg('Inquilino no encontrado.');
83 83
             }
84 84
         }
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
     public function buscar_residentes($param)
189 189
     {
190 190
         if (is_numeric($param)) {
191
-            $where = "(r.codcliente LIKE '%" . $param . "%'"
192
-                    . " OR c.cifnif LIKE '%" . $param . "%'"
193
-                    . " OR c.telefono1 LIKE '" . $param . "%'"
194
-                    . " OR c.telefono2 LIKE '" . $param . "%'"
195
-                    . " OR ca_telefono LIKE '" . $param . "%'"
196
-                    . " OR r.observaciones LIKE '%" . $param . "%')";
197
-        } else {
191
+            $where = "(r.codcliente LIKE '%".$param."%'"
192
+                    . " OR c.cifnif LIKE '%".$param."%'"
193
+                    . " OR c.telefono1 LIKE '".$param."%'"
194
+                    . " OR c.telefono2 LIKE '".$param."%'"
195
+                    . " OR ca_telefono LIKE '".$param."%'"
196
+                    . " OR r.observaciones LIKE '%".$param."%')";
197
+        }else {
198 198
             $buscar = str_replace(' ', '%', $param);
199
-            $where = "(lower(nombre) LIKE '%" . $buscar . "%'"
200
-                    . " OR lower(razonsocial) LIKE '%" . $buscar . "%'"
201
-                    . " OR lower(ca_apellidos) LIKE '%" . $buscar . "%'"
202
-                    . " OR lower(ca_nombres) LIKE '%" . $buscar . "%'"
203
-                    . " OR lower(cifnif) LIKE '%" . $buscar . "%'"
204
-                    . " OR lower(observaciones) LIKE '%" . $buscar . "%'"
205
-                    . " OR lower(ca_email) LIKE '%" . $buscar . "%'"
206
-                    . " OR lower(email) LIKE '%" . $buscar . "%')";
199
+            $where = "(lower(nombre) LIKE '%".$buscar."%'"
200
+                    . " OR lower(razonsocial) LIKE '%".$buscar."%'"
201
+                    . " OR lower(ca_apellidos) LIKE '%".$buscar."%'"
202
+                    . " OR lower(ca_nombres) LIKE '%".$buscar."%'"
203
+                    . " OR lower(cifnif) LIKE '%".$buscar."%'"
204
+                    . " OR lower(observaciones) LIKE '%".$buscar."%'"
205
+                    . " OR lower(ca_email) LIKE '%".$buscar."%'"
206
+                    . " OR lower(email) LIKE '%".$buscar."%')";
207 207
         }
208 208
         return $where;
209 209
     }
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
     public function buscar_inmuebles($param)
212 212
     {
213 213
         if (is_numeric($param)) {
214
-            $where = " r.codigo LIKE '%" . $param . "%'"
215
-                    . " OR r.numero LIKE '%" . $param . "%'"
216
-                    . " OR CONCAT(r.codigo, r.numero) LIKE '%" . $param . "%'";
217
-        } else {
214
+            $where = " r.codigo LIKE '%".$param."%'"
215
+                    . " OR r.numero LIKE '%".$param."%'"
216
+                    . " OR CONCAT(r.codigo, r.numero) LIKE '%".$param."%'";
217
+        }else {
218 218
             $buscar = str_replace(' ', '%', $param);
219
-            $where = " lower(r.codigo) LIKE '%" . $buscar . "%'"
220
-                    . " OR lower(r.numero) LIKE '%" . $buscar . "%'"
221
-                    . " OR CONCAT(lower(r.codigo), r.numero) LIKE '%" . $param . "%'";
219
+            $where = " lower(r.codigo) LIKE '%".$buscar."%'"
220
+                    . " OR lower(r.numero) LIKE '%".$buscar."%'"
221
+                    . " OR CONCAT(lower(r.codigo), r.numero) LIKE '%".$param."%'";
222 222
         }
223 223
         return $where;
224 224
     }
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
     public function buscar_vehiculos($param)
227 227
     {
228 228
         if (is_numeric($param)) {
229
-            $where = "(r.codcliente LIKE '%" . $param . "%'"
230
-                    . " OR vehiculo_placa LIKE '%" . $param . "%'"
231
-                    . " OR CAST(idvehiculo AS CHAR) LIKE '" . $param . "%'"
232
-                    . " OR telefono2 LIKE '" . $param . "%'"
233
-                    . " OR observaciones LIKE '%" . $param . "%')";
234
-        } else {
229
+            $where = "(r.codcliente LIKE '%".$param."%'"
230
+                    . " OR vehiculo_placa LIKE '%".$param."%'"
231
+                    . " OR CAST(idvehiculo AS CHAR) LIKE '".$param."%'"
232
+                    . " OR telefono2 LIKE '".$param."%'"
233
+                    . " OR observaciones LIKE '%".$param."%')";
234
+        }else {
235 235
             $buscar = str_replace(' ', '%', $param);
236
-            $where = "(lower(vehiculo_marca) LIKE '%" . $buscar . "%'"
237
-                    . " OR lower(vehiculo_modelo) LIKE '%" . $buscar . "%'"
238
-                    . " OR lower(vehiculo_color) LIKE '%" . $buscar . "%'"
239
-                    . " OR lower(vehiculo_placa) LIKE '%" . $buscar . "%'"
240
-                    . " OR lower(vehiculo_tipo) LIKE '%" . $buscar . "%'"
241
-                    . " OR lower(codigo_tarjeta) LIKE '%" . $buscar . "%')";
236
+            $where = "(lower(vehiculo_marca) LIKE '%".$buscar."%'"
237
+                    . " OR lower(vehiculo_modelo) LIKE '%".$buscar."%'"
238
+                    . " OR lower(vehiculo_color) LIKE '%".$buscar."%'"
239
+                    . " OR lower(vehiculo_placa) LIKE '%".$buscar."%'"
240
+                    . " OR lower(vehiculo_tipo) LIKE '%".$buscar."%'"
241
+                    . " OR lower(codigo_tarjeta) LIKE '%".$buscar."%')";
242 242
         }
243 243
         return $where;
244 244
     }
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
             $inmueble->ocupado = true;
258 258
             $inmueble->codcliente = $codcliente;
259 259
             $inmueble->iddireccion = $this->actualizar_direccion_residente($codcliente, $iddireccion, $nueva_direccion);
260
-            $inmueble->fecha_ocupacion = ($fecha_ocupacion)?\date('Y-m-d', strtotime($fecha_ocupacion)):null;
260
+            $inmueble->fecha_ocupacion = ($fecha_ocupacion) ?\date('Y-m-d', strtotime($fecha_ocupacion)) : null;
261 261
             $inmueble->fecha_disponibilidad = ($fecha_disponibilidad)
262 262
                 ?\date('Y-m-d', strtotime($fecha_disponibilidad))
263 263
                 :null;
264 264
             if ($inmueble->save()) {
265 265
                 $this->new_message('Residente agregado exitosamente.');
266
-            } else {
266
+            }else {
267 267
                 $this->new_error_msg('No se pudo agregar al residente confirme el nombre '.
268 268
                                     'del residente y las fechs de ocupación y disponibilidad');
269 269
             }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             $inmueble->fecha_disponibilidad = '';
276 276
             if ($inmueble->save()) {
277 277
                 $this->new_message('Residente removido exitosamente.');
278
-            } else {
278
+            }else {
279 279
                 $this->new_error_msg('No se pudo remover al residente');
280 280
             }
281 281
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                         'nombre' => $cli->nombre,
311 311
                         'asignado' => true);
312 312
                 }
313
-            } else {
313
+            }else {
314 314
                 $json[$cli->codcliente] = array('value' => $cli->nombre,
315 315
                     'data' => $cli->codcliente,
316 316
                     'nombre' => $cli->nombre,
@@ -367,13 +367,13 @@  discard block
 block discarded – undo
367 367
 
368 368
     public function paginas()
369 369
     {
370
-        $url = $this->url() . "&query=" . $this->query
371
-                . "&query_r=" . $this->query_r
372
-                . "&query_v=" . $this->query_v
373
-                . "&query_i=" . $this->query_i
374
-                . "&orden=" . $this->order
375
-                . "&deudores=" . $this->deudores
376
-                . "&disponibles=" . $this->disponibles;
370
+        $url = $this->url()."&query=".$this->query
371
+                . "&query_r=".$this->query_r
372
+                . "&query_v=".$this->query_v
373
+                . "&query_i=".$this->query_i
374
+                . "&orden=".$this->order
375
+                . "&deudores=".$this->deudores
376
+                . "&disponibles=".$this->disponibles;
377 377
 
378 378
         $paginas = array();
379 379
         $i = 0;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         /// añadimos todas la página
384 384
         while ($num < $this->total_resultados) {
385 385
             $paginas[$i] = array(
386
-                'url' => $url . "&offset=" . ($i * FS_ITEM_LIMIT),
386
+                'url' => $url."&offset=".($i * FS_ITEM_LIMIT),
387 387
                 'num' => $i + 1,
388 388
                 'actual' => ($num === $this->offset)
389 389
             );
@@ -398,20 +398,20 @@  discard block
 block discarded – undo
398 398
 
399 399
         /// ahora descartamos
400 400
         foreach ($paginas as $j => $value) {
401
-            $enmedio = (int)($i / 2);
401
+            $enmedio = (int) ($i / 2);
402 402
 
403 403
             /**
404 404
              * descartamos todo excepto la primera, la última, la de enmedio,
405 405
              * la actual, las 5 anteriores y las 5 siguientes
406 406
              */
407
-            if (($j>1 && $j<$actual-5 && $j !== $enmedio) || ($j > $actual + 5 && $j < $i - 1 && $j !== $enmedio)) {
407
+            if (($j > 1 && $j < $actual - 5 && $j !== $enmedio) || ($j > $actual + 5 && $j < $i - 1 && $j !== $enmedio)) {
408 408
                 unset($paginas[$j]);
409 409
             }
410 410
         }
411 411
 
412 412
         if (count($paginas) > 1) {
413 413
             return $paginas;
414
-        } else {
414
+        }else {
415 415
             return array();
416 416
         }
417 417
     }
Please login to merge, or discard this patch.
controller/clientes_informacion.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -103,31 +103,31 @@  discard block
 block discarded – undo
103 103
             $ca_parentesco_obs = $this->clean_text(\filter_input(INPUT_POST, 'ca_parentesco_obs'));
104 104
             $vehiculos = \filter_input(INPUT_POST, 'vehiculos');
105 105
             $cliinfo = new residentes_informacion();
106
-            $cliinfo->codcliente=$codcliente;
107
-            $cliinfo->codigo=$codigo;
108
-            $cliinfo->ocupantes=$ocupantes;
109
-            $cliinfo->ocupantes5anos=$ocupantes5anos;
110
-            $cliinfo->ocupantes12anos=$ocupantes12anos;
111
-            $cliinfo->ocupantes18anos=$ocupantes18anos;
112
-            $cliinfo->ocupantes30anos=$ocupantes30anos;
113
-            $cliinfo->ocupantes50anos=$ocupantes50anos;
114
-            $cliinfo->ocupantes70anos=$ocupantes70anos;
115
-            $cliinfo->ocupantes71anos=$ocupantes71anos;
116
-            $cliinfo->informacion_discapacidad= $informacion_discapacidad;
117
-            $cliinfo->propietario= (bool)$propietario;
118
-            $cliinfo->profesion= $profesion;
119
-            $cliinfo->ocupacion= $ocupacion;
120
-            $cliinfo->ca_nombres= $ca_nombres;
121
-            $cliinfo->ca_apellidos= $ca_apellidos;
122
-            $cliinfo->ca_telefono= $ca_telefono;
123
-            $cliinfo->ca_email= $ca_email;
124
-            $cliinfo->ca_propietario= (bool)$ca_propietario;
125
-            $cliinfo->ca_parentesco= $ca_parentesco;
126
-            $cliinfo->ca_parentesco_obs= $ca_parentesco_obs;
127
-            $cliinfo->vehiculos= $vehiculos;
106
+            $cliinfo->codcliente = $codcliente;
107
+            $cliinfo->codigo = $codigo;
108
+            $cliinfo->ocupantes = $ocupantes;
109
+            $cliinfo->ocupantes5anos = $ocupantes5anos;
110
+            $cliinfo->ocupantes12anos = $ocupantes12anos;
111
+            $cliinfo->ocupantes18anos = $ocupantes18anos;
112
+            $cliinfo->ocupantes30anos = $ocupantes30anos;
113
+            $cliinfo->ocupantes50anos = $ocupantes50anos;
114
+            $cliinfo->ocupantes70anos = $ocupantes70anos;
115
+            $cliinfo->ocupantes71anos = $ocupantes71anos;
116
+            $cliinfo->informacion_discapacidad = $informacion_discapacidad;
117
+            $cliinfo->propietario = (bool) $propietario;
118
+            $cliinfo->profesion = $profesion;
119
+            $cliinfo->ocupacion = $ocupacion;
120
+            $cliinfo->ca_nombres = $ca_nombres;
121
+            $cliinfo->ca_apellidos = $ca_apellidos;
122
+            $cliinfo->ca_telefono = $ca_telefono;
123
+            $cliinfo->ca_email = $ca_email;
124
+            $cliinfo->ca_propietario = (bool) $ca_propietario;
125
+            $cliinfo->ca_parentesco = $ca_parentesco;
126
+            $cliinfo->ca_parentesco_obs = $ca_parentesco_obs;
127
+            $cliinfo->vehiculos = $vehiculos;
128 128
             if ($cliinfo->save()) {
129 129
                 $this->new_message('¡Información actualizada correctamente!');
130
-            } else {
130
+            }else {
131 131
                 $this->new_error_msg('Ocurrió un error al actualizar la información por favor revise los ".
132 132
                 "datos ingresados e intente nuevamente.');
133 133
             }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         foreach ($extensiones as $ext) {
163 163
             $fsext0 = new fs_extension($ext);
164 164
             if (!$fsext0->save()) {
165
-                $this->new_error_msg('Imposible guardar los datos de la extensión ' . $ext['name'] . '.');
165
+                $this->new_error_msg('Imposible guardar los datos de la extensión '.$ext['name'].'.');
166 166
             }
167 167
         }
168 168
     }
Please login to merge, or discard this patch.
model/core/residente.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             if (isset($i['deudas'])) {
57 57
                 $this->deudas = floatval($i['deudas']);
58 58
             }
59
-        } else {
59
+        }else {
60 60
             $this->id = null;
61 61
             $this->codcliente = null;
62 62
             $this->fechaalta = Date('d-m-Y');
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
             return '-';
90 90
         } elseif (strlen($this->observaciones) < 60) {
91 91
             return $this->observaciones;
92
-        } else {
93
-            return substr($this->observaciones, 0, 60) . '...';
92
+        }else {
93
+            return substr($this->observaciones, 0, 60).'...';
94 94
         }
95 95
     }
96 96
 
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
         $data = $this->db->select("SELECT * FROM residentes WHERE id = ".$this->var2str($id).";");
100 100
         if ($data) {
101 101
             return new residente($data[0]);
102
-        } else {
102
+        }else {
103 103
             return false;
104 104
         }
105 105
     }
106 106
 
107 107
     public function exists()
108 108
     {
109
-        if(is_null($this->id)) {
109
+        if (is_null($this->id)) {
110 110
             return false;
111
-        } else {
111
+        }else {
112 112
             return $this->db->select("SELECT * FROM residentes WHERE id = ".$this->var2str($this->id).";");
113 113
         }
114 114
     }
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
                 deudas = ".$this->var2str($this->deudas)." WHERE id = ".$this->var2str($this->id).";";
126 126
 
127 127
             return $this->db->exec($sql);
128
-        } else {
128
+        }else {
129 129
             $sql = "INSERT INTO residentes (codcliente,nombre,fechaalta,piso,bloque,mensualidad,agua,gas,".
130
-            "observaciones,fechaagua,fechagas,deudas) " . "VALUES (".$this->var2str($this->codcliente).",".
130
+            "observaciones,fechaagua,fechagas,deudas) "."VALUES (".$this->var2str($this->codcliente).",".
131 131
             $this->var2str($this->nombre).",".$this->var2str($this->fechaalta).","
132 132
             .$this->var2str($this->piso).",".$this->var2str($this->bloque).",".$this->var2str($this->mensualidad).","
133 133
             .$this->var2str($this->agua).",".$this->var2str($this->gas).",".$this->var2str($this->observaciones).","
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             if ($this->db->exec($sql)) {
137 137
                 $this->id = $this->db->lastval();
138 138
                 return true;
139
-            } else {
139
+            }else {
140 140
                 return false;
141 141
             }
142 142
         }
Please login to merge, or discard this patch.
model/core/residentes_edificaciones_mapa.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @author Joe Nilson <joenilson at gmail.com>
23 23
  */
24
-class residentes_edificaciones_mapa extends \fs_model{
24
+class residentes_edificaciones_mapa extends \fs_model {
25 25
     /**
26 26
      * ID correlativo de cada linea
27 27
      * @var serial
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
     public $padre_id;
61 61
     public $edificaciones_tipo;
62 62
     public function __construct($t = FALSE) {
63
-        parent::__construct('residentes_mapa_edificaciones','plugins/residentes');
64
-        if($t){
63
+        parent::__construct('residentes_mapa_edificaciones', 'plugins/residentes');
64
+        if ($t) {
65 65
             $this->id = $t['id'];
66 66
             $this->id_tipo = $t['id_tipo'];
67 67
             $this->codigo_edificacion = $t['codigo_edificacion'];
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $this->padre_tipo = $t['padre_tipo'];
71 71
             $this->padre_id = $t['padre_id'];
72 72
 
73
-        }else{
73
+        }else {
74 74
             $this->id = null;
75 75
             $this->id_tipo = null;
76 76
             $this->codigo_edificacion = null;
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
         $this->edificaciones_tipo = new \residentes_edificaciones_tipo();
82 82
     }
83 83
 
84
-    public function install(){
84
+    public function install() {
85 85
         return "";
86 86
     }
87 87
 
88
-    public function all(){
88
+    public function all() {
89 89
         $sql = "SELECT * FROM ".$this->table_name." ORDER BY id_tipo,codigo_edificacion";
90 90
         $data = $this->db->select($sql);
91
-        if($data){
91
+        if ($data) {
92 92
             $lista = array();
93
-            foreach($data as $d){
93
+            foreach ($data as $d) {
94 94
                 $item = new residentes_edificaciones_mapa($d);
95 95
                 $lista[] = $item;
96 96
             }
97 97
             return $lista;
98
-        }else{
98
+        }else {
99 99
             return false;
100 100
         }
101 101
     }
@@ -107,29 +107,29 @@  discard block
 block discarded – undo
107 107
      * @param type $padre_tipo integer
108 108
      * @return \FacturaScripts\model\residentes_edificaciones_mapa|boolean
109 109
      */
110
-    public function get($id){
110
+    public function get($id) {
111 111
         $sql = "SELECT * FROM ".$this->table_name.
112 112
                 " WHERE id = ".$this->intval($id).";";
113 113
         $data = $this->db->select($sql);
114
-        if($data){
114
+        if ($data) {
115 115
             $item = new residentes_edificaciones_mapa($data[0]);
116 116
             $item->desc_id = $this->edificaciones_tipo->get($item->id_tipo)->descripcion;
117 117
             return $item;
118
-        }else{
118
+        }else {
119 119
             return false;
120 120
         }
121 121
     }
122 122
 
123
-    public function getEstructura(){
123
+    public function getEstructura() {
124 124
         $sql = "SELECT * FROM ".$this->table_name." WHERE codigo_edificacion = ".$this->var2str($this->codigo_edificacion)." AND ".
125 125
                 " codigo_padre = ".$this->var2str($this->codigo_padre)." AND id_tipo = ".$this->intval($this->id_tipo)." AND ".
126 126
                 " padre_tipo = ".$this->intval($this->padre_tipo)." AND padre_id = ".$this->intval($this->padre_id).";";
127 127
         $data = $this->db->select($sql);
128
-        if($data){
128
+        if ($data) {
129 129
             $item = new residentes_edificaciones_mapa($data[0]);
130 130
             $item->desc_id = $this->edificaciones_tipo->get($item->id_tipo)->descripcion;
131 131
             return $item;
132
-        }else{
132
+        }else {
133 133
             return false;
134 134
         }
135 135
     }
@@ -140,34 +140,34 @@  discard block
 block discarded – undo
140 140
      * @param type $value string
141 141
      * @return boolean|\FacturaScripts\model\residentes_edificaciones_mapa
142 142
      */
143
-    public function get_by_field($field,$value){
144
-        $query = (is_string($value))?$this->var2str($value):$this->intval($value);
143
+    public function get_by_field($field, $value) {
144
+        $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value);
145 145
         $sql = "SELECT rem.*, ret.descripcion FROM ".$this->table_name." as rem, residentes_edificaciones_tipo as ret ".
146 146
                 " WHERE ".strtoupper(trim($field))." = ".$query." AND rem.id_tipo = ret.id order by codigo_edificacion ASC;";
147 147
         $data = $this->db->select($sql);
148
-        if($data){
148
+        if ($data) {
149 149
             $lista = array();
150
-            foreach($data as $d){
150
+            foreach ($data as $d) {
151 151
                 $item = new residentes_edificaciones_mapa($d);
152 152
                 $item->desc_id = $d['descripcion'];
153 153
                 $lista[] = $item;
154 154
             }
155 155
             return $lista;
156
-        }else{
156
+        }else {
157 157
             return false;
158 158
         }
159 159
     }
160 160
 
161 161
     public function exists() {
162
-        if(!$this->getEstructura()){
162
+        if (!$this->getEstructura()) {
163 163
             return false;
164
-        }else{
164
+        }else {
165 165
             return $this->getEstructura();
166 166
         }
167 167
     }
168 168
 
169 169
     public function save() {
170
-        if($this->exists()){
170
+        if ($this->exists()) {
171 171
             $sql = "UPDATE ".$this->table_name." SET ".
172 172
                     " codigo_edificacion = ".$this->var2str($this->codigo_edificacion).", ".
173 173
                     " codigo_padre = ".$this->var2str($this->codigo_padre).", ".
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     " padre_id = ".$this->intval($this->padre_id)." ".
178 178
                     "WHERE id = ".$this->intval($this->id).";";
179 179
             return $this->db->exec($sql);
180
-        }else{
180
+        }else {
181 181
             $sql = "INSERT INTO ".$this->table_name." (id_tipo, codigo_edificacion, codigo_padre, numero, padre_tipo, padre_id) VALUES (".
182 182
                     $this->intval($this->id_tipo).", ".
183 183
                     $this->var2str($this->codigo_edificacion).", ".
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
                     $this->var2str($this->numero).", ".
186 186
                     $this->intval($this->padre_tipo).", ".
187 187
                     $this->intval($this->padre_id).");";
188
-            if($this->db->exec($sql)){
188
+            if ($this->db->exec($sql)) {
189 189
                 return true;
190
-            }else{
190
+            }else {
191 191
                 return false;
192 192
             }
193 193
         }
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
         return $this->db->exec($sql);
200 200
     }
201 201
 
202
-    private function pertenencia($d){
202
+    private function pertenencia($d) {
203 203
         $codigo_interno = $d->codigo_interno;
204 204
         $piezas = \json_decode($codigo_interno);
205 205
         $lista = array();
206
-        foreach($piezas as $id=>$data){
206
+        foreach ($piezas as $id=>$data) {
207 207
             $pertenencia = new \stdClass();
208 208
             $pertenencia->id = $id;
209 209
             $pertenencia->desc_id = $this->edificaciones_tipo->get($id)->descripcion;
@@ -214,47 +214,47 @@  discard block
 block discarded – undo
214 214
         return $lista;
215 215
     }
216 216
 
217
-    public function buscar_ubicacion_inmueble($id,$linea){
218
-        $inicio_busqueda = ($linea==0)?"{\"":"{%\"";
217
+    public function buscar_ubicacion_inmueble($id, $linea) {
218
+        $inicio_busqueda = ($linea == 0) ? "{\"" : "{%\"";
219 219
         $sql = "SELECT * FROM ".$this->table_name." WHERE codigo_interno LIKE '".$inicio_busqueda.$id."\":%}' ORDER BY codigo;";
220 220
         $data = $this->db->select($sql);
221
-        if($data){
221
+        if ($data) {
222 222
             $lista = array();
223
-            foreach($data as $d){
223
+            foreach ($data as $d) {
224 224
                 $l = new residentes_edificaciones_mapa($d);
225 225
                 $lista[] = $this->pertenencia($l);
226 226
             }
227 227
             return $lista;
228
-        }else{
228
+        }else {
229 229
             return false;
230 230
         }
231 231
     }
232 232
 
233
-    public function buscar_cantidad_inmuebles($id,$linea){
234
-        $inicio_busqueda = ($linea==0)?"{\"":"{%\"";
233
+    public function buscar_cantidad_inmuebles($id, $linea) {
234
+        $inicio_busqueda = ($linea == 0) ? "{\"" : "{%\"";
235 235
         $sql = "SELECT DISTINCT codigo FROM ".$this->table_name." WHERE codigo_interno LIKE '".$inicio_busqueda.$id."\":%}' ORDER BY codigo;";
236 236
         $data = $this->db->select($sql);
237
-        if($data){
237
+        if ($data) {
238 238
             $lista = array();
239
-            foreach($data as $d){
239
+            foreach ($data as $d) {
240 240
                 $l = $this->get_by_field('codigo', $d['codigo']);
241 241
                 $lista[] = $l;
242 242
             }
243 243
             return $lista;
244
-        }else{
244
+        }else {
245 245
             return false;
246 246
         }
247 247
     }
248 248
 
249
-    public function generar_mapa(){
249
+    public function generar_mapa() {
250 250
         $mapa = array();
251 251
         $linea = 0;
252
-        foreach($this->edificaciones_tipo->all() as $data){
253
-            if($linea==1){
252
+        foreach ($this->edificaciones_tipo->all() as $data) {
253
+            if ($linea == 1) {
254 254
                 break;
255 255
             }
256
-            $items = $this->buscar_cantidad_inmuebles($data->id,$data->padre);
257
-            foreach($items as $inmueble){
256
+            $items = $this->buscar_cantidad_inmuebles($data->id, $data->padre);
257
+            foreach ($items as $inmueble) {
258 258
                 $mapa[$data->id][] = $inmueble;
259 259
             }
260 260
             $linea++;
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
         return $mapa;
263 263
     }
264 264
 
265
-    public function tiene_hijos(){
265
+    public function tiene_hijos() {
266 266
         $sql = "SELECT count(*) as cantidad FROM ".$this->table_name." WHERE padre_id = ".$this->intval($this->id).";";
267 267
         $data = $this->db->select($sql);
268
-        if($data){
268
+        if ($data) {
269 269
             return $data[0]['cantidad'];
270
-        }else{
270
+        }else {
271 271
             return false;
272 272
         }
273 273
     }
Please login to merge, or discard this patch.
model/core/residentes_informacion.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @author Joe Nilson <joenilson at gmail.com>
26 26
  * @version 1
27 27
  */
28
-class residentes_informacion extends \fs_model{
28
+class residentes_informacion extends \fs_model {
29 29
     /**
30 30
      * Codigo del cliente
31 31
      * @var varchar(6)
@@ -140,62 +140,62 @@  discard block
 block discarded – undo
140 140
     public $vehiculos;
141 141
     public $cliente;
142 142
     public function __construct($t = FALSE) {
143
-        parent::__construct('residentes_informacion','plugins/residentes');
144
-        if($t){
145
-            $this->codcliente=$t['codcliente'];
146
-            $this->codigo=$t['codigo'];
147
-            $this->ocupantes=$t['ocupantes'];
148
-            $this->ocupantes5anos=$t['ocupantes5anos'];
149
-            $this->ocupantes12anos=$t['ocupantes12anos'];
150
-            $this->ocupantes18anos=$t['ocupantes18anos'];
151
-            $this->ocupantes30anos=$t['ocupantes30anos'];
152
-            $this->ocupantes50anos=$t['ocupantes50anos'];
153
-            $this->ocupantes70anos=$t['ocupantes70anos'];
154
-            $this->ocupantes71anos=$t['ocupantes71anos'];
155
-            $this->informacion_discapacidad=$t['informacion_discapacidad'];
156
-            $this->propietario=$this->str2bool($t['propietario']);
157
-            $this->profesion=$t['profesion'];
158
-            $this->ocupacion=$t['ocupacion'];
159
-            $this->ca_nombres=$t['ca_nombres'];
160
-            $this->ca_apellidos=$t['ca_apellidos'];
161
-            $this->ca_telefono=$t['ca_telefono'];
162
-            $this->ca_email=$t['ca_email'];
163
-            $this->ca_propietario=$this->str2bool($t['ca_propietario']);
164
-            $this->ca_parentesco=$t['ca_parentesco'];
165
-            $this->ca_parentesco_obs=$t['ca_parentesco_obs'];
166
-            $this->vehiculos=$t['vehiculos'];
167
-        }else{
168
-            $this->codcliente=NULL;
169
-            $this->codigo=NULL;
170
-            $this->ocupantes=NULL;
171
-            $this->ocupantes5anos=NULL;
172
-            $this->ocupantes12anos=NULL;
173
-            $this->ocupantes18anos=NULL;
174
-            $this->ocupantes30anos=NULL;
175
-            $this->ocupantes50anos=NULL;
176
-            $this->ocupantes70anos=NULL;
177
-            $this->ocupantes71anos=NULL;
178
-            $this->informacion_discapacidad=NULL;
179
-            $this->propietario='FALSE';
180
-            $this->profesion=NULL;
181
-            $this->ocupacion=NULL;
182
-            $this->ca_nombres=NULL;
183
-            $this->ca_apellidos=NULL;
184
-            $this->ca_telefono=NULL;
185
-            $this->ca_email=NULL;
186
-            $this->ca_propietario='FALSE';
187
-            $this->ca_parentesco=NULL;
188
-            $this->ca_parentesco_obs='';
189
-            $this->vehiculos=0;
143
+        parent::__construct('residentes_informacion', 'plugins/residentes');
144
+        if ($t) {
145
+            $this->codcliente = $t['codcliente'];
146
+            $this->codigo = $t['codigo'];
147
+            $this->ocupantes = $t['ocupantes'];
148
+            $this->ocupantes5anos = $t['ocupantes5anos'];
149
+            $this->ocupantes12anos = $t['ocupantes12anos'];
150
+            $this->ocupantes18anos = $t['ocupantes18anos'];
151
+            $this->ocupantes30anos = $t['ocupantes30anos'];
152
+            $this->ocupantes50anos = $t['ocupantes50anos'];
153
+            $this->ocupantes70anos = $t['ocupantes70anos'];
154
+            $this->ocupantes71anos = $t['ocupantes71anos'];
155
+            $this->informacion_discapacidad = $t['informacion_discapacidad'];
156
+            $this->propietario = $this->str2bool($t['propietario']);
157
+            $this->profesion = $t['profesion'];
158
+            $this->ocupacion = $t['ocupacion'];
159
+            $this->ca_nombres = $t['ca_nombres'];
160
+            $this->ca_apellidos = $t['ca_apellidos'];
161
+            $this->ca_telefono = $t['ca_telefono'];
162
+            $this->ca_email = $t['ca_email'];
163
+            $this->ca_propietario = $this->str2bool($t['ca_propietario']);
164
+            $this->ca_parentesco = $t['ca_parentesco'];
165
+            $this->ca_parentesco_obs = $t['ca_parentesco_obs'];
166
+            $this->vehiculos = $t['vehiculos'];
167
+        }else {
168
+            $this->codcliente = NULL;
169
+            $this->codigo = NULL;
170
+            $this->ocupantes = NULL;
171
+            $this->ocupantes5anos = NULL;
172
+            $this->ocupantes12anos = NULL;
173
+            $this->ocupantes18anos = NULL;
174
+            $this->ocupantes30anos = NULL;
175
+            $this->ocupantes50anos = NULL;
176
+            $this->ocupantes70anos = NULL;
177
+            $this->ocupantes71anos = NULL;
178
+            $this->informacion_discapacidad = NULL;
179
+            $this->propietario = 'FALSE';
180
+            $this->profesion = NULL;
181
+            $this->ocupacion = NULL;
182
+            $this->ca_nombres = NULL;
183
+            $this->ca_apellidos = NULL;
184
+            $this->ca_telefono = NULL;
185
+            $this->ca_email = NULL;
186
+            $this->ca_propietario = 'FALSE';
187
+            $this->ca_parentesco = NULL;
188
+            $this->ca_parentesco_obs = '';
189
+            $this->vehiculos = 0;
190 190
         }
191 191
         $this->cliente = new cliente();
192 192
     }
193 193
 
194
-    public function install(){
194
+    public function install() {
195 195
         return "";
196 196
     }
197 197
 
198
-    public function info_adicional($i){
198
+    public function info_adicional($i) {
199 199
         $data = $this->cliente->get($i->codcliente);
200 200
         $i->nombre = $data->nombre;
201 201
         $i->telefono1 = $data->telefono1;
@@ -205,17 +205,17 @@  discard block
 block discarded – undo
205 205
         return $i;
206 206
     }
207 207
 
208
-    public function all(){
208
+    public function all() {
209 209
         $sql = "SELECT * FROM ".$this->table_name." ORDER BY codcliente";
210 210
         $data = $this->db->select($sql);
211
-        if($data){
211
+        if ($data) {
212 212
             $lista = array();
213
-            foreach($data as $d){
213
+            foreach ($data as $d) {
214 214
                 $item = new residentes_informacion($d);
215 215
                 $lista[] = $item->info_adicional($item);
216 216
             }
217 217
             return $lista;
218
-        }else{
218
+        }else {
219 219
             return false;
220 220
         }
221 221
     }
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
      * @param type $padre_tipo integer
228 228
      * @return \FacturaScripts\model\residentes_informacion|boolean
229 229
      */
230
-    public function get($codcliente){
230
+    public function get($codcliente) {
231 231
         $sql = "SELECT * FROM ".$this->table_name.
232 232
                 " WHERE codcliente = ".$this->var2str($codcliente).";";
233 233
         $data = $this->db->select($sql);
234
-        if($data){
234
+        if ($data) {
235 235
             $item = new residentes_informacion($data[0]);
236 236
             return $item->info_adicional($item);
237
-        }else{
237
+        }else {
238 238
             return false;
239 239
         }
240 240
     }
@@ -245,32 +245,32 @@  discard block
 block discarded – undo
245 245
      * @param type $value string
246 246
      * @return boolean|\FacturaScripts\model\residentes_informacion
247 247
      */
248
-    public function get_by_field($field,$value){
249
-        $query = (is_string($value))?$this->var2str($value):$this->intval($value);
248
+    public function get_by_field($field, $value) {
249
+        $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value);
250 250
         $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query.";";
251 251
         $data = $this->db->select($sql);
252
-        if($data){
252
+        if ($data) {
253 253
             $lista = array();
254
-            foreach($data as $d){
254
+            foreach ($data as $d) {
255 255
                 $item = new residentes_informacion($d);
256 256
                 $lista[] = $item->info_adicional($item);
257 257
             }
258 258
             return $lista;
259
-        }else{
259
+        }else {
260 260
             return false;
261 261
         }
262 262
     }
263 263
 
264 264
     public function exists() {
265
-        if(!$this->get($this->codcliente)){
265
+        if (!$this->get($this->codcliente)) {
266 266
             return false;
267
-        }else{
267
+        }else {
268 268
             return $this->get($this->codcliente);
269 269
         }
270 270
     }
271 271
 
272 272
     public function save() {
273
-        if($this->exists()){
273
+        if ($this->exists()) {
274 274
             $sql = "UPDATE ".$this->table_name." SET ".
275 275
             "codigo = ".$this->var2str($this->codigo).", ".
276 276
             "ocupantes = ".$this->intval($this->ocupantes).", ".
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             "vehiculos = ".$this->intval($this->vehiculos)." ".
296 296
             "WHERE codcliente = ".$this->var2str($this->codcliente).";";
297 297
             return $this->db->exec($sql);
298
-        }else{
298
+        }else {
299 299
             $sql = "INSERT INTO ".$this->table_name." (codcliente, codigo, ocupantes, ocupantes5anos, ocupantes12anos, ocupantes18anos, ocupantes30anos, ocupantes50anos, ocupantes70anos, ocupantes71anos, informacion_discapacidad, propietario, profesion, ocupacion, ca_nombres, ca_apellidos, ca_telefono, ca_email, ca_propietario, ca_parentesco, ca_parentesco_obs, vehiculos) VALUES (".
300 300
             $this->var2str($this->codcliente).", ".
301 301
             $this->var2str($this->codigo).", ".
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
             $this->var2str($this->ca_parentesco).", ".
320 320
             $this->var2str($this->ca_parentesco_obs).", ".
321 321
             $this->intval($this->vehiculos).");";
322
-            if($this->db->exec($sql)){
322
+            if ($this->db->exec($sql)) {
323 323
                 return true;
324
-            }else{
324
+            }else {
325 325
                 return false;
326 326
             }
327 327
         }
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
         $clilist = array();
336 336
         $query = mb_strtolower($this->no_html($busqueda), 'UTF8');
337 337
 
338
-        $consulta = "SELECT * FROM " . $this->table_name . " WHERE ";
338
+        $consulta = "SELECT * FROM ".$this->table_name." WHERE ";
339 339
         if (is_numeric($query)) {
340
-            $consulta .= "(ca_telefono LIKE '%" . $query . "%' OR codigo LIKE '%" . $query . "%')";
341
-        } else {
340
+            $consulta .= "(ca_telefono LIKE '%".$query."%' OR codigo LIKE '%".$query."%')";
341
+        }else {
342 342
             $buscar = str_replace(' ', '%', $query);
343
-            $consulta .= "(lower(ca_nombres) LIKE '%" . $buscar . "%' OR lower(ca_apellidos) LIKE '%" . $buscar . "%'"
344
-                    . " OR lower(ocupacion) LIKE '%" . $buscar . "%' OR lower(profesion) LIKE '%" . $buscar . "%'"
345
-                    . " OR lower(ca_email) LIKE '%" . $buscar . "%')";
343
+            $consulta .= "(lower(ca_nombres) LIKE '%".$buscar."%' OR lower(ca_apellidos) LIKE '%".$buscar."%'"
344
+                    . " OR lower(ocupacion) LIKE '%".$buscar."%' OR lower(profesion) LIKE '%".$buscar."%'"
345
+                    . " OR lower(ca_email) LIKE '%".$buscar."%')";
346 346
         }
347 347
         $consulta .= " ORDER BY codcliente ASC";
348 348
 
Please login to merge, or discard this patch.
model/core/residentes_edificaciones.php 2 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
         return "$familias_sql $articulos_sql";
144 144
     }
145 145
 
146
-    public function url(){
147
-        if(!is_null($this->id)){
146
+    public function url() {
147
+        if (!is_null($this->id)) {
148 148
             return FS_PATH.'index.php?page=ver_residente&id='.$this->id;
149
-        }else{
149
+        }else {
150 150
             return FS_PATH.'index.php?page=residentes';
151 151
         }
152 152
     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $cliente = new cliente();
157 157
         $cliente_info = new residentes_informacion();
158 158
         $cliente_vehiculo = new residentes_vehiculos();
159
-        if($item->codcliente){
159
+        if ($item->codcliente) {
160 160
             $item->nombre = $cliente->get($item->codcliente)->nombre;
161 161
             $item->telefono = $cliente->get($item->codcliente)->telefono1;
162 162
             $item->email = $cliente->get($item->codcliente)->email;
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 
167 167
     }
168 168
 
169
-    public function all(){
169
+    public function all() {
170 170
         $sql = "SELECT * FROM ".$this->table_name." ORDER BY codigo_interno,numero";
171 171
         $data = $this->db->select($sql);
172
-        if($data){
172
+        if ($data) {
173 173
             $lista = array();
174
-            foreach($data as $d){
174
+            foreach ($data as $d) {
175 175
                 $item = new residentes_edificaciones($d);
176 176
                 $item->pertenencia = $this->pertenencia($item);
177 177
                 $this->info($item);
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
                 $lista[] = $item;
180 180
             }
181 181
             return $lista;
182
-        }else{
182
+        }else {
183 183
             return false;
184 184
         }
185 185
     }
186 186
 
187
-    public function all_ocupados(){
187
+    public function all_ocupados() {
188 188
         $sql = "SELECT re.*, c.nombre FROM ".$this->table_name." as re, clientes as c ".
189 189
                " WHERE ocupado = TRUE and re.codcliente != '' and re.codcliente = c.codcliente ".
190 190
                " ORDER BY re.codigo_interno, re.numero";
191 191
         $data = $this->db->select($sql);
192
-        if($data){
192
+        if ($data) {
193 193
             $lista = array();
194
-            foreach($data as $d){
194
+            foreach ($data as $d) {
195 195
                 $item = new residentes_edificaciones($d);
196 196
                 $item->pertenencia = $this->pertenencia($item);
197 197
                 $item->nombre = $d['nombre'];
@@ -199,20 +199,20 @@  discard block
 block discarded – undo
199 199
                 $lista[] = $item;
200 200
             }
201 201
             return $lista;
202
-        }else{
202
+        }else {
203 203
             return false;
204 204
         }
205 205
     }
206 206
 
207
-    public function get($id){
207
+    public function get($id) {
208 208
         $sql = "SELECT * FROM ".$this->table_name." WHERE id = ".$this->intval($id).";";
209 209
         $data = $this->db->select($sql);
210
-        if($data){
210
+        if ($data) {
211 211
             $item = new residentes_edificaciones($data[0]);
212 212
             $item->pertenencia = $this->pertenencia($item);
213 213
             $this->info($item);
214 214
             return $item;
215
-        }else{
215
+        }else {
216 216
             return false;
217 217
         }
218 218
     }
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
      * @param type $value string
224 224
      * @return boolean|\FacturaScripts\model\residentes_edificaciones
225 225
      */
226
-    public function get_by_field($field,$value){
227
-        $query = (is_string($value))?$this->var2str($value):$this->intval($value);
226
+    public function get_by_field($field, $value) {
227
+        $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value);
228 228
         $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query.
229 229
             " ORDER BY codigo_interno,numero;";
230 230
         $data = $this->db->select($sql);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                 $lista[] = $item;
238 238
             }
239 239
             return $lista;
240
-        } else {
240
+        }else {
241 241
             return false;
242 242
         }
243 243
     }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     {
247 247
         if (is_null($this->id)) {
248 248
             return false;
249
-        } else {
249
+        }else {
250 250
             return $this->get($this->id);
251 251
         }
252 252
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                     "ocupado = ".$this->var2str($this->ocupado)." ".
269 269
                     "WHERE id = ".$this->intval($this->id).";";
270 270
             return $this->db->exec($sql);
271
-        } else {
271
+        }else {
272 272
             $sql = "INSERT INTO ".$this->table_name." (id_edificacion, iddireccion, codigo, codigo_interno, numero, ubicacion, coordenadas,codcliente, ocupado, fecha_ocupacion, fecha_disponibilidad) VALUES (".
273 273
                     $this->intval($this->id_edificacion).", ".
274 274
                     $this->intval($this->iddireccion).", ".
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                     $this->var2str($this->fecha_disponibilidad).");";
284 284
             if ($this->db->exec($sql)) {
285 285
                 return $this->db->lastval();
286
-            } else {
286
+            }else {
287 287
                 return false;
288 288
             }
289 289
         }
@@ -323,59 +323,59 @@  discard block
 block discarded – undo
323 323
         return $codigo_externo;
324 324
     }
325 325
 
326
-    public function buscar_ubicacion_inmueble($id,$linea)
326
+    public function buscar_ubicacion_inmueble($id, $linea)
327 327
     {
328
-        $inicio_busqueda = ($linea==0)?"{\"":"{%\"";
328
+        $inicio_busqueda = ($linea == 0) ? "{\"" : "{%\"";
329 329
         $sql = "SELECT * FROM ".$this->table_name." WHERE codigo_interno LIKE '".$inicio_busqueda.$id."\":%}' ORDER BY codigo;";
330 330
         $data = $this->db->select($sql);
331
-        if($data){
331
+        if ($data) {
332 332
             $lista = array();
333
-            foreach($data as $d){
333
+            foreach ($data as $d) {
334 334
                 $l = new residentes_edificaciones($d);
335 335
                 $lista[] = $this->pertenencia($l);
336 336
             }
337 337
             return $lista;
338
-        }else{
338
+        }else {
339 339
             return false;
340 340
         }
341 341
     }
342 342
 
343
-    public function buscar_cantidad_inmuebles($id,$linea){
344
-        $inicio_busqueda = ($linea==0)?"{\"":"{%\"";
343
+    public function buscar_cantidad_inmuebles($id, $linea) {
344
+        $inicio_busqueda = ($linea == 0) ? "{\"" : "{%\"";
345 345
         $sql = "SELECT DISTINCT codigo FROM ".$this->table_name." WHERE codigo_interno LIKE '".$inicio_busqueda.$id."\":%}' ORDER BY codigo;";
346 346
         $data = $this->db->select($sql);
347
-        if($data){
347
+        if ($data) {
348 348
             $lista = array();
349
-            foreach($data as $d){
349
+            foreach ($data as $d) {
350 350
                 $l = $this->get_by_field('codigo', $d['codigo']);
351 351
                 $lista[] = $l;
352 352
             }
353 353
             return $lista;
354
-        }else{
354
+        }else {
355 355
             return false;
356 356
         }
357 357
     }
358 358
 
359
-    public function cantidad_inmuebles($id_edificacion){
359
+    public function cantidad_inmuebles($id_edificacion) {
360 360
         $sql = "SELECT count(*) as cantidad FROM ".$this->table_name." WHERE id_edificacion = ".$this->intval($id_edificacion).";";
361 361
         $data = $this->db->select($sql);
362
-        if($data){
362
+        if ($data) {
363 363
             return $data[0]['cantidad'];
364
-        }else{
364
+        }else {
365 365
             return false;
366 366
         }
367 367
     }
368 368
 
369
-    public function generar_mapa(){
369
+    public function generar_mapa() {
370 370
         $edificaciones_tipo = new residentes_edificaciones_tipo();
371 371
         $mapa = array();
372 372
         $linea = 0;
373
-        foreach($edificaciones_tipo->all() as $data){
374
-            if($linea==1){
373
+        foreach ($edificaciones_tipo->all() as $data) {
374
+            if ($linea == 1) {
375 375
                 break;
376 376
             }
377
-            $items = $this->buscar_cantidad_inmuebles($data->id,$data->padre);
378
-            foreach($items as $inmueble){
377
+            $items = $this->buscar_cantidad_inmuebles($data->id, $data->padre);
378
+            foreach ($items as $inmueble) {
379 379
                 $mapa[$data->id][] = $inmueble;
380 380
             }
381 381
             $linea++;
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
         return $mapa;
384 384
     }
385 385
 
386
-    public function search($query, $type=""){
386
+    public function search($query, $type = "") {
387 387
         $sql = "SELECT * FROM ".$this->table_name." WHERE ";
388 388
         $OR = "";
389
-        if($type=='inmueble'){
390
-            $sql.=" numero LIKE '%".strtoupper($query)."%' ";
391
-            $sql.=" OR codigo LIKE '%".strtoupper($query)."%' ";
392
-        }else{
393
-            if(is_int($query)){
394
-                $sql.=" id_edificacion LIKE '%".$query."%' ";
395
-                $sql.=" id LIKE '%".$query."%' ";
389
+        if ($type == 'inmueble') {
390
+            $sql .= " numero LIKE '%".strtoupper($query)."%' ";
391
+            $sql .= " OR codigo LIKE '%".strtoupper($query)."%' ";
392
+        }else {
393
+            if (is_int($query)) {
394
+                $sql .= " id_edificacion LIKE '%".$query."%' ";
395
+                $sql .= " id LIKE '%".$query."%' ";
396 396
                 $OR = "OR";
397 397
             }
398
-            $sql.=" $OR numero LIKE '%".strtoupper($query)."%' ";
399
-            $sql.=" OR codigo LIKE '%".strtoupper($query)."%' ";
398
+            $sql .= " $OR numero LIKE '%".strtoupper($query)."%' ";
399
+            $sql .= " OR codigo LIKE '%".strtoupper($query)."%' ";
400 400
         }
401
-        $sql.=" ORDER BY codigo,numero";
401
+        $sql .= " ORDER BY codigo,numero";
402 402
         $data = $this->db->select($sql);
403 403
         $lista = array();
404
-        if($data){
405
-            foreach($data as $d){
404
+        if ($data) {
405
+            foreach ($data as $d) {
406 406
                 $item = new residentes_edificaciones($d);
407 407
                 $item->pertenencia = $this->pertenencia($item);
408 408
                 $item->nombre = 'Libre';
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
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;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     public function url(){
147 147
         if(!is_null($this->id)){
148 148
             return FS_PATH.'index.php?page=ver_residente&id='.$this->id;
149
-        }else{
149
+        } else{
150 150
             return FS_PATH.'index.php?page=residentes';
151 151
         }
152 152
     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 $lista[] = $item;
180 180
             }
181 181
             return $lista;
182
-        }else{
182
+        } else{
183 183
             return false;
184 184
         }
185 185
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                 $lista[] = $item;
200 200
             }
201 201
             return $lista;
202
-        }else{
202
+        } else{
203 203
             return false;
204 204
         }
205 205
     }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             $item->pertenencia = $this->pertenencia($item);
213 213
             $this->info($item);
214 214
             return $item;
215
-        }else{
215
+        } else{
216 216
             return false;
217 217
         }
218 218
     }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
                 $lista[] = $this->pertenencia($l);
336 336
             }
337 337
             return $lista;
338
-        }else{
338
+        } else{
339 339
             return false;
340 340
         }
341 341
     }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
                 $lista[] = $l;
352 352
             }
353 353
             return $lista;
354
-        }else{
354
+        } else{
355 355
             return false;
356 356
         }
357 357
     }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         $data = $this->db->select($sql);
362 362
         if($data){
363 363
             return $data[0]['cantidad'];
364
-        }else{
364
+        } else{
365 365
             return false;
366 366
         }
367 367
     }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         if($type=='inmueble'){
390 390
             $sql.=" numero LIKE '%".strtoupper($query)."%' ";
391 391
             $sql.=" OR codigo LIKE '%".strtoupper($query)."%' ";
392
-        }else{
392
+        } else{
393 393
             if(is_int($query)){
394 394
                 $sql.=" id_edificacion LIKE '%".$query."%' ";
395 395
                 $sql.=" id LIKE '%".$query."%' ";
Please login to merge, or discard this patch.
model/core/residentes_ayudas.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @author Joe Nilson <joenilson at gmail.com>
24 24
  */
25
-class residentes_ayudas extends \fs_model{
25
+class residentes_ayudas extends \fs_model {
26 26
     /**
27 27
      * El codigo de la ayuda ya sea para parentesco u ocupacion
28 28
      * @var vharcar(10)
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public $descripcion;
41 41
     public function __construct($t = FALSE) {
42
-        parent::__construct('residentes_ayudas','plugins/residentes');
43
-        if($t){
42
+        parent::__construct('residentes_ayudas', 'plugins/residentes');
43
+        if ($t) {
44 44
             $this->codigo = $t['codigo'];
45 45
             $this->tipo = $t['tipo'];
46 46
             $this->descripcion = $t['descripcion'];
47
-        }else{
47
+        }else {
48 48
             $this->codigo = null;
49 49
             $this->tipo = null;
50 50
             $this->descripcion = null;
51 51
         }
52 52
     }
53 53
 
54
-    public function install(){
54
+    public function install() {
55 55
         return "insert into residentes_ayudas (codigo,tipo, descripcion) VALUES ".
56 56
             "('EMPPUB','OCUPACION','Empleado Publico'),".
57 57
             "('EMPRI','OCUPACION','Empleado Privado'),".
@@ -65,66 +65,66 @@  discard block
 block discarded – undo
65 65
             "('HIJO','PARENTESCO','HermanHijo (a)');";
66 66
     }
67 67
 
68
-    public function all(){
68
+    public function all() {
69 69
         $sql = "SELECT * FROM ".$this->table_name." ORDER BY tipo,codigo";
70 70
         $data = $this->db->select($sql);
71
-        if($data){
71
+        if ($data) {
72 72
             $lista = array();
73
-            foreach($data as $d){
73
+            foreach ($data as $d) {
74 74
                 $lista[] = new residentes_ayudas($d);
75 75
             }
76 76
             return $lista;
77
-        }else{
77
+        }else {
78 78
             return false;
79 79
         }
80 80
     }
81 81
 
82
-    public function all_tipo($tipo){
82
+    public function all_tipo($tipo) {
83 83
         $sql = "SELECT * FROM ".$this->table_name." WHERE tipo = ".$this->var2str($tipo)." ORDER BY codigo";
84 84
         $data = $this->db->select($sql);
85
-        if($data){
85
+        if ($data) {
86 86
             $lista = array();
87
-            foreach($data as $d){
87
+            foreach ($data as $d) {
88 88
                 $lista[] = new residentes_ayudas($d);
89 89
             }
90 90
             return $lista;
91
-        }else{
91
+        }else {
92 92
             return false;
93 93
         }
94 94
     }
95 95
 
96
-    public function get($codigo,$tipo){
96
+    public function get($codigo, $tipo) {
97 97
         $sql = "SELECT * FROM ".$this->table_name." WHERE codigo = ".$this->var2str($codigo)." AND tipo = ".$this->var2str($tipo).";";
98 98
         $data = $this->db->select($sql);
99
-        if($data){
99
+        if ($data) {
100 100
             return new residentes_ayudas($data[0]);
101
-        }else{
101
+        }else {
102 102
             return false;
103 103
         }
104 104
     }
105 105
 
106 106
     public function exists() {
107
-        if(is_null($this->codigo)){
107
+        if (is_null($this->codigo)) {
108 108
             return false;
109
-        }else{
110
-            return $this->get($this->codigo,$this->tipo);
109
+        }else {
110
+            return $this->get($this->codigo, $this->tipo);
111 111
         }
112 112
     }
113 113
 
114 114
     public function save() {
115
-        if($this->exists()){
115
+        if ($this->exists()) {
116 116
             $sql = "UPDATE ".$this->table_name." SET ".
117 117
                     "descripcion = ".$this->var2str($this->descripcion)." ".
118 118
                     "WHERE codigo = ".$this->var2str($this->codigo)." AND tipo = ".$this->var2str($this->tipo).";";
119 119
             return $this->db->exec($sql);
120
-        }else{
120
+        }else {
121 121
             $sql = "INSERT INTO ".$this->table_name." (codigo, tipo, descripcion) VALUES (".
122 122
                     $this->var2str($this->codigo).", ".
123 123
                     $this->var2str($this->tipo).", ".
124 124
                     $this->var2str($this->descripcion).");";
125
-            if($this->db->exec($sql)){
125
+            if ($this->db->exec($sql)) {
126 126
                 return $this->db->lastval();
127
-            }else{
127
+            }else {
128 128
                 return false;
129 129
             }
130 130
         }
Please login to merge, or discard this patch.
model/core/residentes_edificaciones_tipo.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @author Joe Nilson <joenilson at gmail.com>
24 24
  */
25
-class residentes_edificaciones_tipo extends \fs_model{
25
+class residentes_edificaciones_tipo extends \fs_model {
26 26
     /**
27 27
      * El Id del tipo de edificacion
28 28
      * @var integer serial
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public $padre;
41 41
     public function __construct($t = FALSE) {
42
-        parent::__construct('residentes_edificaciones_tipo','plugins/residentes');
43
-        if($t){
42
+        parent::__construct('residentes_edificaciones_tipo', 'plugins/residentes');
43
+        if ($t) {
44 44
             $this->id = $t['id'];
45 45
             $this->descripcion = $t['descripcion'];
46 46
             $this->padre = $t['padre'];
47
-        }else{
47
+        }else {
48 48
             $this->id = null;
49 49
             $this->descripcion = null;
50 50
             $this->padre = null;
51 51
         }
52 52
     }
53 53
 
54
-    public function install(){
54
+    public function install() {
55 55
         return "insert into residentes_edificaciones_tipo (descripcion) VALUES ('Bloque');";
56 56
     }
57 57
 
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
                 $lista[] = new residentes_edificaciones_tipo($d);
66 66
             }
67 67
             return $lista;
68
-        } else {
68
+        }else {
69 69
             return false;
70 70
         }
71 71
     }
72 72
 
73
-    public function get($id){
73
+    public function get($id) {
74 74
         $sql = "SELECT * FROM ".$this->table_name." WHERE id = ".$this->intval($id).";";
75 75
         $data = $this->db->select($sql);
76
-        if($data){
76
+        if ($data) {
77 77
             return new residentes_edificaciones_tipo($data[0]);
78
-        }else{
78
+        }else {
79 79
             return false;
80 80
         }
81 81
     }
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
      * @param type $value string or integer
87 87
      * @return boolean|\FacturaScripts\model\residentes_edificaciones_tipo
88 88
      */
89
-    public function get_by_field($field,$value){
90
-        $query = (is_string($value))?$this->var2str($value):$this->intval($value);
89
+    public function get_by_field($field, $value) {
90
+        $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value);
91 91
         $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query.";";
92 92
         $data = $this->db->select($sql);
93
-        if($data){
93
+        if ($data) {
94 94
             $lista = array();
95
-            foreach($data as $d){
96
-                $lista[] =  new residentes_edificaciones_tipo($d);
95
+            foreach ($data as $d) {
96
+                $lista[] = new residentes_edificaciones_tipo($d);
97 97
             }
98 98
             return $lista;
99
-        }else{
99
+        }else {
100 100
             return false;
101 101
         }
102 102
     }
103 103
 
104 104
     public function exists() {
105
-        if(is_null($this->id)){
105
+        if (is_null($this->id)) {
106 106
             return false;
107
-        }else{
107
+        }else {
108 108
             return $this->get($this->id);
109 109
         }
110 110
     }
111 111
 
112 112
     public function save() {
113
-        if($this->exists()){
113
+        if ($this->exists()) {
114 114
             $sql = "UPDATE ".$this->table_name." SET ".
115 115
                     "descripcion = ".$this->var2str($this->descripcion).", ".
116 116
                     "padre = ".$this->intval($this->padre)." ".
117 117
                     "WHERE id = ".$this->intval($this->id).";";
118 118
             return $this->db->exec($sql);
119
-        }else{
119
+        }else {
120 120
             $sql = "INSERT INTO ".$this->table_name." (descripcion, padre) VALUES (".
121 121
                     $this->var2str($this->descripcion).", ".
122 122
                     $this->intval($this->padre).");";
123
-            if($this->db->exec($sql)){
123
+            if ($this->db->exec($sql)) {
124 124
                 return $this->db->lastval();
125
-            }else{
125
+            }else {
126 126
                 return false;
127 127
             }
128 128
         }
@@ -132,24 +132,24 @@  discard block
 block discarded – undo
132 132
         return $this->db->exec($sql);
133 133
     }
134 134
 
135
-    public function jerarquia(){
135
+    public function jerarquia() {
136 136
         $lista = $this->all();
137
-        return ($lista)?$this->estructura($lista):null;
137
+        return ($lista) ? $this->estructura($lista) : null;
138 138
     }
139 139
 
140
-    public function estructura($lista, $raiz = 0){
140
+    public function estructura($lista, $raiz = 0) {
141 141
         $estructura = array();
142
-        foreach($lista as $key=>$item){
143
-            if($item->padre == $raiz){
142
+        foreach ($lista as $key=>$item) {
143
+            if ($item->padre == $raiz) {
144 144
                 unset($lista[$key]);
145
-                $estructura[]=array(
145
+                $estructura[] = array(
146 146
                     'id'=>$item->id,
147 147
                     'text'=>$item->descripcion,
148 148
                     'padre'=>$item->padre,
149
-                    'nodes'=>$this->estructura($lista,$item->id)
149
+                    'nodes'=>$this->estructura($lista, $item->id)
150 150
                 );
151 151
             }
152 152
         }
153
-        return empty($estructura)?null:$estructura;
153
+        return empty($estructura) ?null:$estructura;
154 154
     }
155 155
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             $this->id = $t['id'];
45 45
             $this->descripcion = $t['descripcion'];
46 46
             $this->padre = $t['padre'];
47
-        }else{
47
+        } else{
48 48
             $this->id = null;
49 49
             $this->descripcion = null;
50 50
             $this->padre = null;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $data = $this->db->select($sql);
76 76
         if($data){
77 77
             return new residentes_edificaciones_tipo($data[0]);
78
-        }else{
78
+        } else{
79 79
             return false;
80 80
         }
81 81
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                 $lista[] =  new residentes_edificaciones_tipo($d);
97 97
             }
98 98
             return $lista;
99
-        }else{
99
+        } else{
100 100
             return false;
101 101
         }
102 102
     }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     public function exists() {
105 105
         if(is_null($this->id)){
106 106
             return false;
107
-        }else{
107
+        } else{
108 108
             return $this->get($this->id);
109 109
         }
110 110
     }
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
                     "padre = ".$this->intval($this->padre)." ".
117 117
                     "WHERE id = ".$this->intval($this->id).";";
118 118
             return $this->db->exec($sql);
119
-        }else{
119
+        } else{
120 120
             $sql = "INSERT INTO ".$this->table_name." (descripcion, padre) VALUES (".
121 121
                     $this->var2str($this->descripcion).", ".
122 122
                     $this->intval($this->padre).");";
123 123
             if($this->db->exec($sql)){
124 124
                 return $this->db->lastval();
125
-            }else{
125
+            } else{
126 126
                 return false;
127 127
             }
128 128
         }
Please login to merge, or discard this patch.
model/core/residentes_vehiculos.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @author Joe Nilson <joenilson at gmail.com>
26 26
  */
27
-class residentes_vehiculos extends \fs_model{
27
+class residentes_vehiculos extends \fs_model {
28 28
     /**
29 29
      * El Id del vehiculo
30 30
      * @var integer serial
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
     public $codigo_tarjeta;
69 69
     public $cliente;
70 70
     public function __construct($t = FALSE) {
71
-        parent::__construct('residentes_vehiculos','plugins/residentes');
72
-        if($t){
71
+        parent::__construct('residentes_vehiculos', 'plugins/residentes');
72
+        if ($t) {
73 73
             $this->idvehiculo = $t['idvehiculo'];
74 74
             $this->codcliente = $t['codcliente'];
75 75
             $this->vehiculo_marca = $t['vehiculo_marca'];
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             $this->vehiculo_placa = $t['vehiculo_placa'];
79 79
             $this->vehiculo_tipo = $t['vehiculo_tipo'];
80 80
             $this->codigo_tarjeta = $t['codigo_tarjeta'];
81
-        }else{
81
+        }else {
82 82
             $this->idvehiculo = null;
83 83
             $this->codcliente = null;
84 84
             $this->vehiculo_marca = NULL;
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
         $this->cliente = new cliente();
92 92
     }
93 93
 
94
-    public function install(){
94
+    public function install() {
95 95
         return "";
96 96
     }
97 97
 
98
-    public function info_adicional($i){
98
+    public function info_adicional($i) {
99 99
         $data = $this->cliente->get($i->codcliente);
100 100
         $i->nombre = $data->nombre;
101 101
         $i->telefono1 = $data->telefono1;
@@ -105,27 +105,27 @@  discard block
 block discarded – undo
105 105
         return $i;
106 106
     }
107 107
 
108
-    public function all(){
108
+    public function all() {
109 109
         $sql = "SELECT * FROM ".$this->table_name." ORDER BY codcliente,idvehiculo";
110 110
         $data = $this->db->select($sql);
111
-        if($data){
111
+        if ($data) {
112 112
             $lista = array();
113
-            foreach($data as $d){
113
+            foreach ($data as $d) {
114 114
                 $item = new residentes_vehiculos($d);
115 115
                 $lista[] = $item;
116 116
             }
117 117
             return $lista;
118
-        }else{
118
+        }else {
119 119
             return false;
120 120
         }
121 121
     }
122 122
 
123
-    public function get($codcliente,$id){
123
+    public function get($codcliente, $id) {
124 124
         $sql = "SELECT * FROM ".$this->table_name." WHERE codcliente = ".$this->var2str($codcliente)." AND idvehiculo = ".$this->intval($id).";";
125 125
         $data = $this->db->select($sql);
126
-        if($data){
126
+        if ($data) {
127 127
             return new residentes_vehiculos($data[0]);
128
-        }else{
128
+        }else {
129 129
             return false;
130 130
         }
131 131
     }
@@ -136,32 +136,32 @@  discard block
 block discarded – undo
136 136
      * @param type $value string
137 137
      * @return boolean|\FacturaScripts\model\residentes_vehiculos
138 138
      */
139
-    public function get_by_field($field,$value){
140
-        $query = (is_string($value))?$this->var2str($value):$this->intval($value);
139
+    public function get_by_field($field, $value) {
140
+        $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value);
141 141
         $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query.";";
142 142
         $data = $this->db->select($sql);
143
-        if($data){
143
+        if ($data) {
144 144
             $lista = array();
145
-            foreach($data as $d){
145
+            foreach ($data as $d) {
146 146
                 $item = new residentes_vehiculos($d);
147 147
                 $lista[] = $item;
148 148
             }
149 149
             return $lista;
150
-        }else{
150
+        }else {
151 151
             return false;
152 152
         }
153 153
     }
154 154
 
155 155
     public function exists() {
156
-        if(is_null($this->idvehiculo)){
156
+        if (is_null($this->idvehiculo)) {
157 157
             return false;
158
-        }else{
159
-            return $this->get($this->codcliente,$this->idvehiculo);
158
+        }else {
159
+            return $this->get($this->codcliente, $this->idvehiculo);
160 160
         }
161 161
     }
162 162
 
163 163
     public function save() {
164
-        if($this->exists()){
164
+        if ($this->exists()) {
165 165
             $sql = "UPDATE ".$this->table_name." SET ".
166 166
                     "vehiculo_marca = ".$this->var2str($this->vehiculo_marca).", ".
167 167
                     "vehiculo_modelo = ".$this->var2str($this->vehiculo_modelo).", ".
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                     "WHERE idvehiculo = ".$this->intval($this->idvehiculo)." AND ".
173 173
                     "codcliente = ".$this->var2str($this->codcliente).";";
174 174
             return $this->db->exec($sql);
175
-        }else{
175
+        }else {
176 176
             $sql = "INSERT INTO ".$this->table_name." (codcliente, vehiculo_marca, vehiculo_modelo, vehiculo_color, vehiculo_placa, vehiculo_tipo, codigo_tarjeta) VALUES (".
177 177
                     $this->var2str($this->codcliente).", ".
178 178
                     $this->var2str($this->vehiculo_marca).", ".
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                     $this->var2str($this->vehiculo_placa).", ".
182 182
                     $this->var2str($this->vehiculo_tipo).", ".
183 183
                     $this->var2str($this->codigo_tarjeta).");";
184
-            if($this->db->exec($sql)){
184
+            if ($this->db->exec($sql)) {
185 185
                 return $this->db->lastval();
186
-            }else{
186
+            }else {
187 187
                 return false;
188 188
             }
189 189
         }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
         $clilist = array();
198 198
         $query = mb_strtolower($this->no_html($busqueda), 'UTF8');
199 199
 
200
-        $consulta = "SELECT * FROM " . $this->table_name . " WHERE ";
200
+        $consulta = "SELECT * FROM ".$this->table_name." WHERE ";
201 201
         if (is_numeric($query)) {
202
-            $consulta .= "(codigo_tarjeta LIKE '%" . $query . "%' OR CAST(idvehiculo as CHAR) = '%" . $query . "%')";
203
-        } else {
202
+            $consulta .= "(codigo_tarjeta LIKE '%".$query."%' OR CAST(idvehiculo as CHAR) = '%".$query."%')";
203
+        }else {
204 204
             $buscar = str_replace(' ', '%', $query);
205
-            $consulta .= "(lower(codigo_tarjeta) LIKE '%" . $buscar . "%' OR lower(vehiculo_color) LIKE '%" . $buscar . "%'"
206
-                    . " OR lower(vehiculo_marca) LIKE '%" . $buscar . "%' OR lower(vehiculo_modelo) LIKE '%" . $buscar . "%'"
207
-                    . " OR lower(vehiculo_placa) LIKE '%" . $buscar . "%' OR lower(vehiculo_tipo) LIKE '%" . $buscar . "%')";
205
+            $consulta .= "(lower(codigo_tarjeta) LIKE '%".$buscar."%' OR lower(vehiculo_color) LIKE '%".$buscar."%'"
206
+                    . " OR lower(vehiculo_marca) LIKE '%".$buscar."%' OR lower(vehiculo_modelo) LIKE '%".$buscar."%'"
207
+                    . " OR lower(vehiculo_placa) LIKE '%".$buscar."%' OR lower(vehiculo_tipo) LIKE '%".$buscar."%')";
208 208
         }
209 209
         $consulta .= " ORDER BY codcliente ASC";
210 210
 
Please login to merge, or discard this patch.