<?
include("../fnc.php");
enlinea_a();

if($idgrado){
 $id_grado=dec($idgrado);
 $qver=mysql_query("select grados.id, grados.grado, grados.nivel, grados.jornada, grados.guia, niveles.nivel as nnivel, jornadas.jornada as njornada
                    from grados inner join jornadas on jornadas.id = grados.jornada
                    inner join niveles on grados.nivel = niveles.id
                    where grados.id = '$id_grado'");
 if(mysql_num_rows($qver)==0){
  alert("El grado no existe","javascript:history.go(-1)");
 }else{
  $info=mysql_fetch_array($qver);
  $tipo="Update";
 }
}else{
 $tipo="Add";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>e-Ducativo - Administraci&oacute;n grados escolares</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>
<style type="text/css">
<!--
body {
	background-image: url(../images/tema/bg_pagina.png);
}
-->
</style></head>

<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td>    <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E5E5E5">
      <tr bgcolor="#FFFFFF">
        <td width="40%"><img src="../images/logo_5.gif" width="300" height="50"></td>
        <td width="60%" background="../images/back_header_admin.gif" bgcolor="#FFFFFF"><div align="right" class="usuario_nombre_enc"><strong><?echo "$unombre $uapellido";?><br>
          </strong>Tiene <?=mensajes($uuser);?> mensaje(s) sin leer</div></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td height="15" colspan="2" background="../images/barra_encabezado.gif">&nbsp;</td>
        </tr>
    </table>
      <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC">
        <tr>
          <td width="20%" valign="top" background="../images/tema/bg_contenido.png" bgcolor="#FFFFCC"><?php include("menu.php"); ?>&nbsp;</td>
          <td width="80%" valign="top" background="../images/tema/bg_contenido.png"><table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#333333">
            <tr align="center" valign="middle" bgcolor="#FFFFCC">
              <td width="8%" height="20" background="../images/tema/bg_contenido.png" class="titulo_pagina"><div align="center" class="titulo_pagina"></div></td>
              <td background="../images/tema/bg_contenido.png" class="titulo_pagina"><strong>ADMINISTRACION DE GRADOS ESCOLARES </strong></td>
              <td width="8%" background="../images/tema/bg_contenido.png" class="titulo_pagina"><div align="right"><a href="inicio.php" class="link_parrafo">Inicio<img src="../images/ic_home.png" width="21" height="21" border="0"></a></div></td>
            </tr>
            <tr bgcolor="#CFDFEF">
              <td colspan="3" align="left" valign="top" background="../images/tema/bg_frm_campos.png"><div align="left" class="parrafo">
                <table width="100%"  border="0" cellpadding="1" cellspacing="1" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF">
                  <tr bgcolor="#FFFFFF">
                    <td colspan="6" class="titulo_seccion_mn"><?=ggrado_completo($idgrado);?></td>
                    </tr>
                  <tr>
                    <td width="20%" background="../images/tema/bg_frm_campos.png"><div align="center"><a href="frm_grado_info_v2.php?idgrado=<?=$idgrado;?>" class="link_parrafo"><strong>Informaci&oacute;n <br>
                      General </strong></a></div></td>
                    <td width="17%" bgcolor="#ECF2F9"><div align="center">
                      <p><a href="frm_grado_cuotas_v2.php?idgrado=<?=$idgrado;?>" class="link_parrafo">Cargos<br>
                        Plan General</a></p>
                      </div></td>
                    <td width="16%" bgcolor="#ECF2F9"><div align="center"><a href="frm_grado_planespagos_v2.php?idgrado=<?=$idgrado;?>" class="link_parrafo">Planes <br>
                      de pagos </a></div></td>
                    <td width="10%" bgcolor="#ECF2F9"><div align="center"><a href="frm_grado_secciones_v2.php?idgrado=<?=$idgrado;?>" class="link_parrafo">Secciones</a></div></td>
                    <td width="20%" bgcolor="#ECF2F9"><div align="center"><a href="frm_grado_unidades_v2.php?idgrado=<?=$idgrado;?>" class="link_parrafo">Unidades<br> 
                      acad&eacute;micas </a></div></td>
                    <td width="17%" bgcolor="#ECF2F9"><div align="center"><a href="frm_grado_cursos_v2.php?idgrado=<?=$idgrado;?>" class="link_parrafo">Pensum <br>
                      de cursos </a></div></td>
                  </tr>
                </table>
                <form name="form1" method="post" action="mnt_grado_info.php">
                  <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="1" cellspacing="1" bgcolor="#FFFFFF">
                          <tr bgcolor="#336699">
                            <td colspan="2" class="titulo_seccion"><div align="left" class="titulo_formulario">
                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="6%" background="../images/tema/bg_titulo_frm.png"><img src="../images/tema/ic_formularios.png" width="35" height="32"></td>
                                  <td width="94%" background="../images/tema/bg_titulo_frm.png">Informaci&oacute;n del grado escolar </td>
                                </tr>
                              </table>
                            </div></td>
                          </tr>
                          <tr>
                            <td width="31%" align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Nombre del Grado</td>
                            <td width="69%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><div align="left"><span class="lbl_campo">
                              </span> </div>

                                  <div align="left">
                                    <input name="txtgrado" type="text" class="textbox" id="txtgrado" size="50" maxlength="50" value="<?=$info[grado];?>">
                                <img src="../images/con_info.png" width="16" height="16" border="0" onMouseOver="return overlib('<b>Ingrese el nombre del grado.</b><br><br>Ejemplo:<br>Primero<br>Segundo');" onmouseout="return nd();"></div></td>
                          </tr>
                          <tr>
                            <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Nivel</td>
                            <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9" class="lbl_campo">
                             <select name="txtnivel" class="textbox" id="txtnivel">
                             <?
                             $qnivel=mysql_query("select * from niveles where id = {$info[nivel]}");
                             while($inivel=mysql_fetch_array($qnivel)){
                             ?>
                               <option value="<?=$inivel[id];?>" class="selected_option" selected>Actual: <?=$inivel[nivel];?></option>
                             <?
                             }

                             $qnivel=mysql_query("select * from niveles order by id");
                             while($inivel=mysql_fetch_array($qnivel)){
                             ?>
                               <option value="<?=$inivel[id];?>"><?=$inivel[nivel];?></option>
                             <?
                             }
                             ?>
                             </select>
                             <img src="../images/con_info.png" width="16" height="16" border="0" onMouseOver="return overlib('Seleccione el nivel al que pertenece el grado.');" onmouseout="return nd();">                            </td>
                          </tr>
                          <tr>
                            <td width="31%" align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Jornada</td>
                            <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9">
                              <div align="left"><span class="lbl_campo"><strong>
                              <select name="txtjornada" class="textbox" id="txtjornada">
                             <?
                             $qjornada=mysql_query("select * from jornadas where id = {$info[jornada]}");
                             while($ijornada=mysql_fetch_array($qjornada)){
                             ?>
                               <option value="<?=$ijornada[id];?>" class="selected_option" selected>Actual: <?=$ijornada[jornada];?></option>
                             <?
                             }

                             $qjornada=mysql_query("select * from jornadas order by id");
                             while($ijornada=mysql_fetch_array($qnivel)){
                             ?>
                               <option value="<?=$ijornada[id];?>"><?=$ijornada[jornada];?></option>
                             <?
                             }
                             ?>
                             </select>
                              </strong></span><span class="lbl_buscar"></span><span class="lbl_campo"><img src="../images/con_info.png" width="16" height="16" border="0" onMouseOver="return overlib('Seleccione la jornada a la que pertenece el grado.');" onmouseout="return nd();"></span></div></td>
                          </tr>
                          <tr>
                            <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Maestro guia o encargado de todas las secciones: </td>
                            <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9" class="lbl_campo"><strong>
                              <select name="txtguia" class="textbox" id="txtguia">
                              <option value="" selected>Sin maestro guía o encargado</option>
                             <?
                             $andnot="";
                             $qguia=mysql_query("select * from usuarios where usuario = '{$info[guia]}'");
                             if(mysql_num_rows($qguia)==0){
                             ?>
                                <option value="" class="selected_option" selected>Actual: Sin maestro guía</option>
                             <?
                             }else{
                              $andnot="and usuario <> '{$iguia[usuario]}'";
                              while($iguia=mysql_fetch_array($qguia)){
                              ?>
                                <option value="<?=$iguia[usuario];?>" class="selected_option" selected>Actual:<?=$iguia[apellido]." ".$iguia[nombre];?></option>
                              <?
                              }
                             }
                             $qguia=mysql_query("select * from usuarios where 1 $andnot and usuario <>'admin' order by apellido");
                             
                             while($iguia=mysql_fetch_array($qguia)){
                             ?>
                                <option value="<?=$iguia[usuario];?>"><?=$iguia[apellido]." ".$iguia[nombre];?></option>
                             <?
                             }
                             ?>
                              </select>
                              <img src="../images/con_info.png" width="16" height="16" border="0" onMouseOver="return overlib('Seleccione el maestro Guía o encargado de todas las secciones del grado.');" onmouseout="return nd();"></strong></td>
                          </tr>
                          <tr>
                            <td colspan="2" align="left" valign="middle" bgcolor="#CFDFEF" class="lbl_campo"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="50%" background="../images/tema/bg_frm_campos.png"><div align="center">
                                  <input name="Submit" type="submit" class="boton_guardar" value="Guardar los cambios">
                                  <input name="tipo_trn" type="hidden" id="tipo_trn" value="Update">
                                  <input name="idgrado" type="hidden" id="idgrado" value="<?=$idgrado;?>">
</div></td>
                                <td width="50%" background="../images/tema/bg_frm_campos.png"><div align="center">
                                  <input name="Submit2" type="button" class="boton_deshacer" onClick="self.location='frm_grado_mod_v2.php';" value="Salir (No guarda cambios)">
                                </div></td>
                              </tr>
                            </table>                               </td>
                            </tr>
                      </table></td>
                    </tr>
                  </table>
                  </form>
                </div></td>
              </tr>
          </table></td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>
