2 function byteConvert($bytes)
4 $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB');
5 $e = floor(log($bytes)/log(1024));
7 return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e))));
9 function Directorios($base, $tema) {
11 $s = "<h4>$tema</h4><blockquote cite=\"$tema\"><ol>";
12 while($filename=$dir->read()) {
13 if ( $filename != "." && $filename != ".." && $filename != "index.php" ) { $s = $s."<li>".CREAR_LINK("$base$filename", $filename, "Abrir $filename").' [<b>'.byteConvert(filesize($base.$filename)).'</b>]</li><br />'; }
16 $s = $s."</ol></blockquote>";
21 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
22 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
24 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
25 <title>Reporte de Instructores</title>
29 $HTML_FOOT = '</body></html>';
31 function displayUsers_ECHO(){
32 global $database, $link, $base, $motor, $usuario, $clave;
33 $link = @mysql_connect
($motor, $usuario, $clave) or die('Por favor revise sus datos, puesto que se produjo el siguiente error:<br /><pre>' . mysql_error() . '</pre>');
34 mysql_select_db($base, $link) or die('!->La base de datos seleccionada "'.$base.'" no existe');
37 $q = "SELECT username,nombre,userlevel,email,timestamp FROM ".TBL_USERS
." $where ORDER BY userlevel DESC;";
38 $result = $database->query($q, $link);
39 /* Error occurred, return given name by default */
40 $num_rows = mysql_numrows($result);
41 if(!$result ||
($num_rows < 0)){
42 echo "<hr />Error en la consulta<hr />";
46 $s = "No hay instructores, imposible generar reporte.";
49 /* Display table contents */
51 $s = '<table border="1" cellspacing="0" cellpadding="3">';
52 $s = $s . "<tr><td><b>Código</b></td><td><b>Nombre</b></td><td><b>Nivel</b></td><td><b>Email</b></td><td><b>Última actividad</b></td></tr>";
53 for($i=0; $i<$num_rows; $i++
){
54 $uname = mysql_result($result,$i,"username");
55 $nombre = mysql_result($result,$i,"nombre");
56 $ulevel = mysql_result($result,$i,"userlevel");
57 $email = mysql_result($result,$i,"email");
58 $time = date("c", mysql_result($result,$i,"timestamp"));
59 //$horarios ='<a href="./?x=hr&forzar='.$uname.'">Ver</a>';
61 $s = $s . "<tr><td>$uname</td><td>$nombre</td><td>$ulevel</td><td>$email</td><td>$time</td></tr>";
67 function OBTENER_TIPO_R($taller,$dia, $hora) {
68 global $session, $link;
69 // ¿Hay alguien(es) en esa posición?
70 switch ($_SESSION['tipo']) {
74 $q = "SELECT users.username, nombre FROM users, horarios WHERE users.username = horarios.username and taller like '%$taller%' AND tipo = '". $_SESSION['tipo']. "' AND dia='$dia' AND posicion='$hora' AND departamento = '" .$_SESSION['dpto']. "';";
77 $q = "SELECT users.username, nombre FROM users, horarios WHERE users.username = horarios.username AND tipo = '2' AND dia='$dia' AND posicion='$hora' AND departamento = '" . $_SESSION['dpto']. "';";
81 $resultados = @mysql_query
($q, $link);
82 $num_rows = mysql_numrows($resultados);
86 for($i=0; $i<$num_rows; $i++
){
87 $uname = mysql_result($resultados,$i,"nombre");
88 /* Por petición solo el primer nombre es mostrado */
90 ereg("([^ ]*)", $uname, $nombre);
91 $uinfo = mysql_result($resultados,$i,"username");
92 $msj = $msj.$nombre[0]."<br />";
94 return "<td bgcolor=\"#EEEEEE\">".$msj."</td>";
99 return "<td>".$msj."</td>";
102 function MOSTRAR_HORARIOS_ECHO() {
103 global $link, $base, $motor, $usuario, $clave;
104 $link = @mysql_connect
($motor, $usuario, $clave) or die('Por favor revise sus datos, puesto que se produjo el siguiente error:<br /><pre>' . mysql_error() . '</pre>');
105 mysql_select_db($base, $link) or die('!->La base de datos seleccionada "'.$base.'" no existe');
109 <h3>Taller '.$_SESSION['taller'].' - ';
110 switch ($_SESSION['tipo'])
112 case 0: $salida = $salida .TI_0
; break;
113 case 1: $salida = $salida .TI_1
; break;
114 case 2: $salida = $salida .TI_2
; break;
115 case 3: $salida = $salida .TI_3
; break;
121 <table border="1" cellspacing="0" cellpadding="3">
122 <tr><th>Horario</th><th>Lunes</th><th>Martes</th><th>Miercoles</th><th>Jueves</th><th>Viernes</th><th>Sabado</th></tr>
124 for ($i=450; $i<=1170; $i+
=60){
125 $salida = $salida ."<tr><td>". date("h:ia", mktime(0,$i)) . "</td>". OBTENER_TIPO_R($_SESSION['taller'], 1, $i).OBTENER_TIPO_R($_SESSION['taller'], 2, $i).OBTENER_TIPO_R($_SESSION['taller'], 3, $i).OBTENER_TIPO_R($_SESSION['taller'], 4, $i).OBTENER_TIPO_R($_SESSION['taller'], 5, $i).OBTENER_TIPO_R($_SESSION['taller'], 6, $i)."</tr>";
127 $salida = $salida .'</table><br /><p style="page-break-after: always" />';
128 //mysql_close($link);
132 function ADMIN_reportes() {
133 global $HTML_HEAD, $HTML_FOOT;
134 echo "<h2>Generador de Reportes</h2>";
135 if ( isset($_POST['generar']) ) {
136 echo '<h3>Reporte(s) generado(s) en base a las opciones de configuración:<br />';
137 $tiempo_ord = date('y\-m\-d\+h.ia', time());
138 if ($_POST['generar_horarios'] == 1 ) {
139 /***************************************************************************************************************************/
140 /* HORARIOS - HTML */
141 /***************************************************************************************************************************/
143 if (isset($_POST['dpto0'])) {
144 if ($_POST['dpto0'] == 1) {
145 $_SESSION['dpto'] = 0;
146 $s = $s . "<h2>".DE_0
. "</h2>";
147 for ($i=0; $i < 4; $i++
) {
148 if (isset($_POST["tipo_instructor$i"])) {
149 if ( $_POST["tipo_instructor$i"] == 1 ) {
150 $_SESSION['tipo'] = $i;
152 if (isset($_POST['taller0'])) { if ( $_POST['taller0'] ) {$_SESSION['taller'] = 'LSA'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
153 if (isset($_POST['taller1'])) { if ( $_POST['taller1'] ) {$_SESSION['taller'] = 'LID'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
154 if (isset($_POST['taller2'])) { if ( $_POST['taller2'] ) {$_SESSION['taller'] = 'LAI'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
155 if (isset($_POST['taller3'])) { if ( $_POST['taller3'] ) {$_SESSION['taller'] = 'LIV'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
157 //Encargado de Taller, solo mostrar 1 horario.
158 $_SESSION['taller'] = 'GENERAL'; $s = $s . MOSTRAR_HORARIOS_ECHO();
165 if (isset($_POST['dpto1'])) {
166 if ($_POST['dpto1'] == 1) {
167 $_SESSION['dpto'] = 1;
168 $s = $s . "<h2>".DE_1
. "</h2>";
169 for ($i=0; $i < 4; $i++
) {
170 if (isset($_POST["tipo_instructor$i"])) {
171 if ( $_POST["tipo_instructor$i"] == 1 ) {
172 $_SESSION['tipo'] = $i;
174 if (isset($_POST['taller4'])) { if ( $_POST['taller4'] ) {$_SESSION['taller'] = 'TPP'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
175 if (isset($_POST['taller5'])) { if ( $_POST['taller5'] ) {$_SESSION['taller'] = 'TIS'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
176 if (isset($_POST['taller6'])) { if ( $_POST['taller6'] ) {$_SESSION['taller'] = 'TAS'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
177 if (isset($_POST['taller7'])) { if ( $_POST['taller7'] ) {$_SESSION['taller'] = 'TEC'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }}
179 //Encargado de Taller, solo mostrar 1 horario.
180 $_SESSION['taller'] = 'GENERAL'; $s = $s . MOSTRAR_HORARIOS_ECHO();
187 $s = $s . $HTML_FOOT;
189 //Haremos HORARIOS_HTML?
190 if ( $_POST['tipo_reporte1'] == 1 ) {
191 $archivo_HTML_HORARIOS = "reportes/+H/+HTML/horarios+".$tiempo_ord.".html";
192 $fh = @fopen
($archivo_HTML_HORARIOS, 'w') or die("'/reportes/+HTML/' bloqueado");
197 /***************************************************************************************************************************/
199 /***************************************************************************************************************************/
201 if ( $_POST['tipo_reporte0'] == 1 ) {
202 @set_time_limit
(300);
203 $dompdf = new DOMPDF();
204 $dompdf->load_html($s);
206 $PDF_HORARIOS = $dompdf->output();
207 $archivo_PDF_HORARIOS = "reportes/+H/+PDF/horarios+".$tiempo_ord.".pdf";
208 file_put_contents($archivo_PDF_HORARIOS, $PDF_HORARIOS);
210 unset($PDF_HORARIOS);
215 /***************************************************************************************************************************/
216 /* INSTRUCTORES - HTML */
217 /***************************************************************************************************************************/
218 if ( $_POST['generar_instructores'] == 1 ) {
219 $s = $HTML_HEAD. displayUsers_ECHO() . $HTML_FOOT;
221 //Haremos Instructores_HTML?
222 if ( $_POST['tipo_reporte1'] == 1 ) {
223 $archivo_HTML_INSTRUCTORES = "reportes/+I/+HTML/instructores+".$tiempo_ord.".html";
224 $fh = @fopen
($archivo_HTML_INSTRUCTORES, 'w') or die("'/reportes/+HTML/' bloqueado");
229 /***************************************************************************************************************************/
230 /* INSTRUCTORES - PDF */
231 /***************************************************************************************************************************/
232 if ( $_POST['tipo_reporte0'] == 1 ) {
233 @set_time_limit
(300);
234 $dompdf = new DOMPDF();
235 $dompdf->load_html($s);
237 $PDF_INSTRUCTORES = $dompdf->output();
238 $archivo_PDF_INSTRUCTORES = "reportes/+I/+PDF/horarios+".$tiempo_ord.".pdf";
239 file_put_contents($archivo_PDF_INSTRUCTORES, $PDF_INSTRUCTORES);
241 unset($PDF_INSTRUCTORES);
246 /***************************************************************************************************************************/
247 /* GENERACIÓN DE REPORTES TERMINANDA, MOSTRAR LINKS */
248 /***************************************************************************************************************************/
250 if ( $_POST['tipo_reporte1'] == 1 && $_POST['generar_horarios'] == 1 ){ echo '<a href="'.$archivo_HTML_HORARIOS.'">Descargar reportes de Horarios[HTML]</a><br />'; }
251 if ( $_POST['tipo_reporte0'] == 1 && $_POST['generar_horarios'] == 1 ) {echo '<a href="'.$archivo_PDF_HORARIOS.'">Descargar reportes de Horarios[PDF]</a><br />'; }
252 if ( $_POST['tipo_reporte1'] == 1 && $_POST['generar_instructores'] == 1 ){ echo '<a href="'.$archivo_HTML_INSTRUCTORES.'">Descargar reportes de Instructores[HTML]</a><br />'; }
253 if ( $_POST['tipo_reporte0'] == 1 && $_POST['generar_instructores'] == 1 ){ echo '<a href="'.$archivo_PDF_INSTRUCTORES.'">Descargar reportes de Instructores[PDF]</a><br />'; }
255 echo '<blockquote>Por favor realice clic derecho sobre el enlace de descarga y posteriormente utilice la opción "Guardar como" de su navegador</blockquote>';
257 echo "<hr /><h3>Por favor seleccione el/los tipo(s) de reporte(s) a generar</h3>";
258 echo "<h4>Reporte de horarios</h4>";
260 <form action
="./?accion=reportes" method
="post">
261 <input type
="checkbox" name
="generar_horarios" value
="1" checked
="cheked">Generar reporte de horarios
264 <td
><input type
="checkbox" name
="dpto0" value
="1" checked
="cheked"><?
echo DE_0
;?
></td
>
265 <td
><input type
="checkbox" name
="dpto1" value
="1" checked
="cheked"><?
echo DE_1
;?
></td
>
270 <td
><input type
="checkbox" name
="taller0" value
="1" checked
="cheked">LSA
</td
>
271 <td
><input type
="checkbox" name
="taller4" value
="1" checked
="cheked">TPP
</td
>
274 <td
><input type
="checkbox" name
="taller1" value
="1" checked
="cheked">LID
</td
>
275 <td
><input type
="checkbox" name
="taller5" value
="1" checked
="cheked">TIS
</td
>
278 <td
><input type
="checkbox" name
="taller2" value
="1" checked
="cheked">LAI
</td
>
279 <td
><input type
="checkbox" name
="taller6" value
="1" checked
="cheked">TAS
</td
>
282 <td
><input type
="checkbox" name
="taller3" value
="1" checked
="cheked">LIV
</td
>
283 <td
><input type
="checkbox" name
="taller7" value
="1" checked
="cheked">TEC
</td
>
288 <td
><input type
="checkbox" name
="tipo_instructor0" value
="1" checked
="cheked"> <?
echo TI_0
;?
></td
>
289 <td
><input type
="checkbox" name
="tipo_instructor1" value
="1" checked
="cheked"> <?
echo TI_1
;?
></td
>
292 <td
><input type
="checkbox" name
="tipo_instructor2" value
="1" checked
="cheked"> <?
echo TI_2
;?
></td
>
293 <td
><input type
="checkbox" name
="tipo_instructor3" value
="1" checked
="cheked"> <?
echo TI_3
;?
></td
>
296 <?
echo "<h4>Reporte de Instructores</h4>"; ?
>
297 <input type
="checkbox" name
="generar_instructores" value
="1" checked
="cheked">Generar reporte de instructores
300 <td
><input type
="checkbox" name
="instructor_nivel0" value
="1" checked
="cheked"> Administradores
</td
>
301 <td
><input type
="checkbox" name
="instructor_nivel1" value
="1" checked
="cheked"> Instructores
</td
>
304 <?
echo "<hr /><h3>Por favor seleccione el/los tipo(s) de formato de salida a generar</h3>"; ?
>
307 <td
><input type
="checkbox" name
="tipo_reporte0" value
="1" checked
="cheked">PDF
</td
>
308 <td
><input type
="checkbox" name
="tipo_reporte1" value
="1" checked
="cheked">HTML
</td
>
311 <input type
="hidden" name
="generar" value
="1">
312 <input type
="submit" name
="bgenerar" value
="Generar" />
315 echo "<hr /><h3>Se han encontrado estos reportes anteriores</h3>";
316 echo Directorios("reportes/+H/+HTML/", "Horarios - HTML");
317 echo Directorios("reportes/+H/+PDF/", "Horarios - PDF");
318 echo Directorios("reportes/+I/+HTML/", "Instructores - HTML");
319 echo Directorios("reportes/+I/+PDF/", "Instructores - PDF");