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'
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");
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
)
28 for (i
=0;i
<which
.length
;i++
)
30 var tempobj
=which
.elements
[i
]
31 if (((tempobj
.type
=="text"||tempobj
.type
=="textarea")&&tempobj
.value
==''))
39 if (document
.form1
.nome
.value
== "")
44 alert("Você não preencheu todos os campos!")
50 function limita_tamanho(which
,limite
)
54 tamanho
= which
.value
.length
;
57 which
.value
= which
.value
.substring(0,limite
);
59 document
.getElementByID("contador").innerHTML
= "Member";
62 function updateCount(textareaId
, spanId
, limite
)
65 textarea
= document
.getElementById(textareaId
);
66 tamanho
= textarea
.value
.length
;
69 textarea
.value
= textarea
.value
.substring(0,limite
);
75 if (textarea
.value
.length
> limite
)
77 textarea
.value
= textarea
.value
.substring(0, limite
);
79 document
.getElementById(spanId
).innerHTML
= limite
- textarea
.value
.length
;
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)
90 elements
.push(element
);
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
);
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
);
126 <link rel
="stylesheet" type
="text/css" href
="estilo.css">
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">
142 <SELECT id
="user_id" name
="user_id" style
="width:340px">
143 <OPTION checked
></OPTION
>
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";
170 <select id
="dia" name
="dia" onChange
="mudaData()">
173 // para todos os dias do mês, cria opções para selecionar o dia da pendente
174 for ($x=1;$x<=31;$x++
)
181 echo "<option value=\"$dia\" ";
182 if ($dia == date('j'))
190 <!-- define
as opções para selecionar o mês da pendente
-->
193 echo "<select id='mes' name='mes' onChange='mudaData()'>";
195 for ($i = 1; $i <= sizeof($meses); $i++
)
201 echo "<option value=\"$str\" ";
202 if ($str == date('m'))
204 echo ">" . $meses[$i-1];
211 <select id
="ano" name
="ano" onChange
="mudaData()">
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') )
226 <select id
="hora_i" name
="hora_i">
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; ?
>
239 <select id
="minuto_i" name
="minuto_i">
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; ?
>
256 <select id
="data_fim" name
="data_f" style
="width:100%">
262 <select name
="hora_f">
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; ?
>
276 <select name
="minuto_f">
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; ?
>
286 // fecha a conexão com o banco de dados
295 <td colspan
="5"><input type
="text" name
="local" style
="width:340px"></td
>
299 <td
>Justificativa
:</td
>
301 <table style
="border:0">
303 <td
><textarea id
="justificativa" cols
="40" rows
="10" name
="justificativa" onKeyUp
="updateCount('justificativa', 'contador', 1024)"></textarea
></td
>
306 <td
>Restam
<i
><span id
="contador">1024</span
></i
> caracteres
.</td
>
312 <tr
class='tbrow' align
="center">
314 <input type
="submit" value
="Enviar"> 
; 
;<input type
="reset" value
="Limpar Dados">
321 <center
><a href
="index.php"><< Voltar p
/ Logador
</a
></center
>