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

if($idp){
 $id_p=($idp);
 $q=mysql_query("select * from alumnos where carnet = $id_p");
 $info=mysql_fetch_array($q);
}
$tipo="Re-Inscribir";

$qgral=mysql_query("select * from general where id = 1");
$igral=mysql_fetch_array($qgral);

//$info[plan_pago]="";
//$info[grado_estudio]="";

?>
<!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 language="javascript">
function validarf2(){
  if(document.form2.idp.value=="SV"){
    alert("Seleccione un alumno");
    document.form2.txtcarnet.value="";
    document.form2.txtcarnet.focus();
    return (false);
  }
return (true);
}

function mostrar_carnet(){
  if(document.form2.idp.value != "SV"){
    document.form2.txtcarnet.value=document.form2.idp.value;
  }
}

function seleccionar_alumno(){
  var combo = document.form2.idp;
  var mcarnet = document.form2.txtcarnet.value;
  var respuesta;

  for(i=0;i<combo.length;i++){
    if(combo.options[i].value==mcarnet){
         combo.selectedIndex = i;
    }
  }
}
</script>
<script language="JavaScript" type="text/JavaScript">

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function validar(formulario){
  var respuesta;

  if(document.form1.txtyear_estudio.value==document.form1.txtyear_actual.value){
    alert("El alumno ya está inscrito para ese ciclo escolar");
    document.form1.txtyear_estudio.focus();
    return (false);
  }

  if(document.form1.txtseccion.value==""){
    alert("Ingrese una sección de estudios");
    document.form1.txtseccion.focus();
    return (false);
  }
  if(document.form1.txtgrado.value=="SV"){
    alert("Seleccione un grado de estudios");
    document.form1.txtgrado.focus();
    return (false);
  }
  if(document.form1.txtyear_estudio.value==""){
    alert("Debe ingresar el ciclo al que desea inscribir al alumno");
    document.form1.txtyear_estudio.focus();
    return (false);
  }
  if(document.form1.txtplanpago.value=="SV"){
    alert("Seleccione un plan de pago");
    document.form1.txtplanpago.focus();
    return (false);
  }
  if(document.form1.txtsexo.value=="SV"){
    alert("Seleccione el sexo del alumno");
    document.form1.txtsexo.focus();
    return (false);
  }
  if(document.form1.txtfnd.value==""){
    alert("Por favor ingrese la fecha de nacimiento");
    document.form1.txtfnd.focus();
    return (false);
  }
  if(document.form1.txtfnm.value=="SV"){
    alert("Por favor ingrese la fecha de nacimiento");
    document.form1.txtfnm.focus();
    return (false);
  }
  if(document.form1.txtfny.value==""){
    alert("Por favor ingrese la fecha de nacimiento");
    document.form1.txtfny.focus();
    return (false);
  }

  respuesta = confirm("Está seguro de RE-Inscribir a este(a) alumno(a)???");
  if(respuesta){
   return (true);
  }else{
   return (false);
  }
}

function valores(){
  alert("Grado: "+document.form1.txtgrado.value+"\n"+"Plan de pago:"+document.form1.txtplanpago.value);

}

