<?php
 
session_start();
include("DMMYSQLG.php");

include("DMMYSQLG.php");

?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="javascript">
function cpyValText(arrData){
	var id;
	if(arguments[1]!='undefined'){
	for(id in arrData)
		window.opener.document.getElementById(id).value=arrData['id'];		
	}
	else{
		for(id in arrData)
			document.getElementById(id).value=arrData['id'];
	}
}
</script>
<script language="javascript">
<!--
	//--> ABRIR EN OTRA PANTALLA
  function sendValueOV(va1,va2,va3,va4){
	var sv = va1;
	cs = sv.split("|");
	var va = cs[0];
	if (va1 != "") {
		window.opener.document.frm1.tncli.value = va1;
		window.opener.document.frm1.tnom_alt.value = va2 + " " + va3 + " " + va4;
		window.opener.document.frm1.tncli.focus();
	} else {
		alert("EL CLIENTE NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tncli.value = "";
		window.opener.document.frm1.tncli.focus();
	}
	window.close();
}
  //-->FIN
-->
</script>
<body>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="458"  align="center">
      <tr> 
        <th width="594" colspan="2">AGREGAR ARTICULO</th>
      </tr>
      <tr> 
        <th> <input name="r1" type="radio" tabindex="1" value="clave" checked>
        CODIGO</th>
        <th><input name="r1" type="radio" value="nombre" tabindex="2">
        ARTICULO</th>
      </tr>
      <tr>
        <td colspan="2"><input name="tbus" type="text"  onBlur="may(this)" size="75"/></td>
      </tr>
      <tr> 
        <td colspan="2"><div align="center">
            <input type="submit" name="Submit" value="Buscar">
          </div></td>
      </tr>
    </table>
  </form>
</div>
<form id="pp" name="pp" action="">
<table width="392" align = center>
<tr>
	  <th width="32"><div align="center">Sel</div></th>
      	<th width="54"><div align="center">CODIGO </div></th>
  	  <th width="186"><div align="center">ARTICULO</div></th>
	  <th width="100"><div align="center">COSTO</div></th>
      	<!--<th><div align="center">Apellido Materno </div></th>
		<th><div align="center">RFC</div></th>-->
    </tr>
<?php
 
$sql = mysqli_query($con ,"SELECT * FROM farticulos order by descripcion");
echo '<input name="txt_bus" type="hidden" value="'.$_POST['tbus'].'">';
if($_POST['r1']=="clave")
{
	@$sql = mysqli_query($con ,"SELECT * FROM farticulos WHERE nparte1 like '%".$_POST['tbus']."%' ");
}elseif($_POST['r1']=="nombre"){
	@$sql = mysqli_query($con ,"SELECT * FROM farticulos WHERE descripcion like '%".$_POST['tbus']."%' ");
}
while(@$reg = mysqli_fetch_array($sql))
	{
	  	echo "<tr>";
?>
		<td> <div align="center"><input type="button" name="button" value="OK" onClick="
			cpyValText({
				
				<?php
echo $_REQUEST['val'];?>:'<?php
 echo $reg['nparte1'] ?>',
				<?php
echo $_REQUEST['des'];?>:'<?php
 echo $reg['descripcion'] ?>',
				<?php
echo $_REQUEST['por'];?>:'<?php
 echo $reg['t3'] ?>'
			});
			window.close();
			"></div></td>
		<?php


		echo "<td> <div align='center'>" . $reg["nparte1"] . "</div></td>";
		echo "<td> <div align='center'>" . $reg["descripcion"] . "</div></td>";
		echo "<td> <div align='center'>" . $reg["t3"] . "</div></td>";
		//echo "<td> <div align='center'>" . $reg["ap_materno"] . "</div></td>";
		//echo "<td> <div align='center'>" . $reg["rfc"] . "</div></td>";
		//gdescrip:'5' este sirve para regresar valores directos y no volver a reutilizar la ventana ERIK EDUARDO CARREON RODRIGUEZ
		echo "</tr>";
	}
?>
</table>
</form>
</body>
</html>