<?php
 
session_start();
include("DMMYSQLG.php");
include("JQUERY.inc");
?>
<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'];
//	}
//
function cpyValText(arrData){
	var id;

        console.log(arrData);
      for(id in arrData)  
        window.parent.$("#"+id).val(arrData[id]);
        parent.$.fancybox.close();
}
</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" bordercolor="#FFCC00" bordercolordark="#FFCC00">
      <tr> 
        <th width="594" colspan="2">AGREGAR AGRUPADOR</th>
      </tr>
      <!--<tr> 
        <th> <input name="r1" type="radio" tabindex="1" value="clave" checked>
          Clave </th>
        <th><input name="r1" type="radio" value="nombre" tabindex="2">
          Nombre </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="454" align = center>
<tr>
	  <th width="39"><div align="center">Sel</div></th>
   	  <th width="62"><div align="center">CODIGO </div></th>
  	  <th width="148"><div align="center">SUB-AGRUPADOR</div></th>
	  <th width="116"><div align="center">AGRUPADOR</div></th>
	  <th width="65"><div align="center">ALMACEN</div></th>
      
    </tr>
<?php
 
$sql = mysqli_query($con ,"SELECT * FROM fsubagrupadores order by np_desc1");
if(isset($_POST['r1'])&&$_POST['r1']=="clave")
{
	@$sql = mysqli_query($con ,"SELECT * FROM dxbascps WHERE codigo like '%".$_POST['tbus']."%' and act1 = '1'");
}elseif(isset($_POST['r1'])&&$_POST['r1']=="nombre"){
	@$sql = mysqli_query($con ,"SELECT * FROM dxbascps WHERE nombre  like '%".$_POST['tbus']."%' or ap_paterno  like '%".$_POST['tbus']."%' or ap_materno  like '%".$_POST['tbus']."%' and act1 = '1'");
}
while(@$reg = mysqli_fetch_array($sql))
	{
	  	$agrupador=mysqli_fetch_array(mysqli_query($con ,"select * from fagrupadores where n_reg='".$reg['almacen']."'"));
		$almacen=mysqli_fetch_array(mysqli_query($con ,"select * from falmacen where nparte1='".$reg['descripcion']."'"));
		echo "<tr>";
?>
		<td> <div align="center"><input name="button" type="button" class="bot_NgN" onClick="
			cpyValText({    				
				<?php
 echo $_REQUEST['val'];?>:'<?php
 echo $reg['np_desc1'] ?>',
				<?php
 echo $_REQUEST['des'];?>:'<?php
 echo $reg['almacen'] ?>',
				<?php
 echo $_REQUEST['sec'];?>:'<?php
 echo $reg['descripcion'] ?>'
			});
			window.close();
			" value="OK">
		</div></td>
		<?php


		echo "<td> <div align='center' style=' '>" . $reg["codigo"] . "</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["np_desc1"] . "</div></td>";
		echo "<td> <div align='center' style=' '>" . $agrupador["np_desc1"] . "</div></td>";
		echo "<td> <div align='center' style=' '>" . $almacen["np_desc1"] . "</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>