segundo commit para testar
[LogadorPet.git] / enviar_mensagem.php
blobd8ab3fb4c65d417bb9b2141e8a827743fe947ba5
1 <?php
2 /* Envio de Mensagens ao Usuário (submeter_p.php)
3 1. Recebe o texto que formará a mensagem a ser encaminhada ao Administrador
4 2. Possui link para redirecionar os dados para a página 'envia_mensagem.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 require_once("Globals.php");
10 // realiza conexão com o banco de dados
11 conecta();
13 if( isset($_GET['id_to']) && ($_GET['id_to']) )
14 $id_to = $_GET['id_to'];
18 <html>
19 <head>
20 <title>Enviar Mensagem - Logador PET</title>
21 <link rel="stylesheet" type="text/css" href="estilo.css">
22 <script language="JavaScript" type="text/javascript">
24 Função para testar se todos os campos foram preenchidos
27 function checkrequired(which)
29 var pass=true
30 if (document.images)
32 for (i=0;i<which.length;i++)
34 var tempobj=which.elements[i];
35 if (((tempobj.type=="texto"||tempobj.type=="textarea"||tempobj.type=="select-one")&&tempobj.value==''))
37 pass=false
38 break
44 if (!pass)
46 alert("Você não preencheu todos os campos!")
47 return false
52 function limita_tamanho(which,limite)
54 var tamanho;
55 var count;
56 tamanho = which.value.length;
57 if (tamanho > limite)
59 which.value = which.value.substring(0,limite);
61 document.getElementByID("contador").innerHTML = "Member";
64 function updateCount(textareaId, spanId, limite)
66 var tamanho;
67 textarea = document.getElementById(textareaId);
68 tamanho = textarea.value.length;
69 if (tamanho > limite)
71 textarea.value = textarea.value.substring(0,limite);
73 if (textarea == null)
75 return;
77 if (textarea.value.length > limite)
79 textarea.value = textarea.value.substring(0, limite);
81 document.getElementById(spanId).innerHTML = limite - textarea.value.length;
83 </script>
84 </head>
85 <body>
87 <?php
88 if(!isset($id_to))
89 echo "<center><h2>Enviar Mensagem</h2></center>";
92 <form action="envia_mensagem.php" method="POST" name="form1" onsubmit="return checkrequired(this)">
93 <table border="2" class='bordasimples' align="center">
94 <thead>
95 <td colspan="6">
96 <center>
97 Enviar Mensagem
98 </center>
99 </td>
100 </thead>
101 <?php
102 // obtém os dados de todos os usuários
103 $usuario_nome = mysql_query("SELECT usuario.id_user AS id, usuario.login AS nome FROM usuario ORDER BY nome");
104 $usuarios = array();
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))
110 $id = $usuario['id'];
111 $nome = $usuario['nome'];
112 $usuarios[] = array("id"=>$id, "nome"=>$nome);
116 <tr class='tbrow noHover'>
117 <td>Remetente:</td>
118 <td>
119 <SELECT id="user_id_from" name="user_id_from" style="width:340px">
120 <OPTION checked value=""></OPTION>
121 <?php
122 foreach($usuarios as $usuario)
123 echo "<option value=\"". $usuario['id'] ."\">". $usuario['nome'];
125 </SELECT>
126 </td>
127 </tr>
129 <?php
130 if(!isset($id_to))
133 <tr class='tbrow noHover'>
134 <td>Destinatário:</td>
135 <td>
136 <SELECT id="user_id_to" name="user_id_to" style="width:340px">
137 <OPTION checked value="0">Administrador</OPTION>
138 <optgroup label="Usuários">
139 <?php
140 foreach($usuarios as $usuario)
141 echo "<option value=\"". $usuario['id'] ."\">". $usuario['nome'];
143 </optgroup>
144 </SELECT>
145 </td>
146 </tr>
149 else
151 echo "<input type='hidden' name='user_id_to' value='". $id_to ."'>";
156 <tr class='tbrow noHover'>
157 <td>Mensagem:</td>
158 <td>
159 <table style="border:0">
160 <tr>
161 <td><textarea id="texto" cols="40" rows="10" name="texto" onKeyUp="updateCount('texto', 'contador', 1024)"></textarea></td>
162 </tr>
163 <tr>
164 <td>Restam <i><span id="contador">1024</span></i> caracteres.</td>
165 </tr>
166 </table>
167 </td>
168 </tr>
170 <tr class='tbrow noHover' align="center">
171 <td colspan="6">
172 <?php
173 if(!isset($id_to))
174 echo "<input type='hidden' name='quick_send' value='0'>";
175 else
176 echo "<input type='hidden' name='quick_send' value='1'>";
178 <input type="submit" value="Enviar">&nbsp;&nbsp;<input type="reset" value="Limpar Dados">
179 </td>
180 </tr>
181 </table>
182 </form>
184 <center><a href="index.php"><< Voltar p/ Logador</a></center>
186 </body>
187 </html>