get_variable('URA',true); $documento = $agi->get_variable('DOCUMENTO', true); $codPessoa = $agi->get_variable('CODCLIENTE', true); ConnectPG(); $fatura = listaFaturas($codPessoa, $documento); if(!empty($fatura) && $metodoEnvio == 1){ $segundaVia = geraSegundaVia($fatura['fatura'], $codPessoa, 'P'); if($segundaVia){ $agi->exec_goto(GetAnuncio('')); }else{ $agi->exec_goto(GetAnuncio('')); } }elseif(!empty($fatura) && $metodoEnvio == 2){ $segundaVia = geraSegundaVia($fatura['fatura'], $codPessoa, 'L'); if($segundaVia){ $agi->exec_goto(GetAnuncio('')); }else{ $agi->exec_goto(GetAnuncio('')); } }else{ $agi->exec_goto(GetAnuncio('')); } } catch (Exception $ex) { $reg_msg = $ex->getMessage(); $reg_status_exec = 'Er'; __logStr("Consulta de Documento", $reg_msg, $scrpt, true); } @AtualizaIntegracao($uid, $reg_retorno, $reg_msg, $reg_status_exec, $retorno_cliente); if (!$dadosIntegra) @grava_dadosIntegra($reg_retorno); function listaFaturas($codCliente, $docCliente) { try { $url = "https://201.62.48.29:8080/mk/WSSacCobrancasIntegrado.rule?" . "token=6c79d2d477fe7ce53ee494355b810f50&cd_cliente={$codCliente}&doc_cliente={$docCliente}&sys=MK0"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $content = trim(curl_exec($ch)); curl_close($ch); $retorno = json_decode($content); } catch (Exception $ex) { return $ex->getMessage(); } return $retorno; } function geraSegundaVia($fatura, $codCliente,$acaoEnvio) { try { $url = "https://201.62.48.29:8080/mk/WSSacCobrancasAcoesIntegrado.rule?" . "token=6c79d2d477fe7ce53ee494355b810f50&fatura={$fatura}&acao={$acaoEnvio}&cd_cliente={$codCliente}&sys=MK0"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $content = trim(curl_exec($ch)); curl_close($ch); $retorno = json_decode($content); } catch (Exception $ex) { return $ex->getMessage(); } return $retorno; } ?>