<?php
session_start();
///Construtoras listar
include "../phpconfig/config.php";
include "../phpconfig/valida_login.php";
include "../includes/topo.php"; 

$tel = $_GET['tel'];

$sql = mysql_query("SELECT * FROM empresas WHERE telefone LIKE '%$tel%' ORDER BY id ASC");
$num = mysql_num_rows($sql);

?>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript">
  // When the document is ready set up our sortable with it's inherant function(s)
  $(document).ready(function() {
    $("#test-list").sortable({
      handle : '.handle',
      update : function () {
      var order = $('#test-list').sortable('serialize');
      $("#info").load("process-sortable.php?"+order);  
   

      }
    });
}); 

</script>

        <ul class="breadcrumb">
          <li><a href="<?php echo sti('adm');  ?>">Home</a></li>
          <li class="active"><?php echo $num;    ?> empresas similares</li>
        </ul>


        <table class="table table-bordered">

        <thead>
          <tr>
            <th  colspan='3'> 

             
              
            </th>

          </tr>
          <tr>
   


            <th>Nome</th>

            
             <th>Ação</th>
             <th>Telefone</th>
          </tr>
        </thead>
        <tbody id='test-list'>

          <div id="info"></div>
          <?php  

          while($lin = mysql_fetch_assoc($sql)){  ?>
          <tr id="listItem_<?php echo $lin['id']; ?>">



            <td><?php echo $lin['empresa'];  ?></td>
            <td><?php echo $lin['telefone'];  ?></td>
           
              <td>
              <a href="edit.php?id=<?php echo $lin['id'];  ?>" class="btn btn-default" ><span class="glyphicon glyphicon-pencil"></span></a>
              <a href="del.php?id=<?php echo $lin['id'];  ?>" onclick="return confirma('Deseja deletar este cliente?');" class="btn btn-default" ><span class="glyphicon glyphicon-trash"></span></a>
            </td>
          </tr>
          <?php  } if($num==0){echo "<tr><td  colspan='3'>Não há cadastro de empresas similares</td></tr>";} ?>


        </tbody>
      </table>

<?php include "../includes/rodape.php"; ?>
