<?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 usuarios ORDER BY nome ASC");
$num = mysql_num_rows($sql);

?>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>


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


        <table class="table table-bordered">

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

              <a href="add.php" class="btn btn-success" >Adicionar novo <span class="glyphicon glyphicon-plus" a></span></i></a>
              
            </th>

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

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

          while($lin = mysql_fetch_assoc($sql)){ if($lin['username']!='ncms'){  ?>
          <tr id="listItem_<?php echo $lin['id']; ?>">
            
            <td><?php echo $lin['nome'];  ?> <?php echo $lin['sobrenome'];  ?></td>
            <td><?php echo $lin['username'];  ?></td>
            <td><?php echo $lin['email'];  ?></td>
              <td>
              <a href="edit.php?id=<?php echo $lin['id'];  ?>" class="btn btn-default" ><span class="glyphicon glyphicon-pencil" ></span></i></a>
              <?php if($lin['id']!=$_SESSION['adm']['id_user']){  ?><a href="del.php?id=<?php echo $lin['id'];  ?>" onclick="return confirma('Deseja deletar esta usuário?');" class="btn btn-default" ><span class="glyphicon glyphicon-trash" ></span></a><?php  }  ?>
            </td>
          </tr>
          <?php  }}  if($num==0){echo "<tr><td  colspan='4'>Não há cadastro de usuários</td></tr>";} ?>


        </tbody>
      </table>


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