<?
include("../fnc.php");
enlinea_a();
$qdet=mysql_query("select * from cp_tmp_det_facturas where tipo = $mtipo order by id");
if(mysql_num_rows($qdet)==0){
  alert("Debe tener por lo menos una linea de detalle","frm_cp_det_recibod.php?mtipo=$mtipo");
}

$qdet2=mysql_query("select sum(cantidad*valorunit) as total from cp_tmp_det_facturas where tipo = $mtipo order by id");
$idet2=mysql_fetch_array($qdet2);
?>
<!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(){
  document.form1.txtcarnet.value = document.form1.txtalumno.value;
}

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

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

}


function validar(){
 var objeto;
 var respuesta;

 objeto=document.form1.txtnfc;
 if(objeto.value==""){
   alert("Ingrese el número de factura");
   objeto.focus();
   return (false);
 }

 objeto=document.form1.txtfecha;
 if(objeto.value==""){
   alert("Ingrese la fecha del documento");
   objeto.focus();
   return (false);
 }
<?
if($mtipo==2){
?>
 objeto=document.form1.txtnit;
 if(objeto.value==""){
   alert("Ingrese el nit del cliente");
   objeto.focus();
   return (false);
 }
<?
}
?>

 objeto=document.form1.txtnombre;
 if(objeto.value==""){
   alert("Ingrese el nombre del cliente");
   objeto.focus();
   return (false);
 }

 respuesta=confirm("DESEA OPERAR LA TRANSACCION?")
 if(respuesta){
  return (true);
 }else{
  return (false);
 }

}
</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">INGRESOS VARIOS <img src="../images/flecha_3.jpg" width="9" height="9"> Informaci&oacute;n para <?=get_talonario($mtipo);?>  </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>
            <?
            $qfc=mysql_query("select correlativo + 1 as numero from cp_talonarios where id = '$mtipo'");
            $ifc=mysql_fetch_array($qfc);
            ?>
            <tr>
              <td align="left" valign="top" background="../images/tema/bg_contenido.png" bgcolor="#FFFFCC"><div align="left" class="parrafo">
               <form action="mnt_cp_recibod.php" method="post" name="form1" id="form1" onsubmit="return validar();">
                 <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                   <tr>
                     <td colspan="3" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo"><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" class="titulo_formulario">Ingrese la informaci&oacute;n del documento </td>
                       </tr>
                     </table></td>
                     </tr>
                   <tr>
                     <td width="20%" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">No. de documento:</td>
                     <td width="64%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="txtnfc" type="text" class="textbox" id="txtnfc" size="11" maxlength="11" value="<?=$ifc[numero];?>" readonly="true"></td>
                     <td width="16%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><div align="right" class="lbl_roja">TOTAL <?=moneda($idet2[total],"Q");?></div></td>
                   </tr>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Fecha:</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="txtfecha" type="text" class="textbox" id="txtfecha" size="10" maxlength="10" value="<?=date("d/m/Y");?>" <?=fmascara();?>></td>
                   </tr>
                   <?if($mtipo==2){?>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">NIT:</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="txtnit" type="text" class="textbox" id="txtnit" size="12" maxlength="12"></td>
                   </tr>
                   <?}?>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Nombre:</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><input name="txtnombre" type="text" class="textbox" id="txtnombre" size="60" maxlength="100"></td>
                   </tr>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">Direcci&oacute;n:</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><textarea name="txtdireccion" cols="70" rows="2" class="textbox" id="txtdireccion"></textarea></td>
                   </tr>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">No. Carnet:</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><input name="txtcarnet" type="text" class="textbox" id="txtcarnet" size="15" maxlength="15" onkeyup="seleccionar_alumno();">
                       <select name="txtalumno" class="textbox" id="txtalumno" onchange="mostrar_carnet();">
                        <option value="SV">Seleccione uno...</option>
                       <?
                       $qalmn=mysql_query("select * from alumnos where year_estudio = ".get_ciclo_activo()." or year_estudio=".get_ciclo_inscripcion()." order by apellido");
                       while($ialmn=mysql_fetch_array($qalmn)){
                         echo "<option value='{$ialmn[carnet]}'>{$ialmn[apellido]} {$ialmn[nombre]}</option>";
                       }
                       ?>
                       </select>
                       <br>
                       <span class="font_red_11">Llene &uacute;nicamente si desea que la transacci&oacute;n sea asociada a un alumno.</span></td>
                   </tr>
                   <tr>
                     <td colspan="3" bgcolor="#CFDFEF" class="lbl_campo"><table width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
                       <tr bgcolor="#CFDFEF">
                         <td colspan="4" class="titulo_seccion"><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_pagos.png" width="35" height="32"></td>
                             <td width="94%" background="../images/tema/bg_titulo_frm.png" class="titulo_formulario"><div align="left">Ingrese la forma de pago </div></td>
                           </tr>
                         </table></td>
                       </tr>
                       <tr>
                         <td width="17%" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Efectivo</strong></td>
                         <td colspan="3" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txtvef" type="text" class="textbox" id="txtvef" dir="rtl" value="0" size="11" maxlength="11" ondblclick="this.value='<?=$idet2[total];?>';">
                         </strong></td>
                       </tr>
                       <tr bgcolor="#FFFFFF">
                         <td colspan="4" background="../images/tema/bg_frm_campos.png"><hr size="1"></td>
                       </tr>
                       <tr>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Valor del Cheque</strong></td>
                         <td width="13%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txtvchq" type="text" class="textbox" id="txtvchq" dir="rtl" value="0" size="11" maxlength="11">
                         </strong></td>
                         <td width="19%" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><div align="right"><strong># Cheque </strong></div></td>
                         <td width="51%" background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txtchq" type="text" class="textbox" id="txtchq" size="10" maxlength="10">
                         </strong></td>
                       </tr>
                       <tr bgcolor="#FFFFFF">
                         <td colspan="4" background="../images/tema/bg_frm_campos.png"><hr size="1"></td>
                       </tr>
                       <tr>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Valor dep&oacute;sito </strong></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txtvdep" type="text" class="textbox" id="txtvdep" dir="rtl" value="0" size="11" maxlength="11">
                         </strong></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><div align="right"><strong># Boleta dep&oacute;sito</strong></div></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>
                           <input name="txtdep" type="text" class="textbox" id="txtdep" size="10" maxlength="10">
      Fecha Deposito:
      <input name="txtfechadep" type="text" class="textbox" id="txtfechadep" size="10" maxlength="10" onkeyup="mascara(this,'/',patron,true)">
                         </strong></td>
                       </tr>
                       <tr bgcolor="#FFFFFF">
                         <td colspan="4" background="../images/tema/bg_frm_campos.png"><hr size="1"></td>
                       </tr>
                       <tr>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Valor del Vale </strong></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txtvvale" type="text" class="textbox" id="txtvvale" dir="rtl" onKeyUp="fnc_vale()" value="0" size="11" maxlength="11">
                         </strong></td>
                         <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong># Vale: </strong> <strong>
                           <input name="txtvale" type="text" class="textbox" id="txtvale" size="20" maxlength="15">
                         </strong></td>
                       </tr>
                       <tr>
                         <td colspan="4" background="../images/tema/bg_frm_campos.png"><hr size="1"></td>
                       </tr>
                       <tr>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><strong>Valor <br>
      Tarjeta Cr&eacute;dito</strong></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txtvtc" type="text" class="textbox" id="txtvtc" dir="rtl" value="0" size="11" maxlength="11">
                         </strong></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><div align="right"><strong># Tarjtea de cr&eacute;dito</strong></div></td>
                         <td background="../images/tema/bg_frm_campos.png" bgcolor="#ECF2F9"><strong>
                           <input name="txttc" type="text" class="textbox" id="txttc2" size="16" maxlength="16">
                         </strong>                           <div align="right">                         </div></td>
                         </tr>
                     </table></td>
                     </tr>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF">&nbsp;</td>
                   </tr>
                   <tr>
                     <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF" class="lbl_campo">&nbsp;</td>
                     <td colspan="2" background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><input name="Submit" type="submit" class="boton_guardar" value="Guardar <?=get_talonario($mtipo);?>">
                       <input name="tipo_trn" type="hidden" id="tipo_trn" value="general">
                       <input name="mtipo" value="<?=$mtipo;?>" type="hidden">                       </td>
                   </tr>
                 </table>
               </form>
                <br>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td colspan="4"><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_editar.png" width="35" height="32"></td>
                        <td width="47%" background="../images/tema/bg_titulo_frm.png" class="titulo_formulario">Detalle del documento </td>
                        <td width="47%" background="../images/tema/bg_titulo_frm.png" class="titulo_formulario"><div align="right">
                          <input name="Submit2" type="submit" class="boton_guardar" onClick="self.location='frm_cp_det_recibod.php?mtipo=<?=$mtipo;?>'" value="&laquo; Regresar al detalle">
                        </div></td>
                      </tr>
                    </table></td>
                    </tr>
                  <tr bgcolor="#CFDFEF" class="lbl_formulario">
                    <td background="../images/tema/bg_frm_campos.png"><div align="center">Cantidad</div></td>
                    <td background="../images/tema/bg_frm_campos.png"><div align="center">Descripci&oacute;n</div></td>
                    <td background="../images/tema/bg_frm_campos.png"><div align="center">Valor Unit. </div></td>
                    <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><div align="center">Total</div></td>
                    </tr>
                  <?
                  $i=0;
                  $total=0;
                  while($idet=mysql_fetch_array($qdet)){
                  $i++;
                  $total+=$idet[cantidad]*$idet[valorunit];
                  ?>
                  <tr bgcolor="<?=color_fila($i);?>">
                    <td width="8%"><div align="center">
                        <?=$idet[cantidad];?>
                    </div></td>
                    <td width="51%"><?=$idet[descripcion];?></td>
                    <td width="18%"><div align="right">
                        <?=moneda($idet[valorunit]);?>
                    </div></td>
                    <td bgcolor="<?=color_fila($i);?>"><div align="right">
                        <?=moneda($idet[valorunit]*$idet[cantidad]);?>
                    </div></td>
                    </tr>
                  <?}?>
                  <tr bgcolor="#CFDFEF">
                    <td background="../images/tema/bg_frm_campos.png">&nbsp;</td>
                    <td colspan="2" background="../images/tema/bg_frm_campos.png"><div align="right"><strong>TOTAL:</strong></div></td>
                    <td background="../images/tema/bg_frm_campos.png" bgcolor="#CFDFEF"><div align="right"><strong>
                        <?=moneda($total);?>
                    </strong></div>                      <div align="right"></div></td>
                    </tr>
                </table>
              </div></td>
              </tr>
          </table></td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>
