<? 
require_once('../../../../conf/connection.php');
$numero =$_GET["numero"];
$nombreuser =$_GET["nombreuser"];

//$sucu =$_GET["sucu"];
//$query_sucu="SELECT * FROM sucu WHERE codsucu='$sucu' ";
	//   $res_sucu=mysql_query($query_sucu);
	  // $nom_sucu=mysql_result($res_sucu,0,"nombre");

$ano=date("Y");
$hoy=date("d-m-Y");

$query_num="SELECT sum(valor_total) AS total_pedido FROM detalles_pedido_bd WHERE numero='$numero'";
$res_num=mysql_query($query_num);
$total=mysql_result($res_num,0,"total_pedido");

//$query_sql="SELECT * FROM tp_doc  WHERE pedido='$numero'";
//$res_sql=mysql_query($query_sql); 
//$nr_ide=mysql_num_rows($res_sql);
//consulta si el numero del pedido esta disponible 
  //if($nr_ide<>1){

?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.1.0.59861 -->
    <meta charset="utf-8">
    <title>mod_venta</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>
function cantidad(){
	
			miPopup = window.open("cantidad.php?cod="+document.getElementById('codigo').value+"&num=<? echo $numero ?>","cant_","width=300,height=130,top=200,left=300,status=no, scrollbars=no, toolbars=no, menubar=no,resizable=yes,directories=no");
			miPopup.focus();
		}

function busqueda(){
	
			miPopup = window.open("ver_articulos.php?cod="+document.getElementById('codigo').value+"&num=<? echo $numero ?>&sucu=<? echo $sucu ?>","cant_","width=900,height=500,top=80,left=200,status=no, scrollbars=no, toolbars=no, menubar=no,resizable=yes,directories=no");
			miPopup.focus();
		}
function borrar(codarticulo){
		
 window.location.href = "borrar_pro.php?codigo=" + codarticulo + "&numero=<? echo $numero ?>&sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>";
		}

function finalizar(){
	
			window.location.href="final.php?num=<? echo $numero ?>&sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>";
			
		}

function cotiza(){
	
			window.location.href="cotiza.php?num=<? echo $numero ?>&sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>";
			
		}

function cierre(){
	
	miPopup = window.open("cierre/index.php?sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>","cant_","width=500,height=500,top=10,left=300,status=no, scrollbars=no, toolbars=no, menubar=no,resizable=yes,directories=no");
			miPopup.focus();
	
	}
function anular(){
	
	miPopup = window.open("anular/index.php?nombreuser=<? echo $nombreuser ?>","cant_","width=500,height=500,top=10,left=300,status=no, scrollbars=no, toolbars=no, menubar=no,resizable=yes,directories=no");
			miPopup.focus();
	
	}

function post(){
	

			 window.location.href="../admin/post_venta/add.php?sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>";
	
	}
		
		function salir(){
	
			window.close();
			
		}
</script>
<script type="text/javascript">

function num(e) {
  evt = e ? e : event;
  tcl = (window.Event) ? evt.which : evt.keyCode;
  if (tcl == 13 )
  {
	  var codigo=document.getElementById("codigo").value;
	  window.location.assign("verificar1.php?numero=<? echo $numero?>&sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>");
	  window.location.href="add_pro.php?cod="+document.getElementById('codigo').value+"&num=<? echo $numero ?>&sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>";
  }
}
function info (elEvento) { 
         evento = elEvento || window.event;
         k=evento.keyCode; //número de código de la tecla.
        
		       //busqueda avanzda f4 
          if (k==115){
			   
			    miPopup = window.open("ver_articulos.php?cod="+document.getElementById('codigo').value+"&num=<? echo $numero ?>&sucu=<? echo $sucu ?>","cant_","width=900,height=500,top=80,left=200,status=no, scrollbars=no, toolbars=no, menubar=no,resizable=yes,directories=no");
			miPopup.focus();
			  
			  }
		  //finalizar pedido f2
		  if (k==113){
			   
			   window.location.href="final.php?num=<? echo $numero ?>&sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>";
			
			  
			  }
		  
		   //cierre de caja f6
		  if (k==117){
			   
			   miPopup = window.open("cierre/index.php?sucu=<? echo $sucu ?>&nombreuser=<? echo $nombreuser ?>","cant_","width=500,height=500,top=10,left=300,status=no, scrollbars=no, toolbars=no, menubar=no,resizable=yes,directories=no");
			miPopup.focus();
			  
			  }
		 		 
		 }
window.onload = function() {
document.onkeydown = info;
}
</script>
<style>
.marca-de-agua {
    background: url(../images/logoadmin-post.png);
    width: 1400px;
    height: 540px;
	alignment-adjust:central
    position: relative;
}

