<?php
header('Cache-Control: no-cache');
header('Pragma: no-cache'); 
?>
<html>
<head>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
</head>
<script language="javascript">

function pon_prefijo(cdgbar,dscart,pre001,cantidad,cob_iv,dsccli,tipart,existencia, pasillo, estante, desmin, desmax, descli) {
	parent.document.formulario_lineas.dsccli2.value=dsccli;
	parent.document.formulario_lineas.tipart.value=tipart;
	parent.document.formulario_lineas.cdgbar.value=cdgbar;
	parent.document.formulario_lineas.dscart.value=dscart;
	parent.document.formulario_lineas.preivi.value=pre001;
	parent.document.formulario_lineas.cantidad.value=1.00;
	parent.document.formulario_lineas.desmin.value=desmin;
	parent.document.formulario_lineas.desmax.value=desmax;
	parent.document.formulario_lineas.descuento.value=descli;
	parent.document.formulario.cob_iv.value=cob_iv;	
	parent.validar();

}



</script>
 <?php include ("../conexion.php"); 


//$cdgbar=$_POST["cdgbar"];
//$dscart=strtoupper($_POST["dscart"]);
if (!isset($_POST["dsccli"])) { $dscart=""; } else  { $dscart=strtoupper($_POST["dscart"]); }
$cdgcli=$_POST["cdgcli2"];
//$dsccli=$_POST["dsccli"];  //
//$cliexento=$_POST["cliexento"];  //
if (!isset($_POST["dsccli"])) { $dsccli=""; } else  { $dsccli=$_POST["dsccli"]; }
if (!isset($_POST["cliexento"])) { $cliexento=""; } else  { $cliexento=$_POST["cliexento"]; }
$cdgfam=$_POST["cdgfam"];
$cdglin=$_POST["cdglin"];


		
				$consulta = "SELECT * FROM web_0301 WHERE cdgcli='$cdgcli'";
				$resultado = $mysqli->query($consulta);
				$fila = $resultado->fetch_array();
				$tippre= $fila["TIPPRE"];
				$descli= $fila["descli"];		

	
		if ($result = $mysqli->query("SELECT * FROM web_1001  WHERE cdgfam = '$cdgfam'  and tipart != 2 and cdglin = '$cdglin' and estart = 1 ORDER BY dscart ASC  LIMIT 30" )) {
   $nrs = $result->num_rows;
   $result->close();
}

	

	
	

?>
<div id=""  >
<form id="form1" name="form1">


<?php

