segundo commit para testar
[LogadorPet.git] / submeter_p.php
blobcd080ef6fb882716233a0b9644774f3c05d3e6e2
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 */
6 header ("Pragma: no-cache"); // sempre carregar página (não vai ser armazenada no cache http 1,0
7 header("Cache-Control: no-cache, must-revalidate"); // idem http 1,1
9 //realiza a conexão com o banco de dados
10 require_once("Globals.php");
11 conecta();
14 <html>
15 <head>
16 <title>Submeter Pendente - Logador PET</title>
17 <script language="JavaScript" type="text/javascript">
19 Função para testar se todos os campos foram preenchidos
22 function checkrequired(which)
24 var pass=true
25 var dia=true
26 if (document.images)
28 for (i=0;i<which.length;i++)
30 var tempobj=which.elements[i]
31 if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value==''))
33 pass=false
34 break
39 if (document.form1.nome.value == "")
40 pass = false
42 if (!pass)
44 alert("Você não preencheu todos os campos!")
45 return false
50 function limita_tamanho(which,limite)
52 var tamanho;
53 var count;
54 tamanho = which.value.length;
55 if (tamanho > limite)
57 which.value = which.value.substring(0,limite);
59 document.getElementByID("contador").innerHTML = "Member";
62 function updateCount(textareaId, spanId, limite)
64 var tamanho;
65 textarea = document.getElementById(textareaId);
66 tamanho = textarea.value.length;
67 if (tamanho > limite)
69 textarea.value = textarea.value.substring(0,limite);
71 if (textarea == null)
73 return;
75 if (textarea.value.length > limite)
77 textarea.value = textarea.value.substring(0, limite);
79 document.getElementById(spanId).innerHTML = limite - textarea.value.length;
82 function $() {
83 var elements = new Array();
84 for (var i = 0; i < arguments.length; i++) {
85 var element = arguments[i];
86 if (typeof element == 'string')
87 element = document.getElementById(element);
88 if (arguments.length == 1)
89 return element;
90 elements.push(element);
92 return elements;
96 function mudaData()
98 var meses = new Array("janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro");
100 dia_i = $('dia').value;
101 mes_i = $('mes').value;
102 ano_i = $('ano').value;
103 var myday = new Date(""+ ano_i + "/" + mes_i + "/" +dia_i);
105 limit = 2;
107 selectBox = $('data_fim');
108 selectBox.options.length = 0;
109 myday.setDate(myday.getDate());
110 dia_f = myday.getDate();
111 mes_f = myday.getMonth()+1;
112 ano_f = myday.getFullYear();
113 selectBox.options[0] = new Option(dia_f + " " + meses[mes_f-1] + " " + ano_f);
115 for (i=1; i<limit; i++)
117 myday.setDate(myday.getDate()+1);
118 dia_f = myday.getDate();
119 mes_f = myday.getMonth()+1;
120 ano_f = myday.getFullYear();
121 selectBox.options[i] = new Option(dia_f + " " + meses[mes_f-1] + " " + ano_f);
125 </script>
126 <link rel="stylesheet" type="text/css" href="estilo.css">
127 </head>
128 <body onLoad="updateCount('justificativa', 'contador', 1024);mudaData()">
130 <form action="recebe_p.php" method="POST" name="form1" onSubmit="return checkrequired(this)">
131 <table border="2" class='bordasimples' align="center">
132 <thead>
133 <td colspan="6">
134 <center>
135 Solicitar Pendentes
136 </center>
137 </td>
138 </thead>
139 <tr class='tbrow'>
140 <td>Nome:</td>
141 <td colspan="5">
142 <SELECT id="user_id" name="user_id" style="width:340px">
143 <OPTION checked></OPTION>
144 <?php
145 // obtém os dados de todos os usuários
146 $usuario_nome = mysql_query("SELECT usuario.id_user AS id, usuario.login AS nome FROM usuario ORDER BY nome");
148 // pesquisa usuário um a um e define a opção para selecionar seu nome para indicar quem está solicitando pendentes
149 while ($usuario = mysql_fetch_array($usuario_nome))
151 $id = $usuario['id'];
152 $nome = $usuario['nome'];
153 echo "<option value=\"$id\">$nome";
156 </SELECT>
157 </td>
158 </tr>
159 <tr class='tbrow'>
160 <td width="50"></td>
161 <td>Dia</td>
162 <td>Mês</td>
163 <td>Ano</td>
164 <td>Hora</td>
165 <td>Minutos</td>
166 </tr>
167 <tr class='tbrow'>
168 <td>Início</td>
169 <td>
170 <select id="dia" name="dia" onChange="mudaData()">
171 <?php
173 // para todos os dias do mês, cria opções para selecionar o dia da pendente
174 for ($x=1;$x<=31;$x++)
176 if ($x<10)
177 $dia = "0$x";
178 else
179 $dia = $x;
181 echo "<option value=\"$dia\" ";
182 if ($dia == date('j'))
183 echo "selected";
184 echo ">$dia";
187 </select>
188 </td>
189 <td>
190 <!-- define as opções para selecionar o mês da pendente -->
191 <?php
193 echo "<select id='mes' name='mes' onChange='mudaData()'>";
195 for ($i = 1; $i <= sizeof($meses); $i++)
197 if ($i < 10)
198 $str = "0$i";
199 else
200 $str = $i;
201 echo "<option value=\"$str\" ";
202 if ($str == date('m'))
203 echo "selected";
204 echo ">" . $meses[$i-1];
207 echo "</select>";
209 </td>
210 <td>
211 <select id="ano" name="ano" onChange="mudaData()">
212 <?php
214 // para todos os anos entre atual e atual+1, oferece a opção de selecionar o ano específico da pendente
215 for ($x=(date('Y')-1);$x<=date('Y')+1;$x++)
217 echo "<option value=\"$x\" ";
218 if( $x == date('Y') )
219 echo "selected";
220 echo ">$x";
223 </select>
224 </td>
225 <td>
226 <select id="hora_i" name="hora_i">
227 <?php
228 // oferece opções para selecionar as horas do início da pendente
229 for ($x=0;$x<=23;$x++)
232 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
233 <?php
236 </select>
237 </td>
238 <td>
239 <select id="minuto_i" name="minuto_i">
240 <?php
241 // oferece opções para selecionar os minutos do início da pendente
242 for ($x=0;$x<=59;$x++)
245 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
246 <?php
249 </select>
250 </td>
251 </tr>
253 <tr class='tbrow'>
254 <td>Fim</td>
255 <td colspan="3">
256 <select id="data_fim" name="data_f" style="width:100%">
257 <option>
258 </select>
259 </td>
260 <td>
262 <select name="hora_f">
263 <?php
264 // oferece opções para selecionar a hora final da pendente
265 for ($x=0;$x<=23;$x++)
268 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
269 <?php
272 </select>
273 </td>
274 <td>
276 <select name="minuto_f">
277 <?php
278 // oferece opções para selecionar o minuto final da pendente
279 for ($x=0;$x<=59;$x++)
282 <option value=<?php if ($x<10) echo "0$x"; else echo $x; ?> > <?php if ($x<10) echo "0$x"; else echo $x; ?>
283 <?php
286 // fecha a conexão com o banco de dados
289 </select>
290 </td>
291 </tr>
293 <tr class='tbrow'>
294 <td>Local:</td>
295 <td colspan="5"><input type="text" name="local" style="width:340px"></td>
296 </tr>
298 <tr class='tbrow'>
299 <td>Justificativa:</td>
300 <td colspan="5">
301 <table style="border:0">
302 <tr>
303 <td><textarea id="justificativa" cols="40" rows="10" name="justificativa" onKeyUp="updateCount('justificativa', 'contador', 1024)"></textarea></td>
304 </tr>
305 <tr>
306 <td>Restam <i><span id="contador">1024</span></i> caracteres.</td>
307 </tr>
308 </table>
309 </td>
310 </tr>
312 <tr class='tbrow' align="center">
313 <td colspan="6">
314 <input type="submit" value="Enviar">&nbsp;&nbsp;<input type="reset" value="Limpar Dados">
315 </td>
316 </tr>
318 </table>
319 </form>
321 <center><a href="index.php"><< Voltar p/ Logador</a></center>
324 </body>
325 </html>