segundo commit para testar
[LogadorPet.git] / adm_p.php
blobc812a045e4e80fef0bf27855a048030411dfe788
1 <?php
2 /* Administrar Pendentes e Pendentes Esquecidas (adm_p.php)
3 1. Mostra a tabela com todas as pendentes existentes
4 2. Oferece botões de 'Aceitar' e 'Rejeitar' para cada pendente
5 3. Caso admin
6 */
7 header ("Pragma: no-cache"); // sempre carregar página (não vai ser armazenada no cache http 1,0
8 header("Cache-Control: no-cache, must-revalidate"); // idem http 1,1
10 require_once("Globals.php");
11 //verifica se o administrador está logado
12 checkCookie();
13 // realiza conexão com o banco de dados
14 conecta();
16 if(isset($_GET['passado']))
18 $title = "Pendentes Esquecidas";
19 $sinal_sql = "<=";
20 $action = "valida_p.php?passado";
22 else
24 $title = "Administrar Pendentes";
25 $sinal_sql = ">";
26 $action = "valida_p.php";
30 <html>
31 <head>
32 <title><?php echo $title; ?> - Logador PET</title>
33 <link rel="stylesheet" type="text/css" href="estilo.css">
34 </head>
35 <body>
36 <center><h2> <?php echo $title; ?> </h2></center>
39 <?php
42 // obtém todas as pendentes existentes da tabela pendentes
43 $sql = "SELECT
44 pendentes.id AS pendId,
45 usuario.login AS nome,
46 DATE_FORMAT(pendentes.inicio, '%d/%m/%Y %H:%i:%s') AS inicio,
47 UNIX_TIMESTAMP(inicio) as unix_inicio,
48 DATE_FORMAT(pendentes.fim, '%d/%m/%Y %H:%i:%s') AS fim,
49 TIMEDIFF(pendentes.fim, pendentes.inicio) AS diferenca,
50 local,
51 justificativa
52 FROM
53 config,
54 pendentes
55 JOIN
56 usuario
57 ON usuario.id_user = pendentes.id_user
58 WHERE fim ".$sinal_sql." config.mes_anterior
59 ORDER BY unix_inicio ASC, nome ASC";
60 $pesq_pend = mysql_query($sql);
62 // se existir pelo menos 1 pendente, cria a tabela de pendentes
63 if (mysql_num_rows($pesq_pend)>0)
67 <table border=2 class="bordasimples" align="center">
68 <thead>
69 <th width="100">
70 <center>
71 Nome
72 </center>
73 </th>
74 <th>
75 <center>
76 Início
77 </center>
78 </th>
79 <th>
80 <center>
81 Fim
82 </center>
83 </th>
84 <th>
85 <center>
86 Tempo Total
87 </center>
88 </th>
89 <th width="100">
90 <center>
91 Local
92 </center>
93 </th>
94 <th width="200">
95 <center>
96 Justificativa
97 </center>
98 </th>
99 <th>
100 <center>
101 &nbsp;
102 </center>
103 </th>
104 <th>
105 <center>
106 &nbsp;
107 </center>
108 </th>
109 </thead>
111 <?php
113 while($usuario = mysql_fetch_array($pesq_pend))
116 <form action="<?php echo $action; ?>" method="POST">
117 <input type="hidden" name="pendId" value="<?php echo $usuario['pendId'];?>" />
118 <tr class='tbrow'>
119 <td><?php echo $usuario['nome']; ?></td>
120 <td><?php echo $usuario['inicio']; ?></td>
121 <td><?php echo $usuario['fim']; ?></td>
122 <td><center><?php echo $usuario['diferenca']; ?></center></td>
123 <td><?php echo $usuario['local']; ?></td>
124 <td><?php echo $usuario['justificativa']; ?></td>
125 <td>
126 <input type="submit" name="val" value="Aceitar">
127 </td>
128 <td>
129 <input type="submit" name="val" value="Rejeitar">
130 </td>
131 </tr>
132 </form>
135 <?php
139 </table>
140 <?php
142 } // caso não haja nenhuma pendente
143 else
145 echo "<center style='color: #ff0000;'>Sem pendentes!!!</center>";
147 echo "<br><br>";
149 <center>
150 <a href="admin.php"><< Administrador</a><br>
151 <a href="index.php"><< Logador</a>
152 </center>
159 </body>
160 </html>