<?
include("../fnc.php");
enlinea_a();
?>
<!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">
<?=mascara();?>
<script language="javascript">

function mostrar_carnet(){
  if(document.form1.txtalumno.value!="SV"){
     document.form1.txtcarnet.value = document.form1.txtalumno.value;
  }else{
     document.form1.txtcarnet.value = "";
  }
}

function seleccionar_alumno(){
  var combo = document.form1.txtalumno;
  var mcarnet = document.form1.txtcarnet.value;
  var respuesta;

  for(i=0;i<combo.length;i++){
    if(combo.options[i].value==mcarnet){
         combo.selectedIndex = i;
         return (false);
    }
    combo.selectedIndex = 0;
  }

}
function validar(formulario){
 if(document.form2.txtdesccargo.value=="SV"){
   alert("Seleccione un cargo...");
   document.form2.txtdesccargo.focus();
   return (false);
 }

 if(document.form2.txtvcargo.value==""){
   alert("Ingrese el valor del cargo");
   document.form2.txtvcargo.focus();
   return (false);
 }
 if(document.form2.txtdpago.value==""){
   alert("Ingrese la fecha maxima de pago dia/mes/año");
   document.form2.txtdpago.focus();
   return (false);
 }

return (true);
}
</script>
<style type="text/css">
<!--
body {
	background-image: url(../images/tema/bg_pagina.png);
}
-->
</style></head>

