<?php session_start();
include 'script_php/conexao.php';
require_once 'script_php/login_verificar.php'; 

?>
<!DOCTYPE html>
<html>
<head>

<?php include_once 'head.html' ?>

<title></title>
</head>

<body>

<?php include_once 'header.php'; ?>

  <!--mensagens na tela-->
<?php
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']);

}
?>
<h4>Cadastro de usuário</h4>
<hr>

<h4>Usuário e senha</h4>
<hr>

	<form action="script_php/cadastrar_usuario.php" method="post">

<section class="">
		

		<input type="text" name="usuario" placeholder="usuario" class = "form-control form_forn"  > <p> <p> 
		<input type="password" name="senha" placeholder="Senha" class = "form-control form_forn" ><p> <p> 
		
    <h4>Tipo usuário</h4>
<hr>

<p></p>
		<input type="radio" value="comprador" name="tipo"> Comprador
<p></p>

		<input type="radio" value="recebimento" name="tipo"> Recebimento
<p></p>

		<input type="radio" value="fiscal" name="tipo"> Fiscal
<p></p>

		<input type="radio" value="admsistema" name="tipo"> ADM SISTEMA
<p></p>

<h4>Permissão empresas</h4>
<hr>
<p></p>
<input type="checkbox" name="matriz" value="sim">
<label for="horns">MATRIZ</label>
<p></p>

<input type="checkbox" name="loja02" value="sim">
<label for="horns">LOJA 02</label>
<p></p>

<input type="checkbox" name="loja03" value="sim">
<label for="horns">LOJA 03</label>
<p></p>


<input type="checkbox" name="loja04" value="sim">
<label for="horns">LOJA 04</label>
<p></p>

<input type="checkbox" name="loja05" value="sim">
<label for="horns">LOJA 05</label>
<p></p>

<input type="checkbox" name="loja06" value="sim">
<label for="horns">LOJA 06</label>
<p></p>



		<input type="submit" name="botao" value="Cadastrar" class="btn btn-success">
<p></p>




	</form>

  <section>
    
  </section>

	<hr>

<h4>Usuários Cadastrados</h4>

<hr>

<table class="table">
  <thead>
    <tr class="table-primary">
      <th scope="col" title="Código de registro">ID</th>
      

     <th scope="col" >Nome </th>
     <th scope="col" >Tipo </th>
     <th scope="col" >Alterar Senha</th>
     <th scope="col" >Excluir </th>
     
    </tr>
  </thead>
  <tbody>
    
    <?php
$listagem = mysqli_query($conexao, "SELECT * from usuarios ;");
//o while repete a criaçao de linhas na tabela igual a quantidade de itens.
while($linha = mysqli_fetch_array($listagem)) {
?>


    <tr>
      <td><?php echo $linha['id'] ; ?></td>
      <td><?php echo $linha['usuario'] ; ?></td>
      <td><?php echo $linha['tipouser'] ; ?></td>
      

        <td>

          <a  href="editarusuario.php?id=<?= $linha['id']?>&nome=<?=$linha['usuario']?>" onclick="return confirm('Alterar senha')" >
          <button type="button" class="btn btn-warning" title="Alterar Senha">Alterar Senha</button></a></td>
      <td>
        <a  href="script_php/exluir_usuario.php?id=<?= $linha['id']?>" onclick="return confirm('Excluir?')" >
        <button type="button" class="btn btn-danger" title="Excluir">Excluir</button></td>
      </a>

    </tr>
     

<?php } ?>

  
  </tbody>
</table>


<?php include_once 'footer.php' ?>