ok

Mini Shell

Direktori : /home/pequenacapitolio/www/administrador/
Upload File :
Current File : /home/pequenacapitolio/www/administrador/modulos_admin.php

<?php

include '../conexao.php';

// ############# UPDATE CATEGORIA ###################
if (isset($_GET["act"]) && $_GET["act"] == "editar") {

    $user_id = $_GET["id"];
    $status = $_POST["status"];
    $nome = $_POST["nome"];
    
    $dados_atualiza = array(
        'id' => $user_id,
        'status' => $status,
        'nome' => $nome,
    );

    $conn->prepare("UPDATE modulos SET nome = :nome, status = :status WHERE idmodulo = :id")->execute($dados_atualiza);

    $redirect = "/administrador/modulos_admin.php";
    //$redirect = "/administrador/modulos_admin.php";
    header("location:$redirect");
}
?>

<!DOCTYPE html>
<html>
<head>
    <?php include 'include_head.php';?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">

  <?php include 'estrutura_menu.php';?>

  <!-- =============================================== -->

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="col-md-12" style="background: #fff;border-bottom: 1px solid #bbbbbb">
      <div class="col-md-12" style="text-align: left;padding-left: 0px">
        <p style="color: #040404;font-weight: 700;font-size: 32px;margin-top: 1%;margin-bottom: 0px">Gerenciamento de Módulo</p>
      </div>
      <div class="col-md-8" style="height: 34px;padding-left: 0px">
        <p style="color: #3a3a3a;font-size: 14px;">Tela Inicial/Gerenciamento de Módulo</p>
      </div>
      <div class="col-md-4" style="text-align: right;margin-bottom: 1%">
        <a href="#" data-toggle="modal" data-target="#modal-inserir" class="btn btn-primary btn-flat" style="margin-right: 4%">Inserir</a>
        <a href="#" data-toggle="modal" data-target="#modal-inserir" class="btn btn-primary btn-flat">Inserir</a>
      </div>
    </div>
    <div class="col-md-12" style="height: 22px">
    </div>

    <!-- Main content -->
    <section class="content">

    <?php

    $user = $conn->query("SELECT * FROM modulos order by idmodulo asc");

    ?>

    <div class="row">
        <div class="col-xs-12">
          <div class="box" style="border-top:5px solid #408db9">

            <?php if ($user->rowCount()) {?>

            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              <table class="table table-hover">

                <?php while ($usuario = $user->fetch(PDO::FETCH_OBJ)) {?>
                <tr>
                  <td width="70%"><?php echo $usuario->nome ?></td>
                  <td width="70%">
                    <?php 
                    if ($usuario->status == 'ativo') { 
                      echo "<i style='color: green;' class='fas fa-check-circle'></i>"; 
                    } else {
                      echo "<i style='color: red;' class='fas fa-times-circle'></i>"; 
                    } 
                    ?>
                      
                  </td>
                  <td width="10%">
                      <a href="#" data-toggle="modal" data-target="#modal-atualizar<?php echo $usuario->idmodulo ?>"><i style="margin-right:20px;" class="fas fa-pencil-alt"></i></a>
                  </td>
                </tr>

                <?php }?>

              </table>
            </div>

            <?php }?>

            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <?php include 'estrutura_rodape.php';?>


  <?php
$userparamodal = $conn->query("SELECT * FROM modulos order by idmodulo desc");
// ##### SELECT IGUAL O DA LISTA COM MESMA ORDENAÇÃO PARA QUE TENHA O MESMO RESULTADO #######
while ($usermodal = $userparamodal->fetch(PDO::FETCH_OBJ)) {
    // ######### LAÇO DE REPETIÇÃO MODAL CONFORME SELECT ANTERIOR
    ?>

    <!-- ########## MODAL ATUALIZAR ########## -->
    <div class="modal fade" id="modal-atualizar<?php echo $usermodal->idmodulo ?>">
      <div class="modal-dialog">
      <div class="modal-content">
          <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title">Atualizar Módulo</h4>
          </div>
          <div class="modal-body">

            <div class="row">
              <form action="modulos_admin.php?act=editar&id=<?php echo $usermodal->idmodulo ?>" method="POST">
                  
                  <div class="col-xs-12" style="margin-bottom: 20px;">
                      <input type="text" name="nome" class="form-control" placeholder="Nome*" value="<?php echo $usermodal->nome ?>" required>
                  </div>

                  <div class="col-xs-12">
                      <select class="form-control" name="status">
                          <option value="ativo" <?php if ($usermodal->status == "ativo"){?> selected <?php }?> >Ativo</option>
                          <option value="inativo" <?php if ($usermodal->status == "inativo"){?> selected <?php }?> >Inativo</option>
                      </select>
                  </div>

                  <div class="col-xs-12">
                      <button type="submit" class="btn btn-primary" style="margin-top:20px;">Salvar</button>
                  </div>

              </form>
            </div>

          </div>
          <!-- <div class="modal-footer">
          <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Fechar</button>
          </div> -->
      </div>
      <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
  <?php }?>

  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<script>
  $(document).ready(function () {
    $('.sidebar-menu').tree()
  })
</script>
</body>
</html>

Zerion Mini Shell 1.0