Written by Anonymous

<html>
<title>Maquinas</title>
<link rel="stylesheet" href="style.css">
<?php
session_start();
include("header.html");
?>
</head>

<body>
  <div class="container position-absolute top-50 start-50 translate-middle">
    <?php include("mensagem.php")
    ?>
    <div class="row">
      <div class="col-12 col-md-12">
        <div class="card">
          <div class="card-body">
            <div class="card-header mb-3">
              <div class=" navbar-light bg-light float-end ">
                <div class="container-fluid">
                  <div class="">
                    <input class="form-control me-2" id="pesquisaTable" type="search" placeholder="Pesquisar..." aria-label="Search">
                  </div>
                </div>
              </div>
              <h4>Maquinas Cadastradas</h4>
              <script>
                $(document).ready(function() {
                  $("#pesquisaTable").on("keyup", function() {
                    var value = $(this).val().toLowerCase();
                    $("#tabelaMaquinas tr").filter(function() {
                      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
                    });
                  });
                });
              </script>
            </div>
            <div class="scrollTabela">
              <table class="table table-hover table-bordered table-light ">
                <thead>
                  <tr>
                    <th scope="col">ID</th>
                    <th scope="col">Usuário</th>
                    <th scope="col">Setor</th>
                    <th scope="col">Maquina</th>
                    <th scope="col">Compra</th>
                    <th scope="col">Garantia</th>
                    <th scope="col">Status</th>
                    <th scope="col">Ações</th>
                  </tr>
                </thead>
                <tbody id="tabelaMaquinas">
                  <?php
                  include('database/database.php');


                  //faz a busca dos dados da tabela
                  $maquinas = "SELECT idMaquina, usuario, setor, maquina, memoria_ram, processador, hd, monitor, sistema_operacional, upgrade, 
                    vpn, data_compra, garantia, server_tag, manutencao, obs_manutencao, statusMaquina FROM maquinas WHERE flag = 1";

                  //salva os dados encontrados
                  $result = mysqli_query($conn, $maquinas);

                  if (mysqli_num_rows($result) > 0) {
                    // acessa os dados encontratos e imprime na tela 
                    while ($row = mysqli_fetch_array($result)) {
                      $idMaquina = $row['idMaquina'];
                      $dataCompra = $row['data_compra'];
                      $dataGarantia = $row['garantia'];

                      $dataCompraFormatada = date('d/m/Y', strtotime($dataCompra));
                      $garantiaFormatada = date('d/m/Y', strtotime($dataGarantia));
                      $idMaquinaFormatado = sprintf("%03d", $idMaquina);

                      if ($row['statusMaquina'] == 1) {
                        $status = "Ativo";
                      } else {
                        $status = "Inativo";
                      }

                      if ($status == "Ativo") {
                        $color = "table-success";
                      } else {
                        $color = "table-danger";
                      }
                  ?>

                      <tr class="<?php echo $color ?>">
                        <td scope="row"><?php echo $idMaquinaFormatado ?></td>
                        <td scope="row"><?php echo $row['usuario'] ?></td>
                        <td scope="row"><?php echo $row['setor'] ?></td>
                        <td scope="row"><?php echo $row['maquina'] ?></td>
                        <td scope="row"><?php echo $dataCompraFormatada ?></td>
                        <td scope="row"><?php echo $garantiaFormatada ?></td>
                        <td scope="row"><?php echo $status ?></td>
                        <td>
                          <button class="bg-success border border-0 rounded-1">
                            <a href="formVisualizar?param=
                            <?php echo trim($row['idMaquina']) . "|" . trim($row['usuario']) . "|" . trim($row['setor']) . "|" . trim($row['maquina']) . "|" .
                              trim($row['memoria_ram']) . "|" . trim($row['processador']) . "|" . trim($row['hd']) . "|" . trim($row['monitor']) . "|" .
                              trim($row['sistema_operacional']) . "|" . trim($row['upgrade']) . "|" . trim($row['vpn']) . "|" . trim($row['data_compra']) . "|" . trim($row['garantia']) . "|" . trim($row['server_tag']) . "|" .
                              trim($row['manutencao']) . "|" . trim($row['obs_manutencao']) . "|" . trim($row['statusMaquina']) ?>">
                              <i class="bi bi-eye text-light" style="font-size: 23px;"></i>
                            </a>
                          </button>
                          <button class="bg-primary border border-0 rounded-1" style="margin-left: 3px;">
                            <a href="formEditar?param=
                            <?php echo trim($row['idMaquina']) . "|" . trim($row['usuario']) . "|" . trim($row['setor']) . "|" . trim($row['maquina']) . "|" .
                              trim($row['memoria_ram']) . "|" . trim($row['processador']) . "|" . trim($row['hd']) . "|" . trim($row['monitor']) . "|" .
                              trim($row['sistema_operacional']) . "|" . trim($row['upgrade']) . "|" . trim($row['vpn']) . "|" . trim($row['data_compra']) . "|" . trim($row['garantia']) . "|" . trim($row['server_tag']) . "|" .
                              trim($row['manutencao']) . "|" . trim($row['obs_manutencao']) . "|" . trim($row['statusMaquina']) ?>">
                              <i class="bi bi-pencil-square text-light" style="font-size: 23px;"></i>
                            </a>
                          </button>
                          <form action="acoes.php" method="post" class="d-inline" style="margin-left: 3px;">
                            <input type="hidden" name="idMaquina" value="<?php echo $row['idMaquina'] ?>">
                            <button type="submit" class="bg-danger border border-0 rounded-1" name="delete_usuario" onclick="return confirm('Você tem certeza que deseja excluir essa máquina?')">
                              <i class="bi bi-trash text-light" style="font-size: 23px;"></i>
                            </button>
                          </form>
                          <form action="pdf.php" method="post" class="d-inline" style="margin-left: 3px;">
                            <input type="hidden" name="id" value="<?php echo $row['idMaquina'] ?>">
                            <button type="submit" class="bg-danger border border-0 rounded-1" name="pdf" onclick="return confirm('Você deseja baixar o PDF dessa máquina?')">
                              <i class="bi bi-filetype-pdf text-light" style="font-size: 23px;"></i>
                            </button>
                          </form>
                        </td>
                      </tr>
                  <?php
                    }
                  }


                  mysqli_close($conn);

                  ?>
                </tbody>
                <div class="position-absolute top-50 start-50 translate-middle">
                  <?php if (mysqli_num_rows($result) <= 0) : ?>
                    <h2>Não há nenhum registro de maquinas</h2>
                  <?php endif; ?>
                </div>
              </table>
            </div>
            <div class="d-flex justify-content-center">
              <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                <div>
                  <button type="button" class="btn btn-primary btn-sm mt-3 rounded" onclick="window.location='formCadastro'">
                    <a>Novo cadastro</a>
                  </button>
                </div>
                <?php if (mysqli_num_rows($result) >= 1) : ?>
                  <div>
                    <a type="button" class="btn btn-success btn-sm mt-3 rounded" href="csv" onclick="return confirm('Você deseja baixar o CSV com informações de todas as máquinas?')">
                      Baixar CSV
                </a>
                  </div>
                <?php endif; ?>
                <?php if (mysqli_num_rows($result) >= 1) : ?>
                  <div>
                    <form action="acoes.php" method="post">
                      <button type="submit" class="btn btn-danger btn-sm mt-3 rounded" name="delete_all_usuario" onclick="return confirm('Você tem certeza que deseja deletar todas as máquinas?')">
                        <a>Deletar tudo</a>
                      </button>
                    </form>
                  </div>
                <?php endif; ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  </div>
</body>

</html>
Notepad
Select All