<?php
include('../config/db.php');
	include('../config/conexion.php');
	include('../config/conexion2.php');

$dato = $_POST['dato'];
$desde ="";
$hasta ="";
$i=0;
//EJECUTAMOS LA CONSULTA DE BUSQUEDA


$registro = mysql_query("SELECT * FROM despachos WHERE factura LIKE '%$dato%' OR  responsable LIKE '%$dato%' ORDER BY id_despacho ASC");	

//CREAMOS NUESTRA VISTA Y LA DEVOLVEMOS AL AJAX

echo '<table class="table-responsive" align="center">
			  <table class="table">
			  <tr>
             <td colspan="8" class="text-right">
               <a href="imp_compras.php?q=$dato&desde=&hasta=$hasta"><button type="button" class="btn btn-info"><span class="glyphicon glyphicon-print" ></span> Descargar PDF</button></a>
              </td>
              </tr>
			  
              <tr  class="info">
			    <th>item</th>
			    <th>Fecha Despacho</th>
            	<th>Numero Factura</th>
                <th>Cliente o Responsable</th>
                <th>destino</th>
            </tr>';
			
if(mysql_num_rows($registro)>0){
	while($registro2 = mysql_fetch_array($registro)){
 	$i=$i+1;
		
		echo '<tr>
				<td>'.$i.'</td>
		        <td>'.$registro2['fecha'].'</td>
				<td>'.$registro2['factura'].'</td>
				<td>'.$registro2['responsable'].'</td>
				<td>'.$registro2['destino'].'</td>
						  </tr>';		
	}
	
	
	echo '<tr class="info">
	            <td></td>
				<td></td>
				<td>total de despacho</td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
		</tr>
		<tr>
	            <td></td>
				<td></td>
				<td>'.$i.'</td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
		</tr>
		
		';
	
}else{
	echo '<tr>
				<td colspan="6">No se encontraron resultados</td>
			</tr>';
}
echo '</table>';
?>