1 | <?php |
---|
2 | |
---|
3 | //require_once ('./xajax/xajax.inc.php'); |
---|
4 | |
---|
5 | $xajax = new xajax(); |
---|
6 | $xajax->registerFunction('selecionarTipoColuna'); |
---|
7 | $xajax->registerFunction('sincronizar'); |
---|
8 | |
---|
9 | $xajax->setCharEncoding('ISO-8859-1'); |
---|
10 | $xajax->decodeUTF8InputOn(); |
---|
11 | |
---|
12 | $xajax->processRequests(); |
---|
13 | |
---|
14 | // Funes XAJAX |
---|
15 | function selecionarTipoColuna($tipo) { |
---|
16 | global $conn; |
---|
17 | $objResponse = new xajaxResponse(); |
---|
18 | |
---|
19 | $objResponse->addScript("formUtilOcultaCampos('lslccalculada,lslccheckbox');"); |
---|
20 | |
---|
21 | if ($tipo == "int") { |
---|
22 | $objResponse->addScript("formUtilExibeCampos('lslccalculada,lslccheckbox,lslctotalizador_condicao,lslcsubtotalizador_condicao,lslccheckbox_condicao');"); |
---|
23 | } |
---|
24 | |
---|
25 | if ($tipo == "moeda") { |
---|
26 | $objResponse->addScript("formUtilExibeCampos('lslccalculada,lslctotalizador_condicao,lslcsubtotalizador_condicao');"); |
---|
27 | } |
---|
28 | |
---|
29 | if ($tipo == "hora") { |
---|
30 | $objResponse->addScript("formUtilExibeCampos('lslccalculada,lslctotalizador_condicao,lslcsubtotalizador_condicao');"); |
---|
31 | } |
---|
32 | |
---|
33 | return $objResponse->getXML(); |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | function sincronizar($idlistagem,$conexao = "1") { |
---|
38 | global $conn; |
---|
39 | $objResponse = new xajaxResponse(); |
---|
40 | |
---|
41 | $xml_params = '<?xml version="1.0" encoding="ISO-8859-1"?> |
---|
42 | <raiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
---|
43 | <sincronizaVersao> |
---|
44 | <lstidlistagem>'. $idlistagem . '</lstidlistagem> |
---|
45 | <conexao>'. $conexao . '</conexao> |
---|
46 | </sincronizaVersao> |
---|
47 | </raiz>'; |
---|
48 | |
---|
49 | $xml_params = utf8_encode($xml_params); |
---|
50 | |
---|
51 | |
---|
52 | $server_url = "http://url_servidor/webservice/cad_listagem_sincronizacao/cadListagem_server.php?wsdl"; |
---|
53 | |
---|
54 | $client = new SoapClient( $server_url, |
---|
55 | array( 'trace' => 1, 'exceptions' => 1,'soap_version' => SOAP_1_1)); |
---|
56 | |
---|
57 | try { |
---|
58 | |
---|
59 | $save_result = $client->sincronizar($xml_params); |
---|
60 | |
---|
61 | $objResponse->addAssign("botoes_sincronizacao","innerHTML","<br><br><br><img src='./images/icones/v.gif'>"); |
---|
62 | |
---|
63 | if ($conexao == "1") { |
---|
64 | $objResponse->addScript("document.getElementById('versao_producao').innerHTML = document.getElementById('versao_labirinto').innerHTML;"); |
---|
65 | } else { |
---|
66 | $objResponse->addScript("document.getElementById('versao_desenvolvimento').innerHTML = document.getElementById('versao_producao').innerHTML;"); |
---|
67 | } |
---|
68 | |
---|
69 | $objResponse->addScript("ExibirMensagem('Sincronizacao Efetuada com sucesso.')"); |
---|
70 | $objResponse->addAlert('Sincronizacao Efetuada com sucesso.'); |
---|
71 | |
---|
72 | } catch (SoapFault $e){ |
---|
73 | $objResponse->addAlert("FALHOU! SOAP Fault: ".$e->getMessage()); |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | return $objResponse->getXML(); |
---|
78 | } |
---|
79 | |
---|
80 | function atualizaStatus($listagems,$status,$debug = false) { |
---|
81 | $versoes = ""; |
---|
82 | foreach ($listagems as $listagem) { |
---|
83 | $versoes .= ' |
---|
84 | <atualizaStatus> |
---|
85 | <lstidlistagem>' . $listagem . '</lstidlistagem> |
---|
86 | <status>' . $status . '</status> |
---|
87 | </atualizaStatus>'; |
---|
88 | } |
---|
89 | |
---|
90 | $xml_params='<?xml version="1.0" encoding="ISO-8859-1"?> |
---|
91 | <raiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $versoes . ' |
---|
92 | </raiz>'; |
---|
93 | //$xml_params = utf8_encode($xml_params); |
---|
94 | |
---|
95 | //echo $xml_params; |
---|
96 | |
---|
97 | $server_url = "http://url_servidor/webservice/cad_listagem_sincronizacao/cadListagem_server.php?wsdl"; |
---|
98 | |
---|
99 | $client = new SoapClient( $server_url, |
---|
100 | array( 'trace' => 1, 'exceptions' => 1,'soap_version' => SOAP_1_1)); |
---|
101 | |
---|
102 | try { |
---|
103 | |
---|
104 | $save_result = $client->atualizaStatus($xml_params); |
---|
105 | |
---|
106 | |
---|
107 | if ($debug) { |
---|
108 | echo "<hr>"; |
---|
109 | echo "<pre>\n\n"; |
---|
110 | echo "Request Cabeï¿œalho:\n"; |
---|
111 | echo htmlspecialchars($client->__getLastRequestHeaders())."\n"; |
---|
112 | echo "</pre>"; |
---|
113 | |
---|
114 | echo "<pre>\n\n"; |
---|
115 | echo "Request:\n"; |
---|
116 | echo htmlspecialchars($client->__getLastRequest())."\n"; |
---|
117 | echo "</pre>"; |
---|
118 | echo "<hr>"; |
---|
119 | |
---|
120 | echo "<pre>\n\n"; |
---|
121 | echo "Retorno Cabeï¿œalho:\n"; |
---|
122 | echo htmlspecialchars($client->__getLastResponseHeaders())."\n"; |
---|
123 | echo "</pre>"; |
---|
124 | |
---|
125 | echo "<pre>\n\n"; |
---|
126 | echo "Retorno:\n"; |
---|
127 | echo htmlspecialchars($client->__getLastResponse())."\n"; |
---|
128 | echo "</pre>"; |
---|
129 | |
---|
130 | echo "<br>ENVIO FINALIZADO!<br>"; |
---|
131 | } |
---|
132 | |
---|
133 | return $save_result; |
---|
134 | |
---|
135 | } catch (SoapFault $e){ |
---|
136 | echo "<br>FALHOU! SOAP Fault: ".$e->getMessage()."<br>"; |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | function verificaVersao($listagems,$debug = false) { |
---|
142 | $versoes = ""; |
---|
143 | foreach ($listagems as $listagem) { |
---|
144 | $versoes .= ' |
---|
145 | <verificaVersao> |
---|
146 | <lstidlistagem>' . $listagem . '</lstidlistagem> |
---|
147 | </verificaVersao>'; |
---|
148 | } |
---|
149 | |
---|
150 | $xml_params='<?xml version="1.0" encoding="ISO-8859-1"?> |
---|
151 | <raiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $versoes . ' |
---|
152 | </raiz>'; |
---|
153 | //$xml_params = utf8_encode($xml_params); |
---|
154 | |
---|
155 | //echo $xml_params; |
---|
156 | |
---|
157 | $server_url = "http://url_servidor/webservice/cad_listagem_sincronizacao/cadListagem_server.php?wsdl"; |
---|
158 | |
---|
159 | $client = new SoapClient( $server_url, |
---|
160 | array( 'trace' => 1, 'exceptions' => 1,'soap_version' => SOAP_1_1)); |
---|
161 | |
---|
162 | try { |
---|
163 | |
---|
164 | $save_result = $client->verificaVersao($xml_params); |
---|
165 | |
---|
166 | |
---|
167 | if ($debug) { |
---|
168 | echo "<hr>"; |
---|
169 | echo "<pre>\n\n"; |
---|
170 | echo "Request Cabecalho:\n"; |
---|
171 | echo htmlspecialchars($client->__getLastRequestHeaders())."\n"; |
---|
172 | echo "</pre>"; |
---|
173 | |
---|
174 | echo "<pre>\n\n"; |
---|
175 | echo "Request:\n"; |
---|
176 | echo htmlspecialchars($client->__getLastRequest())."\n"; |
---|
177 | echo "</pre>"; |
---|
178 | echo "<hr>"; |
---|
179 | |
---|
180 | echo "<pre>\n\n"; |
---|
181 | echo "Retorno Cabecalho:\n"; |
---|
182 | echo htmlspecialchars($client->__getLastResponseHeaders())."\n"; |
---|
183 | echo "</pre>"; |
---|
184 | |
---|
185 | echo "<pre>\n\n"; |
---|
186 | echo "Retorno:\n"; |
---|
187 | echo htmlspecialchars($client->__getLastResponse())."\n"; |
---|
188 | echo "</pre>"; |
---|
189 | |
---|
190 | echo "<br>ENVIO FINALIZADO!<br>"; |
---|
191 | } |
---|
192 | |
---|
193 | return $save_result; |
---|
194 | |
---|
195 | } catch (SoapFault $e){ |
---|
196 | echo "<br>FALHOU! SOAP Fault: ".$e->getMessage()."<br>"; |
---|
197 | } |
---|
198 | } |
---|
199 | |
---|
200 | function atualizarVersao($conn,$lstoid) { |
---|
201 | $sql = "update listagem.listagem set lstversao = lstversao + 1 where lstoid = $lstoid"; |
---|
202 | $res = pg_query($conn,$sql); |
---|
203 | return ($res); |
---|
204 | } |
---|
205 | |
---|
206 | function retornaParametros($sql) { |
---|
207 | $sqlparametros = array(); |
---|
208 | $abre_chaves = explode("{",$sql); |
---|
209 | foreach ($abre_chaves as $chave) { |
---|
210 | $_chaves = array(); |
---|
211 | if (stristr($chave,"}")) { |
---|
212 | $_chaves = explode("}",$chave); |
---|
213 | $sqlparametros[] = $_chaves[0]; |
---|
214 | } |
---|
215 | } |
---|
216 | return $sqlparametros; |
---|
217 | } |
---|
218 | |
---|
219 | $xajax->printJavascript("workflow/inc/report/"); |
---|
220 | |
---|
221 | ?> |
---|