repositório com os arquivos utilizados para integração entre o sistema SimplesIP e diversos sistemas.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

61 lines
1.5 KiB

<?php
require "SGP.php";
$registros = array(
"id" => '',
"reg_ura" => $ura,
"reg_tronco" => $tronco,
"reg_uniqueid" => $uid,
"reg_id_metodo" => $idMetodo,
"reg_uniqueid" => $uid,
"reg_uniqueid_old" => $uidOld,
"reg_fone" => $numero,
"reg_status_exec" => '1',
"reg_inicio" => date());
$sgp = new SGP(CONF_TOKEN_API, CONF_URL_API, CONF_USERID_API, CONF_LOGGER_ATIVO);
$sgp->db()->setRegistros($registros);
if (CONF_AUDIO_ERROR) {
$sgp->db()->setIdAudioError(CONF_AUDIO_ERROR);
}
$sgp->agi()->set_music(true, 'default');
$response= true;
$documento = $sgp->agi()->get_variable('DOCUMENTO', true);
$clienteDados = $sgp->identificarDocumento($documento);
if (!$clienteDados['contratos'][0]['clienteId']){
$response = false;
}
$boletos = [];
foreach($clienteDados['contratos'] as $clienteContrato){
$item = $sgp->segundaVia($clienteContrato['contratoId'])['links'];
$boletos += $item;
}
if(!$boletos){
$response = false;
}
if($response){
foreach($boletos as $boleto){
$sgp->SimpleMail(CONF_SENDER_EMAIL_USER, CONF_SENDER_EMAIL_PASSWORD, CONF_EMAIL_SUBTITLE_INVOICE);
$sgp->confSMTP(CONF_SMTP_HOST, CONF_SMTP_POST, CONF_EMAIL_TITLE_INVOICE, true, 'tls');
$response = $sgp->enviarBoletoEmail($boleto, $clienteDados);
}
}
$sgp->agi()->set_music(false, 'default');
if ($response) {
$sgp->agi()->exec_goto($sgp->db()->getAnuncio('INT_FATURA_SUCESSO'));
} else {
$sgp->agi()->exec_goto($sgp->db()->getAnuncio('INT_FATURA_FALHA'));
}
$sgp->db()->atualizaIntegracao();
?>