Passed
Push — master ( 63d1f8...7c50e7 )
by Joe Nilson
02:33
created

informe_residentes::informacion_interna()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 14
rs 9.9
1
<?php
2
3
/*
4
 * Copyright (C) 2017 Joe Nilson <joenilson at gmail.com>
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
/**
20
 * @author Carlos García Gómez      [email protected]
21
 * @author Joe Nilson Zegarra Galvez      [email protected]
22
 * @copyright 2015, Carlos García Gómez. All Rights Reserved.
23
 */
24
//require_model('residentes_edificaciones.php');
25
//require_model('residentes_informacion.php');
26
//require_model('residentes_vehiculos.php');
27
//require_model('residentes_edificaciones_tipo.php');
28
//require_model('residentes_edificaciones_mapa.php');
29
require_once 'plugins/facturacion_base/extras/xlsxwriter.class.php';
30
require_once 'plugins/residentes/extras/residentes_controller.php';
31
/**
32
 * Description of informe_residentes
33
 *
34
 * @author carlos <[email protected]>
35
 * @author Joe Nilson <joenilson at gmail.com>
36
 */
37
class informe_residentes extends residentes_controller
38
{
39
    /**
40
     * @var string
41
     */
42
    public $bloque;
43
    /**
44
     * @var string
45
     */
46
    public $cliente;
47
    /**
48
     * @var string
49
     */
50
    public $clientes;
51
    public $desde;
52
    public $hasta;
53
    public $resultados;
54
    public $tipo;
55
    public $residentes;
56
    public $edificaciones;
57
    public $total;
58
    public $total_resultado;
59
    public $lista;
60
    public $vehiculos;
61
    public $codigo_edificacion;
62
    public $edificaciones_tipo;
63
    public $edificaciones_mapa;
64
    public $inmuebles_libres;
65
    public $inmuebles_ocupados;
66
    public $total_vehiculos;
67
    public $limit;
68
    public $offset;
69
    public $order;
70
    public $search;
71
    public $sort;
72
    public $archivo = 'Residentes';
73
    public $archivoXLSX;
74
    public $archivoXLSXPath;
75
    public $documentosDir;
76
    public $exportDir;
77
    public $publicPath;
78
    public $where_code;
79
    public $pagos_pendientes;
80
    public $pagos_realizados;
81
82
    public function __construct()
83
    {
84
        parent::__construct(__CLASS__, 'Residentes', 'informes', false, true);
85
    }
86
87
    protected function private_core()
88
    {
89
        $this->shared_extensions();
90
        $this->init_variables();
91
        $this->init_filters();
92
93
        $tipos = $this->edificaciones_tipo->all();
94
        $this->padre = $tipos[0];
0 ignored issues
show
Bug Best Practice introduced by
The property padre does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
95
96
        $this->tipo = 'informacion';
97
        if (isset($_GET['tipo'])) {
98
            $this->tipo = $_GET['tipo'];
99
        }
100
101
        if ($this->tipo === 'mostrar_informacion_residente') {
102
            $this->mostrar_informacion_residente();
103
        }
104
105
        $this->codigo_edificacion = null;
106
        if ($this->filter_request('codigo_edificacion')) {
107
            $this->codigo_edificacion = $this->filter_request('codigo_edificacion');
108
        }
109
110
        if ($this->codigo_edificacion) {
111
            $this->where_code = " AND r.codigo like '" . $this->codigo_edificacion . "%' ";
112
        }
113
114
        if ($this->tipo === 'informacion') {
115
            $this->mapa = $this->edificaciones_mapa->get_by_field('id_tipo', $this->padre->id);
0 ignored issues
show
Bug Best Practice introduced by
The property mapa does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
'id_tipo' of type string is incompatible with the type FacturaScripts\model\type expected by parameter $field of FacturaScripts\model\res...es_mapa::get_by_field(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

115
            $this->mapa = $this->edificaciones_mapa->get_by_field(/** @scrutinizer ignore-type */ 'id_tipo', $this->padre->id);
Loading history...
116
            $this->informacion_edificaciones();
117
        }
118
119
        if ($this->filter_request('lista')) {
120
            $this->procesarLista($this->filter_request('lista'));
121
        }
122
    }
123
124
    public function init_variables()
125
    {
126
        $this->edificaciones_tipo = new residentes_edificaciones_tipo();
127
        $this->edificaciones_mapa = new residentes_edificaciones_mapa();
128
        $this->edificaciones = new residentes_edificaciones();
129
        $this->vehiculos = new residentes_vehiculos();
130
        $this->clientes = new cliente();
131
    }
132
133
    public function init_filters()
134
    {
135
        $this->desde = \Date('01-m-Y');
136
        if ($this->filter_request('desde')) {
137
            $this->desde = $this->filter_request('desde');
138
        }
139
140
        $this->hasta = \Date('t-m-Y');
141
        if ($this->filter_request('hasta')) {
142
            $this->hasta = $this->filter_request('hasta');
143
        }
144
145
        $sort = $this->filter_request('sort');
146
        $order = $this->filter_request('order');
147
        $this->offset = $this->confirmarValor($this->filter_request('offset'), 0);
148
        $this->limit = $this->confirmarValor($this->filter_request('limit'), FS_ITEM_LIMIT);
1 ignored issue
show
Bug introduced by
The constant FS_ITEM_LIMIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
149
        $this->search = $this->confirmarValor($this->filter_request('search'), false);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $valor2 of informe_residentes::confirmarValor(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

149
        $this->search = $this->confirmarValor($this->filter_request('search'), /** @scrutinizer ignore-type */ false);
Loading history...
150
        $this->sort = ($sort and $sort!='undefined')?$sort:'r.codigo, r.numero';
0 ignored issues
show
introduced by
The condition $sort != 'undefined' is always true.
Loading history...
151
        $this->order = ($order and $order!='undefined')?$order:'ASC';
0 ignored issues
show
introduced by
The condition $order != 'undefined' is always true.
Loading history...
152
    }
153
154
    public function informacion_edificaciones()
155
    {
156
        $this->resultado = array();
0 ignored issues
show
Bug Best Practice introduced by
The property resultado does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
157
        [$edificaciones, $inmuebles, $vehiculos, $inmuebles_ocupados] = $this->datosInformacion();
158
        foreach ($edificaciones as $edif) {
159
            $l = new stdClass();
160
            $l->descripcion = $edif['descripcion'];
161
            $l->cantidad = $edif['total'];
162
            $this->resultado[] = $l;
163
        }
164
        if ($inmuebles) {
165
            $l = new stdClass();
166
            $l->descripcion = 'Inmueble';
167
            $l->cantidad = $inmuebles;
168
            $this->resultado[] = $l;
169
        }
170
171
        //Verificamos los que están ocupados
172
        $this->inmuebles_libres = $inmuebles-$inmuebles_ocupados;
173
        $this->inmuebles_ocupados = $inmuebles_ocupados;
174
        $this->total_vehiculos = $vehiculos;
175
        $this->carpetasPlugin();
176
        $this->generarArchivoExcel();
177
    }
178
179
    public function generarArchivoExcel()
180
    {
181
        $this->archivoXLSX = $this->exportDir . DIRECTORY_SEPARATOR .
182
                            $this->archivo . "_" . $this->user->nick . ".xlsx";
183
        $this->archivoXLSXPath = $this->publicPath . DIRECTORY_SEPARATOR .
184
                            $this->archivo . "_" . $this->user->nick . ".xlsx";
185
        if (file_exists($this->archivoXLSX)) {
186
            unlink($this->archivoXLSX);
187
        }
188
        $writer = new XLSXWriter();
1 ignored issue
show
Bug introduced by
The type XLSXWriter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
189
        $headerR = array(
190
            'Código'=>'string',
191
            'Residente'=>'string',
192
            FS_CIFNIF=>'string',
1 ignored issue
show
Bug introduced by
The constant FS_CIFNIF was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
193
            'Teléfono'=>'string',
194
            'Email'=>'string',
195
            'Ubicación'=>'string',
196
            'Inmueble'=>'string',
197
            'Fecha de Ocupación'=>'date');
198
        $headerTextR = array(
199
            'codcliente'=>'Código',
200
            'nombre'=>'Residente',
201
            'cifnif'=>FS_CIFNIF,
202
            'telefono1'=>'Teléfono',
203
            'email'=>'Email',
204
            'codigo'=>'Ubicación',
205
            'numero'=>'Inmueble',
206
            'fecha_ocupacion'=>'Fecha Ocupación');
207
        $dataResidentes = $this->lista_residentes(true);
208
        $this->crearXLSX($writer, 'Residentes', $headerR, $headerTextR, $dataResidentes[0]);
209
        $headerI = array(
210
            'Pertenece'=>'string',
211
            'Edificación'=>'string',
212
            'Código'=>'string',
213
            'Residente'=>'string',
214
            FS_CIFNIF=>'string',
215
            'Teléfono'=>'string',
216
            'Email'=>'string',
217
            'Ubicación'=>'string',
218
            'Inmueble Nro'=>'integer',
219
            'Fecha de Ocupación'=>'date',
220
            'Ocupado'=>'string');
221
        $headerTextI = array(
222
            'padre_desc'=>'Pertenece',
223
            'edif_desc'=>'Edificacion',
224
            'codcliente'=>'Código',
225
            'nombre'=>'Residente',
226
            'cifnif'=>FS_CIFNIF,
227
            'telefono1'=>'Teléfono',
228
            'email'=>'Email',
229
            'codigo'=>'Ubicación',
230
            'numero'=>'Inmueble Nro',
231
            'fecha_ocupacion'=>'Fecha Ocupación',
232
            'ocupado'=>'Ocupado');
233
        $dataInmuebles = $this->lista_inmuebles(true);
234
        $this->crearXLSX($writer, 'Inmuebles', $headerI, $headerTextI, $dataInmuebles[0]);
235
        $headerC = array(
236
            'Código'=>'string',
237
            'Residente'=>'string',
238
            FS_CIFNIF=>'string',
239
            'Teléfono'=>'string',
240
            'Email'=>'string',
241
            'Ubicación'=>'string',
242
            'Inmueble'=>'string',
243
            'Pagado'=>'price',
244
            'Pendiente'=>'price');
245
        $headerTextC = array(
246
            'codcliente'=>'Código',
247
            'nombre'=>'Residente',
248
            'cifnif'=>FS_CIFNIF,
249
            'telefono1'=>'Teléfono',
250
            'email'=>'Email',
251
            'codigo'=>'Ubicación',
252
            'numero'=>'Inmueble',
253
            'pagado'=>'Pagado',
254
            'pendiente'=>'Pendiente');
255
        $dataCobros = $this->lista_cobros(true);
256
        $this->crearXLSX($writer, 'Cobros', $headerC, $headerTextC, $dataCobros[0]);
257
        $writer->writeToFile($this->archivoXLSXPath);
258
        $this->fileXLSX = $this->archivoXLSXPath;
0 ignored issues
show
Bug Best Practice introduced by
The property fileXLSX does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
259
    }
260
261
    public function datosInformacion()
262
    {
263
        //Cantidad de Edificaciones
264
        $sql_edificaciones = "SELECT ret.id,ret.descripcion, count(rme.id) as total " .
265
            "FROM residentes_edificaciones_tipo as ret " .
266
            " join residentes_mapa_edificaciones as rme on (rme.id_tipo = ret.id) " .
267
            " group by ret.id,ret.descripcion " .
268
            " order by ret.padre;";
269
        $data_edificaciones = $this->db->select($sql_edificaciones);
270
        //cantidad de Inmuebles
271
        $sql_inmuebles = "select count(*) as total from residentes_edificaciones;";
272
        $data_inmuebles = $this->db->select($sql_inmuebles);
273
        //cantidad de Inmuebles Ocupados
274
        $sql_inmuebles_ocupados = "select count(*) as total from residentes_edificaciones WHERE ocupado = true;";
275
        $data_inmuebles_ocupados = $this->db->select($sql_inmuebles_ocupados);
276
        //cantidad de Vehiculos
277
        $sql_vehiculos = "select count(*) as total from residentes_vehiculos;";
278
        $data_vehiculos = $this->db->select($sql_vehiculos);
279
280
        return array(
281
            $data_edificaciones,
282
            $data_inmuebles[0]['total'],
283
            $data_vehiculos[0]['total'],
284
            $data_inmuebles_ocupados[0]['total']
285
        );
286
    }
287
288
    public function procesarLista($lista)
289
    {
290
        $this->template = false;
1 ignored issue
show
Bug Best Practice introduced by
The property template does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
291
        switch ($lista) {
292
            case 'informe_residentes':
293
                [$resultados, $cantidad] = $this->lista_residentes();
294
                break;
295
            case 'informe_inmuebles':
296
                [$resultados, $cantidad] = $this->lista_inmuebles();
297
                break;
298
            case 'informe_cobros':
299
                [$resultados, $cantidad] = $this->lista_cobros();
300
                break;
301
            default:
302
                break;
303
        }
304
        header('Content-Type: application/json');
305
        $data['rows'] = $resultados;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.
Loading history...
Comprehensibility Best Practice introduced by
The variable $resultados does not seem to be defined for all execution paths leading up to this point.
Loading history...
306
        $data['total'] = $cantidad;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $cantidad does not seem to be defined for all execution paths leading up to this point.
Loading history...
307
        echo json_encode($data, JSON_THROW_ON_ERROR);
308
    }
309
310
    public function lista_residentes ($todo = false)
311
    {
312
        $sql = " select r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, codigo, numero, fecha_ocupacion ".
313
            " from residentes_edificaciones as r, clientes as c ".
314
            " where r.codcliente = c.codcliente ".$this->where_code.
315
            " order by ".$this->sort." ".$this->order;
316
        if ($todo) {
317
            $data = $this->db->select($sql);
318
        } else {
319
            $data = $this->db->select_limit($sql, $this->limit, $this->offset);
320
        }
321
        $sql_cantidad = "select count(r.id) as total from residentes_edificaciones as r ".
322
            " where r.codcliente != '' ".$this->where_code;
323
        $data_cantidad = $this->db->select($sql_cantidad);
324
        return array($data, $data_cantidad[0]['total']);
325
    }
326
327
    public function lista_inmuebles($todo = false)
328
    {
329
        $sql = "select r.id, r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero, ".
330
            "case when r.ocupado then 'Si' else 'NO' end as ocupado, r.fecha_ocupacion, rme.padre_id, ".
331
            "ret.descripcion as padre_desc, rme.codigo_padre, ret2.descripcion as edif_desc, codigo_edificacion ".
332
            " from residentes_edificaciones as r ".
333
            " join residentes_mapa_edificaciones as rme on (r.id_edificacion = rme.id ".$this->where_code.") ".
334
            " join residentes_edificaciones_tipo as ret on (rme.padre_tipo = ret.id) ".
335
            " join residentes_edificaciones_tipo as ret2 on (rme.id_tipo = ret2.id) ".
336
            " left join clientes as c on (r.codcliente = c.codcliente) ".
337
            " order by ".$this->sort." ".$this->order;
338
        if ($todo) {
339
            $data = $this->db->select($sql);
340
        } else {
341
            $data = $this->db->select_limit($sql, $this->limit, $this->offset);
342
        }
343
344
        $sql_cantidad = "select count(r.id) as total from residentes_edificaciones as r";
345
        if ($this->where_code) {
346
            $sql_cantidad.=" WHERE r.codigo!='' ".$this->where_code;
347
        }
348
        $data_cantidad = $this->db->select($sql_cantidad);
349
        return array($data, $data_cantidad[0]['total']);
350
    }
351
352
    public function lista_cobros($todo = false)
353
    {
354
        $sql = "select r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero, ".
355
            "sum(f1.total) as pagado, sum(f2.total) as pendiente ".
356
            " from residentes_edificaciones as r ".
357
            " join clientes as c on (r.codcliente = c.codcliente ".$this->where_code.") ".
358
            " left join (select codcliente,anulada,pagada, sum(total) as total ".
359
            "from facturascli group by codcliente,anulada, pagada ) as f1 on ".
360
            "(r.codcliente = f1.codcliente and f1.anulada = false and f1.pagada = true) ".
361
            " left join (select codcliente,anulada,pagada, sum(total) as total ".
362
            "from facturascli group by codcliente,anulada, pagada ) as f2 on ".
363
            "(r.codcliente = f2.codcliente and f2.anulada = false and f2.pagada = false) ".
364
            " group by r.codcliente, c.nombre, c.cifnif, c.telefono1, c.email, r.codigo, r.numero ".
365
            " order by ".$this->sort." ".$this->order;
366
        if ($todo) {
367
            $data = $this->db->select($sql);
368
        } else {
369
            $data = $this->db->select_limit($sql, $this->limit, $this->offset);
370
        }
371
372
        $sql_cantidad = "select count(r.id) as total ".
373
            " from residentes_edificaciones as r".
374
            " where r.codcliente != '' ".$this->where_code;
375
        $data_cantidad = $this->db->select($sql_cantidad);
376
        return array($data, $data_cantidad[0]['total']);
377
    }
378
379
//    public function informacion_interna($id)
380
//    {
381
//        $lista_tipo = $this->edificaciones_tipo->get_by_field('padre', $id);
382
//        if ($lista_tipo) {
383
//            foreach ($lista_tipo as $linea) {
384
//                $l = new stdClass();
385
//                $l->descripcion = $linea->descripcion;
386
//                $l->cantidad = count($this->edificaciones_mapa->get_by_field('id_tipo', $linea->id));
387
//                $this->resultado[] = $l;
388
//                $this->total_resultado++;
389
//                $this->informacion_interna($linea->id);
390
//            }
391
//        } else {
392
//            return true;
393
//        }
394
//    }
395
396
    /**
397
     * Función para devolver un valor u otro dependiendo si está presente
398
     * el primer valor y si la variable existe
399
     * @param string $variable
400
     * @param string $valor_si
401
     * @param string $valor_no
402
     * @return string
403
     */
404
    public function setValor($variable, $valor_si, $valor_no)
405
    {
406
        $valor = $valor_no;
407
        if (!empty($variable) && ($variable === $valor_si)) {
408
            $valor = $valor_si;
409
        }
410
        return $valor;
411
    }
412
413
    /**
414
     * Función para devolver el valor que no esté vacio
415
     * @param string $valor1
416
     * @param string $valor2
417
     * @return string
418
     */
419
    public function confirmarValor($valor1, $valor2)
420
    {
421
        $valor = $valor2;
422
        if (!empty($valor1)) {
423
            $valor = $valor1;
424
        }
425
        return $valor;
426
    }
427
428
    /**
429
     * Función para devolver el valor de una variable pasada ya sea por POST o GET
430
     * @param type string
431
     * @return type string
432
     */
433
    public function filter_request($nombre)
434
    {
435
        $nombre_post = \filter_input(INPUT_POST, $nombre);
436
        $nombre_get = \filter_input(INPUT_GET, $nombre);
437
        return ($nombre_post) ?: $nombre_get;
438
    }
439
440
    public function filter_request_array($nombre)
441
    {
442
        $nombre_post = \filter_input(INPUT_POST, $nombre, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
443
        $nombre_get = \filter_input(INPUT_GET, $nombre, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
444
        return ($nombre_post) ?: $nombre_get;
445
    }
446
447
    public function crearXLSX(&$writer, $hoja_nombre, $header, $headerText, $data)
448
    {
449
        $style_header = array('border'=>'left,right,top,bottom','font'=>'Arial','font-size'=>10,'font-style'=>'bold');
450
        $writer->writeSheetRow($hoja_nombre, $headerText, $style_header);
451
        $writer->writeSheetHeader($hoja_nombre, $header, true);
452
        $this->agregarDatosXLSX($writer, $hoja_nombre, $data, $headerText);
453
    }
454
455
    public function agregarDatosXLSX(&$writer, $hoja_nombre, $datos, $indice)
456
    {
457
        $total_importe = 0;
458
        if ($datos) {
459
            foreach ($datos as $linea) {
460
                $data = $this->prepararDatosXLSX($linea, $indice, $total_importe);
461
                $writer->writeSheetRow($hoja_nombre, $data);
462
            }
463
        }
464
    }
465
466
    public function prepararDatosXLSX($linea, $indice, &$total_importe)
467
    {
468
        $item = array();
469
        foreach ($indice as $idx=>$desc) {
470
            $item[] = $linea[$idx];
471
            if ($idx === 'total') {
472
                $total_importe += $linea['total'];
473
            }
474
        }
475
        return $item;
476
    }
477
478
    public function carpetasPlugin()
479
    {
480
        $basepath = dirname(__DIR__, 3);
481
        $this->documentosDir = $basepath . DIRECTORY_SEPARATOR . FS_MYDOCS . 'documentos';
1 ignored issue
show
Bug introduced by
The constant FS_MYDOCS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
482
        $this->exportDir = $this->documentosDir . DIRECTORY_SEPARATOR . "informes_residentes";
483
        $this->publicPath = FS_PATH . FS_MYDOCS . 'documentos' . DIRECTORY_SEPARATOR . 'informes_residentes';
0 ignored issues
show
Bug introduced by
The constant FS_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
484
        if (!is_dir($this->documentosDir)) {
485
            if (!mkdir($concurrentDirectory = $this->documentosDir) && !is_dir($concurrentDirectory)) {
486
                throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
487
            }
488
        }
489
490
        if (!is_dir($this->exportDir)) {
491
            if (!mkdir($concurrentDirectory = $this->exportDir) && !is_dir($concurrentDirectory)) {
492
                throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
493
            }
494
        }
495
    }
496
497
    public function url()
498
    {
499
        if (isset($_REQUEST['inmueble'])) {
500
            return 'index.php?page=informe_residentes&inmueble=' . $_REQUEST['inmueble'];
501
        } else {
502
            return parent::url();
503
        }
504
    }
505
506
    private function str2bool($v)
0 ignored issues
show
Unused Code introduced by
The method str2bool() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
507
    {
508
        return ($v === 't' or $v === '1');
509
    }
510
511
    public function shared_extensions() {
512
        $extensiones = array(
513
            array(
514
                'name' => '001_informe_edificaciones_js',
515
                'page_from' => __CLASS__,
516
                'page_to' => __CLASS__,
517
                'type' => 'head',
518
                'text' => '<script src="' . FS_PATH .
0 ignored issues
show
Bug introduced by
The constant FS_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
519
                                'plugins/residentes/view/js/1/bootstrap-table.min.js" type="text/javascript"></script>',
520
                'params' => ''
521
            ),
522
            array(
523
                'name' => '002_informe_edificaciones_js',
524
                'page_from' => __CLASS__,
525
                'page_to' => __CLASS__,
526
                'type' => 'head',
527
                'text' => '<script src="' . FS_PATH .
528
                    'plugins/residentes/view/js/1/bootstrap-table-locale-all.min.js" type="text/javascript"></script>',
529
                'params' => ''
530
            ),
531
            array(
532
                'name' => '003_informe_edificaciones_js',
533
                'page_from' => __CLASS__,
534
                'page_to' => __CLASS__,
535
                'type' => 'head',
536
                'text' => '<script src="' . FS_PATH .
537
                'plugins/residentes/view/js/plugins/bootstrap-table-filter.min.js" type="text/javascript"></script>',
538
                'params' => ''
539
            ),
540
            array(
541
                'name' => '004_informe_edificaciones_js',
542
                'page_from' => __CLASS__,
543
                'page_to' => __CLASS__,
544
                'type' => 'head',
545
                'text' => '<script src="' . FS_PATH .
546
                'plugins/residentes/view/js/plugins/bootstrap-table-toolbar.min.js" type="text/javascript"></script>',
547
                'params' => ''
548
            ),
549
            array(
550
                'name' => '005_informe_edificaciones_js',
551
                'page_from' => __CLASS__,
552
                'page_to' => __CLASS__,
553
                'type' => 'head',
554
                'text' => '<script src="' . FS_PATH .
555
                'plugins/residentes/view/js/plugins/bootstrap-table-mobile.min.js" type="text/javascript"></script>',
556
                'params' => ''
557
            ),
558
            array(
559
                'name' => '009_informe_edificaciones_js',
560
                'page_from' => __CLASS__,
561
                'page_to' => __CLASS__,
562
                'type' => 'head',
563
                'text' => '<script src="' . FS_PATH . 'view/js/chart.bundle.min.js" type="text/javascript"></script>',
564
                'params' => ''
565
            ),
566
            array(
567
                'name' => '001_informe_edificaciones_css',
568
                'page_from' => __CLASS__,
569
                'page_to' => __CLASS__,
570
                'type' => 'head',
571
                'text' => '<link rel="stylesheet" type="text/css" media="screen" href="' . FS_PATH .
572
                    'plugins/residentes/view/css/bootstrap-table.min.css"/>',
573
                'params' => ''
574
            ),
575
        );
576
577
        foreach ($extensiones as $ext) {
578
            $fsext0 = new fs_extension($ext);
579
            if (!$fsext0->save()) {
580
                $this->new_error_msg('Imposible guardar los datos de la extensión ' . $ext['name'] . '.');
581
            }
582
        }
583
    }
584
}
585