Resultados 1 a 2 de 2
  1. #1
    WHT-BR Top Member
    Data de Ingresso
    Nov 2010
    Posts
    1,611

    Relatório de futuras faturas

    Pessoal,

    Estava procurando uma solução para editar a data de vencimento dos clientes e não estava com saco (ou seja, estava com preguiça de verificar um por um)

    Precisava de uma solução para centralizar a data de vencimento dos clientes sem ser pelo pró-rata do whmcs.

    Então pesquisei no whmcs.com e achei este script que me pareceu ser bem legal.

    O tópico original e os creditos do user que criou o script estão neste link:
    WHMCS Forums

    Procedimento para utilizar este script é simples

    Crie um arquivo php (exemplo: upcoming_automatic_invoices.php) e coloque o seguinte codigo nele:
    Código:
    <?php 
    if (!defined("WHMCS")) 
        die("This file cannot be accessed directly"); 
    
    if(!isset($calculate)) 
    { 
        $startday = date("d"); 
        $startmonth = date("m"); 
        $startyear=date("Y"); 
        $endday = date("d",mktime(0,0,0,date("m"),date("d")+7,date("Y"))); 
        $endmonth = date("m",mktime(0,0,0,date("m"),date("d")+7,date("Y"))); 
        $endyear=date("Y",mktime(0,0,0,date("m"),date("d")+7,date("Y"))); 
        $startdate = $startyear.$startmonth.$startday; 
        $enddate=mktime(23,59,59,date("m"),date("d")+7,date("Y")); 
        $enddate = date("Y-m-d",$enddate); 
    } 
    
    $reportdata["title"] = "Upcoming Automatic Invoices"; 
    $reportdata["description"] = "A summary of invoices that are due to be automatically created."; 
    
    $reportdata["headertext"] = "<form method=\"post\" action=\"$PHP_SELF?report=$report&calculate=true\"><center>Start Date: <select name=\"startday\">"; 
    
    for ( $counter = 1; $counter <= 31; $counter += 1) { 
    
        $reportdata["headertext"] .= "<option"; 
    
        if ($counter==$startday) { $reportdata["headertext"] .= " selected"; } 
    
        $reportdata["headertext"] .= ">$counter"; 
    
    } 
    
    $reportdata["headertext"] .= "</select> <select name=\"startmonth\">"; 
    
    for ( $counter = 1; $counter <= 12; $counter += 1) { 
    
        $reportdata["headertext"] .= "<option"; 
    
        if ($counter==$startmonth) { $reportdata["headertext"] .= " selected"; } 
    
        $reportdata["headertext"] .= ">$counter"; 
    
    } 
    
    $reportdata["headertext"] .= "</select> <select name=\"startyear\">"; 
    
    for ( $counter = 1998; $counter <= 2010; $counter += 1) { 
    
        $reportdata["headertext"] .= "<option"; 
    
        if ($counter==$startyear) { $reportdata["headertext"] .= " selected"; } 
    
        $reportdata["headertext"] .= ">$counter"; 
    
    } 
    
    $reportdata["headertext"] .= "</select> End Date: <select name=\"endday\">"; 
    
    for ( $counter = 1; $counter <= 31; $counter += 1) { 
    
        $reportdata["headertext"] .= "<option"; 
    
        if ($counter==$endday) { $reportdata["headertext"] .= " selected"; } 
    
        $reportdata["headertext"] .= ">$counter"; 
    
    } 
    
    $reportdata["headertext"] .= "</select> <select name=\"endmonth\">"; 
    
    for ( $counter = 1; $counter <= 12; $counter += 1) { 
    
        $reportdata["headertext"] .= "<option"; 
    
        if ($counter==$endmonth) { $reportdata["headertext"] .= " selected"; } 
    
        $reportdata["headertext"] .= ">$counter"; 
    
    } 
    
    $reportdata["headertext"] .= "</select> <select name=\"endyear\">"; 
    
    for ( $counter = date("Y"); $counter <= date("Y")+1; $counter += 1) { 
    
        $reportdata["headertext"] .= "<option"; 
    
        if ($counter==$endyear) { $reportdata["headertext"] .= " selected"; } 
    
        $reportdata["headertext"] .= ">$counter"; 
    
    } 
    
    $reportdata["headertext"] .= "</select> <input type=\"submit\" value=\"Generate Report\"></form>";  
    
    
    
    
    
        $startday = str_pad($startday,2,"0",STR_PAD_LEFT); 
    
        $startmonth = str_pad($startmonth,2,"0",STR_PAD_LEFT); 
    
        $endday = str_pad($endday,2,"0",STR_PAD_LEFT); 
    
        $endmonth = str_pad($endmonth,2,"0",STR_PAD_LEFT); 
    
    
    
        $startdate = $startyear."-".$startmonth."-".$startday; 
    
        $enddate = $endyear."-".$endmonth."-".$endday; 
    
    $reportdata["tableheadings"] = array("Next Invoice Due","Client","Product/Service","OrderID","Total"); 
    $reportdata["tablevalues"][] = array("**<B>Upcoming/Active</B>"); 
    $cancelrequests=mysql_query("SELECT relid FROM tblcancelrequests"); 
    while($cancelrequestsrow=mysql_fetch_array($cancelrequests)) 
    { 
        $cancellations[]=$cancelrequestsrow[0]; 
    } 
    $sql="SELECT DATE_FORMAT(tblhosting.nextinvoicedate,'%d/%m/%Y') AS NextDue, tblclients.id, tblclients.firstname, tblclients.lastname, tblproducts.name, tblhosting.orderid, tblhosting.amount, tblhosting.id AS hostingid FROM tblhosting, tblclients, tblproducts WHERE tblhosting.userid = tblclients.id AND tblhosting.packageid = tblproducts.id AND tblhosting.billingcycle != 'Free Account' AND tblhosting.nextinvoicedate>='$startdate' AND tblhosting.nextinvoicedate<='$enddate' AND (tblhosting.domainstatus='Active' OR tblhosting.domainstatus='Pending' OR tblhosting.domainstatus='Suspended') ORDER BY tblhosting.nextinvoicedate"; 
    $result=mysql_query($sql); 
    while($row=mysql_fetch_array($result)) 
    { 
        if(!in_array($row[7],$cancellations)) 
        { 
            if($row['orderid']) 
                $reportdata["tablevalues"][] = array($row['NextDue'],'<a href="clientssummary.php?userid='.$row['id'].'">'.$row['firstname']." ".$row['lastname'].'</a>','<a href="clientshosting.php?userid='.$row['id'].'&hostingid='.$row['hostingid'].'">'.$row['name'].'</a>','<a href="orders.php?action=view&id='.$row['orderid'].'">'.$row['orderid'].'</a>',$CONFIG["CurrencySymbol"].format_as_currency($row['amount'])); 
            else 
                $reportdata["tablevalues"][] = array($row['NextDue'],'<a href="clientssummary.php?userid='.$row['id'].'">'.$row['firstname']." ".$row['lastname'].'</a>','<a href="clientshosting.php?userid='.$row['id'].'&hostingid='.$row['hostingid'].'">'.$row['name'],'-',$CONFIG["CurrencySymbol"].format_as_currency($row['amount'])); 
            $amount+=$row['amount']; 
        } 
    } 
    $reportdata["tablevalues"][] = array("**<B>Overdue/Pending</B>"); 
    $sql="SELECT DATE_FORMAT(tblhosting.nextinvoicedate,'%d/%m/%Y') AS NextDue, tblclients.id, tblclients.firstname, tblclients.lastname, tblproducts.name, tblhosting.orderid, tblhosting.amount, tblhosting.id AS hostingid FROM tblhosting, tblclients, tblproducts WHERE tblhosting.userid = tblclients.id AND tblhosting.packageid = tblproducts.id AND tblhosting.billingcycle != 'Free Account' AND tblhosting.nextinvoicedate<='$startdate' AND (tblhosting.domainstatus='Active' OR tblhosting.domainstatus='Pending' OR tblhosting.domainstatus='Suspended') ORDER BY tblhosting.nextinvoicedate"; 
    $result=mysql_query($sql); 
    while($row=mysql_fetch_array($result)) 
    { 
        if(!in_array($row[7],$cancellations)) 
        { 
            if($row['orderid']) 
                $reportdata["tablevalues"][] = array($row['NextDue'],'<a href="clientssummary.php?userid='.$row['id'].'">'.$row['firstname']." ".$row['lastname'].'</a>','<a href="clientshosting.php?userid='.$row['id'].'&hostingid='.$row['hostingid'].'">'.$row['name'].'</a>','<a href="orders.php?action=view&id='.$row['orderid'].'">'.$row['orderid'].'</a>',$CONFIG["CurrencySymbol"].format_as_currency($row['amount'])); 
            else 
                $reportdata["tablevalues"][] = array($row['NextDue'],'<a href="clientssummary.php?userid='.$row['id'].'">'.$row['firstname']." ".$row['lastname'].'</a>','<a href="clientshosting.php?userid='.$row['id'].'&hostingid='.$row['hostingid'].'">'.$row['name'],'-',$CONFIG["CurrencySymbol"].format_as_currency($row['amount'])); 
            $amount+=$row['amount']; 
        } 
    } 
    $data["footertext"]="<p align=\"right\"><b>Total Income:</b> ".$CONFIG["CurrencySymbol"].format_as_currency($amount)."</p>"; 
    ?>
    Depois disso, coloque este arquivo dentro deste da pasta report do seu whmcs:
    whmcs/modules/reports/
    Depois disso, acesse seu whmcs, clique na aba reports e poderá acompanhar ao lado esquerdo o link deste relatório.

    Deve ficar + ou - Assim:
    WHMCS - Reports | Awesome Screenshot

    Abraços

    oGigante.com*• Revenda de Hospedagem Cloud Linux + WHMCS Grátis
    VWhost.com.br • Revenda de Hospedagem Linux Cpanel + CloudFlare
    Zocka.com.br • Hospedagem de Sites Cpanel + Construtor de Sites

  2. #2
    Membro
    Data de Ingresso
    May 2011
    Localização
    Campina Grande/PB
    Posts
    3

    Smile Parabéns

    Parabéns pela dica.
    Me ajudou bastante.

Permissões de Postagem

  • Você não pode iniciar novos tópicos
  • Você não pode enviar respostas
  • Você não pode enviar anexos
  • Você não pode editar suas mensagens
  •