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



$sql2 = mysql_query("SELECT * FROM campanhas ORDER BY id DESC");
$num = mysql_num_rows($sql2);


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


        <table class="table table-bordered">

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

              <a href="rapido.php" class="btn btn-success" >Adicionar nova <i class="icon-plus icon-white"></i></a>
              
            </th>

          </tr>
          <tr>

          <tr>
   

             <th>ID</th>
             <th>Empresa</th>   
             


             <th>Cidade / UF</th>
             <th>Bairro</th>

      <th>Views</th>

             <th>Clique topo</th>
             <th>Clique lateral</th>
             <th>Clique inferior</th>   
             <th>Deletar</th>
             <th>Dados</th>

       
          

             <th>Ativar</th>
          </tr>
        </thead>
        <tbody id='test-list'>

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

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

            <?php

            $empresa = retorna($lin['id_emp'], 'empresas');
            $cidade = retorna($lin['id_cidade'], 'l_cidades');
            $estado = retorna($lin['id_uf'], 'l_estados');
            $bairro = retorna($lin['id_bairro'], 'l_bairros');

            ?>

            <td><?php echo $empresa['id'];  ?></td>
            <td><?php echo $empresa['empresa'];  ?></td>
            <td><?php echo $cidade['cidade'];  ?> - <?php echo strtoupper($estado['uf']);  ?></td>

            <td><?php echo $bairro['bairro'];  ?></td>
            <td width='12'><?php echo $lin['latv'];  ?></td>
            <td width='12'><?php echo $lin['topc'];  ?></td>
            <td width='12'><?php echo $lin['latc'];  ?></td>
            <td width='12'><?php echo $lin['infc'];  ?></td>
           
              <td>

              <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>

            <td>
              <a href="../campanhas/edit.php?id=<?php echo $lin['id'];  ?>" class="btn btn-warning" ><span class="glyphicon glyphicon-list"></span></a>
              <a href="../campanhas/banners.php?id=<?php echo $lin['id'];  ?>" class="btn btn-warning" ><span class="glyphicon glyphicon-picture"></span></a>
              <a href="../completo/edit.php?id=<?php echo $empresa['id'];  ?>" class="btn btn-warning" ><span class="glyphicon glyphicon-plus"></span></a>
            
            </td>
            <td>
              <a href="ativar.php?id=<?php echo $lin['id'];  ?>&ativo=<?php echo $lin['ativo']; ?>"  <?php if($lin['ativo']!=1){  ?> class="btn btn-danger" <?php }else{  ?> class="btn btn-success" <?php }  ?> ><i class="glyphicon glyphicon-ok"></i></a>
            </td>            
          </tr>
          <?php  } if($num==0){echo "<tr><td  colspan='11'>Não há cadastro de campanhas</td></tr>";} ?>


        </tbody>
      </table>

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