</style>
</head>
<body>
<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, marca-de-agua"><div class="art-content-layout">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-1" style="width: 100%" >
        <h3>Solicitud de Productos (Bodega) | Fecha: <? echo $hoy ?></h3>
        <p style="width:100%;" >
       
        <table width="1100" border="0">
  <tr>
    <td width="213" height="36" valign="top">
      <input name="codigo" type="text" autofocus id="codigo"  placeholder="Ingrese codigo"
      style="height:20px; background-color:#CCC;"
      onKeyPress="return num(event)" size="50">
    </td>
    
    <td width="605" valign="top"><a href="#" onClick="busqueda()">
    <img src="../../../images/searchicon.png" width="16" height="16"
    title="Busqueda avanzada"></a></td>
    <td >
       <input type="button" class="art-button" id="final2" name="final2" value=" 
       <? echo $numero ?>"
      style="height:50px; width:120px; font-size:36px; text-align:right;">
    
    
    </td>
    
    </tr>
  <tr>
    <td colspan="2" valign="top">
    <div style="height:300px; width:100%;  overflow: auto;">
    
      <?  
          $buscar='select *, SUM(cantidad) as cant, SUM(valor_total) as valor from detalles_pedido_bd inner join articulos ON 
          articulos.referencia=detalles_pedido_bd.codarticulo where  numero like \'%'.$numero.'%\' group by detalles_pedido_bd.codarticulo';
		   $r=mysql_query($buscar,$conn) or die("Error en el query: ".mysql_error());
		   $n=mysql_num_rows($r);
		  
		    //si hay registros los procesamos
			if($n>0)
			{
			?>
				<table  width="100%" border="0">
				<tr >
				<td width="53" bgcolor="#46BBD2">CODIGO</td>
				<td bgcolor="#46BBD2">&nbsp;</td>
				<td bgcolor="#46BBD2">PRODUCTO</td>
				<td width="78" bgcolor="#46BBD2">CANTIDAD</td>
				<td width="51" bgcolor="#46BBD2">STOCK ACTUAL</td>
				<td width="52" bgcolor="#46BBD2">PRECIO UNITARIO</td>
				<td width="60" bgcolor="#46BBD2">TOTAL</td>
              <td width="38" bgcolor="#46BBD2"></td>
				</tr><?
				while($row=mysql_fetch_assoc($r))
				{ //Procesamos cada registro como una fila de tabla
					?>
					<tr><?
					//$row["nomCampo"] estos nomCampo son los campos devueltos por el
					//query en la variable $r que procesa mysql_fetch_assoc
					?>
					 <td height="22" bgcolor="#FFFFFF"><? echo  $row["referencia"] ?></td>
					 <td width="77" bgcolor="#FFFFFF">
                      <?
                                
                             $foto=$row["foto1"];
							 if($foto=="img/"){}else{
           
            echo '<img src="../admin/inventario/'.$row["foto1"].'" width="100" heigth="100">';
							 }
		?></td>
					 <td width="276" bgcolor="#FFFFFF"><? $codarticulo=$row["referencia"]; echo  $row["descripcion"] ?></td>
					 <td align="right" bgcolor="#FFFFFF">
					 
                     <form action="agregar.php" name="agregar_s" id="agregar_s" method="post">
                     <input name="codarticulo" type="hidden" id="codarticulo" value="<? echo $row["referencia"] ?>" size="3"/>
                     <input name="numero" type="hidden" id="numero" value="<? echo $numero ?>" size="3"/>
                     <input name="sucu" type="hidden" id="sucu" value="<? echo $sucu ?>" size="3"/>
                     <input name="nombreuser" type="hidden" id="nombreuser" value="<? echo $nombreuser ?>"  size="3"/>
                     
                     <input name="stock" type="text" id="stock" value="<? echo $row["cant"] ?>" size="3"/>
                     <input type="submit"  id="enviar" name="enviar" value="  " 
                     style="background-image:url(../../../../images/add.png)" /> 
                     </form>
                     
                     </td>
					 <td align="right" bgcolor="#FFFFFF"><? echo 
					 $row["stock"]; ?></td>
					 <td align="right" bgcolor="#FFFFFF"><? echo 
					 $format_number = number_format($row["valor_unitario"], 0, ',', '.'); ?></td>
					 <td align="right" bgcolor="#FFFFFF"><? echo 
					 $format_number = number_format($row["valor"], 0, ',', '.');
					 
					 $idplatos=$row["idplatos"];  ?></td>
					 <td align="right" bgcolor="#FFFFFF" >
                     <a href="#"><img src="../../../images/delete.png" width="16" height="16" 
                     onClick="borrar('<? echo  $codarticulo; ?>')" title="Eliminar articulo"></a></td>
					
				    </tr>
				<? }
				
				?>
				</table>
			<? } ?>
    
          </div>
    </td>
    <td width="268" >
      
        
     
        <input type="buscar" class="art-button" id="buscar" name="bucar" value="Busqueda ART (f4)"
      style="height:50px; width:120px;" onClick="busqueda()" title="Busqueda avanzada">
      <br><br><br><br><br><br><br><br><br><br><br><br><br>
      
         

   
      
      
	  <input type="button" class="art-button" id="salir" name="salir" value="Salir"
      style="height:50px; width:120px;" onClick="salir()" title="Salir del sistema">
      
     
      </td>
        </tr>
  <tr>
    <td colspan="2" align="right" bgcolor="#46BBD2"> <font color="#FFFFFF" size="+4">TOTAL $<? echo 
	$format_number = number_format($total, 0, ',', '.'); ?></font></td>
    <td>
      <input type="button" class="art-button" id="final" name="final" value="Finalizar pedido (f2)"
      style="height:50px; width:120px;" onClick="finalizar()" title="Finalizar pedido">
    </td>
    </tr>
</table>

        </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 © <? echo $ano ?>. 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>

