<?php
include_once("conexion.php");
include("top.php");
/**************************validacion de area***************************/
if($_SESSION['nivel'] != 2){
oiError("Usted no tiene acceso a este recurso");
?>
<td width="100%">
<tr>
<td colspan="2"><div class="heading1">Sin acceso, solicite información con su administrador</div></td>
</tr>
<tr>
<td width="1"><img src="imagenes/pixel.gif" width="1" height="0" border="0"></td>
<td width="100%" valign="top">
<?php
include ("pie.php");
exit();
}
/***********************************************************************************************************************/
/***************************comprobando la responsabilidad del area***************************************/
$mi_iden = $_SESSION['id_usuario'];
$mi_area = datosUsuario( $mi_iden, 'id_area');
$responsable = datosArea($mi_area,'responsable');
if($responsable == $mi_iden){
$ar_datos = miEquipo($mi_area);
$ar_areas = misAreas2($mi_area);
$nivelx = datosArea($mi_area,"tipo");
$cuestion2 = "where $nivelx = '$mi_area'";
$cuestion = "and $nivelx = '$mi_area'";
}else{
?>
<td width="100%">
<tr>
<td colspan="2"><div class="heading1">Debe tener permisos de acceso, así como pertenecer al área correspondiente para acceder a este recurso</div></td>
</tr>
<tr>
<td width="1"><img src="imagenes/pixel.gif" width="1" height="0" border="0"></td>
<td width="100%" valign="top">
<?php
include ("pie.php");
exit();
}
/***************************************************************************************************/
/*********verifica si el area pertenece al usuario****************************************************/
foreach( $ar_areas as $itm => $desc )
{
if($itm == $_GET['area']){
$pila6 = $pila6 + 1;
}
}
if ($pila6 == 0 && $_GET['area'] != ""){
?>
<td width="100%">
<tr>
<td colspan="2"><div class="heading1">Los datos del área que intenta ver no están disponibles.</div></td>
</tr>
<tr>
<td width="1"><img src="imagenes/pixel.gif" width="1" height="0" border="0"></td>
<td width="100%" valign="top">
<?php
include ("pie.php");
exit();
}
/**********************************************************************************************/
/*****************************************verificar si el usuario pertenece al area***********/
$preg = "SELECT * FROM `usuarios` where $nivelx = '{$mi_area}' order by id_usuario";
$res = mysql_query($preg,$sql_link);
$i = 0;
$pila = 0;
while($fila = mysql_fetch_array($res)){
$getusuario = $_GET['usuario'];
if($fila[id_usuario] == $getusuario){
$pila = $pila + 1;
}
}
if($pila == 0 && $_GET['usuario'] != ""){
?>
<td width="100%">
<tr>
<td colspan="2"><div class="heading1">El usuario que solicitó no pertenece a su área, pida información a su administrador.</div></td>
</tr>
<tr>
<td width="1"><img src="imagenes/pixel.gif" width="1" height="0" border="0"></td>
<td width="100%" valign="top">
<?php
include ("pie.php");
exit();
}
mysql_free_result($res);
/**********************************************************************************************/
?>
<td width="100%">
<tr>
<td colspan="2"><div class="heading1">Estadísticas (usuario)</div></td>
</tr>
<tr>
<td width="1"><img src="imagenes/pixel.gif" width="1" height="0" border="0"></td>
<td width="100%" valign="top"><br><br>
<!------------------------------------------------------------------------------------------------------------>
<script language="JavaScript">
function popupwin(url,x,y,title,resize,scroll){
var left = Math.floor( (screen.width-x) / 2);
var top = Math.floor( (screen.height-y) / 2);
var winParms = "top=" + top + ",left=" + left + ",height="+y+",width="+x+",scrollbars="+scroll+",toolbar=no,menubar=no,resizable="+resize+",location=no,directories=no,status=no";
mywin=open(url,title,winParms);
}
</script>
<div align="right">
<a href='estadisticas.php'>General</a> |
<a href='estadis_area2.php'>Por área</a> |
<a href='estadis_user2.php'>Por usuario</a> <br><br><br></div>
<?php
$num_user = $_GET['usuario'];
$usuario1 = (datosUsuario($num_user,"nombre"));
$usuario2 = (datosUsuario($num_user,"apellido_paterno"));
$usuario3 = (datosUsuario($num_user,"apellido_materno"));
$usuario_actual = "$usuario1"." "."$usuario2"." "."$usuario3";
$ar_datos = miEquipo($mi_area);
if( is_array($ar_datos) && $ar_datos != "-1" )
{
echo "<form action=\"estadis_user2.php\" method=\"get\" id=\"seluser\"><div align=\"left\">\n";
echo "<table width=\"95%\" border=0 cellpadding=2 cellspacing=0 align=\"center\">\n";
echo "<tr class=\"row2\">\n";
echo "<td>\n";
echo "<div align=\"right\">\n";
echo "seleccione:<select class=\"Text290\" name=\"usuario\" size='1' onChange= \"seluser.submit();\">\n";
echo "<option></option>\n";
lista_usuarios_area($mi_area);
echo "</select>\n";
echo "</div></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><table class=\"heading2\" width=\"95%\" border=0 cellpadding=2 cellspacing=0 align=\"center\">\n";
}
if( isset($_GET['usuario']) && !empty($_GET['usuario']))
{
if($num_user=="enviados"){
$num_user = "enviado";
$usuario_actual = "Usuarios externos";
}
$img2 = "<a href=\"seguimento2.php?donde=no_oficio&a=busqueda&qr=BQ&usuario=$num_user&area=&que=&busqueda=Buscar\"><img title=\"ir a seguimiento para este usuario\" src=\"imagenes/seg_plus.png\" border=\"0\"></a>";
echo "<tr align=\"center\"><td>$img2 $usuario_actual</td></tr></table></form>\n";
echo "<table width=\"95%\" border=0 cellpadding=2 cellspacing=0 align=\"center\">\n";
echo "<tr>\n";
echo "<td class=\"stat1\" colspan=4>Avance global de cumplimiento</td>\n";
echo "</tr>\n\n\n";
$pg = "SELECT * FROM `seguimiento` where estatus = 'Finalizado' and turnado_a = '{$num_user}'";
$ans = mysql_query($pg,$sql_link);
$t1=mysql_num_rows ($ans);
$pa = "SELECT * FROM `seguimiento` where estatus = 'En proceso' and turnado_a = '{$num_user}'";
$ans2 = mysql_query($pa,$sql_link);
$t2=mysql_num_rows ($ans2);
$i = 0;
$actualizacion = 2;
while($i < $actualizacion )
{
$a = $t1;
$b = $t2;
$valor[0]= $a;
$valor[1]= $b;
$Titulo[0]= "Finalizados";
$Titulo[1]= "En proceso";
$tot = $a+$b;
if($tot != 0){
$porcentaje = ($valor[$i]/ $tot) * 100.0;
echo "<tr><td width=\"20%\" class=\"stat2\">$Titulo[$i]</td>\n";
echo "<td class=\"stat2\"><img src=\"imagenes/poll_bar_left.png\">";
echo "<img src=\"imagenes/poll_bar_mid.png\" height=10 width=".intval($porcentaje*3).">";
echo "<img src=\"imagenes/poll_bar_right.png\"></td>\n";
echo "<td class=\"stat2\" align=\"right\">$valor[$i]</td>\n";
echo "<td class=\"stat2\" align=\"right\">".number_format($porcentaje,1,".",",")." %</td></tr>\n\n\n";
$i++;
}else{
echo "<tr><td class=\"stat2\">No existen datos para el usuario actual</td>\n";
echo "<tr><td class=\"stat2\">Verifique si tiene tareas asignadas o</td>\n";
echo "<tr><td class=\"stat2\">si se trata de un usuario de nuevo ingreso</td>\n";
$i++;
$i++;
}
}
mysql_free_result($ans);
mysql_free_result($ans2);
echo "<tr>\n";
echo "<td class=\"stat3\" colspan=2>Total...</td>\n";
echo "<td class=\"stat3\" align=\"right\">$tot</td>\n";
echo "<td class=\"stat3\" align=\"right\">100.0 %</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table><tr><td> </td></tr></table>";
?>
<?php
if($t1>0){
echo "<table width=\"95%\" border=0 cellpadding=2 cellspacing=0 align=\"center\">\n";
echo "<tr>\n";
echo "<td class=\"stat1\" colspan=4>Cumplimiento en tiempo de oficios finalizados</td>\n";
echo "</tr>\n\n\n";
$pg = "SELECT * FROM `seguimiento` where estatus = 'Finalizado' and turnado_a = '{$num_user}'";
$ans = mysql_query($pg,$sql_link);
$t1=mysql_num_rows ($ans);
$i = 0;
$k= 0;
$j = 0;
while($row = mysql_fetch_array($ans))
{
++$i;
$mifecha1 = $row[fecha_limite];
$mifecha = $row[fecha_captura];
$mifecha2 = substr($mifecha, 0, 10);
$descripcion = $row[id_seguimiento];
if($mifecha1 >= $mifecha2)
{
$resultado = "$mifecha1 es mayor a $mifecha2";
$color = "bgcolor=\"#99CC00\"";
++$k;
}else{
$resultado = "$mifecha1 es menor a $mifecha2";
$color = "bgcolor=\"#f0f0f0\"";
++$j;
}
}
$i = 0;
$actualizacion = 2;
while($i < $actualizacion )
{
$a = $k;
$b = $j;
$valor[0]= $a;
$valor[1]= $b;
$Titulo[0]= "A tiempo";
$Titulo[1]= "Destiempo";
$tot = $a+$b;
$porcentaje = ($valor[$i]/ $tot) * 100.0;
echo "<tr><td width=\"20%\" class=\"stat2\">$Titulo[$i]</td>\n";
echo "<td class=\"stat2\"><img src=\"imagenes/poll_bar_left.png\">";
echo "<img src=\"imagenes/poll_bar_mid.png\" height=10 width=".intval($porcentaje*3).">";
echo "<img src=\"imagenes/poll_bar_right.png\"></td>\n";
echo "<td class=\"stat2\" align=\"right\">$valor[$i]</td>\n";
echo "<td class=\"stat2\" align=\"right\">".number_format($porcentaje,1,".",",")." %</td></tr>\n\n\n";
$i++;
}
mysql_free_result($ans);
echo "<tr>\n";
echo "<td class=\"stat3\" colspan=2>Total...</td>\n";
echo "<td class=\"stat3\" align=\"right\">$tot</td>\n";
echo "<td class=\"stat3\" align=\"right\">100.0 %</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>";
echo "<table><tr><td> </td></tr></table>";
}
}else{
echo "<tr align=\"center\"><td>— Seleccione un usuario —</td></tr></table></form>\n";
}
?>
<?php
echo"<A Href='#' onClick=\"popupwin('imprestatics_u2.php?usuario=$num_user',720 ,500,'','yes','yes')\" title=\"Presentar gráficas para impresión\"><img alt=\"\" align=\"right\" src=\"imagenes/imprimir.png\" border=0></a>";
include ("pie.php");
?>