2 function Directorios($base, $tema) {
4 $s = "<h4>$tema</h4><blockquote cite=\"$tema\"><ol>";
5 while($filename=$dir->read()) {
6 if ( $filename != "." && $filename != ".." && $filename != "index.php" ) { $s = $s."<li>".CREAR_LINK("$base$filename", $filename, "Abrir $filename").'</li><br />'; }
9 $s = $s."</ol></blockquote>";
14 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
15 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
17 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
18 <title>Reporte de Instructores</title>
22 $HTML_FOOT = '</body></html>';
24 function displayUsers_ECHO(){
25 global $database, $link, $base, $motor, $usuario, $clave;
26 $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>');
27 mysql_select_db($base, $link) or die('!->La base de datos seleccionada "'.$base.'" no existe');
28 $q = "SELECT username,nombre,userlevel,email,timestamp FROM ".TBL_USERS
." ORDER BY userlevel DESC;";
29 $result = $database->query($q, $link);
30 /* Error occurred, return given name by default */
31 $num_rows = mysql_numrows($result);
32 if(!$result ||
($num_rows < 0)){
33 echo "<hr />Error en la consulta<hr />";
37 echo "<hr />No hay instructores, imposible generar reporte.<hr />";
40 /* Display table contents */
42 $s = '<table border="1" cellspacing="0" cellpadding="3">';
43 $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>";
44 for($i=0; $i<$num_rows; $i++
){
45 $uname = mysql_result($result,$i,"username");
46 $nombre = mysql_result($result,$i,"nombre");
47 $ulevel = mysql_result($result,$i,"userlevel");
48 $email = mysql_result($result,$i,"email");
49 $time = date("c", mysql_result($result,$i,"timestamp"));
50 //$horarios ='<a href="./?x=hr&forzar='.$uname.'">Ver</a>';
52 $s = $s . "<tr><td>$uname</td><td>$nombre</td><td>$ulevel</td><td>$email</td><td>$time</td></tr>";
58 function OBTENER_TIPO_R($taller,$dia, $hora) {
59 global $session, $link;
60 // ¿Hay alguien(es) en esa posición?
61 $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'";
63 $resultados = @mysql_query
($q, $link);
64 $num_rows = mysql_numrows($resultados);
68 for($i=0; $i<$num_rows; $i++
){
69 $uname = mysql_result($resultados,$i,"nombre");
70 /* Por petición solo el primer nombre es mostrado */
72 ereg("([^ ]*)", $uname, $nombre);
73 $uinfo = mysql_result($resultados,$i,"username");
74 $msj = $msj."<li>".$nombre[0].'</li>';
76 return "<td bgcolor=\"#EEEEEE\">".$msj."</td>";
81 return "<td>".$msj."</td>";
84 function MOSTRAR_HORARIOS_ECHO() {
85 global $link, $base, $motor, $usuario, $clave;
86 $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>');
87 mysql_select_db($base, $link) or die('!->La base de datos seleccionada "'.$base.'" no existe');
91 <h3>Taller '.$_SESSION['taller'].' - ';
92 switch ($_SESSION['tipo'])
94 case 0: $salida = $salida .TI_0
; break;
95 case 1: $salida = $salida .TI_1
; break;
96 case 2: $salida = $salida .TI_2
; break;
97 case 3: $salida = $salida .TI_3
; break;
103 <table border="1" cellspacing="0" cellpadding="3">
104 <tr><th>Horario</th><th>Lunes</th><th>Martes</th><th>Miercoles</th><th>Jueves</th><th>Viernes</th><th>Sabado</th></tr>
106 for ($i=450; $i<=1170; $i+
=60){
107 $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>";
109 $salida = $salida ."</table><br />";
110 //mysql_close($link);
114 function ADMIN_reportes() {
115 echo "<h2>Generador de Reportes</h2>";
116 if ( isset($_POST['generar']) ) {
118 echo '<h3>Reporte(s) generado(s) en base a las opciones de configuración:<br />';
120 echo 'dpto1->'.$_POST['dpto0'].'<br />';
121 echo 'dpto2->'.$_POST['dpto1'].'<br />';
122 echo 'taller0>'.$_POST['taller0'].'<br />';
123 echo 'taller1>'.$_POST['taller1'].'<br />';
124 echo 'taller2>'.$_POST['taller2'].'<br />';
125 echo 'taller3>'.$_POST['taller3'].'<br />';
126 echo 'taller4>'.$_POST['taller4'].'<br />';
127 echo 'taller5>'.$_POST['taller5'].'<br />';
128 echo 'taller6>'.$_POST['taller6'].'<br />';
129 echo 'taller7>'.$_POST['taller7'].'<br />';
130 echo 'tipo_instructor0>'.$_POST['tipo_instructor0'].'<br />';
131 echo 'tipo_instructor1>'.$_POST['tipo_instructor1'].'<br />';
132 echo 'tipo_instructor2>'.$_POST['tipo_instructor2'].'<br />';
133 echo 'tipo_instructor3>'.$_POST['tipo_instructor3'].'<br />';
136 global $HTML_HEAD, $HTML_FOOT;
140 if ($_POST['dpto0'] == 1) {
141 $s = $s . "<h2>".DE_0
. "</h2>";
142 for ($i=0; $i < 4; $i++
) {
143 if ( $_POST["tipo_instructor$i"] == 1 ) {
144 $_SESSION['tipo'] = $i;
145 if ( $_POST['taller0'] ) {$_SESSION['taller'] = 'LSA'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
146 if ( $_POST['taller1'] ) {$_SESSION['taller'] = 'LID'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
147 if ( $_POST['taller2'] ) {$_SESSION['taller'] = 'LAI'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
148 if ( $_POST['taller3'] ) {$_SESSION['taller'] = 'LIV'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
152 if ($_POST['dpto1'] == 1) {
153 $s = $s . "<h2>".DE_1
. "</h2>";
154 for ($i=0; $i < 4; $i++
) {
155 if ( $_POST["tipo_instructor$i"] == 1 ) {
156 $_SESSION['tipo'] = $i;
157 if ( $_POST['taller4'] ) {$_SESSION['taller'] = 'TPP'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
158 if ( $_POST['taller5'] ) {$_SESSION['taller'] = 'TIS'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
159 if ( $_POST['taller6'] ) {$_SESSION['taller'] = 'TAS'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
160 if ( $_POST['taller7'] ) {$_SESSION['taller'] = 'TEC'; $s = $s . MOSTRAR_HORARIOS_ECHO(); }
164 $s = $s . $HTML_FOOT;
166 $tiempo_ord = date('y\-m\-d\+h.ia', time());
167 $myFile = "reportes/+H/+HTML/horarios+".$tiempo_ord.".html";
168 $fh = @fopen
($myFile, 'w') or die("'/reportes/+HTML/' bloqueado");
171 echo '<a href="'.$myFile.'">Descargar reportes de Horarios[HTML]</a><br />';
172 //Instructores/Usuarios
174 $s = $s . displayUsers_ECHO() . $HTML_FOOT;
175 $myFile = "reportes/+I/+HTML/instructores+".$tiempo_ord.".html";
176 $fh = @fopen
($myFile, 'w') or die("'/reportes/+HTML/' bloqueado");
179 echo '<a href="'.$myFile.'">Descargar reportes de Instructores[HTML]</a><br />';
180 echo "<hr /><h3>Por favor seleccione el/los tipo(s) de reporte(s) a generar</h3>";
181 echo "<h4>Reporte de horarios</h4>";
183 <form action
="./?accion=reportes" method
="post">
186 <td
><input type
="checkbox" name
="dpto0" value
="1" checked
="cheked"><?
echo DE_0
;?
></td
>
187 <td
><input type
="checkbox" name
="dpto1" value
="1" checked
="cheked"><?
echo DE_1
;?
></td
>
192 <td
><input type
="checkbox" name
="taller0" value
="1" checked
="cheked">LSA
</td
>
193 <td
><input type
="checkbox" name
="taller4" value
="1" checked
="cheked">TPP
</td
>
196 <td
><input type
="checkbox" name
="taller1" value
="1" checked
="cheked">LID
</td
>
197 <td
><input type
="checkbox" name
="taller5" value
="1" checked
="cheked">TIS
</td
>
200 <td
><input type
="checkbox" name
="taller2" value
="1" checked
="cheked">LAI
</td
>
201 <td
><input type
="checkbox" name
="taller6" value
="1" checked
="cheked">TAS
</td
>
204 <td
><input type
="checkbox" name
="taller3" value
="1" checked
="cheked">LIV
</td
>
205 <td
><input type
="checkbox" name
="taller7" value
="1" checked
="cheked">TEC
</td
>
210 <td
><input type
="checkbox" name
="tipo_instructor0" value
="1" checked
="cheked"> <?
echo TI_0
;?
></td
>
211 <td
><input type
="checkbox" name
="tipo_instructor1" value
="1" checked
="cheked"> <?
echo TI_1
;?
></td
>
214 <td
><input type
="checkbox" name
="tipo_instructor2" value
="1" checked
="cheked"> <?
echo TI_2
;?
></td
>
215 <td
><input type
="checkbox" name
="tipo_instructor3" value
="1" checked
="cheked"> <?
echo TI_3
;?
></td
>
219 <?
echo "<h4>Reporte de Instructores</h4>"; ?
>
221 <?
echo "<hr /><h3>Por favor seleccione el/los tipo(s) de formato de salida a generar</h3>"; ?
>
224 <td
><input type
="checkbox" name
="tipo_reporte0" value
="1" checked
="cheked">PDF
</td
>
225 <td
><input type
="checkbox" name
="tipo_reporte1" value
="1" checked
="cheked">HTML
</td
>
228 <input type
="hidden" name
="generar" value
="1">
229 <input type
="submit" name
="generar" value
="Generar" />
232 echo "<hr /><h3>Se han encontrado estos reportes anteriores</h3>";
233 echo Directorios("reportes/+H/+HTML/", "Horarios - HTML");
234 echo Directorios("reportes/+H/+PDF/", "Horarios - PDF");
235 echo Directorios("reportes/+I/+HTML/", "Instructores - HTML");
236 echo Directorios("reportes/+I/+PDF/", "Instructores - PDF");