<body>
<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%"><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" bgcolor="#FFFFCC" class="titulo_pagina"><div align="center" class="titulo_seccion">
                <div align="left">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td background="../images/tema/bg_contenido.png"><div align="center" class="titulo_pagina">
                        <div align="left" class="parrafo">CONTROL DE PAGOS <img src="../images/flecha_3.jpg" width="9" height="9"> Cargo a alumno en forma individual </div>
                      </div></td>
                      <td width="65" background="../images/tema/bg_contenido.png"><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>
                  </table>
                </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="1">
                  <tr>
                    <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td background="../images/tema/bg_contenido.png"><form name="form1" method="post" action="">
                          <table width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
                            <tr>
                              <td width="27%" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Seleccione un alumno </strong></td>
                              <td width="61%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9">
                               <select name="txtalumno" class="textbox" id="txtalumno" onchange="mostrar_carnet()">
                                <option value="SV" selected>Seleccione uno...</option>
                               <?
                               $where="where year_estudio = ".get_ciclo_activo()." or year_estudio = ".get_ciclo_inscripcion()." ";
                               $sqlal="select carnet, apellido, nombre
                                                   from alumnos
                                                   $where
                                                   order by apellido, nombre";
                               $qalum=mysql_query($sqlal);

                               while($ialum=mysql_fetch_array($qalum)){
                                $sel="";
                                if($txtalumno==$ialum[carnet]){
                                 $sel="selected class='selected_option'";
                                }
                                echo "<option value='{$ialum[carnet]}' $sel>{$ialum[apellido]}, {$ialum[nombre]}</option>";
                               }
                               ?>
                               </select>
                              </td>
                              <td width="12%" rowspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="Submit" type="submit" class="boton_guardar" value="Continuar"></td>
                            </tr>
                            <tr>
                              <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>o ingrese n&uacute;mero de carn&eacute;:</strong></td>
                              <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="txtcarnet" type="text" class="textbox" id="txtcarnet" size="15" maxlength="15" onkeyup="seleccionar_alumno()"></td>
                              </tr>
                          </table>
                          <?
                          if(!$txtalumno and !$txtcarnet){
                           exit();
                          }

                          if($txtalumno<>'SV'){
                           $p_alumno=$txtalumno;
                          }else{
                           $p_alumno=$txtcarnet;
                          }

                          $qalm=mysql_query("select * from alumnos where carnet = '$p_alumno'");
                          if(mysql_num_rows($qalm)==0){
                            alert("El alumno no existe","javascript:history.go(-1)");
                          }
                          $ialm=mysql_fetch_array($qalm);
                          $qvam=mysql_query("select grados.*, jornadas.jornada as njornada, niveles.nivel as nnivel
                                             from grados inner join jornadas ON jornadas.id = grados.jornada
                                             inner join niveles on grados.nivel = niveles.id
                                             where grados.id = {$ialm[grado_estudio]}");
                          if(mysql_num_rows($qvam)==0){
                           alert("ERROR:\\nEl alumno no está inscrito en ningun grado","javascript:history.go(-1)");
                          }
                          $ivam=mysql_fetch_array($qvam);
                          ?>
                          </form>
                          <br>
                          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td><form name="form2" method="post" action="mnt_cargo.php?op=Add&key=<?=enc("ind");?>&cargo=<?=enc("Otros");?>&ida=<?=enc($p_alumno);?>" onsubmit="return validar(this.form2);">
                                <table width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
                                  <tr>
                                    <td width="20%" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong># Carn&eacute;:</strong></td>
                                    <td width="80%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9" class="lbl_formulario"><?=$ialm[carnet];?></td>
                                  </tr>
                                  <tr>
                                    <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Alumno:</strong></td>
                                    <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><span class="lbl_formulario">
                                      <?=$ialm[apellido].", ".$ialm[nombre];?>
                                    </span></td>
                                  </tr>
                                  <tr>
                                    <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Grado:</td>
                                    <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><span class="lbl_formulario">
                                      <?=ggrado(enc($ialm[grado_estudio]))." | ".$ivam[nnivel]." | ".$ivam[njornada];?>
                                    </span></td>
                                  </tr>
                                </table>
                                <br>
                                <table width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#CFDFEF">
                                  <tr bgcolor="#CFDFEF">
                                    <td colspan="4"><div align="center">
                                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="6%" background="../images/tema/bg_titulo_frm.png"><div align="left"><img src="../images/tema/ic_pagos.png" width="35" height="32"></div></td>
                                          <td width="94%" background="../images/tema/bg_titulo_frm.png" class="titulo_formulario"><div align="left">Ingrese la informaci&oacute;n del cargo</div></td>
                                        </tr>
                                      </table>
                                    </div></td>
                                  </tr>
                                  <tr align="center" valign="top" bgcolor="#ECF2F9">
                                    <td width="1%" rowspan="4" background="../images/tema/bg_frm_campos.png">&nbsp;</td>
                                    <td width="68%" background="../images/tema/bg_frm_campos.png" class="lbl_campo">Seleccione un cargo </td>
                                    <td width="6%" background="../images/tema/bg_frm_campos.png" class="lbl_campo">Valor</td>
                                    <td width="25%" background="../images/tema/bg_frm_campos.png" class="lbl_campo">D&iacute;a m&aacute;ximo de pago </td>
                                  </tr>
                                  <tr align="center" valign="top" bgcolor="#ECF2F9">
                                    <td background="../images/tema/bg_frm_campos.png">
                                     <select name="txtdesccargo" class="lbl_formulario" id="txtdesccargo" onchange="document.form2.txtdescadicional.focus();">
                                      <option value="SV">Seleccione un cargo...</option>
                                     <?
                                     $qcr=mysql_query("select * from cp_tipos_cargos order by descripcion");
                                     while($icr=mysql_fetch_array($qcr)){
                                     ?>
                                       <option value="<?=$icr[id];?>"><?=$icr[descripcion];?></option>
                                     <?}?>
                                     </select>
                                     <br>
                                     <span class="lbl_campo">Descripci&oacute;n Adicional</span><br>
                                     <input name="txtdescadicional" type="text" class="textbox" id="txtdescadicional" size="40" maxlength="40">
                                    </td>
                                    <td background="../images/tema/bg_frm_campos.png"><input name="txtvcargo" type="text" class="font_red_11" id="txtvcargo3" size="6" maxlength="10"></td>
                                    <td background="../images/tema/bg_frm_campos.png"><input name="txtdpago" type="text" class="font_red_11" id="txtdpago" value="08" size="2" maxlength="2">
                                      <span class="font_red_11"><br>
                                      </span><span class="lbl_campo">A&ntilde;o <br>
                                      <input name="txtyearcargo" type="text" class="textbox" id="txtyearcargo" value="<?=get_ciclo_activo();?>" size="4" maxlength="4">
                                      </span></td>
                                  </tr>
                                  <tr align="center" valign="top" bgcolor="#ECF2F9">
                                    <td colspan="3" background="../images/tema/bg_frm_campos.png"><span class="lbl_formulario">Seleccione los meses para aplicar el cargo</span><br>                                      
                                      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                      <tr class="parrafo">
                                        <td width="16%"><div align="center"><strong>ENE</strong></div></td>
                                        <td width="16%"><div align="center"><strong>FEB</strong></div></td>
                                        <td width="16%"><div align="center"><strong>MAR</strong></div></td>
                                        <td width="16%"><div align="center"><strong>ABR</strong></div></td>
                                        <td width="16%"><div align="center"><strong>MAY</strong></div></td>
                                        <td width="16%"><div align="center"><strong>JUN</strong></div></td>
                                      </tr>
                                      <?
                                  $chk_m1="";
                                  $chk_m2="";
                                  $chk_m3="";
                                  $chk_m4="";
                                  $chk_m5="";
                                  $chk_m6="";
                                  $chk_m7="";
                                  $chk_m8="";
                                  $chk_m9="";
                                  $chk_m10="";
                                  $chk_m11="";
                                  $chk_m12="";
                                  if($info[m1]=="S"){$chk_m1="checked";}
                                  if($info[m2]=="S"){$chk_m2="checked";}
                                  if($info[m3]=="S"){$chk_m3="checked";}
                                  if($info[m4]=="S"){$chk_m4="checked";}
                                  if($info[m5]=="S"){$chk_m5="checked";}
                                  if($info[m6]=="S"){$chk_m6="checked";}
                                  if($info[m7]=="S"){$chk_m7="checked";}
                                  if($info[m8]=="S"){$chk_m8="checked";}
                                  if($info[m9]=="S"){$chk_m9="checked";}
                                  if($info[m10]=="S"){$chk_m10="checked";}
                                  if($info[m11]=="S"){$chk_m11="checked";}
                                  if($info[m12]=="S"){$chk_m12="checked";}
                                  ?>
                                      <tr bgcolor="#ECF2F9">
                                        <td background="../images/tema/bg_frm_campos.png">
                                          <div align="center">
                                            <input name="m1" type="checkbox" id="m1" value="S" <?=$chk_m1;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m2" type="checkbox" id="m2" value="S"  <?=$chk_m2;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m3" type="checkbox" id="m3" value="S"  <?=$chk_m3;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m4" type="checkbox" id="m4" value="S"  <?=$chk_m4;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m5" type="checkbox" id="m5" value="S"  <?=$chk_m5;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m6" type="checkbox" id="m6" value="S"  <?=$chk_m6;?>>
                                        </div></td>
                                      </tr>
                                      <tr bgcolor="#ECF2F9" class="parrafo">
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center"><strong>JUL</strong></div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center"><strong>AGO</strong></div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center"><strong>SEP</strong></div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center"><strong>OCT</strong></div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center"><strong>NOV</strong></div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center"><strong>DIC</strong></div></td>
                                      </tr>
                                      <tr bgcolor="#ECF2F9">
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m7" type="checkbox" id="m7" value="S"  <?=$chk_m7;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m8" type="checkbox" id="m8" value="S"  <?=$chk_m8;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m9" type="checkbox" id="m9" value="S"  <?=$chk_m9;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m10" type="checkbox" id="m10" value="S"  <?=$chk_m10;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m11" type="checkbox" id="m11" value="S" <?=$chk_m11;?>>
                                        </div></td>
                                        <td background="../images/tema/bg_frm_campos.png"><div align="center">
                                            <input name="m12" type="checkbox" id="m12" value="S" <?=$chk_m12;?>>
                                        </div></td>
                                      </tr>
                                    </table></td>
                                  </tr>
                                  <tr align="center" valign="top" bgcolor="#ECF2F9">
                                    <td colspan="3" background="../images/tema/bg_frm_campos.png">        <div align="center">
                                      <input name="Submit2" type="submit" class="boton_guardar" value="Operar cargo">
                                    </div></td>
                                    </tr>
                                </table>
                              </form>
                                <hr size="1">
                                <table width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
                                  <tr bgcolor="#CFDFEF">
                                    <td colspan="8"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="6%" background="../images/tema/bg_titulo_frm.png"><div align="left"><img src="../images/tema/ic_editar.png" width="35" height="32"></div></td>
                                        <td width="94%" background="../images/tema/bg_titulo_frm.png" class="titulo_formulario"><div align="left">Detalle de cargos del alumno(a)</div></td>
                                      </tr>
                                    </table></td>
                                    </tr>
                                  <tr bgcolor="#CFDFEF">
                                    <td width="5%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>TIPO</strong></div></td>
                                    <td width="11%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>FECHA</strong></div></td>
                                    <td width="31%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>DESCRIPCION DEL CARGO</strong></div></td>
                                    <td width="10%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>VALOR</strong></div></td>
                                    <td width="10%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>SALDO</strong></div></td>
                                    <td width="11%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>DOC PAGO </strong></div></td>
                                    <td width="12%" background="../images/tema/bg_frm_campos.png"><div align="center"><strong>FECHA PAGO </strong></div></td>
                                    <td width="10%" background="../images/tema/bg_frm_campos.png"><strong>OPCIONES</strong></td>
                                  </tr>
                                  <?
                                  $qcargo=mysql_query("select * from cp_cargos where carnet='$p_alumno' and saldo > 0 order by fecha_cargo");
                                  $i=0;
                                  $suma_cargo=0;
                                  $suma_saldo=0;
                                  while($icargo=mysql_fetch_array($qcargo)){
                                  $i++;
                                  $suma_cargo+=$icargo[valor];
                                  $suma_saldo+=$icargo[saldo];
                                  ?>
                                  <tr bgcolor="<?=color_fila($i);?>">
                                    <td><div align="center"><?=$icargo[tipo];?></div></td>
                                    <td><div align="center"><?=fecha($icargo[fecha_cargo]);?></div></td>
                                    <td><div align="left"><?=($icargo[descripcion]);?></div></td>
                                    <td><div align="right"><?=moneda($icargo[valor],"Q");?></div></td>
                                    <td><div align="right"><?=moneda($icargo[saldo],"Q");?></div></td>
                                    <td><div align="center">
                                      <?=$icargo[tipo_doc]."-".$icargo[documento];?>
                                    </div></td>
                                    <td align="center"><?=fecha($icargo[fecha_pago]);?></td>
                                    <td><div align="center">
									<?
									/*
									<a href="frm_cp_updcargo.php?idc=<?=enc($icargo[id])."&ida=".enc($p_alumno);?>" class="link_parrafo">Modificar</a>
									*/
									?>
									</div></td>
                                  </tr>
                                  <?
                                  }
                                  $qcargo=mysql_query("select * from cp_cargos where carnet='$p_alumno'  and saldo <= 0 order by fecha_cargo");
                                  while($icargo=mysql_fetch_array($qcargo)){
                                  $i++;
                                  $suma_cargo+=$icargo[valor];
                                  $suma_saldo+=$icargo[saldo];
                                  ?>
                                  <tr bgcolor="<?=color_fila($i);?>">
                                    <td><div align="center"><?=$icargo[tipo];?></div></td>
                                    <td><div align="center"><?=fecha($icargo[fecha_cargo]);?></div></td>
                                    <td><div align="left"><?=($icargo[descripcion]);?></div></td>
                                    <td><div align="right"><?=moneda($icargo[valor],"Q");?></div></td>
                                    <td><div align="right"><?=moneda($icargo[saldo],"Q");?></div></td>
                                    <td><div align="center">
                                      <?=$icargo[tipo_doc]."-".$icargo[documento];?>
                                    </div></td>
                                    <td align="center"><?=fecha($icargo[fecha_pago]);?></td>
                                    <td><div align="center">
									<?
									/*
									<a href="frm_cp_updcargo.php?idc=<?=enc($icargo[id])."&ida=".enc($p_alumno);?>" class="link_parrafo">Modificar</a>
									*/
									?>
									</div></td>
                                  </tr>
                                  <?
                                  }
                                  ?>
                                  <tr bgcolor="#CFDFEF">
                                    <td background="../images/tema/bg_frm_campos.png"><div align="center">&nbsp;</div></td>
                                    <td background="../images/tema/bg_frm_campos.png"><div align="left"><strong>TOTALES</strong></div></td>
                                    <td background="../images/tema/bg_frm_campos.png"><div align="left"><?=($icargo[descripcion]);?></div></td>
                                    <td background="../images/tema/bg_frm_campos.png"><div align="right"><strong>
                                      <?=moneda($suma_cargo,"Q");?>
                                    </strong></div></td>
                                    <td background="../images/tema/bg_frm_campos.png"><div align="right"><strong>
                                      <?=moneda($suma_saldo,"Q");?>
                                    </strong></div></td>
                                    <td background="../images/tema/bg_frm_campos.png"><div align="center">&nbsp;</div></td>
                                    <td align="center" background="../images/tema/bg_frm_campos.png">&nbsp;</td>
                                    <td background="../images/tema/bg_frm_campos.png"><div align="center"></div></td>
                                  </tr>
                                </table></td>
                            </tr>
                          </table></td>
                      </tr>
                    </table></td>
                    </tr>
                </table>
                </div></td>
              </tr>
          </table></td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>
