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

include("DFJSISCI.inc");
?>
<html>
<head>

<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<?php

require_once("DFJQUERY.inc");
?>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script language="javascript">
$(document).ready(function(){
	$("#tbus").autocomplete('BUSMESA.php',{
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		//max:3                        //maximo de resultados mostrados, se manda como limit en autosugestion
		selectFirst:false,
		delay: 200,                  //Retardo de autocompletar 
		width: 500,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: false	,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 500,           //alto del cuadro para el scroll
		formatItem:function (row, i, n, value) { //formato de presentacion de las posibles busquedas
			return "(<strong>"+row[1]+"</strong>)"+row[0];
		},	     
		formatResult:function(row){  //formato de seleccion de busqueda
			return row[0];
		},
		extraParams:{tipBus:'d'}     //Parametros Extra a Mandar en autosugestion
	});
	$("#tbus").result(function(event, row, formatted){
		//if(!row && confirm("Articulo:'"+$(this).val()+"'\nDesea AGREGARLO?"))
			openpage("MS10000_AG.php?tap2="+$(this).val(),'_self');
		//else if(confirm("Articulo:'" +row[0]+"'\nDesea Consultar/Modificar?"))
			openpage("MS10000_MO.php?bot="+row[1],'_self');
	}).keypress (function(){
    	var evt = (evt) ? evt : event; 
    	var tecla = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode:((evt.which) ? evt.which : 0)); 
    	if(tecla==13){
			$(this).search();
			return false;	
		}
		return true;
	});	

});

function busca(){
	getOnLayer({
			action:'MS10000_PR-SRV.php',
			idLayer:'regBus'
		},{
			tbus:ge('tbus').value
	});
}

</script>

</head>
<body>

<div align="center">
  <form name="form1" method="post" action="">
    <table  align="center">
      <tr>
        <th colspan="2">MESAS</th>
      </tr>
      
      <tr>
        <th width="286">BUSQUEDA.
          <input name="r1" type="radio" value="nombre" tabindex="2"></th>
        <td width="102">&nbsp;</td>
      </tr>
    
      <tr>
        <td><input type="submit" name="Submit" value="Buscar" />
        <input name="tbus" type="text" onBlur="may(this)" size="30"/></td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <th colspan="3">MESAS</th>
      </tr>
      <tr>
        <td colspan="3"><div align="center">
          <input name="tbus2" type="text" id="tbus" onBlur="may(this)" size="50"
		<?php

			if(isset($_POST['tbus'])){ 
				echo 'value="' . $_POST['tbus'] .  '"';
			}
		?>
		/>
        </div></td>
      </tr> 
    </table>
	
  </form>
</div>
<div align="center">
<form name="frm1" id="frm1" method="post" action="" >
    <?php
 
	$sql = mysqli_query($con ,"SELECT * FROM ctmesas order by nparte1");
	include("DE10000.php");
	?>
    <table width="587" border='1'>
      <tr>
        <th colspan="8"> 
          <div align="center">
		     <input type="button" name="bot2" value="Nuevo" onClick="openpage('MS10000_AG.php','_self')"/>
            <input type="button" name="bot2" value="Modificar" onClick="openpage('MS10000_MO.php','_self')"/>
            <input type="button" name="bot4" value="Imprimir " onClick="openpage('MS10000_IM.php','_self')"/>  
            <input type="button" name="bot42" value="Exporta Exel" onClick="openpage('MS10000_IME.php','_self')"/>
          </div>
          <div align="right"></div>
		</th></tr>
      <tr>
        <th width="129"><div align="center">SEL.</div></th>
        <th width="190"><div align="center">CLAVE. </div></th>
        <th width="246"><div align="center">DESCRIPCION.</div></th>
		<th width="246"><div align="center">DESCRIPCION PUNTO VTA.</div></th>
		<th width="246"><div align="center">AREA.</div></th>
	  </tr>
      <?php

	echo '<input name="tip_bus" type="hidden" value="'.$_POST['tbus'].'">';
	if($_POST['r1']=="clave")
	{
		echo '<input name="tip_bus" type="hidden" value="clave">';
	  	@$sql = mysqli_query($con ,"SELECT * FROM ctmesas WHERE np_desc1 like '%".$_POST['tbus']."%'");
		
	}elseif($_POST['r1']=="nombre")
	{
		echo '<input name="tip_bus" type="hidden" value="nombre">';
		@$sql = mysqli_query($con ,"SELECT * FROM ctmesas WHERE np_desc1 like '%".$_POST['tbus']."%'");
	}
	while($reg = mysqli_fetch_array($sql))
	{
	  	echo "<tr>";
		echo '<td> <div align="center"><input name="bot" type="radio" value="'. $reg["nparte1"].'"></div></td>';
		echo "<td> <div align='center'>" . $reg["nparte1"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'>" . $reg["np_desc1"] . "&nbsp;</div></td>";
		@$bus = mysqli_query($con ,"SELECT * FROM ptventa WHERE nparte1 = '".$reg['descripcion']."'");
		$re = mysqli_fetch_array($bus);
		echo "<td> <div align='center'>" . $re["np_desc1"] . "&nbsp;</div></td>";
		@$bus = mysqli_query($con ,"SELECT * FROM ctarea WHERE nparte1 = '".$reg['area']."'");
		$re = mysqli_fetch_array($bus);
		echo "<td> <div align='center'>" . $re["np_desc1"] . "&nbsp;</div></td>";
//		echo '<td> <div align="center" style="background-color:'.$reg["color"].';">&nbsp;</div></td>';
		echo "</tr>";
	}
	mysqli_close($con);
	?>
    </table>
  </form>



</div>
</body>
</html>