get_variable('URA',true); $nomeCliente = $agi->get_variable('NOMECLI',true); $valorFatura = $agi->get_variable('VALORFATURAS', true); $email = $agi->get_variable('EMAILCLI', true); $celular =$agi->get_variable('CELULARCLIENTE', true); $codBarra = mt_rand(1000000, 999999999); if($opt == 1){ $email = EnviaSegundaViaEmail($nomeCliente, $email, $valorFatura); if(substr($email, 0,2) == 'Ok'){ $agi->exec_goto(GetAnuncio('FATURA_ENVIADA')); }else{ $agi->exec_goto(GetAnuncio('REDIRECIONA_ATENDIMENTO')); } } if($opt == 2){ $sms = enviaSMS($celular, $nomeCliente, $codBarra, $valorFatura); } } catch (Exception $ex) { $reg_msg = $ex->getMessage(); $reg_status_exec = 'Er'; __logStr("Envia Segunda Via", $reg_msg , $scrpt, true); } @AtualizaIntegracao($uid, $reg_retorno, $reg_msg, $reg_status_exec, $retorno_cliente); if (!$dadosIntegra) @grava_dadosIntegra($reg_retorno); function EnviaSegundaViaEmail($nomeCliente, $destinatario, $valorFatura) { $vencimento = date('d/m/Y'); if (empty($destinatario)) { throw new Exception("Erro - destinatário não pode estar vazio"); } try { $mail = new PHPMailer(true); // Passing `true` enables exceptions //Configurações do Servidor $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'mail.simplesip.com.br'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'workflow@simplesip.com.br'; // SMTP username $mail->Password = '#w0rkFl0w@'; // SMTP password //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to //Remetente $mail->setFrom('desenvolvimento01@simplesip.com.br', 'Desenvolvimento01'); //Recebedores $mail->addAddress($destinatario, $nomeCliente); //Anexos $mail->addAttachment(); // Add attachments $mail->addAttachment("/var/lib/asterisk/scripts/workflow/logoPrincipal.jpg"); // Optional name //Conteudo $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'NO-REPLY Fatura por Email Simples IP'; $mail->Body = "

 Atendimento Simples IP

Prezado(a), {$nomeCliente}

Estamos encaminhando o titulo com vencimento em {$vencimento} no valor de R$ {$valorFatura}

Clique aqui para visualizar sua conta

EVITE A REDUÇÃO DA VELOCIDADE CONTRATADA.

Caso seja necessário, entre em contato conosco pelo telefone: (65)3616-8280
<<<<< Nao Responda esse email >>>>>

Atenciosamente,
Simples IP
Visite nosso site.



"; $mail->send(); return "Ok - mensagem enviada com sucesso"; } catch (phpmailerException $e) { return $e->errorMessage(); } catch (Exception $ex) { return $ex->getMessage(); } } function enviaSMS($telefone, $nomeCliente, $codBarra, $valorFatura) { $numero = soNumero($telefone); $url = sprintf("http://179.188.2.57/integracao?method=EnviaSMS&TroncoSainte=TRONCO&" . "NumeroDestino=%s&Texto=%s&login=aplicativos&senha=1234&tipoRetorno=XML", $numero, urlencode($nomeCliente." Segue Codigo de barras para pagamento de sua fatura, " . "no valor de R$.".$valorFatura." Código: ". $codBarra)); $xml = simplexml_load_string(file_get_contents($url)); $result = array(); $result['result'] = strval($xml->result); $result['status'] = strval($xml->status); $result['message'] = 'OK - '.strval($xml->message); $result['SIPID'] = strval($xml->SIPID); return $result; } ?>