<?php
		
		include('../conexion.php'); 

 $numfac=$_GET["numfac"];
 $cdgpro=$_GET["cdgpro"];


$consulta = "SELECT * FROM web_2201 WHERE numfac='$numfac' AND cdgpro='$cdgpro'";
$resultado = $mysqli->query($consulta);
$row = $resultado->fetch_array();

$cdgpro   = $row["cdgpro"];
$dscpro   = $row["dscpro"];
$fecfac   = $row["fecfac"];
$fecfac   = implode("-", array_reverse(explode("-", $fecfac))); 
$fecpro   = $row["fecpro"];
$fecpro   = implode("-", array_reverse(explode("-", $fecpro))); 
$numfac   = $row["numfac"];
$fecven   = $row["fecven"];
$pladia   = $row["pladia"];
$subexe   = $row["subexe"];
$subgra   = $row["subgra"];
$desfactot= $row["desfactot"];
$impfac   = $row["impfac"];
$flefac   = $row["flefac"];
$otrfac   = $row["otrfac"];
$totfac   = $row["totfac"];
$cdgtipven= $row["cdgtipven"];
$cdgtipcxp= $row["cdgtipcxp"];
$estado   = $row["estado"];
$marcaborrado = $row["borrado"];
$marcaestado  = $row["estado"];
$obsfac  = $row["obsfac"];


  if ($marcaborrado == 1) { $borrado="Factura Anulada"; } else { $borrado=""; } 
  
    $sel3="SELECT * FROM facturas_compras WHERE  numfac='$numfac' AND cdgpro='$cdgpro'  "; 
		$resultado3 = $mysqli->query($sel3);
		$row3 = $resultado3->fetch_array();
		
    	$codfactura   = $row3["codfactura"];
		
		
  $sel4="SELECT * FROM factulinea_compra WHERE  codfactura = '$codfactura'   "; 
		$resultado4 = $mysqli->query($sel4);
		$row4 = $resultado4->fetch_array();
		
		$cob_iv  = $row4["cdgimp"];	
		$tarifa  = $row4["cdgtar"];	
		$ivporc  = $row4["tarimp"];		

?>


<html>
	<head>
		<title>Principal</title>
		<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
		
		
		<script src="../jquery/jquery-1.3.2.js" type="text/javascript"></script>
		<script src="../jquery/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
		
		<script language="javascript">
	
		var cursor;
		if (document.all) {
		// Está utilizando EXPLORER
		cursor='hand';
		} else {
		// Está utilizando MOZILLA/NETSCAPE
		cursor='pointer';
		}
		

