segundo commit para testar
[LogadorPet.git] / inserir_horas.php
blob125204e86b74689b25f292740a28dc581622893c
1 <?php
2 /* Submissão de Pendentes (submeter_p.php)
3 1. Recebe os dados selecionados pelo usuário para pendente
4 2. Possui link para redirecionar os dados para a página 'recebe_p.php'
5 */
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 //realiza a conexão com o banco de dados
11 require_once("Globals.php");
12 //verifica se o administrador está logado
13 checkCookie();
14 conecta();
18 <html>
19 <head>
20 <title>Inserir Horas - Logador PET</title>
21 <script language="JavaScript" type="text/javascript">
23 Função para testar se todos os campos foram preenchidos
26 function checkrequired(which)
28 pass = true;
29 if ($('user_id').value == "")
30 pass = false
32 if (!pass)
34 alert("Você não preencheu todos os campos!")
35 return false
40 function mudaData()
42 var meses = new Array("janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro");
44 dia_i = $('dia').value;
45 mes_i = $('mes').value;
46 ano_i = $('ano').value;
47 var myday = new Date(""+ ano_i + "/" + mes_i + "/" +dia_i);
49 limit = 2;
51 selectBox = $('data_fim');
52 selectBox.options.length = 0;
53 myday.setDate(myday.getDate());
54 dia_f = myday.getDate();
55 mes_f = myday.getMonth()+1;
56 ano_f = myday.getFullYear();
57 selectBox.options[0] = new Option(dia_f + " " + meses[mes_f-1] + " " + ano_f);
59 for (i=1; i<limit; i++)
61 myday.setDate(myday.getDate()+1);
62 dia_f = myday.getDate();
63 mes_f = myday.getMonth()+1;
64 ano_f = myday.getFullYear();
65 selectBox.options[i] = new Option(dia_f + " " + meses[mes_f-1] + " " + ano_f);
70 function $() {
71 var elements = new Array();
72 for (var i = 0; i < arguments.length; i++) {
73 var element = arguments[i];
74 if (typeof element == 'string')
75 element = document.getElementById(element);
76 if (arguments.length == 1)
77 return element;
78 elements.push(element);
80 return elements;
82 </script>
83 <link rel="stylesheet" type="text/css" href="estilo.css">
84 </head>
85 <body onLoad="mudaData()">
88 <form action="insere_horas.php" method="POST" name="form1" onSubmit="return checkrequired(this)">
89 <table border="2" class='bordasimples' align="center">
90 <thead>
91 <td colspan="6">
92 <center>
93 Inserir Horas
94 </center>
95 </td>
96 </thead>
97 <tr class='tbrow'>
98 <td>Nome:</td>
99 <td colspan="5">
100 <SELECT id="user_id" name="user_id" style="width:340px">
101 <OPTION checked></OPTION>
102 <?php
103 // obtém os dados de todos os usuários
104 $usuario_nome = mysql_query("SELECT usuario.id_user AS id, usuario.login AS nome FROM usuario ORDER BY nome");
106 // pesquisa usuário um a um e define a opção para selecionar seu nome para indicar quem está solicitando pendentes
107 while ($usuario = mysql_fetch_array($usuario_nome))
109 $id = $usuario['id'];
110 $nome = $usuario['nome'];
111 echo "<option value=\"$id\">$nome";
114 </SELECT>
115 </td>
116 </tr>
117 <tr class='tbrow noHover'>
118 <td width="50"></td>
119 <td>Dia</td>
120 <td>Mês</td>
121 <td>Ano</td>
122 <td>Hora</td>
123 <td>Minutos</td>
124 </tr>
125 <tr class='tbrow'>
126 <td>Início</td>
127 <td>
128 <select id="dia" name="dia" onChange="mudaData()">
129 <?php
131 // para todos os dias do mês, cria opções para selecionar o dia da pendente
132 for ($x=1;$x<=31;$x++)
134 if ($x<10)
135 $dia = "0$x";
136 else
137 $dia = $x;
139 echo "<option value=\"$dia\" ";
140 if ($dia == date('j'))
141 echo "selected";
142 echo ">$dia";
145 </select>
146 </td>
147 <td>
148 <!-- define as opções para selecionar o mês da pendente -->
149 <?php
151 echo "<select id='mes' name='mes' onChange='mudaData()'>";
153 for ($i = 1; $i <= sizeof($meses); $i++)
155 if ($i < 10)
156 $str = "0$i";
157 else
158 $str = $i;
159 echo "<option value=\"$str\" ";
160 if ($str == date('m'))
161 echo "selected";
162 echo ">" . $meses[$i-1];
165 echo "</select>";
167 </td>
168 <td>
169 <select id="ano" name="ano" onChange="mudaData()">
170 <?php
172 // para todos os anos entre atual e atual+1, oferece a opção de selecionar o ano específico da pendente
173 for ($x=(date('Y')-1);$x<=date('Y')+1;$x++)
175 echo "<option value=\"$x\" ";
176 if( $x == date('Y') )
177 echo "selected";
178 echo ">$x";
181 </select>
182 </td>
183 <td>
184 <select id="hora_i" name="hora_i">
185 <?php
186 // oferece opções para selecionar as horas do início da pendente
187 for ($x=0;$x<=23;$x++)
190 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
191 <?php
194 </select>
195 </td>
196 <td>
197 <select id="minuto_i" name="minuto_i">
198 <?php
199 // oferece opções para selecionar os minutos do início da pendente
200 for ($x=0;$x<=59;$x++)
203 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
204 <?php
207 </select>
208 </td>
209 </tr>
211 <tr class='tbrow'>
212 <td>Fim</td>
213 <td colspan="3">
214 <select id="data_fim" name="data_f" style="width:100%">
215 <option>
216 </select>
217 </td>
218 <td>
220 <select name="hora_f">
221 <?php
222 // oferece opções para selecionar a hora final da pendente
223 for ($x=0;$x<=23;$x++)
226 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
227 <?php
230 </select>
231 </td>
232 <td>
234 <select name="minuto_f">
235 <?php
236 // oferece opções para selecionar o minuto final da pendente
237 for ($x=0;$x<=59;$x++)
240 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
241 <?php
244 // fecha a conexão com o banco de dados
247 </select>
248 </td>
249 </tr>
251 <tr class='tbrow' align="center">
252 <td colspan="6">
253 <input type="submit" value="Enviar">&nbsp;&nbsp;<input type="reset" value="Limpar Dados">
254 </td>
255 </tr>
257 </table>
258 </form>
261 <center>
262 <a href="admin.php"><< Administrador</a><br>
263 <a href="index.php"><< Logador </a><br>
264 </center>
265 </body>
266 </html>