<?
//error_reporting(E_ALL);
include("./fnc.php");
$encontrado=false;
$tipo_usr="";
$msg="";
$qas=mysql_query("select * from alumnos where codigo_asistencia = '$txtcodigo'");

if(mysql_num_rows($qas)>0){
  $encontrado=true;
  $info=mysql_fetch_array($qas);
  $tipo_usr="alumno";

  $sql="select *
                     from asistencias
                     where fecha ='$fecha'
                     and grado='{$info[grado_estudio]}'
                     and alumno='{$info[carnet]}'
                     and seccion = '{$info[seccion]}'";
  $qver=mysql_query($sql);

  if(mysql_num_rows($qver)==0){

    $ins=mysql_query("insert into asistencias
                      set
                      fecha='$fecha',
                      grado='{$info[grado_estudio]}',
                      alumno='{$info[carnet]}',
                      seccion = '{$info[seccion]}',
                      asiste ='S'");
  }else{
    $msg="Asistencia ya ingresada!!!";
  }
}else{
  $qadm=mysql_query("select * from usuarios where codigo_asistencia = '$txtcodigo'");
  if(mysql_num_rows($qadm)>0){
     $encontrado=true;
     $info=mysql_fetch_array($qadm);
     $tipo_usr="personal";
  }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>e-Ducativo - Bienvenido</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="estilo1.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="jsincludes/overlib.js"></script>
<script language="javascript">

function validar(formulario){
 if(document.form1.txtcodigo.value=="SV"){
   alert("Ingrese un código de usuario");
   document.form1.txtcodigo.focus();
   return (false);
 }

 return (true);
}
</script>
<style type="text/css">
<!--
body {
        background-color: #006699;
}
.style1 {font-size: 18px}
-->
</style>
  <script language="javascript">
   <!--
   var limit="0:02";
   if (document.images){
    var parselimit=limit.split(":")
    parselimit=parselimit[0]*60+parselimit[1]*1
   }

   function begintimer(){
    if (!document.images)
     return
     if (parselimit==1){
      window.location = "./frm_asistencia.php";
     }else{
      parselimit-=1
      curmin=Math.floor(parselimit/60)
      cursec=parselimit%60
      if (curmin!=0){
        curtime=curmin+" MINUTOS Y "+cursec+" SEGUNDOS"
      }else{
        curtime=cursec+" SEGUNDOS"
//        document.form1.tiempo_rest.value = curtime
        setTimeout("begintimer()",1000)
      }
     }
   }

</script>

</head>

<body onload="begintimer()">
<table width="780"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#333333">
  <tr align="center" valign="middle" bgcolor="#FFFFCC">
    <td height="20" class="titulo_pagina"><strong>TOMA ELECTR&Oacute;NICA DE ASISTENCIA</strong></td>
  </tr>
  <tr align="center" valign="middle" bgcolor="#FFFFCC">
    <td height="20" class="titulo_pagina"><div align="center" class="titulo_pagina"></div>
    <div align="center" class="font_red_11"></div></td>
  </tr>
  <tr>
    <td align="left" valign="top" bgcolor="#FFFFCC"><div align="left" class="parrafo">          <table width="99%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000099">
          <tr>
            <td bgcolor="#ECE9D8"><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
                <tr bgcolor="#6699CC">
                  <td colspan="3" class="titulo_seccion"><table width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#CFDFEF">
                      <tr bgcolor="#6699CC">
                        <td bgcolor="#6699CC" class="titulo_formulario">Toma de asistencia </td>
                      </tr>
                  </table></td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td width="15%" align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">Nombre(s):</td>
                  <td width="55%" bgcolor="#ECF2F9" class="lbl_campo"><div align="left" class="style1"><?=$info[nombre];?></div></td>
                  <td width="30%" rowspan="10" bgcolor="#ECF2F9"><div align="center">

                     <?
                     if($tipo_usr=="alumno"){
                       if(file_exists("./fotos_usr/{$info[carnet]}.jpg")){
                          echo rd_imagen("./fotos_usr/","{$info[carnet]}.jpg",125,"border='1'");
                       }else{
                       ?>
                        <img src="fotos_usr/sin_foto.jpg" width="95" height="125" border="1">
                      <?
                       }
                     }
                     ?>


                  </div></td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">Apellido(s):</td>
                  <td bgcolor="#ECF2F9" class="lbl_campo"><strong class="style1">
                    <?=$info[apellido];?>
                  </strong></td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td colspan="2" align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo"><div align="center" class="lbl_roja style1"><?=$msg;?></div></td>
                </tr>
                <tr bgcolor="#E8E8E8">
                  <td align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                  <td bgcolor="#ECF2F9">&nbsp;</td>
                </tr>
            </table>              </td>
          </tr>
          </table>
        <br>
        <table width="99%"  border="0" align="center" cellpadding="5" cellspacing="1">
          <tr>
            <td width="33%">
              <div align="center">
                <input name="Button" type="button" class="boton_guardar" value="Regresar" onclick="self.location='./frm_asistencia.php'">
            </div></td>
            <td width="33%"><div align="center">
            </div></td>
            <td width="33%"><div align="center">
                <button class="boton_salir" onClick="self.location='inicio.php'">SALIR</button>
            </div></td>
          </tr>
        </table>
    </div></td>
  </tr>
</table>
</body>
</html>