function aceptar() {
			location.href="index.php?cadena_busqueda=<? echo $cadena_busqueda?>";
		}
	

					function nobackbutton(){	
   window.location.hash="no-back-button";	
   window.location.hash="Again-No-back-button" //chrome	
   window.onhashchange=function(){window.location.hash="no-back-button";}	
}
	
		</script>
	</head>
   
			<body onLoad="  nobackbutton(); ">
		<div id="">
			<div id="zonaContenido">
				<div align="center">
				
				<div id="tituloForm" class="header">Ver Cuenta por Pagar</div>
			
				<p>&nbsp;</p>
				<form id="formulario" name="formulario" method="post" action="guardar_cxp.php" >
				<div id="formulario" class="contenidoCliente">
							<table class="fuente8" width="100%" cellspacing=2 cellpadding=0 border=0>
                    <tr>
                      <td width="6%">&nbsp;</td>
                      <td width="15%">&nbsp;</td>
                      <td>&nbsp;</td>
                      <td colspan="5"><div align="right"><span class="Estilo1">MODULO CXP </span></div></td>
                      <td><div align="center"></div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td width="15%"> Factura </td>
                      <td><input NAME="numfac" type="text" class="cajaGrande" id="numfac" style='text-align:center;'  value="<?php echo $numfac?>"  readonly="" ></td>
                      <td>&nbsp;</td>
                      <td><div align="center">Fecha</div></td>
                      <td><input name="fecfac" type="text" class="cajaGrande" id="fecfac"  readonly="" maxlength="10" style='text-align:center;'  value="<?php echo $fecfac?>" onFocus="siguienteCampo ='fecpro', nombreForm ='formulario';" onChange="comprobar_fechas()" ></td>
                      <td><div align="center">Proceso</div></td>
                      <td><input name="fecpro" type="text" class="cajaGrande" id="fecpro" readonly  maxlength="10" style='text-align:center;'  value="<?php echo $fecpro?>" onFocus="siguienteCampo ='subexe', nombreForm ='formulario';" onChange="comprobar_fechas()" ></td>
                      <input NAME="cdgprofac" class="cajaMedia" id="cdgprofac"   type="hidden" >
                      <input NAME="limcre" class="cajaMedia" id="limcre"  type="hidden"    >
                      <input NAME="salact" class="cajaMedia" id="salact"  type="hidden"    >
			
                      <td width="13%">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Proveedor</td>
                      <td><input name="cdgpro" type="text" class="cajaGrande" id="cdgpro"  style='text-align:center;'   value="<?php echo $cdgpro ?>"  readonly=""></td>
                     
                      <td colspan="4"><input name="dscpro" type="text" class="cajaGrande" id="dscpro"  maxlength="45" value="<?php echo $dscpro?>" readonly></td>
                      <td>&nbsp;</td> 
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Sub. Exento </td>
                      <td><input name="subexe" type="text" autocomplete="off"  readonly="" class="cajaGrande" id="subexe" style='text-align:right;'  value="<?php echo $subexe?>"  onkeypress="mascara(this,moneda)"  onChange=" calcular_factura()" onFocus=" calcular_factura(), siguienteCampo ='subgra', nombreForm ='formulario';"></td>
                      <td>&nbsp;</td>
                      <td><div align="left">Credito</div></td>
                        <?php

                        	$query_tipoventa="SELECT * FROM tipoventa ";
                            $result = $mysqli->query($query_tipoventa);
           
					  ?>
					
					  <td ><select id="combotipoventa" name="combotipoventa"  disabled="disabled" class="comboGrande" >
							<?php
								while ($fila = $result->fetch_assoc()) { 
									if ($cdgtipven ==  $fila["cdgtipven"]) { ?>
                            <option value="<?php echo  $fila["cdgtipven"]?>" selected="selected"><?php echo  $fila["dsctipven"]?></option>
                            <?php } else { ?>
                            <option value="<?php echo  $fila["cdgtipven"]?>"><?php echo  $fila["dsctipven"]?></option>
                            <?php } ;
								} ?>
                          </select>						  </td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Sub. Gravado </td>
                      <td><input name="subgra" type="text"autocomplete="off"  readonly=""  class="cajaGrande" id="subgra" style='text-align:right;'  value="<?php echo $subgra?>"   onkeypress="mascara(this,moneda)"   onBlur="calcular_impuesto(); calcular_factura();"  onChange="calcular_impuesto();" onFocus=" calcular_impuesto(); calcular_factura();    siguienteCampo ='desfactot', nombreForm ='formulario';"></td>
                      <td>&nbsp;</td>
                      <td><div align="left">Tipo</div></td>
                     
                        <?php
						
						  	$query_tipocxp="SELECT * FROM tipo_cxp ORDER BY cdgcxp ASC";
                            $result = $mysqli->query($query_tipocxp);
					  ?>
                        <td ><select id="combotipocxp" name="combotipocxp" disabled="disabled" class="comboGrande" >
                              <?php
			
	
								while ($fila = $result->fetch_assoc()) { 
									if ($cdgtipcxp ==  $fila["cdgcxp"]) { ?>
                            <option value="<?php echo  $fila["cdgcxp"]?>" selected="selected"><?php echo  $fila["dsccxp"]?></option>
                            <?php } else { ?>
                            <option value="<?php echo  $fila["cdgcxp"]?>"><?php echo  $fila["dsccxp"]?></option>
                            <?php } ;
								} ?>
       
                          </select> </td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td><div align="left">Descuento </div></td>
                      <td><input name="desfactot" type="text" class="cajaGrande" readonly autocomplete="off"  id="desfactot" value="<?php echo $desfactot?>"  style='text-align:right;' onKeyPress="mascara(this,moneda)"  onChange=" calcular_factura()"   onFocus="calcular_factura(), siguienteCampo ='impfac', nombreForm ='formulario';"></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td><div align="left">Impuesto</div></td>
                      <td><input name="impfac" type="text" class="cajaGrande" readonly  autocomplete="off"  id="impfac"  style='text-align:right;' value="<?php echo $impfac?>"  onkeypress="mascara(this,moneda)"  onChange=" calcular_factura()"  onFocus=" calcular_factura(), siguienteCampo ='flefac', nombreForm ='formulario';"  ></td>
                      <td>&nbsp;</td>
					  
					   <?php
					        $cob_iv  = $row4["cdgimp"];	
                            $query_artexe = "SELECT * FROM tipocliente ORDER BY cdgtipcli ASC";
                            $result = $mysqli->query($query_artexe);
							
							$tarifa=$row4["cdgtar"];
							$query2 = "SELECT * FROM hac_tipo_tarifa where cob_iv = '$cob_iv' and cdgtar =  '$tarifa'   ";
							$resultado2=$mysqli->query($query2);
	
	
						
					  ?>
					  
                      <td>Tipo</td>
                      <td><select id="cob_iv" name="cob_iv" class="comboGrande"   disabled="disabled" onFocus="siguienteCampo ='comboestatus';" onChange="calcular_precio001()"  >
                          <?php
					 while ($fila = $result->fetch_assoc()) { 
					          if ($cob_iv ==  $fila["cdgtipcli"]) { ?>
                          <option value="<?php echo  $fila["cdgtipcli"]?>" selected="selected"><?php echo  $fila["dsctipcli"]?></option>
                          <?php } else { ?>
                          <option value="<?php echo  $fila["cdgtipcli"]?>"><?php echo  $fila["dsctipcli"]?></option>
                          <?php } ;
								} ?>
                      </select></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td><div align="left">Flete</div></td>
                      <td><input name="flefac" type="text" class="cajaGrande"  readonly="" autocomplete="off"  id="flefac"  style='text-align:right;' value="<?php echo $flefac?>" onKeyPress="mascara(this,moneda)"  onChange="  calcular_factura()"   onFocus="calcular_factura(), siguienteCampo ='otrfac', nombreForm ='formulario';"></td>
                      <td>&nbsp;</td>
                      <td>Tarifa</td>
                      <td><select id="tarifa" name="tarifa" class="comboGrande" disabled="disabled"  onFocus="calcular_precio001()"  onChange="actualiza_impuesto() "  >
                          <?php
					 while ($fila = $resultado2->fetch_assoc()) { 
					          if ($tarifa ==  $fila["cdgtar"]) { ?>
                          <option value="<?php echo  $fila["cdgtar"]?>" selected="selected"><?php echo  $fila["dsctar"]?></option>
                          <?php } else { ?>
                          <option value="<?php echo  $fila["cdgtar"]?>"><?php echo  $fila["dsctar"]?></option>
                          <?php } ;
								} ?>
                      </select></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td><div align="left">Otros</div></td>
                      <td><input name="otrfac" type="text" class="cajaGrande" readonly id="otrfac" autocomplete="off"  style='text-align:right;' onKeyPress="mascara(this,moneda)"  value="<?php echo $otrfac?>" onChange=" calcular_factura()"  onFocus=" calcular_factura(), siguienteCampo ='subexe', nombreForm ='formulario';"></td>
                      <td>&nbsp;</td>
                      <td>Monto</td>
                      <td><select id="ivporc" name="ivporc" class="comboGrande"    disabled="disabled" onFocus="calcular_precio001()"  >
                          <option value="<?php echo $row4["tarimp"];?>" selected="selected"><?php echo   $row4["tarimp"];?></option>
                      </select></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td><div align="left">Total</div></td>
                      <td><input name="totfac" type="text" class="cajaGrande" readonly id="totfac"   onChange=" calcular_factura()" value="<?php echo $totfac?>"   style='text-align:right;'onFocus="siguienteCampo ='cdgbar', nombreForm ='formulario';"></td>
                      <td>&nbsp;</td>
                      <td>Observación</td>
                      <td colspan="3" rowspan="2"> <textarea name="obsfac" cols="55" rows="3" class=""  id="obsfac" title="Observacion"    onBlur=""   > <?php echo $obsfac  ?> </textarea>  </td>
                      <td>&nbsp;</td>
                    <tr>
                      <td width="6%" height="22">&nbsp;</td>
                      <td width="15%">&nbsp;</td>
                      <td width	="14%">&nbsp;</td>
                      <td width="5%">&nbsp;</td>
                      <td width="8%">&nbsp;</td>
                      <td width="13%">&nbsp;</td>
                  </table>
				</div>
			      <span class="contenido"><img src="../img/Undo_48x48-32.png" alt="salir" width="48" height="48" border="0" class="aCentro" title="Salir" onClick="aceptar()" onMouseOver="style.cursor=cursor"></span>
				</form>
			  </div>
		  </div>
		</div>
	</body>
</html>
