Jump to content

Atualizar data de boleto vencido cef sigcb


Recommended Posts

Salve galera,

Alguém pode me dar uma luz no que pode estar errado no código abaixo, pois a data só atualiza se estiver com mais de 30 dias em atraso, menos que isso ela não atualiza.

<?php

include("../../../dbconnect.php");
include("../../../includes/functions.php");
include("../../../includes/clientfunctions.php");
include("../../../includes/invoicefunctions.php");

require("../../../init.php");
$whmcs->load_function('gateway');
$whmcs->load_function('client');

$GATEWAY = getGatewayVariables("boleto");
if (!$GATEWAY["type"]) die("Module Not Activated");

if ( !isset($_SESSION["uid"]) && !isset($_SESSION['adminid']) ) {
    redirSystemURL("", "clientarea.php");
}

$GATEWAY = array();
$gwresult = select_query("tblpaymentgateways","",array("gateway"=>"boleto"));
while ($data = mysql_fetch_array($gwresult)) {
    $gVgwsetting = $data["setting"];
    $gVgwvalue = $data["value"];
    $GATEWAY[$gVgwsetting] = $gVgwvalue;
}
if (!in_array($GATEWAY['banco'],array('cef'))) exit;

$result = select_query("tblinvoices","",array("id"=>(int)$invoiceid));
$data = mysql_fetch_array($result);
$id = $data["id"];
$userid = $data["userid"];
$date = $data["date"];
$duedate = $data["duedate"];
$subtotal = $data["subtotal"];
$credit = $data["credit"];
$tax = $data["tax"];
$taxrate = $data["taxrate"];
$total = $data["total"];


if ( $id && $userid && ( isset($_SESSION['adminid']) || $_SESSION["uid"]==$userid ) ) {} else {
    die("Invalid Access Attempt");
}

$clientsdetails = getclientsDetails($data["userid"]);

function Data($date){
	$expdata = explode("-",$date);
	$date = $expdata[2]."/".$expdata[1]."/".$expdata[0];
	return $date;
}

$year = substr($duedate,0,4);
$month = substr($duedate,5,2);
$day = substr($duedate,8,2);


function MaisDias($day,$toadd) {
     $tmp = explode("/",$day);
     $dadate = mktime(0,0,0,$tmp[1],$tmp[0]+($toadd),$tmp[2]);
     return date('d/m/Y',$dadate);
}

$venc = date("d/m/Y",mktime(0,0,0,$month,$day,$year));
$venc = strtotime($venc);

$today = date("d/m/Y");
$hoje = strtotime($today);

if ($venc < $hoje){$data_venc = date("d/m/Y",mktime(0,0,0,$month,$day,$year));
	
}
else {$venc = MaisDias($today,3);
}


//$data_venc = date("d/m/Y",mktime(0,0,0,$month,$day,$year));  // It has to be the same as the invoice due date


//----------------------------------------
// DADOS DO BOLETO PARA O SEU CLIENTE
$dias_de_prazo_para_pagamento = 0;
$taxa_boleto = 6.30;

//$data_venc = date("d/m/Y",mktime(0,0,0,$month,$day,$year)); 

$valor_cobrado = $total;
$valor_cobrado = str_replace(",", ".",$valor_cobrado);
$valor_boleto=number_format($valor_cobrado+$taxa_boleto, 2, ',', '');

// Composição Nosso Numero - CEF SIGCB
$dadosboleto["nosso_numero1"] = "000"; // tamanho 3
$dadosboleto["nosso_numero_const1"] = "1"; //constanto 1 , 1=registrada , 2=sem registro
$dadosboleto["nosso_numero2"] = "000"; // tamanho 3
$dadosboleto["nosso_numero_const2"] = "4"; //constanto 2 , 4=emitido pelo proprio cliente
$dadosboleto["nosso_numero3"] = $invoiceid; // tamanho 9
$dadosboleto["numero_documento"] = $invoiceid;

$dadosboleto["data_vencimento"] = $data_venc;

$dadosboleto["data_documento"] = Data($data[date]); 
$dadosboleto["data_processamento"] = date("d/m/Y");
$dadosboleto["valor_boleto"] = $valor_boleto;

 

Link to comment
Share on other sites

9 horas atrás, msaulohenrique disse:

Creio que não precisa do 

 


include("../../../dbconnect.php"); include("../../../includes/functions.php"); include("../../../includes/clientfunctions.php"); include("../../../includes/invoicefunctions.php");  require("../../../init.php");

 

Olá @msaulohenrique, sem esses includes meu boleto não abre! mas valeu!

Link to comment
Share on other sites

  • Administration
15 horas atrás, CarllosRA disse:

if ($venc < $hoje){$data_venc = date("d/m/Y",mktime(0,0,0,$month,$day,$year)); } else {$venc = MaisDias($today,3); }

Sensação de que fui eu que escrevi esse código kkkk  E se foi mesmo, acho que tem uma versão mais recente dele pegando o boleto atualizado usando o CPF/CNPJ.

 

'Cause he's my best friend, he's my pal. He's my homeboy, my rotten soldier. He's my sweet cheese. My good-time boy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Do you agree with our terms?