WHMCS Guru Support Forums

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reports Server Account Report

Additional Reports

whmcsguru

Chief Guru
Staff member
This is a report tool I wrote a few years back (looks like it might have been v5 or 6 based on the code). Cleaned it up, updated it for V6+ . This is just a report, nothing fancy there.

Save the following as server_account_report.php in modules/reports. The file name is quite specific

PHP:
<?php
use Illuminate\Database\Capsule\Manager as Capsule;

# The title of your report
$serverid = $_GET['serverid'];
//search for clients in that group

$reportdata["title"] = "Hosting account report by server";
# Report Table of Data Column Headings - should be an array of values

if (!isset($serverid))
{
    //make 'em get the server list first
    $reportdata["tableheadings"] = array("Server","Hostname","IP Address","Total Accounts List");
    //$query="select name, hostname, id, ipaddress FROM tblservers";

    foreach (Capsule::table(tblservers) ->get() as $res)

    {
        $retrow = "";
        $servername = $res->name;
        $sid=$res->id;
        $hostname = $res->hostname;
        $ipaddress = $res->ipaddress;
        $retrow .="<a href=\"reports.php?report=server_account_report&serverid=$sid\">$servername</a>";
        $accountlist = fetch_the_account_num($sid);
        $reportdata["tablevalues"][] = array($retrow,$hostname,$ipaddress,$accountlist);

    }


}

else
{

    $reportdata["tableheadings"] = array("Name","Service","Domain","Next Due", "Account Status");

    foreach (Capsule::table(tblhosting)->WHERE('server','=',$serverid) ->get() as $serverdata)

    {
        $theid = $serverdata->id;
        $packageid = $serverdata->packageid;
        $regdate = $serverdata->regdate;
        $userid = $serverdata->userid;
        $domain = $serverdata->domain;
        $nextdue = $serverdata->nextduedate;
        $theuser = fetch_the_account_name($userid);
        $pkgname = fetch_the_package_name($packageid);
        $status = $serverdata->domainstatus;
        $pkglink = "<a href=clientsservices.php?productselect=$theid>$pkgname</a>";
        $reportdata["tablevalues"][] = array($theuser,$pkglink,$domain, $nextdue,$status);
    }

}
function fetch_the_package_name($packageid)
{

    foreach (Capsule::table(tblproducts)->WHERE('id','=',$packageid) ->get() as $pres)
    {
        $thename = $pres->name;
        return($thename);
    }
}

function fetch_the_account_name($userid)
{

    foreach (Capsule::table(tblclients)->WHERE('id','=',$userid) ->get() as $res3)
    {
        $fname = $res3->firstname;
        $lname = $res3->lastname;
        $bname = $res3->companyname;
        $clientlink = "<a href=\"clientssummary.php?userid=$userid\">";
        $retname = "$fname $lname [$bname]</a>";
        $clientlink .= $retname;
        return($clientlink);
    }
}
function fetch_the_account_num($serverid)
{
    $anrows = Capsule::table('tblhosting')->where('server', '=', $serverid)->count();
    return ($anrows);
}

$data["footertext"] = "<div align=\"center\">[<a href=\"reports.php?report=server_account_report\">Report Home</a>]</div>";

?>
 

Users who are viewing this thread

Back
Top