commit masivo.
[ecomupi.git] / contenido / admin+reportes+dinamico.php
bloba9d68d38d39c2f46f2698af4a88b705edd7bd650
1 <?php
2 error_reporting(E_ALL);
3 ob_start("ob_gzhandler");
4 date_default_timezone_set ('America/El_Salvador');
5 ini_set("memory_limit","128M");
6 set_time_limit(600);
7 require_once('../include/const.php');
8 require_once('../include/sesion.php');
9 require_once('../include/fecha.php');
10 require_once('sub.php');
11 //====================PROCESAR REPORTES============================//
13 if (isset($_GET['sub']) && isset($_GET['reporte']) && $session->logged_in)
15 $andUsuario = ($session->isAdmin()) ? "" : "AND codigo='" . $session->codigo . "'";
16 switch ($_GET['reporte'])
18 case "rapido_todos_los_mupis":
19 $c = "SELECT concat(codigo_calle, '.', codigo_mupi) 'Código', (SELECT ubicacion FROM emupi_calles AS b WHERE b.codigo_calle = a.codigo_calle) AS 'Ubicación', direccion 'Dirección' FROM emupi_mupis AS a ORDER BY codigo_calle, CAST(codigo_mupi as UNSIGNED)";
20 break;
22 case "rapido_mupis_catorcena_anterior":
23 $c = "SELECT @codigo_mupi := (SELECT id_mupi FROM ".TBL_MUPI." as b WHERE a.codigo_mupi=b.id_mupi) as codigo_mupi, @codigo_mupi_traducido := (SELECT CONCAT((SELECT @ubicacion := b.ubicacion FROM emupi_calles AS b WHERE c.codigo_calle=b.codigo_calle), '. ', direccion , ' | ' , c.codigo_calle, '.' , @codigo_mupi_parcial := c.codigo_mupi ) FROM emupi_mupis as c WHERE c.id_mupi= @codigo_mupi) AS ubicacion, tipo_pantalla, id_pantalla FROM ".TBL_MUPI_FACES. " AS a WHERE catorcena = '".Obtener_catorcena_anterior()."' ORDER BY ubicacion, @codigo_mupi_parcial, tipo_pantalla";
24 break;
26 case "rapido_mupis_catorcena_actual":
27 $c = "";
28 break;
30 case "rapido_usuarios_catorcena_anterior":
32 break;
34 case "rapido_usuarios_catorcena_actual":
36 break;
38 DEPURAR($c,0);
39 $resultado = $database->query($c);
40 $html = db_ui_tabla($resultado, 'style="border:1px"');
41 //======GENERAR PDF==========================//
42 require_once('../include/tcpdf/config/lang/eng.php');
43 require_once('../include/tcpdf/tcpdf.php');
44 $pdf = new TCPDF('L', PDF_UNIT, "LETTER", true, 'UTF-8', false);
45 $pdf->SetCreator(PDF_CREATOR);
46 $pdf->SetAuthor('Ecomupis, CEPASA DE C.V.');
47 $pdf->SetTitle('Ecomupis I·PRINT');
48 $pdf->SetSubject('Reporte solicitado vía interfaz web');
49 $pdf->SetKeywords('ECOMUPIS, CEPASA, REPORTE');
50 // set default header data
51 $pdf->SetHeaderData("logo.png", 20, "Reporte de Ecomupis", date("h:m:ia.d-m-Y"));
53 // set header and footer fonts
54 $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
55 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
57 // set default monospaced font
58 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
60 //set margins
61 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
62 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
63 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
65 //set auto page breaks
66 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
68 //set image scale factor
69 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
71 //set some language-dependent strings
72 $pdf->setLanguageArray($l);
74 // ---------------------------------------------------------
76 // set font
77 $pdf->SetFont('dejavusans', '', 10);
79 // add a page
80 $pdf->AddPage();
82 // add HTML
83 $pdf->writeHTML($html, true, 0, true, 0);
85 // reset pointer to the last page
86 $pdf->lastPage();
88 //Close and output PDF document
89 $pdf->Output('Reporte Ecomupis.'.date("h:m:ia.d-m-Y").'.pdf', 'I');