<?php
 
session_start();
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'];
//	}
//}
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.explode("|");
	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 TARIFAS INDIVIDUALES/PAQUETES</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="354" align = center>
<tr>
	  <th width="32"><div align="center">Sel</div></th>
      	<th width="54"><div align="center">CLAVE</div></th>
  	  <th width="125"><div align="center">DESCRIPCION</div></th>
	  <th width="123"><div align="center">TEMPORADA</div></th>
      <th><div align="center">COSTO</div></th>
		<!--th><div align="center">RFC</div></th>-->
    </tr>
<?php

		
	   $fecha = (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	   //$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
	   ?>

<?php
 

$sql = mysqli_query($con ,"SELECT * FROM ftarifas WHERE (gfecini <= '$fecha' and gfecfin >= '$fecha') and cclave = 'BAJA' order by gclave");

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))
	{
	  	echo "<tr>";
?>
		<td> <div align="center"><input type="button" name="button" value="OK" onClick="
			cpyValText({
				
				<?php
 echo $_REQUEST['val'];?>:'<?php
 echo $reg['gclave'] ?>',
				<?php
 echo $_REQUEST['des'];?>:'<?php
 echo $reg['gdescrip'] ?>',
				<?php
 echo $_REQUEST['kji'];?>:'<?php
 echo $reg['gtotal'] ?>'
			});
			window.close();
			"></div></td>
		<?php

		echo "<td> <div align='center'>" . $reg["gclave"] . "</div></td>";
		echo "<td> <div align='center'>" . $reg["gdescrip"] . "</div></td>";
		echo "<td> <div align='center'>" . $reg["cclave"] . "</div></td>";
		echo "<td> <div align='center'>$" . number_format(floatval ($reg["gtotal"]),2,'.',',') . "&nbsp;</div></td>";
		echo "</tr>";
	}
?>
</table>
</form>
</body>
</html>