if ($tippre ==1) {

 if ($nrs>0) { ?>
<div  class="totalResultado"> 
	<table class="fuente8" width="98%" cellspacing=0 cellpadding=0 border=0>
		 <tr class="cabeceraTabla" >
			<td width="80%">SELECCIONE UN PRODUCTO </td>
		    <div align="center"></td>
	  </tr>
       
		<?php
		
	$consulta = "SELECT * FROM web_1001  WHERE cdgfam = '$cdgfam'  and tipart != 2 and cdglin = '$cdglin' and estart = 1 ORDER BY dscart ASC   ";
if ($resultado = $mysqli->query($consulta)) 
$contador=0;
			 while ($fila = $resultado->fetch_assoc()) {

				$cdgbar = $fila["CDGBAR"];
				$dscart = $fila["DSCART"];
				$precio = $fila["PRE001"];
				$exiact = $fila["EXIACT"];
				$existencia = $fila["EXIACT"];
				$pasillo = $fila["pasillo"];
				$estante = $fila["estante"];
				$cob_iv = $fila["COB_IV"];
				$tipart = $fila["tipart"];
				$desmin = $fila["desmin"];
				$desmax = $fila["desmax"];
     	
						 if ($cob_iv==1) { $pre001=$precio/1.13; } else {  $pre001=$precio; }
				 if ($contador % 2) { $fondolinea="itemParTabla"; } else { $fondolinea="itemImparTabla"; }?>
						<tr class="<?php echo $fondolinea?>">
					<td>
        <div align="left"><?php echo $dscart;?></div></td>
		<?php  $cantidad="";?>
                    
<td align="center"><div align="center"><a href="javascript:pon_prefijo('<?php echo $cdgbar ?>','<?php echo htmlspecialchars( $dscart ) ?>','<?php echo $pre001 ?>','<?php echo $cantidad ?>','<?php echo $cob_iv ?>','<?php echo $dsccli ?>','<?php echo $tipart ?>','<?php echo $existencia ?>','<?php echo $pasillo ?>','<?php echo $estante ?>' , '<?php echo $desmin ?>', '<?php echo $desmax ?>' , '<?php echo $descli ?>' )"><img src="../img/Arrow-Left_48x48-32.png" width="48" height="48" border="0" title="Seleccionar"></a></div></td>	
                    
                                   
                    				
				</tr>
			<?php }
		?>
  </table>
		<?php } else { ?>
					<table class="fuente8" width="87%" cellspacing=0 cellpadding=3 border=0>
						<tr>
							<td width="100%" class="mensaje"><?php echo "No existe articulo que cumpla con los criterios de b&uacute;squeda";?></td>
					    </tr>
					</table>					
					<?php }  
					
					
					} else { 
					
					 if ($nrs>0) { ?>
<div  class="totalResultado"> 
		<table class="fuente8" width="98%" cellspacing=0 cellpadding=0 border=0>
		 <tr class="cabeceraTabla" >
			<td width="80%"><div align="center" class="cabeceraTabla">
			  <p>SELECCIONE UN PRODUCTO </p>
		   </div></td>
		   <td width="20%"><span class="totalResultado"><span class="totalResultado"></td>
		  </tr>
       
		<?php
		$consulta = "SELECT * FROM web_1001  WHERE cdgfam = '$cdgfam'  and tipart != 2 and cdglin = '$cdglin' and estart = 1 ORDER BY dscart ASC    ";
if ($resultado = $mysqli->query($consulta)) 
$i=0;
			 while ($fila = $resultado->fetch_assoc()) {
		
		
				$cdgbar = $fila["CDGBAR"];
				$dscart = $fila["DSCART"];
				$precio = $fila["PRE002"];
				$exiact = $fila["EXIACT"];
				$existencia = $fila["EXIACT"];
				$pasillo = $fila["pasillo"];
				$estante = $fila["estante"];
				$cob_iv = $fila["COB_IV"];
				$tipart = $fila["tipart"];
				$desmin = $fila["desmin"];
				$desmax = $fila["desmax"];
		
							 if ($cob_iv==1) { $pre001=$precio/1.13; } else {  $pre001=$precio; }
				 if ($i % 2) { $fondolinea="itemParTabla"; } else { $fondolinea="itemImparTabla"; }?>
						<tr class="<?php echo $fondolinea?>">
					<td>
        <div align="left"><?php echo substr($dscart,0,30);?></div></td>
					<?php  $cantidad="";?>
                    
					<td align="center"><div align="center"><a href="javascript:pon_prefijo('<?php echo $cdgbar?>','<?php echo htmlspecialchars( $dscart ) ?>','<?php echo $pre001 ?>','<?php echo $cantidad ?>','<?php echo $cob_iv ?>','<?php echo $dsccli ?>','<?php echo $tipart ?>','<?php echo $existencia ?>','<?php echo $pasillo ?>','<?php echo $estante ?>' , '<?php echo $desmin ?>', '<?php echo $desmax ?>', '<?php echo $descli ?>' )"><img src="../img/Arrow-Left_48x48-32.png" width="48" height="48" border="0" title="Seleccionar"></a></div></td>					
				</tr>
			<?php }
		?>
  </table>
		<?php } else { ?>
					<table class="fuente8" width="87%" cellspacing=0 cellpadding=3 border=0>
						<tr>
							<td width="100%" class="mensaje"><?php echo "No existe articulo que cumpla con los criterios de b&uacute;squeda";?></td>
					    </tr>
					</table>					
					<?php }
					
					
					}?>	
<iframe id="frame_datos2" name="frame_datos2" width="0%" height="0" frameborder="0">
	<ilayer width="0" height="0" id="frame_datos2" name="frame_datos2"></ilayer>
</iframe>
<input type="hidden" id="accion" name="accion">
</form>
</div>
</body>
</html>
