<? 
$nivel = $_GET["nivel"];
$nombrevar =$_GET["nombreuser"];
$hoy=date("d-m-Y");
require_once('../../../conf/connection.php');


?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
  

    <meta charset="utf-8">
    <title>INVENTARIO</title>
    <meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">

    <!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <link rel="stylesheet" href="../../../style.css" media="screen">
    <!--[if lte IE 7]><link rel="stylesheet" href="../style.ie7.css" media="screen" /><![endif]-->
    <link rel="stylesheet" href="../../../style.responsive.css" media="all">

    <script src="../../../jquery.js"></script>
    <script src="../../../script.js"></script>
    <script src="../../../script.responsive.js"></script>



<style>.art-content .art-postcontent-0 .layout-item-0 { border-top-width:1px;border-top-style:solid;border-top-color:#B1C9C7;margin-top: 10px;margin-bottom: 10px;  }
.art-content .art-postcontent-0 .layout-item-1 { border-right-style:solid;border-right-width:1px;border-right-color:#B1C9C7; padding-right: 10px;padding-left: 10px;  }
.ie7 .art-post .art-layout-cell {border:none !important; padding:0 !important; }
.ie6 .art-post .art-layout-cell {border:none !important; padding:0 !important; }

</style>
<script>
var cursor;
		if (document.all) {
		// Está utilizando EXPLORER
		cursor='hand';
		} else {
		// Está utilizando MOZILLA/NETSCAPE
		cursor='pointer';
		}
</script>
<script type="text/javascript">
function cancelar () {  
          opener.document.getElementById("codcliente").focus();
          window.close() }
function info (elEvento) { 
         evento = elEvento || window.event;
         k=evento.keyCode; //número de código de la tecla.
        
          if (k==27){ 
		         document.getElementById("tipo").focus();
		
         }
		 		
		 if (k==39){ 
		         document.getElementById("volver").focus();
		
         }
		 if (k==37){ 
		         document.getElementById("agregar").focus();
		
         }}
window.onload = function() {
document.onkeydown = info;
}
</script> 

<script>

function inicio() {
	
			document.getElementById("tipo").focus();
		}
		

		
function validar()
			{
				var mensaje="";
				if (document.getElementById("tipo").value=="") mensaje+="  - Tipo de documento\n";
				if (document.getElementById("neto").value=="") mensaje+="  - Neto\n";
				if (document.getElementById("iva").value=="") mensaje+="  - IVA\n";
				if (document.getElementById("total").value=="") mensaje+="  - total\n";
				if (document.getElementById("vendedor").value=="") mensaje+="  - Codigo de administrador\n";
				if (mensaje!="") {
					alert("Atencion, se han detectado los siguientes campos vacios:\n\n"+mensaje);
					document.getElementById("tipo").focus();
				} else {
					
					
					 document.getElementById("form1").submit(); window.opener.location.reload();  
					
				}
			}	
</script>

<script>
// recorrercampo cliente 
function rut_teclado (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
				
				//acciones 
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
} 
</script>
</head>
<body  onLoad="buscar()">
<div id="art-main">

<div class="art-sheet clearfix">
            <div class="art-layout-wrapper">
                <div class="art-content-layout">
                  <div class="art-content-layout-row">
                    <div class="art-layout-cell art-content"><article class="art-post art-article">
                                
                                                
                                <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-1" style="width: 100%" >
        <h3>Facturas de compras </h3>
     <p >
<? require_once('../../../conf/connection.php');
$codcliente=$_GET["codcliente"];
$sel_tipo="SELECT * FROM preveedores WHERE nif='$codcliente'";
$rs_tipo=mysql_query($sel_tipo);


$codfactura=$_GET["codfacturatmp"];
$sel_lineas="SELECT * FROM factulineatmp_proveedor WHERE codfactura='$codfactura'";
$rs_lineas=mysql_query($sel_lineas);

$sel_sum="SELECT SUM(importe) AS suma FROM factulineatmp_proveedor WHERE codfactura='$codfactura'";
$rs_sum=mysql_query($sel_sum);
$neto=mysql_result($rs_sum,0,"suma");

	$iva=$neto*(19/100);
	$total=$neto+$iva;

$num=mysql_num_rows($rs_lineas); 
?> 
<form name="form1" id="form1" method="post" action="guardar_factura_teclado.php" >
  <input id="accion" name="accion" value="alta" type="hidden">
  <input name="ivas" type="hidden" class="cajaMinima" id="ivas" value="19">
  <table width="95%"  align="center">
	<tr>
  		<td>
	

      <table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0>
        <tr>
          <td width="21%">documento de compra</td>
          <td>Proveedor</td>
          <td width="50%">fecha          </td>
        </tr>
        <tr>
          <td><input name="codfacturatmp" type="text" class="itemParTabla" id="codfacturatmp" value="<? echo $codfactura ?>" readonly> <input name="num" type="hidden" id="num" value="<? echo $num ?>" readonly><input type="hidden" value="2" name="pagos" class="comboMedio" id="pagos" ></td>
          <td><input name="codcliente" type="text" class="itemParTabla" id="codcliente" value="<? echo $codcliente; ?>" readonly></td>
          <td width="50%"><? $hoy=date("d/m/Y"); ?><input NAME="fecha" type="text" class="itemParTabla" id="fecha" value="<? echo $hoy?>" readonly></td>
        </tr>
        <tr>
          <td>Tipo de documento</td>
          <td>
          
          <select name="tipo" class="comboMedio" id="tipo" onkeypress="return rut_teclado(this, event)" >
          
           <option value=""></option>
						      <option value="1">Factura electronica</option>
						      <option value="2">Factura manual </option>						  
						      <option value="3">Guia de despacho electronica</option>
						      <option value="4">Guia de despacho manual </option>
						      <option value="5">Boleta electronica</option>
						      <option value="6">Boleta manual </option>
           
     
          </select></td>
          <td width="50%">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3">           </td>
          </tr>
        <tr>
          <td width="21%" align="right">NETO</td>
          <td><input NAME="neto" type="text" class="cajaTotales" id="neto" onKeyPress="return rut_teclado(this, event)"  value="<? echo  number_format($neto, 0, '', '');  ?>"></td>
          <td width="50%" rowspan="3">&nbsp;</td>
        </tr>
        <tr>
          <td align="right">IVA</td>
          <td><input NAME="iva" type="text" class="cajaTotales" id="iva" value="<? echo number_format($iva, 0, '', '');  ?>"  onKeyPress="return rut_teclado(this, event)"></td>
        </tr>
        <tr>
          <td align="right">TOTAL</td>
          <td><input NAME="total" type="text" class="cajaTotales" id="total" value="<? echo number_format($total, 0, '', '');
		  ?>"  onKeyPress="return rut_teclado(this, event)"></td>
        </tr>
        <tr>
          <td width="21%">CODIGO ADMINISTRADOR</td>
          <td><input NAME="vendedor" type="password" class="cajaGrande" id="vendedor" onKeyPress="return rut_teclado(this, event)"></td>
          <td width="50%">&nbsp;</td>
        </tr>
        <tr>
          <td width="21%">&nbsp;</td>
          <td width="29%" align="right"><input type="button" name="agregar" id="agregar" class="boton" value="Enviar" 
           onClick="validar()">
           <input type="button" name="volver" id="volver" class="boton" value="Volver" onClick="cancelar()">
           </td>
          <td width="50%">&nbsp;</td>
        </tr>
        <tr><? $mensaje= "VERIFIQUE LOS VALORES DE IVA Y TOTAL"; ?> 
          <td colspan="3" class="mensajeminimo"><? echo  $mensaje ?></td>
          </tr>
       
      </table>
   

		</td>
	</tr>
</table>
<input type="hidden" id="iniciopagina" name="iniciopagina">
</form>
     
      </p>
   
     <p align="left">  
     <div id="resultado">
     </div></p>
    
    </div>
    </div>
</div>
<div class="art-content-layout-br layout-item-0">
</div></div>


</article></div>
                    </div>
                </div>
            </div><footer class="art-footer">

<p>Copyright © 2015. All Rights Reserved.</p>
</footer>

    </div>
    <p class="art-page-footer">
        <span id="art-footnote-links">Informatica Francisco Arias E.I.R.L.</span>
    </p>
</div>


</body></html>