修订版 | 13 (tree) |
---|---|
时间 | 2020-02-18 05:17:24 |
作者 | derekwildstar |
Implementada função para limpar a lista de mensagens do CiCoD, liberando da memória os itens que tem a propriedade Data definida
Implementado em cico.php o histórico. Ajustes nas endentações e estilos
Ajustada a função effectiveMessage em index.php
@@ -89,6 +89,7 @@ | ||
89 | 89 | <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes> |
90 | 90 | <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> |
91 | 91 | <VerInfo_Locale>1033</VerInfo_Locale> |
92 | + <Debugger_RunParams>u 02322719412 9722701c</Debugger_RunParams> | |
92 | 93 | <AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode> |
93 | 94 | </PropertyGroup> |
94 | 95 | <PropertyGroup Condition="'$(Cfg_2)'!=''"> |
@@ -44,6 +44,7 @@ | ||
44 | 44 | function ObterMatricula(ACPFMatricula: String): String; |
45 | 45 | procedure MensagensAProcessar; |
46 | 46 | procedure ProcessarMensagens; |
47 | + procedure LimparMensagensAProcessar; | |
47 | 48 | procedure ConfigToGUI; |
48 | 49 | procedure GUIToConfig; |
49 | 50 | procedure ConnectToDataBase; |
@@ -84,10 +85,8 @@ | ||
84 | 85 | procedure TDAMOPrincipal.DataModuleDestroy(Sender: TObject); |
85 | 86 | begin |
86 | 87 | GUIToConfig; |
87 | - if Length(FMensagensAProcessar) > 0 then | |
88 | 88 | |
89 | - for var MAP: TMensagemAProcessar in FMensagensAProcessar do | |
90 | - MAP.Free; | |
89 | + LimparMensagensAProcessar; | |
91 | 90 | end; |
92 | 91 | |
93 | 92 | procedure TDAMOPrincipal.FDCOBeforeConnect(Sender: TObject); |
@@ -103,8 +102,12 @@ | ||
103 | 102 | MAP: TMensagemAProcessar; |
104 | 103 | begin |
105 | 104 | try |
105 | + LimparMensagensAProcessar; | |
106 | + | |
106 | 107 | FMensagensAProcessar := GetCheckInCheckOutPortType(False,FAddr).MensagensAProcessar; |
107 | 108 | |
109 | + // Manterá na tela a última troca de mensagens, até que novas mensagens | |
110 | + // cheguem | |
108 | 111 | if Length(FMensagensAProcessar) > 0 then |
109 | 112 | TFORMPrincipal(Owner).LIVIMensagens.ClearEx; |
110 | 113 |
@@ -277,6 +280,14 @@ | ||
277 | 280 | Result := (Length(ACheckInChecOutInfo.History) > 0) and (ACheckInChecOutInfo.History[High(ACheckInChecOutInfo.History)].Direction = 'ci') |
278 | 281 | end; |
279 | 282 | |
283 | +procedure TDAMOPrincipal.LimparMensagensAProcessar; | |
284 | +begin | |
285 | + for var MAP: TMensagemAProcessar in FMensagensAProcessar do | |
286 | + MAP.Free; | |
287 | + | |
288 | + SetLength(FMensagensAProcessar,0); | |
289 | +end; | |
290 | + | |
280 | 291 | procedure TDAMOPrincipal.ProcessarMensagens; |
281 | 292 | var |
282 | 293 | MAP: TMensagemAProcessar; |
@@ -3,185 +3,198 @@ | ||
3 | 3 | // "colapsar" os códigos de forma organizada |
4 | 4 | $resposta = null; |
5 | 5 | |
6 | +// Funções anônimas para uso dentro da sintaxe heredoc | |
7 | +$simOuNao = function($valor) { return $valor=="1"?"Sim":"Não"; }; | |
8 | +$checkInCheckOut = function($valor) { return $valor=="ci"?"Check-In":"Check-Out"; }; | |
9 | + | |
6 | 10 | //$_POST["cpf"] = "02322719412"; |
7 | 11 | //$_POST["matricula"] = "1842951"; |
8 | 12 | |
9 | -if ((isset($_POST["cpf"]) && $_POST["cpf"] != "") && (isset($_POST["matricula"]) && $_POST["matricula"] != "") && (isset($_POST["ci"]) || isset($_POST["co"]) || isset($_POST["ss"]) || isset($_POST["ms"]) || isset($_POST["sa"]))) | |
13 | +if ((isset($_POST["cpf"]) && $_POST["cpf"] != "") && (isset($_POST["matricula"]) && $_POST["matricula"] != "") && (isset($_POST["ci"]) || isset($_POST["co"]) || isset($_POST["ms"]) || isset($_POST["sa"]) || isset($_POST["hi"]))) | |
10 | 14 | { |
11 | - error_reporting(E_ALL ^ E_DEPRECATED); | |
12 | - require("./lib/nusoap.php"); | |
15 | + error_reporting(E_ALL ^ E_DEPRECATED); | |
16 | + require("./lib/nusoap.php"); | |
13 | 17 | |
14 | - $wsdl = null; | |
15 | - | |
16 | - if ($_SERVER["SERVER_NAME"] == "localhost") | |
17 | - { | |
18 | - $wsdl = "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . str_replace("\\","/",dirname($_SERVER["REQUEST_URI"])) . "?wsdl"; | |
19 | - } | |
20 | - else | |
21 | - { | |
22 | - $wsdl = "http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["REQUEST_URI"]) . "/?wsdl"; | |
23 | - } | |
24 | - | |
25 | - $client = new nusoap_client($wsdl, "wsdl"); | |
26 | - $client->soap_defencoding = "utf-8"; | |
27 | - $err = $client->getError(); | |
28 | - | |
29 | - if ($err) | |
30 | - { | |
31 | - $resposta = <<<EOH | |
32 | - <table class="erro" border="1"> | |
33 | - <tr> | |
34 | - <td align="center">Não foi possível criar o cliente de acesso ao WebService</td> | |
35 | - </tr> | |
36 | - <tr> | |
37 | - <td>$err</td> | |
38 | - </tr> | |
39 | - </table> | |
18 | + $wsdl = null; | |
19 | + | |
20 | + if ($_SERVER["SERVER_NAME"] == "localhost") | |
21 | + { | |
22 | + $wsdl = "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . str_replace("\\","/",dirname($_SERVER["REQUEST_URI"])) . "?wsdl"; | |
23 | + } | |
24 | + else | |
25 | + { | |
26 | + $wsdl = "http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["REQUEST_URI"]) . "/?wsdl"; | |
27 | + } | |
28 | + | |
29 | + $client = new nusoap_client($wsdl, "wsdl"); | |
30 | + $client->soap_defencoding = "utf-8"; | |
31 | + $err = $client->getError(); | |
32 | + | |
33 | + if ($err) | |
34 | + { | |
35 | + $resposta = <<<EOH | |
36 | + <table class="erro" border="1"> | |
37 | + <tr> | |
38 | + <td align="center">Não foi possível criar o cliente de acesso ao WebService</td> | |
39 | + </tr> | |
40 | + <tr> | |
41 | + <td>$err</td> | |
42 | + </tr> | |
43 | + </table> | |
44 | + | |
40 | 45 | EOH; |
41 | - } | |
42 | - else | |
43 | - { | |
44 | - $cpfmatricula = $_POST["cpf"] . $_POST["matricula"]; | |
45 | - | |
46 | - if (isset($_POST["ci"])) | |
47 | - { | |
48 | - $result = $client->call("CheckInMessage", array("ACPFMatricula"=>$cpfmatricula)); | |
49 | - | |
50 | - if (isset($result["faultcode"]) && ($result["faultcode"] == "SOAP-ENV:Server")) | |
51 | - { | |
52 | - $resposta = <<<EOH | |
53 | - <table class="erro" border="1"> | |
54 | - <tr> | |
55 | - <td align="center">{$result["faultstring"]}</td> | |
56 | - </tr> | |
57 | - <tr> | |
58 | - <td>{$result["detail"]}</td> | |
59 | - </tr> | |
60 | - </table> | |
46 | + } | |
47 | + else | |
48 | + { | |
49 | + $cpfmatricula = $_POST["cpf"] . $_POST["matricula"]; | |
50 | + | |
51 | + if (isset($_POST["ci"])) // Check-In | |
52 | + { | |
53 | + $result = $client->call("CheckInMessage", array("ACPFMatricula"=>$cpfmatricula)); | |
54 | + | |
55 | + if (isset($result["faultcode"]) && ($result["faultcode"] == "SOAP-ENV:Server")) | |
56 | + { | |
57 | + $resposta = <<<EOH | |
58 | + <table class="erro" border="1"> | |
59 | + <tr> | |
60 | + <td align="center">{$result["faultstring"]}</td> | |
61 | + </tr> | |
62 | + <tr> | |
63 | + <td>{$result["detail"]}</td> | |
64 | + </tr> | |
65 | + </table> | |
66 | + | |
61 | 67 | EOH; |
62 | - } | |
63 | - else | |
64 | - { | |
65 | - $result = str_replace("T"," ",$result); | |
66 | - $result = str_replace("-03:00","",$result); | |
68 | + } | |
69 | + else | |
70 | + { | |
71 | + $result = str_replace("T"," ",$result); | |
72 | + $result = str_replace("-03:00","",$result); | |
67 | 73 | |
68 | - $resposta = <<<EOH | |
69 | - <table class="sucesso" border="1"> | |
70 | - <tr> | |
71 | - <td align="center">Sucesso!</td> | |
72 | - </tr> | |
73 | - <tr> | |
74 | - <td>Mensagem de Check-In enviada em $result. Verifique seu status em 2 minutos para saber se a mensagem foi processada pelo CiCo Deamon</td> | |
75 | - </tr> | |
76 | - </table> | |
74 | + $resposta = <<<EOH | |
75 | + <table class="sucesso" border="1"> | |
76 | + <tr> | |
77 | + <td align="center">Sucesso!</td> | |
78 | + </tr> | |
79 | + <tr> | |
80 | + <td>Mensagem de Check-In enviada em $result. Verifique seu status em 2 minutos para saber se a mensagem foi processada pelo CiCo Deamon</td> | |
81 | + </tr> | |
82 | + </table> | |
83 | + | |
77 | 84 | EOH; |
78 | - } | |
79 | - } | |
80 | - else if (isset($_POST["co"])) | |
81 | - { | |
82 | - $result = $client->call("CheckOutMessage", array("ACPFMatricula"=>$cpfmatricula)); | |
83 | - | |
84 | - if (isset($result["faultcode"]) && ($result["faultcode"] == "SOAP-ENV:Server")) | |
85 | - { | |
86 | - $resposta = <<<EOH | |
87 | - <table class="erro" border="1"> | |
88 | - <tr> | |
89 | - <td align="center">{$result["faultstring"]}</td> | |
90 | - </tr> | |
91 | - <tr> | |
92 | - <td>{$result["detail"]}</td> | |
93 | - </tr> | |
94 | - </table> | |
85 | + } | |
86 | + } | |
87 | + else if (isset($_POST["co"])) // Check-Out | |
88 | + { | |
89 | + $result = $client->call("CheckOutMessage", array("ACPFMatricula"=>$cpfmatricula)); | |
90 | + | |
91 | + if (isset($result["faultcode"]) && ($result["faultcode"] == "SOAP-ENV:Server")) | |
92 | + { | |
93 | + $resposta = <<<EOH | |
94 | + <table class="erro" border="1"> | |
95 | + <tr> | |
96 | + <td align="center">{$result["faultstring"]}</td> | |
97 | + </tr> | |
98 | + <tr> | |
99 | + <td>{$result["detail"]}</td> | |
100 | + </tr> | |
101 | + </table> | |
102 | + | |
95 | 103 | EOH; |
96 | - } | |
97 | - else | |
98 | - { | |
99 | - $result = str_replace("T"," ",$result); | |
100 | - $result = str_replace("-03:00","",$result); | |
101 | - | |
102 | - $resposta = <<<EOH | |
103 | - <table class="sucesso" border="1"> | |
104 | - <tr> | |
105 | - <td align="center">Sucesso!</td> | |
106 | - </tr> | |
107 | - <tr> | |
108 | - <td>Mensagem de Check-Out enviada em $result. Verifique seu status em 2 minutos para saber se a mensagem foi processada pelo CiCo Deamon</td> | |
109 | - </tr> | |
110 | - </table> | |
104 | + } | |
105 | + else | |
106 | + { | |
107 | + $result = str_replace("T"," ",$result); | |
108 | + $result = str_replace("-03:00","",$result); | |
109 | + | |
110 | + $resposta = <<<EOH | |
111 | + <table class="sucesso" border="1"> | |
112 | + <tr> | |
113 | + <td align="center">Sucesso!</td> | |
114 | + </tr> | |
115 | + <tr> | |
116 | + <td>Mensagem de Check-Out enviada em $result. Verifique seu status em 2 minutos para saber se a mensagem foi processada pelo CiCo Deamon</td> | |
117 | + </tr> | |
118 | + </table> | |
119 | + | |
111 | 120 | EOH; |
112 | - } | |
113 | - } | |
114 | - else if (isset($_POST["sa"])) | |
115 | - { | |
116 | - $result = $client->call("StatusAtual", array("ACPFMatricula"=>$cpfmatricula)); | |
117 | - | |
118 | - if (isset($result["faultcode"]) && ($result["faultcode"] == "SOAP-ENV:Server")) | |
119 | - { | |
120 | - $resposta = <<<EOH | |
121 | - <table class="erro" border="1"> | |
122 | - <tr> | |
123 | - <td align="center">{$result["faultstring"]}</td> | |
124 | - </tr> | |
125 | - <tr> | |
126 | - <td>{$result["detail"]}</td> | |
127 | - </tr> | |
128 | - </table> | |
121 | + } | |
122 | + } | |
123 | + else if (isset($_POST["sa"])) // Status Atual | |
124 | + { | |
125 | + $result = $client->call("StatusAtual", array("ACPFMatricula"=>$cpfmatricula)); | |
126 | + | |
127 | + if (isset($result["faultcode"]) && ($result["faultcode"] == "SOAP-ENV:Server")) | |
128 | + { | |
129 | + $resposta = <<<EOH | |
130 | + <table class="erro" border="1"> | |
131 | + <tr> | |
132 | + <td align="center">{$result["faultstring"]}</td> | |
133 | + </tr> | |
134 | + <tr> | |
135 | + <td>{$result["detail"]}</td> | |
136 | + </tr> | |
137 | + </table> | |
138 | + | |
129 | 139 | EOH; |
130 | - | |
131 | - | |
132 | - } | |
133 | - else if (isset($result) && $result) | |
134 | - { | |
135 | - $resposta = <<<EOH | |
136 | - <table class="sucesso" border="1"> | |
137 | - <tr> | |
138 | - <td width="50%">Status atual</td><td width="50%">Confirmado em</td> | |
139 | - </tr> | |
140 | + | |
141 | + | |
142 | + } | |
143 | + else if (isset($result) && $result) | |
144 | + { | |
145 | + $resposta = <<<EOH | |
146 | + <table class="sucesso" border="1"> | |
147 | + <tr> | |
148 | + <td width="50%">Status atual</td><td width="50%">Confirmado em</td> | |
149 | + </tr> | |
150 | + | |
140 | 151 | EOH; |
141 | - // Uma resposta foi obtida do servidor, no entanto precisamos | |
142 | - // verificar se ela pertence a um dia anterior, pois neste caso, | |
143 | - // o sistema deve reportar como se o usuário estivesse no estado | |
144 | - // Checked-Out | |
145 | - if (date("Y-m-d") != substr($result["Momento"],0,10)) | |
146 | - { | |
147 | - $statusAtual = 'Checked-Out'; | |
148 | - $momento = date("Y-m-d 00:00:00"); | |
149 | - } | |
150 | - else | |
151 | - { | |
152 | - if ($result["CheckedIn"]) { | |
153 | - $statusAtual = 'Checked-In'; | |
154 | - } else { | |
155 | - $statusAtual = 'Checked-Out'; | |
156 | - } | |
157 | - | |
158 | - $momento = $result["Momento"]; | |
159 | - } | |
152 | + // Uma resposta foi obtida do servidor, no entanto precisamos | |
153 | + // verificar se ela pertence a um dia anterior, pois neste caso, | |
154 | + // o sistema deve reportar como se o usuário estivesse no estado | |
155 | + // Checked-Out | |
156 | + if (date("Y-m-d") != substr($result["Momento"],0,10)) | |
157 | + { | |
158 | + $statusAtual = 'Checked-Out'; | |
159 | + $momento = date("Y-m-d 00:00:00"); | |
160 | + } | |
161 | + else | |
162 | + { | |
163 | + if ($result["CheckedIn"]) { | |
164 | + $statusAtual = 'Checked-In'; | |
165 | + } else { | |
166 | + $statusAtual = 'Checked-Out'; | |
167 | + } | |
168 | + | |
169 | + $momento = $result["Momento"]; | |
170 | + } | |
160 | 171 | |
161 | - $resposta .= <<<EOH | |
162 | - <tr> | |
163 | - <td>$statusAtual</td><td>$momento</td> | |
164 | - </tr> | |
165 | - </table> | |
166 | - <i>Atenção:<br>Este resultado pode não ser o resultado real pois ele se baseia apenas na fila de mensagens assíncrona. Caso um Check-In ou um Check-Out tenha sido realizado através do Cliente CiCo ou do sistema oficial de controle de frequência poderá haver resultados diversos. Um status Checked-Out com um momento igual a zero hora do dia atual significa que o último status real foi confirmado no dia anterior. O sistema de controle de frequência automaticamente considera que à meia noite todos os usuários fazem Check-Out</i> | |
172 | + $resposta .= <<<EOH | |
173 | + <tr> | |
174 | + <td>$statusAtual</td><td>$momento</td> | |
175 | + </tr> | |
176 | + </table> | |
177 | + <i>Atenção:<br>Este resultado pode não ser o resultado real pois ele se baseia apenas na fila de mensagens assíncrona. Caso um Check-In ou um Check-Out tenha sido realizado através do Cliente CiCo ou do sistema oficial de controle de frequência poderá haver resultados diversos. Um status Checked-Out com um momento igual a zero hora do dia atual significa que o último status real foi confirmado no dia anterior. O sistema de controle de frequência automaticamente considera que à meia noite todos os usuários fazem Check-Out</i> | |
178 | + | |
167 | 179 | EOH; |
168 | - } | |
169 | - else | |
170 | - { | |
171 | - $resposta = <<<EOH | |
172 | - <table class="erro" border="1"> | |
173 | - <tr> | |
174 | - <td align="center">Nenhum resultado foi obtido / Status atual indefinido</td> | |
175 | - </tr> | |
176 | - <tr> | |
177 | - <td>1) Verifique seu CPF e sua matrícula. Você pode ter digitado algo errado<br>2) O CiCo Daemon ainda não enviou nehuma resposta positiva. Tente novamente mais tarde<br>3) Se este resultado persistir por muito tempo, tente realizar novamente seu Check-In ou Check-Out</td> | |
178 | - </tr> | |
179 | - </table> | |
180 | + } | |
181 | + else | |
182 | + { | |
183 | + $resposta = <<<EOH | |
184 | + <table class="erro" border="1"> | |
185 | + <tr> | |
186 | + <td align="center">Nenhum resultado foi obtido / Status atual indefinido</td> | |
187 | + </tr> | |
188 | + <tr> | |
189 | + <td>1) Verifique seu CPF e sua matrícula. Você pode ter digitado algo errado<br>2) O CiCo Daemon ainda não enviou nehuma resposta positiva. Tente novamente mais tarde<br>3) Se este resultado persistir por muito tempo, tente realizar novamente seu Check-In ou Check-Out</td> | |
190 | + </tr> | |
191 | + </table> | |
192 | + | |
180 | 193 | EOH; |
181 | - } | |
182 | - } | |
183 | - else if (isset($_POST["ms"])) | |
184 | - { | |
194 | + } | |
195 | + } | |
196 | + else if (isset($_POST["ms"])) // ??? | |
197 | + { | |
185 | 198 | /* |
186 | 199 | último status confirmado. Se nada for retornado, nenhum status foi confirmado |
187 | 200 | e consequentemente o status atual é indefinido |
@@ -188,18 +201,18 @@ | ||
188 | 201 | removendo a condição de feito mostra um historico geral de mensagens |
189 | 202 | processadas (é necessário remover o order by e o limit) |
190 | 203 | select men.id as idRequisicao |
191 | - , men.de as idUsuario | |
192 | - , men.mensagem as requisicao | |
193 | - , men.envio as enviadaEm | |
194 | - , men2.id as idResposta | |
195 | - , men2.mensagem as resposta | |
196 | - , men2.envio as respondidaEm | |
197 | - from mensagens men | |
198 | - join mensagens men2 on men.id = men2.idpai | |
204 | + , men.de as idUsuario | |
205 | + , men.mensagem as requisicao | |
206 | + , men.envio as enviadaEm | |
207 | + , men2.id as idResposta | |
208 | + , men2.mensagem as resposta | |
209 | + , men2.envio as respondidaEm | |
210 | + from mensagens men | |
211 | + join mensagens men2 on men.id = men2.idpai | |
199 | 212 | where men.de = '023227194121842951' |
200 | - and men.processada = 1 | |
201 | - and men2.mensagem = 'Feito!' -- remova pra obter um historico geral | |
202 | -order by men.id desc | |
213 | + and men.processada = 1 | |
214 | + and men2.mensagem = 'Feito!' -- remova pra obter um historico geral | |
215 | +order by men.id desc | |
203 | 216 | limit 1 |
204 | 217 | |
205 | 218 |
@@ -208,193 +221,297 @@ | ||
208 | 221 | incluindo todos os erros. Se uma mensagem ainda não teve qualquer resposta (positiva ou negativa) ela não será exibida |
209 | 222 | trocando 0 por 1 mostra a última mensagem processada positivamente |
210 | 223 | select men.id as idRequisicao |
211 | - , men.de as idUsuario | |
212 | - , men.mensagem as requisicao | |
213 | - , men.envio as enviadaEm | |
214 | - , men2.id as idResposta | |
215 | - , men2.mensagem as resposta | |
216 | - , men2.envio as respondidaEm | |
217 | - from mensagens men | |
218 | - join mensagens men2 on men.id = men2.idpai | |
224 | + , men.de as idUsuario | |
225 | + , men.mensagem as requisicao | |
226 | + , men.envio as enviadaEm | |
227 | + , men2.id as idResposta | |
228 | + , men2.mensagem as resposta | |
229 | + , men2.envio as respondidaEm | |
230 | + from mensagens men | |
231 | + join mensagens men2 on men.id = men2.idpai | |
219 | 232 | where men.de = '023227194151842951' |
220 | - and men.processada = 0 | |
233 | + and men.processada = 0 | |
221 | 234 | order by men2.id desc |
222 | 235 | limit 1 |
223 | - | |
236 | + | |
224 | 237 | */ |
225 | - | |
238 | + | |
226 | 239 | |
227 | - | |
240 | + | |
228 | 241 | // O bloco abaixo mostra todo o histórico de mensagens, talvez seja |
229 | -// interressante mostrar isso em forma de árvore, já que uma mensagem pode receber várias respostas | |
230 | -// if (file_exists("./db/cico.db")) { | |
231 | -// $db = new PDO("sqlite:./db/cico.db",null,null,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); | |
232 | -// try { | |
233 | -// $sql = <<<EOS | |
234 | -// select id as idrequisicao | |
235 | -// , null as idresposta | |
236 | -// , de | |
237 | -// , para | |
238 | -// , envio | |
239 | -// , mensagem | |
240 | -// , processada | |
241 | -// from mensagens | |
242 | -// where de = '$cpfmatricula' | |
242 | +// interressante mostrar isso em forma de árvore, já que uma mensagem pode receber várias respostas | |
243 | +// if (file_exists("./db/cico.db")) { | |
244 | +// $db = new PDO("sqlite:./db/cico.db",null,null,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); | |
245 | +// try { | |
246 | +// $sql = <<<EOS | |
247 | +// select id as idrequisicao | |
248 | +// , null as idresposta | |
249 | +// , de | |
250 | +// , para | |
251 | +// , envio | |
252 | +// , mensagem | |
253 | +// , processada | |
254 | +// from mensagens | |
255 | +// where de = '$cpfmatricula' | |
243 | 256 | //union |
244 | -// select idpai as idrequisicao | |
245 | -// , id as idresposta | |
246 | -// , de | |
247 | -// , para | |
248 | -// , envio | |
249 | -// , mensagem | |
250 | -// , null as processada | |
251 | -// from mensagens | |
252 | -// where para = '$cpfmatricula' | |
257 | +// select idpai as idrequisicao | |
258 | +// , id as idresposta | |
259 | +// , de | |
260 | +// , para | |
261 | +// , envio | |
262 | +// , mensagem | |
263 | +// , null as processada | |
264 | +// from mensagens | |
265 | +// where para = '$cpfmatricula' | |
253 | 266 | //EOS; |
254 | -// $resultSet = $db->query($sql); | |
255 | -// $resposta = <<<EOH | |
256 | -// <table class="status" border="1"> | |
257 | -// <tr> | |
258 | -// <td>idrequisicao</td><td>idresposta</td><td>de</td><td>para</td><td>envio</td><td>mensagem</td><td>processada</td> | |
259 | -// </tr> | |
267 | +// $resultSet = $db->query($sql); | |
268 | +// $resposta = <<<EOH | |
269 | +// <table class="status" border="1"> | |
270 | +// <tr> | |
271 | +// <td>ID</td><td>idresposta</td><td>de</td><td>para</td><td>envio</td><td>mensagem</td><td>processada</td> | |
272 | +// </tr> | |
260 | 273 | //EOH; |
261 | -// while ($row = $resultSet->fetchObject()) { | |
262 | -// $resposta .= <<<EOH | |
263 | -// <tr> | |
264 | -// <td>{$row->idrequisicao}</td><td>{$row->idresposta}</td><td>{$row->de}</td><td>{$row->para}</td><td>{$row->envio}</td><td>{$row->mensagem}</td><td>{$row->processada}</td> | |
265 | -// </tr> | |
274 | +// while ($row = $resultSet->fetchObject()) { | |
275 | +// $resposta .= <<<EOH | |
276 | +// <tr> | |
277 | +// <td>{$row->idrequisicao}</td><td>{$row->idresposta}</td><td>{$row->de}</td><td>{$row->para}</td><td>{$row->envio}</td><td>{$row->mensagem}</td><td>{$row->processada}</td> | |
278 | +// </tr> | |
266 | 279 | //EOH; |
267 | -// } | |
268 | -// $resposta .= <<<EOH | |
269 | -// </table> | |
280 | +// } | |
281 | +// $resposta .= <<<EOH | |
282 | +// </table> | |
270 | 283 | //EOH; |
271 | -// } finally { | |
272 | -// $db = null; | |
273 | -// } | |
274 | -// } | |
275 | - } | |
276 | - } | |
284 | +// } finally { | |
285 | +// $db = null; | |
286 | +// } | |
287 | +// } | |
288 | + } | |
289 | + else if (isset($_POST["hi"])) // Histórico | |
290 | + { | |
291 | + if (file_exists("./db/cico.db")) { | |
292 | + $db = new PDO("sqlite:./db/cico.db",null,null,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); | |
293 | + try { | |
294 | + $sql = <<<EOS | |
295 | + select id as idrequisicao | |
296 | + , null as idresposta | |
297 | + , de | |
298 | + , para | |
299 | + , envio | |
300 | + , mensagem | |
301 | + , processada | |
302 | + from mensagens | |
303 | + where de = '$cpfmatricula' | |
304 | +union | |
305 | + select idpai as idrequisicao | |
306 | + , id as idresposta | |
307 | + , de | |
308 | + , para | |
309 | + , envio | |
310 | + , mensagem | |
311 | + , null as processada | |
312 | + from mensagens | |
313 | + where para = '$cpfmatricula' | |
314 | +order by 1 desc, 2 asc | |
315 | +EOS; | |
316 | + | |
317 | + | |
318 | + $resultSet = $db->query($sql); | |
319 | + | |
320 | + $resposta = <<<EOH | |
321 | + <table class="historico" border="1"> | |
322 | + <tr> | |
323 | + <td>ID da requisição</td><td>Mensagem</td><td>Enviada em</td><td>Processada</td> | |
324 | + </tr> | |
325 | + | |
326 | +EOH; | |
327 | + $idRequisicao = 0; | |
328 | + | |
329 | + while ($row = $resultSet->fetchObject()) { | |
330 | + if ($row->idrequisicao != $idRequisicao) { // Item pai ou item único | |
331 | + $resposta .= <<<EOH | |
332 | + <tr class="requisicao"> | |
333 | + <td>{$row->idrequisicao}</td><td>{$checkInCheckOut($row->mensagem)}</td><td>{$row->envio}</td><td>{$simOuNao($row->processada)}</td> | |
334 | + </tr> | |
335 | + | |
336 | +EOH; | |
337 | + | |
338 | + | |
339 | + $idRequisicao = $row->idrequisicao; | |
340 | + } else { // Item filho | |
341 | + $resposta .= <<<EOH | |
342 | + <tr class="resposta"> | |
343 | + <td> </td><td>{$row->mensagem}</td><td>{$row->envio}</td><td> </td> | |
344 | + </tr> | |
345 | + | |
346 | +EOH; | |
347 | + } | |
348 | + } | |
349 | + | |
350 | + $resposta .= <<<EOH | |
351 | + </table> | |
352 | + | |
353 | +EOH; | |
354 | + } finally { | |
355 | + $db = null; | |
356 | + } | |
357 | + } | |
358 | + } | |
359 | + } | |
277 | 360 | } |
278 | 361 | else |
279 | 362 | { |
280 | - $resposta = <<<EOH | |
281 | - <table class="erro" border="1"> | |
282 | - <tr> | |
283 | - <td align="center">Parâmetros inválidos</td> | |
284 | - </tr> | |
285 | - <tr> | |
286 | - <td>Favor informar o CPF e matrícula</td> | |
287 | - </tr> | |
288 | - </table> | |
363 | + $resposta = <<<EOH | |
364 | + <table class="erro" border="1"> | |
365 | + <tr> | |
366 | + <td align="center">Parâmetros inválidos</td> | |
367 | + </tr> | |
368 | + <tr> | |
369 | + <td>Favor informar o CPF e matrícula</td> | |
370 | + </tr> | |
371 | + </table> | |
372 | + | |
289 | 373 | EOH; |
290 | 374 | } |
291 | 375 | ?> |
292 | 376 | <html> |
293 | - <head> | |
294 | - <title>CheckIn / CheckOut</title> | |
295 | - <style type="text/css"> | |
296 | - body { | |
297 | - text-align: center; | |
298 | - font-family: monospace; | |
299 | - } | |
300 | - | |
301 | - input { | |
302 | - font-family: monospace; | |
303 | - } | |
304 | - | |
305 | - input[type="submit"] { | |
306 | - width: 61.5pt; | |
307 | - } | |
377 | + <head> | |
378 | + <title>CheckIn / CheckOut</title> | |
379 | + <style type="text/css"> | |
380 | + body { | |
381 | + text-align: center; | |
382 | + font-family: monospace; | |
383 | + } | |
384 | + | |
385 | + input { | |
386 | + font-family: monospace; | |
387 | + } | |
388 | + | |
389 | + input[type="submit"] { | |
390 | + width: 61.5pt; | |
391 | + } | |
308 | 392 | |
309 | - input[type="submit"].full { | |
310 | - width: 123pt; | |
311 | - } | |
393 | + input[type="submit"].full { | |
394 | + width: 123pt; | |
395 | + } | |
312 | 396 | |
313 | - input[name="cpf"],input[name="matricula"] { | |
314 | - width: 123pt; | |
315 | - text-align: center; | |
316 | - } | |
317 | - | |
318 | - fieldset { | |
319 | - border: 1px dotted black; | |
320 | - width: 90%; | |
321 | - padding: 0; | |
322 | - margin-left: auto; | |
323 | - margin-right: auto; | |
324 | - padding-bottom: 5pt; | |
325 | - padding-left: 5pt; | |
326 | - padding-right: 5pt; | |
327 | - } | |
328 | - | |
329 | - table.sucesso { | |
330 | - width: 100%; | |
331 | - border: 1px solid #008000; | |
332 | - } | |
333 | - | |
334 | - table.sucesso > tbody > tr > td { | |
335 | - background-color: #008000; | |
336 | - color: #FFFFFF; | |
337 | - text-align: center; | |
338 | - } | |
397 | + input[name="cpf"],input[name="matricula"] { | |
398 | + width: 123pt; | |
399 | + text-align: center; | |
400 | + } | |
401 | + | |
402 | + fieldset { | |
403 | + border: 1px dotted black; | |
404 | + width: 90%; | |
405 | + padding: 0; | |
406 | + margin-left: auto; | |
407 | + margin-right: auto; | |
408 | + padding-bottom: 5pt; | |
409 | + padding-left: 5pt; | |
410 | + padding-right: 5pt; | |
411 | + } | |
412 | + | |
413 | + table.sucesso { | |
414 | + width: 100%; | |
415 | + border: 1px solid #008000; | |
416 | + } | |
417 | + | |
418 | + table.sucesso > tbody > tr > td { | |
419 | + background-color: #008000; | |
420 | + color: #FFFFFF; | |
421 | + text-align: center; | |
422 | + } | |
339 | 423 | |
340 | - table.sucesso > tbody > tr:first-child > td { | |
341 | - font-weight: bold; | |
342 | - font-size: 12pt; | |
343 | - } | |
424 | + table.sucesso > tbody > tr:first-child > td { | |
425 | + font-weight: bold; | |
426 | + font-size: 12pt; | |
427 | + } | |
344 | 428 | |
345 | - table.erro { | |
346 | - width: 100%; | |
347 | - border: 1px solid #FF0000; | |
348 | - } | |
349 | - | |
350 | - table.erro > tbody > tr > td { | |
351 | - background-color: #FF0000; | |
352 | - color: #FFFFFF; | |
353 | - text-align: center; | |
354 | - } | |
355 | - | |
356 | - table.erro > tbody > tr:first-child > td { | |
357 | - font-weight: bold; | |
358 | - font-size: 12pt; | |
359 | - } | |
429 | + table.erro { | |
430 | + width: 100%; | |
431 | + border: 1px solid #FF0000; | |
432 | + } | |
360 | 433 | |
434 | + table.erro > tbody > tr > td { | |
435 | + background-color: #FF0000; | |
436 | + color: #FFFFFF; | |
437 | + text-align: center; | |
438 | + } | |
439 | + | |
440 | + table.erro > tbody > tr:first-child > td { | |
441 | + font-weight: bold; | |
442 | + font-size: 12pt; | |
443 | + } | |
444 | + | |
361 | 445 | ul { |
362 | 446 | text-align: left; |
363 | 447 | width: 90%; |
364 | - margin-left: auto; | |
365 | - margin-right: auto; | |
448 | + margin-left: auto; | |
449 | + margin-right: auto; | |
366 | 450 | } |
367 | - </style> | |
368 | - </head> | |
369 | - <body> | |
370 | - <form method="post" action="cico.php"> | |
371 | - <label for="cpf">CPF</label><br> | |
372 | - <input type="number" name="cpf" id="cpf" max="99999999999" value="<?php echo(isset($_POST["cpf"])?$_POST["cpf"]:""); ?>"><br><br> | |
373 | - <label for="matricula">Matrícula</label><br> | |
374 | - <input type="number" name="matricula" id="matricula" max="9999999" value="<?php echo(isset($_POST["matricula"])?$_POST["matricula"]:""); ?>"><br><br> | |
375 | - Ações<br> | |
376 | - <input type="submit" name="ci" value="Check-In"><input type="submit" name="co" value="Check-Out"><br> | |
377 | - <input type="submit" class="full" name="sa" value="Status atual"><br><br> | |
451 | + | |
452 | + table.historico { | |
453 | + width: 100%; | |
454 | + border: 1px solid #000080; | |
455 | + } | |
456 | + | |
457 | + table.historico > tbody > tr > td { | |
458 | + text-align: center; | |
459 | + color: #FFFFFF; | |
460 | + } | |
461 | + | |
462 | + table.historico > tbody > tr:first-child > td { | |
463 | + text-align: center; | |
464 | + background-color: #000080; | |
465 | + font-weight: bold; | |
466 | + font-size: 12pt; | |
467 | + } | |
468 | + | |
469 | + table.historico > tbody > tr.requisicao { | |
470 | + background-color: #80FF80; | |
471 | + } | |
472 | + | |
473 | + table.historico > tbody > tr.requisicao > td { | |
474 | + color: #000000; | |
475 | + } | |
476 | + | |
477 | + table.historico > tbody > tr.resposta { | |
478 | + background-color: #FFFF80; | |
479 | + } | |
480 | + | |
481 | + table.historico > tbody > tr.resposta > td { | |
482 | + color: #000000; | |
483 | + } | |
484 | + </style> | |
485 | + </head> | |
486 | + <body> | |
487 | + <form method="post" action="cico.php"> | |
488 | + <label for="cpf">CPF</label><br> | |
489 | + <input type="number" name="cpf" id="cpf" max="99999999999" value="<?php echo(isset($_POST["cpf"])?$_POST["cpf"]:""); ?>"><br><br> | |
490 | + <label for="matricula">Matrícula</label><br> | |
491 | + <input type="number" name="matricula" id="matricula" max="9999999" value="<?php echo(isset($_POST["matricula"])?$_POST["matricula"]:""); ?>"><br><br> | |
492 | + Ações<br> | |
493 | + <input type="submit" name="ci" value="Check-In"><input type="submit" name="co" value="Check-Out"><br> | |
494 | + <input type="submit" class="full" name="sa" value="Status atual"><br> | |
495 | + <input type="submit" class="full" name="hi" value="Histórico"><br> | |
496 | + <br><br> | |
378 | 497 | <?php |
379 | - if (isset($resposta)) { | |
498 | +if (isset($resposta)) { | |
380 | 499 | ?> |
381 | - <fieldset> | |
382 | - <legend> Resultado </legend> | |
383 | - <?php echo($resposta); ?> | |
384 | - </fieldset> | |
500 | + <fieldset> | |
501 | + <legend> Resultado </legend> | |
385 | 502 | <?php |
386 | - } | |
503 | + echo($resposta); | |
387 | 504 | ?> |
388 | - <ul> | |
389 | - <li>O CiCoD processa mensagens a cada 1 minuto, enviando uma resposta ao servidor que pode ser de sucesso ou falha</li> | |
390 | - <li>Caso uma mensagem não retorne um status de sucesso, serão feitas tentativas de processamento por até 5 minutos, totalizando 5 tentativas</li> | |
391 | - <li>Após o envio de uma mensagem o usuário não pode enviar outra mensagem até que a anterior tenha sido processada com sucesso ou que o número de tentativas de processamento tenha sido excedido</li> | |
392 | - <li>Após excedido o tempo de processamento, o sistema permite que outra mensagem seja enviada</li> | |
393 | - </ul> | |
394 | - | |
395 | - | |
396 | - | |
397 | - | |
505 | + </fieldset> | |
506 | +<?php | |
507 | +} | |
508 | +?> | |
509 | + <ul> | |
510 | + <li>O CiCoD processa mensagens a cada 1 minuto, enviando uma resposta ao servidor que pode ser de sucesso ou falha</li> | |
511 | + <li>Caso uma mensagem não retorne um status de sucesso, serão feitas tentativas de processamento por até 5 minutos, totalizando 5 tentativas</li> | |
512 | + <li>Após o envio de uma mensagem o usuário não pode enviar outra mensagem até que a anterior tenha sido processada com sucesso ou que o número de tentativas de processamento tenha sido excedido</li> | |
513 | + <li>Após excedido o tempo de processamento, o sistema permite que outra mensagem seja enviada, a qual será processada em no máximo 1 minuto</li> | |
514 | + </ul> | |
398 | 515 | </form> |
399 | - </body> | |
516 | + </body> | |
400 | 517 | </html> |
@@ -325,7 +325,9 @@ | ||
325 | 325 | function effectiveMessage($aRow) { |
326 | 326 | $mensagem = $aRow->mensagem; |
327 | 327 | |
328 | - if (isset($aRow->confirmacao) && (date("Y-m-d") != substr($aRow->confirmacao,1,10))) { | |
328 | + date_default_timezone_set("America/Recife"); | |
329 | + | |
330 | + if (isset($aRow->confirmacao) && (date("Y-m-d") != substr($aRow->confirmacao,0,10))) { | |
329 | 331 | $mensagem = 'co'; |
330 | 332 | } |
331 | 333 |
@@ -1,7 +1,6 @@ | ||
1 | 1 | <?php |
2 | 2 | header("content-type: text/html; charset: iso-8859-1"); |
3 | - | |
4 | - | |
3 | +/* | |
5 | 4 | if (file_exists("./db/cico.db")) { |
6 | 5 | $db = new PDO("sqlite:./db/cico.db",null,null,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); |
7 | 6 | try { |
@@ -21,8 +20,8 @@ | ||
21 | 20 | $db = null; |
22 | 21 | } |
23 | 22 | } |
23 | +*/ | |
24 | 24 | |
25 | - | |
26 | 25 | // select * |
27 | 26 | // from mensagens |
28 | 27 | // where para = 'CiCo' |
@@ -31,11 +30,73 @@ | ||
31 | 30 | // having min(id) |
32 | 31 | //order by id |
33 | 32 | |
33 | +$cpfmatricula = "023227194121842951"; | |
34 | 34 | |
35 | + if (file_exists("./db/cico.db")) { | |
36 | + $db = new PDO("sqlite:./db/cico.db",null,null,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); | |
37 | + try { | |
38 | + $sql = <<<EOS | |
39 | + select id as idrequisicao | |
40 | + , null as idresposta | |
41 | + , de | |
42 | + , para | |
43 | + , envio | |
44 | + , mensagem | |
45 | + , processada | |
46 | + from mensagens | |
47 | + where de = '$cpfmatricula' | |
48 | +union | |
49 | + select idpai as idrequisicao | |
50 | + , id as idresposta | |
51 | + , de | |
52 | + , para | |
53 | + , envio | |
54 | + , mensagem | |
55 | + , null as processada | |
56 | + from mensagens | |
57 | + where para = '$cpfmatricula' | |
58 | +EOS; | |
59 | + | |
60 | + $resultSet = $db->query($sql); | |
61 | + | |
62 | + $idrequisicao = 0; | |
63 | + $fecharInterno = false; | |
64 | + | |
65 | + echo("<ul>\n"); | |
66 | + | |
67 | + while ($row = $resultSet->fetchObject()) { | |
68 | + if ($row->idrequisicao != $idrequisicao) { // Item pai ou item único | |
69 | + if ($fecharInterno) { | |
70 | + echo("\t</ul>\n"); | |
71 | + $fecharInterno = false; | |
72 | + } | |
73 | + echo("\t<li>Requisição: ID=<b>" . $row->idrequisicao . "</b>; Mensagem=<b>" . ($row->mensagem=="ci"?"Check-In":"Check-Out") . "</b>; Data=<b>" . $row->envio . "</b></li>\n"); | |
74 | + $idrequisicao = $row->idrequisicao; | |
75 | + } else { // Item filho | |
76 | + | |
77 | + if (!$fecharInterno) { | |
78 | + echo("\t<ul>\n"); | |
79 | + $fecharInterno = true; | |
80 | + } | |
81 | + | |
82 | + echo("\t\t<li>Resposta: ID=<b>". $row->idresposta . "</b>; Mensagem=<b>" .$row->mensagem . "</b>; Data=<b>" . $row->envio . "</b></li>\n"); | |
83 | + } | |
84 | + } | |
35 | 85 | |
86 | + if ($fecharInterno) { | |
87 | + echo("\t</ul>\n"); | |
88 | + } | |
36 | 89 | |
90 | + echo("</ul>\n"); | |
37 | 91 | |
92 | + } finally { | |
93 | + $db = null; | |
94 | + } | |
95 | + } | |
38 | 96 | |
97 | +//echo($resposta); | |
98 | + | |
99 | + | |
39 | 100 | /* |
40 | 101 | error_reporting(E_ALL ^ E_DEPRECATED); |
41 | 102 | require_once("./lib/nusoap.php"); |