// CODIGO COMBOS PLANES DE PAGO - GRADOS
var grado= new Array();
var plan_pago = new Array();
var plan_pago= new Array();
<?php
 $qgrado=mysql_query("select grados.id as idgrado, grados.grado, niveles.nivel, niveles.id as idnivel
                      from grados inner join niveles on niveles.id = grados.nivel
                      order by grados.jornada, niveles.en_numeros, grados.en_numeros, grados.grado");

 $n=1;
 while($igrado=mysql_fetch_array($qgrado)){
  echo "grado[$n]='".$igrado[grado]." ".$igrado[nivel]."|".$igrado[idgrado]."';\n";
  $n++;
 }

 $qpp=mysql_query("select * from cp_planesdepagos order by plan");
 $n=0;
 while($ipp=mysql_fetch_array($qpp)){
  echo "plan_pago[$n]='".$ipp[grado]."|".$ipp[plan]."|".$ipp[id]."';\n";
  $n++;
 }
 
 $qpp=mysql_query("select * from cp_planesdepagos order by plan");
 $n=0;
 while($ipp=mysql_fetch_array($qpp)){
  echo "plan_pago[$n]='".$ipp[grado]."|  -".$ipp[plan]."|".$ipp[id]."';\n";
  $n++;
 }
?>

function llenarg(){
 var cont = 0;
 document.form1.txtgrado.options[cont] = new Option ("Seleccione un grado...","SV");
 cont++;
 for(i=1;i<grado.length;i++){
  var tmp = grado[i].split("|");
  document.form1.txtgrado.options[cont] = new Option(tmp[0],tmp[1]);
  cont++;
 }
}

function llenarpp(){
 for(i=document.form1.txtplanpago.length; i>-1; i--){
   document.form1.txtplanpago.options[i]=null;
 }
 cont=0;
 document.form1.txtplanpago.options[cont] = new Option ("Seleccione un plan de pago...","SV");
 cont++;
 var mGrado=document.form1.txtgrado.value;

 for(i=0;i<plan_pago.length;i++){

   var tmp = plan_pago[i].split("|");
   var encontrado=false;
   var tmp2 = tmp[0].split(",");

   for(k=0;k<=tmp2.length;k++){
     if (tmp2[k]==mGrado){
       encontrado = true;
     }
   }

   if(encontrado==true){
    document.form1.txtplanpago.options[cont] = new Option (tmp[1], tmp[2]);
    cont++;
   }
 }
}

function llenar_planpago(){
 for(i=document.form1.txtplanpago.length; i>-1; i--){
   document.form1.txtplanpago.options[i]=null;
 }
 cont=0;
 document.form1.txtplanpago.options[cont] = new Option ("Seleccione...","SV");
 cont++;
 document.form1.txtplanpago.options[cont] = new Option ("Plan General","PG");
 cont++;
 
 var mGrado=document.form1.txtgrado.value;

 for(i=0;i<plan_pago.length;i++){

   var tmp = plan_pago[i].split("|");
   var encontrado=false;
   var tmp2 = tmp[0].split(",");

   for(k=0;k<=tmp2.length;k++){
     if (tmp2[k]==mGrado){
       encontrado = true;
     }
   }

   if(encontrado==true){
    document.form1.txtplanpago.options[cont] = new Option (tmp[1], tmp[2]);
    cont++;
   }
 }
}
// FIN CODIGO COMBOS PLANES DE PAGO - GRADOS
 var seccion_grado = new Array();
 
<?
 $qpp=mysql_query("select * from secciones_grados order by seccion");
 $n=0;
 while($ipp=mysql_fetch_array($qpp)){
  echo "seccion_grado[$n]='".$ipp[grado]."|".$ipp[seccion]."|".$ipp[seccion]."';\n";
  $n++;
 }
?> 
function llenar_seccion(){
 for(i=document.form1.txtseccion.length; i>-1; i--){
   document.form1.txtseccion.options[i]=null;
 }
 cont=0;
 document.form1.txtseccion.options[cont] = new Option ("Seleccione...","SV");
 cont++;
 var mGrado=document.form1.txtgrado.value;

 for(i=0;i<seccion_grado.length;i++){

   var tmp = seccion_grado[i].split("|");
   var encontrado=false;
   var tmp2 = tmp[0].split(",");

   for(k=0;k<=tmp2.length;k++){
     if (tmp2[k]==mGrado){
       encontrado = true;
     }
   }

   if(encontrado==true){
    document.form1.txtseccion.options[cont] = new Option (tmp[1], tmp[2]);
    cont++;
   }
 }
}
</script>
<style type="text/css">
<!--
body {
	background-image: url(../images/tema/bg_pagina.png);
}
-->
</style></head>

<body <?if($idp){?>onload="llenarg();"<?}?>>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td bgcolor="#336699">    <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E5E5E5">
      <tr bgcolor="#FFFFFF">
        <td width="40%" bgcolor="#FFFFD2"><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" bgcolor="#FFFFCC"><table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#333333">
            <tr align="center" valign="middle" bgcolor="#FFFFCC">
              <td height="20" background="../images/tema/bg_contenido.png" bgcolor="#FFFFCC" class="titulo_pagina"><div align="center" class="titulo_seccion">
                <div align="left" class="titulo_pagina">REINSCRIPCION DE ALUMNOS </div>
              </div></td>
            </tr>
            <tr>
              <td align="left" valign="top" background="../images/tema/bg_contenido.png" bgcolor="#FFFFCC"><div align="left" class="parrafo">
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td background="../images/tema/bg_frm_campos.png">
                     <form action="<?=$PHP_SELF;?>" method="post" name="form2" id="form2" onsubmit="return validarf2();">
                      <strong class="lbl_campo">Seleccione un alumno</strong>
                      <select name="idp" class="textbox" id="idp" onchange="mostrar_carnet();">
                       <option value="SV" selected>Seleccione uno...</option>
                       <?
                       $qpr=mysql_query("select * from alumnos order by apellido");
                       while($ipr=mysql_fetch_array($qpr)){
                       $sel="";
                       if(dec($idp)==$ipr[carnet]){
                         $sel="selected class='selected_option'";
                       }
                       ?>
                        <option value="<?=$ipr[carnet];?>"<?=$sel;?>><?=$ipr[apellido].", ".$ipr[nombre];?></option>
                       <?}?>
                      </select>

                      <input name="Submit" type="submit" class="boton_guardar" value="Continuar">
                      <br>
                      <strong>o ingrese el n&uacute;mero de carn&eacute;</strong>
                      <input name="txtcarnet" type="text" class="textbox" id="txtcarnet" onKeyUp="seleccionar_alumno();" size="15" maxlength="15">
                      <br>
                        </form></td>
                  </tr>
                </table>
                <br>
                <?if(!$idp){exit();}?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><form action="mnt_alumno_info.php" method="post" name="form1" id="form1" onsubmit="return validar(this.form);">
                      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
                              <tr bgcolor="#6699CC">
                                <td colspan="2" class="titulo_seccion"><table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#CFDFEF">
                                    <tr bgcolor="#6699CC">
                                      <td width="81%" background="../images/tema/bg_titulo_frm.png" bgcolor="#6699CC" class="titulo_formulario"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="8%" background="../images/tema/bg_titulo_frm.png"><img src="../images/tema/ic_formularios.png" width="35" height="32"></td>
                                          <td width="92%" background="../images/tema/bg_titulo_frm.png">Informaci&oacute;n general del alumno
                                            <input name="idp2" type="hidden" id="idp2" value="<?=$idp;?>">
                                            <input name="txtyear_actual" type="hidden" value="<?=$info[year_estudio];?>"></td>
                                        </tr>
                                      </table></td>
                                      <td width="19%" background="../images/tema/bg_titulo_frm.png" bgcolor="#6699CC" class="titulo_formulario">
                                        <div align="right">
                                          <input name="Submit22" type="submit" class="boton_guardar" value="Reinscribir Alumno">
                                        </div></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr bgcolor="#A4DBFF" class="font_red_11">
                                <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" class="lbl_roja">Grado:</td>
                                <td width="85%" background="../images/tema/bg_frm_campos.png" class="lbl_roja">
                                  <select name="txtgrado" class="textbox" id="txtgrado" onchange="llenar_seccion();llenar_planpago();">
                                    <option value="SV">Seleccione uno...</option>
                                    <?/*
                   $where="";
                   if(isset($idp)){
                    $where="where grados.id = {$info[grado_estudio]}";

                    $qgrado=mysql_query("select grados.id as idgrado, grados.grado, niveles.nivel, niveles.id as idnivel
                                         from grados inner join niveles on niveles.id = grados.nivel
                                         $where
                                         order by niveles.id, grados.id");

                    while($igrado=mysql_fetch_array($qgrado)){
                     echo "<option value='$igrado[idgrado]' class='selected_option' selected>{$igrado[grado]} {$igrado[nivel]}</option>";
                    }
                   }

                    $qgrado=mysql_query("select gradoss.id as idgrado, grados.grado, niveles.nivel, niveles.id as idnivel
                                         from grados inner join niveles on niveles.id = grados.nivel
                                         order by niveles.id, grados.id");

                    while($igrado=mysql_fetch_array($qgrado)){
                     echo "<option value='$igrado[idgrado]'>{$igrado[grado]} {$igrado[nivel]}</option>";
                    }                   */
                    ?>
                                </select>                                  <strong>Secci&oacute;n:
                                  <select name="txtseccion" class="textbox" id="txtseccion">
                                  </select>
                                  </strong></td>
                              </tr>
                              <tr bgcolor="#A4DBFF" class="font_red_11">
                                <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" class="font_red_11"><strong class="lbl_roja">A&ntilde;o escolar: </strong></td>
                                <td background="../images/tema/bg_frm_campos.png"><input name="txtyear_estudio" type="text" class="font_red_11" id="txtyear_estudio" value="<?=$igral[ciclo_inscripcion];?>" size="4" maxlength="4" readonly="true"></td>
                              </tr>
                              <tr bgcolor="#A4DBFF" class="font_red_11">
                                <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" class="lbl_roja">Plan de pago: </td>
                                <td background="../images/tema/bg_frm_campos.png" class="lbl_roja"><select name="txtplanpago" class="textbox" id="txtplanpago">
                                    <option value="SV" selected>Seleccione un plan</option>
                                    <option value="PG">Plan General</option>
                                  </select>                                                            </tr>
                              <tr bgcolor="#E8E8E8">
                                <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Carn&eacute;</td>
                                <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="txtcarnet" type="text" class="textbox" id="txtnombre" value="<?=$info[carnet];?>" size="15" maxlength="15" readonly="true"></td>
                              </tr>
                              <tr bgcolor="#E8E8E8">
                                <td width="15%" align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Nombre(s)</td>
                                <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><div align="left">
                                    <input name="txtnombre" type="text" class="textbox" id="txtnombre2" value="<?=$info[nombre];?>" size="60" maxlength="100" readonly="true">
                                </div></td>
                              </tr>
                              <tr bgcolor="#E8E8E8">
                                <td width="15%" align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Apellido(s)</td>
                                <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><div align="left">
                                    <input name="txtapellido" type="text" class="textbox" id="txtapellido2" value="<?=$info[apellido];?>" size="60" maxlength="100" readonly="true">
                                </div></td>
                              </tr>
                              <tr bgcolor="#E8E8E8">
                                <td align="left" valign="middle" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Grado Actual: </td>
                                <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9" class="lbl_formulario"><?=ggrado_completo(enc($info[grado_estudio]),$info[seccion]);?></td>
                              </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="33%" background="../images/tema/bg_frm_campos.png"><div align="center">
                                <input name="Submit2" type="button" class="boton_guardar" value="Reinscribir Alumno" onclick="document.form1.submit();">
                                <span class="font_red_11"><strong><strong><span class="lbl_campo"><strong><strong>
                                <input name="tipo_trn" type="hidden" id="idi6" value="<?=$tipo;?>">
                                <strong><strong>
                                <input name="idi" type="hidden" id="idi" value="<?=$idi;?>">
                                </strong></strong> </strong></strong></span></strong></strong></span></div></td>
                              <td width="33%" background="../images/tema/bg_frm_campos.png"><div align="center">
                                <input name="Submit4" type="reset" class="boton_deshacer" value="Recargar Informaci&oacute;n">
                              </div></td>
                              <td width="33%" background="../images/tema/bg_frm_campos.png"><div align="center"></div></td>
                            </tr>
                          </table></td>
                        </tr>
                      </table>
                    </form></td>
                  </tr>
                </table>
              </div></td>
              </tr>
          </table></td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>
