123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?php
- session_start();
- if (!isset($_SESSION['hash_user'])) {
- header('Location: login.php');
- exit;
- }
- ?>
-
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
- <title>LInE Quest</title>
- <style>
- body {
- font-family: Arial;
- }
- table {
- border-collapse: collapse;
- width: 100%;
- margin-bottom: 1em;
- }
- table td, table th {
- border: 1px solid #ddd;
- padding: 8px;
- }
- table tr:nth-child(even){background-color: #f2f2f2;}
- table tr:hover {background-color: #ddd;}
- table th {
- padding-top: 12px;
- padding-bottom: 12px;
- text-align: left;
- background-color: #4CAF50;
- color: white;
- }
- .pagination {
- display: inline-block;
- margin-top: 1em;
- }
- .pagination a {
- color: black;
- float: left;
- padding: 8px 16px;
- text-decoration: none;
- border: 1px solid #ddd;
- }
- .pagination a:hover:not(.active) {background-color: #ddd;}
- .pagination a:first-child {
- border-top-left-radius: 5px;
- border-bottom-left-radius: 5px;
- }
- .pagination a:last-child {
- border-top-right-radius: 5px;
- border-bottom-right-radius: 5px;
- }
- .disabled {
- pointer-events: none;
- cursor: default;
- text-decoration: none;
- color: #918a8a !important;;
- background-color: #f0efef;
- }
- .export {
- float: right;
- }
- .total {
- float: left;
- }
- </style>
- </head>
- <body>
- <?php
- require_once('../controller/forms.php');
- $all_forms = get_forms();
- ?>
- <form>
- Selecione o identificador do formulário:
- <select name="formulario" onchange="this.form.submit()">
- <option></option>";
- <?php
- foreach($all_forms as $form) {
- if ((isset($_GET['formulario'])
- && $_GET['formulario'] == $form)) {
- print "<option selected>$form</option>";
- } else {
- print "<option>$form</option>";
- }
- }
- ?>
- </select>
- </form>
-
- <table>
- <?php
- if ((!isset($_GET['formulario']))) exit;
- if (isset($_GET['pageno'])) {
- $pageno = $_GET['pageno'];
- } else {
- $pageno = 1;
- }
- $no_of_records_per_page = 10;
- $offset = ($pageno-1) * $no_of_records_per_page;
- $form_id = $_GET['formulario'];
- $total_rows = get_total_rows($form_id);
- $total_pages = ceil($total_rows / $no_of_records_per_page);
- $res_data = get_records_pagination($form_id, $offset, $no_of_records_per_page);
-
- $all_fields = array();
- foreach($res_data as $form) {
- foreach($form as $key => $val) {
- if(!in_array($key, $all_fields)) {
- $all_fields[] = $key;
- }
- }
- }
- print '<tr>';
- foreach($all_fields as $field) {
- print "<th>$field</th>";
- }
- print '</tr>';
- foreach($res_data as $form) {
- print '<tr>';
- foreach($all_fields as $field) {
- //if ($field === 'form') continue;
- print '<td>';
- if ($field === 'timestamp') {
- print date("H:i:s d/m/Y", $form->$field).'</td>';
- continue;
- }
- print $form->$field.'</td>';
-
- }
- print '</tr>';
- }
-
- ?>
- </table>
- <div class="total">
- Total de registros: <b><?= $total_rows ?></b>
- </div>
- <div class="export">
- Exportar como: <a href="export.php?formulario=<?= $form_id ?>&format=csv">CSV</a>
- </div>
- <center>
- <div class="pagination">
- <a class="<?php if($pageno <= 1){ echo 'disabled'; } ?>" href="?formulario=<?= $form_id ?>&pageno=1">Primeira</a>
- <a class="<?php if($pageno <= 1){ echo 'disabled'; } ?>" href="<?php if($pageno <= 1){ echo '#'; } else { echo "?formulario=$form_id&pageno=".($pageno - 1); } ?>">Anterior</a>
-
- <a class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>" href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?formulario=$form_id&pageno=".($pageno + 1); } ?>">Próxima</a>
- <a class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>" href="?formulario=<?= $form_id ?>&pageno=<?php echo $total_pages; ?>">Última</a>
- </div>
- </center>
- </body>
- </html>
|