get_variable('EMP',true);
$codBoleto = $agi->get_variable('CODBOLETO',true);
$nomeCliente = $agi->get_variable('NOMECLI', true);
//$emailCliente = $Agi->get_variable('EMAILCLI', true);
$linkBoleto = RetornaLinkBoleto($codBoleto, $emp);
if (substr($linkBoleto, 0, 4) == "Erro") {
$agi->exec_goto(GetAnuncio(''));
} else {
__logStr("Envio de boletos", "Link do boleto: " . print_r($linkBoleto, true), $script, true);
if ($emp == 'VMAIS') {
$boleto = EnviaBoletoEmailVmais('desenvolvimento01@simplesip.com.br', $linkBoleto, $nomeCliente);
if ($boleto == 'OK') {
$agi->exec_goto(GetAnuncio('AGRADECIMENTO')); // Agradecimento
} else {
$agi->exec_goto(GetAnuncio('REDIR_VMAIS')); // Fila financeiro
}
} else {
$boleto = EnviaBoletoEmailOptcom('desenvolvimento01@simplesip.com.br', $linkBoleto, $nomeCliente);
if ($boleto == 'OK') {
$agi->exec_goto(GetAnuncio('AGRADECIMENTO')); // Agradecimento
} else {
$agi->exec_goto(GetAnuncio('REDIR_OPTCOM')); // Fila financeiro
}
}
}
} catch (Exception $ex) {
$reg_msg = $ex->getMessage();
$reg_status_exec = 'Er';
__logStr("Consulta de Cliente", $reg_msg . " Consulta de Cliente: $cpf", $script, true);
}
@AtualizaIntegracao($uid, $reg_retorno, $reg_msg, $reg_status_exec, $retorno_cliente);
if (!$dadosIntegra){
@grava_dadosIntegra($reg_retorno);
}
function RetornaLinkBoleto($idBoleto, $emp)
{
try {
if ($emp == 'VMAIS') {
$url = "https://srv.vmaisnet.com/routerbox/ws_json/ws_json.php";
$json = "{
\"get_banking_billet\": {
\"document_id\": {$idBoleto}
}
}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml; charset=utf-8',
'Content-Length: ' . strlen($json),
'authentication_key: YA2Y0ZAPF2G7TH60YURKTX6BXXKYDL'
));
} else {
$url = "https://srv.optcom.net.br/routerbox/ws_json/ws_json.php";
$json = "{
\"get_banking_billet\": {
\"document_id\": {$idBoleto}
}
}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml; charset=utf-8',
'Content-Length: ' . strlen($json),
'authentication_key: MOKCJEMITFNCK6GBRM92ORLOUWCG8B'
));
}
$result = curl_exec($ch);
$response = objectToArray(json_decode($result));
if ($response['error_code'] != 0) {
throw new Exception("Erro - ".$response['error_description']);
}
return $response['result']['banking_billet_link'];
} catch (Exception $ex) {
return $ex->getMessage();
}
}
function EnviaBoletoEmailVmais($emailCli, $linhaDigi, $nomeCli)
{
try {
if (empty($emailCli) || empty($linhaDigi) || empty($nomeCli)) {
throw new Exception("ERRO - variaveis de entrada estao vazias!");
}
$mail = new PHPMailer(true); // Passing `true` enables exceptions
//Configurações do Servidor
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'automatico@vmaisnet.com'; // SMTP username
$mail->Password = 'Ki22br03@!'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Remetente
$mail->setFrom('automatico@vmaisnet.com', 'Financeiro V Mais Net');
//Recebedores
$mail->addAddress($emailCli);
//Conteudo
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Linha digitavel de fatura';
$mail->CharSet = 'ISO-8859-1';
$mail->AddEmbeddedImage(__DIR__ . '/login.png', 'imagem_login');
$mail->AddEmbeddedImage(__DIR__ . '/menu.png', 'imagem_menu');
$mail->AddEmbeddedImage(__DIR__ . '/logo.jpg', 'logo_vmaisnet');
$mail->Body = "Ola {$nomeCli}
"
. "Clique aqui para baixar seu boleto
"
. "Sabia que a V+ Net disponibiliza a central do assinante para a 2ª via de boletos online e outros serviços ?
"
. "Siga as orientações abaixo:
"
. "