<?php
session_start();
if(strpos(strtolower($_SERVER['REQUEST_URI']), 'phpsessid') !== false)
{
  session_destroy();
  session_regenerate_id();
  session_start();
                              
}
///Construtoras listar
include "../phpconfig/config.php";
include "../phpconfig/valida_login.php";
include "../includes/topo.php"; 

$sql = mysql_query("SELECT * FROM cobertura ORDER BY bairro asc");
$num = mysql_num_rows($sql);


?>

<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;    ?> Bairros</li>
        </ul>


        <table class="table table-bordered">

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

              <a href="add.php" class="btn btn-success" >Adicionar novo <i class="icon-plus icon-white"></i></a>

              
            </th>

          </tr>
          <tr>
            <!-- <th>MOVER</th> -->

            <th>Nome</th>  

            <th>Taxa</th>   

             <th>Ação</th>

             <!-- <th>Deletar</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> <div class="box_img handle" style="cursor:move;display:block">
            <div class="mover"><i class='icon-move'></i></div></td> -->
            <td><?php echo $lin['bairro']; ?></td>
            <td><p class='pull-right'>R$ <?php echo $lin['taxa']; ?></p></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 bairro?');" class="btn btn-default" ><span class="glyphicon glyphicon-trash"></i></a>

            </td>
          <!--   <td>
              <a href="del.php?id=<?php echo $lin['id'];  ?>" onclick="return confirma('Deseja deletar este bairro?');" class="btn btn-danger" ><i class="icon-trash"></i></a>
            </td> -->
          </tr>
          <?php  } if($num==0){echo "<tr><td  colspan='5'>Não há cadastro de bairros.</td></tr>";} ?>


        </tbody>
      </table>

<script type="text/javascript">
    $(document).ready(function(){
      //link atual momentaneo
      //$('header#topo nav ul li a.sobre').closest('li').addClass('atual');
      $("#retorno").change(function(){
        var current = $("#retorno").val();
        if (current != "select") {
          var novaURL = "<?php echo sti('adm'); ?>bairros/index.php?area="+current;
          $(window.document.location).attr('href',novaURL);
        };
      });
    });
  </script>

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