Jump to content

New report: new signups by month


Patty

Recommended Posts

I wanted to know how many clients signed up each month so I put together a neat report that shows client ID, client name, status and sign up date.

 

It looks like this:

 

newclients.gif

 

 

 

Here's the code. Just save as monthly_clients.php and upload to whmcs/modules/reports:

 

<?php

$months = array('January','February','March','April','May','June','July','August','September','October','November','December');

if ($month=="") {
   $month=date("m");
   $year=date("Y");
}

$pmonth = str_pad($month, 2, "0", STR_PAD_LEFT);  

$reportdata["title"] = "New Clients for ".$months[$month-1]." ".$year;
$reportdata["description"] = "This report shows all new clients for a given month";

$query = "SELECT id,firstname,lastname,status,datecreated FROM tblclients WHERE datecreated LIKE '$year-$pmonth%' ORDER BY datecreated ASC";
$result = mysql_query($query); 
$num_rows = mysql_num_rows($result); 

$reportdata["headertext"] = "Total New Clients: " . $num_rows;

$reportdata["tableheadings"] = array("ID","Client Name","Status","Signup Date");

while ($data = mysql_fetch_array($result)) {
   $id = $data["id"];
   $clientname = "<a href=\"clientssummary.php?userid=". $data['id'] ."\" target=\"_blank\"\">" . $data["firstname"]." ".$data["lastname"] . "</a>"; 
   $status = $data["status"];
   $datecreated = $data["datecreated"];
   $datecreated = fromMySQLDate($datecreated);
   $colour = "<span style='color:"; 
switch($status) 
{ 
       case "Active": 
               $colour .= "blue"; 
       break; 
       case "Inactive": 
               $colour .= "lightgrey"; 
       break; 
       case "Closed": 
               $colour .= "red"; 
       break; 
} 
$colour .= ";'>"; 

   $reportdata["tablevalues"][] = array($id,$clientname,$colour . $status . "</span>",$datecreated);
}
$data["footertext"]="<table width=90% align=center><tr><td>";
if ($month=="1") {
   $data["footertext"].="<a href=\"$PHP_SELF?report=$report&month=12&year=".($year-1)."\"><< December ".($year-1)."</a>";
} else {
   $data["footertext"].="<a href=\"$PHP_SELF?report=$report&month=".($month-1)."&year=".$year."\"><< ".$months[($month-2)]." $year</a>";
}
$data["footertext"].="</td><td align=right>";
if ($month=="12") {
   $data["footertext"].="<a href=\"$PHP_SELF?report=$report&month=1&year=".($year+1)."\">January ".($year+1)." >></a>";
} else {
   $data["footertext"].="<a href=\"$PHP_SELF?report=$report&month=".($month+1)."&year=".$year."\">".$months[(($month+1)-1)]." $year >></a>";
}
$data["footertext"].="</td></tr></table>";

?>

 

Enjoy! :)

Link to comment
Share on other sites

  • 3 weeks later...

Hi, i have a little request. Currently we offer free trial so we have lots of new clients, but only a few of these pay, is there a way to separate accounts that have free plans form the others?

 

Thanks in advance for your help.

 

Regards,

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.

Guest
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

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated