Jump to content

Is there s smarty syntax to display total # of clients?


Blu_

Recommended Posts

Okay so basically im not sure if this is possible or not but i want my clients to know how many total clients there are in our WHMCS system... Is there a smarty syntax thing that displays the total number of clients we have? In number form.

 

Please help, cant find anywhere! :|

Link to comment
Share on other sites

there isn't a direct Smarty variable that you can use, so you will have to query the database to get these values and assign them to a variable...

 

if you wanted to display the total number of clients, you could use the following in a template...

 

{php}
$counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients");
$num = mysql_fetch_array($counter);
$count = $num["id"];
$this->assign('clienttotal',$count); 
{/php}

Then you can add the code below to where you want to display the number.

 

{$clienttotal}

in a similar way, you could show number of domains...

 

{php}
$counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains");
$num2 = mysql_fetch_array($counter2);
$count2 = $num2["id"];
$this->assign('domaintotal',$count2);
{/php}

Then you can add the code below to where you want to display the result.

 

{$domaintotal}

this will show you the total number of domains in WHMCS, but will also include expired domains too... if you wanted to show only "Active" domains, you would replace the first line of the above with...

 

{php}
$counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains WHERE status='Active'");
$num2 = mysql_fetch_array($counter2);
$count2 = $num2["id"];
$this->assign('domaintotal',$count2);
{/php}

similarly, you could show the number of active clients by using...

 

$counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients WHERE status='Active'");

for completeness, if you wanted to show number of products/services (hosting), you could use...

 

{php}
$counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting");
$num3 = mysql_fetch_array($counter3);
$count3 = $num3["id"];
$this->assign('hostingtotal',$count3);
{/php}

or for active products only...

 

$counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting WHERE domainstatus='Active'");

all three combined...

 

{php}
$counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients WHERE status='Active'");
$num = mysql_fetch_array($counter);
$count = $num["id"];
$this->assign('clienttotal',$count); 

$counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains WHERE status='Active'");
$num2 = mysql_fetch_array($counter2);
$count2 = $num2["id"];
$this->assign('domaintotal',$count2); 

$counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting WHERE domainstatus='Active'");
$num3 = mysql_fetch_array($counter3);
$count3 = $num3["id"];
$this->assign('hostingtotal',$count3); 
{/php}

Number of Clients - {$clienttotal}<br>
Number of Domains - {$domaintotal}<br>
Number of Products - {$hostingtotal}

Link to comment
Share on other sites

there isn't a direct Smarty variable that you can use, so you will have to query the database to get these values and assign them to a variable...

 

if you wanted to display the total number of clients, you could use the following in a template...

 

{php}
$counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients");
$num = mysql_fetch_array($counter);
$count = $num["id"];
$this->assign('clienttotal',$count); 
{/php}

Then you can add the code below to where you want to display the number.

 

 

in a similar way, you could show number of domains...

 

{php}
$counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains");
$num2 = mysql_fetch_array($counter2);
$count2 = $num2["id"];
$this->assign('domaintotal',$count2);
{/php}

Then you can add the code below to where you want to display the result.

 

 

this will show you the total number of domains in WHMCS, but will also include expired domains too... if you wanted to show only "Active" domains, you would replace the first line of the above with...

 

{php}
$counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains WHERE status='Active'");
$num2 = mysql_fetch_array($counter2);
$count2 = $num2["id"];
$this->assign('domaintotal',$count2);
{/php}

similarly, you could show the number of active clients by using...

 

$counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients WHERE status='Active'");

for completeness, if you wanted to show number of products/services (hosting), you could use...

 

{php}
$counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting");
$num3 = mysql_fetch_array($counter3);
$count3 = $num3["id"];
$this->assign('hostingtotal',$count3);
{/php}

or for active products only...

 

$counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting WHERE domainstatus='Active'");

all three combined...

 

{php}
$counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients WHERE status='Active'");
$num = mysql_fetch_array($counter);
$count = $num["id"];
$this->assign('clienttotal',$count); 

$counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains WHERE status='Active'");
$num2 = mysql_fetch_array($counter2);
$count2 = $num2["id"];
$this->assign('domaintotal',$count2); 

$counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting WHERE domainstatus='Active'");
$num3 = mysql_fetch_array($counter3);
$count3 = $num3["id"];
$this->assign('hostingtotal',$count3); 
{/php}

Number of Clients - {$clienttotal}<br>
Number of Domains - {$domaintotal}<br>
Number of Products - {$hostingtotal}

 

Thank you dude! This is exactly what i was looking for! Big props my good sir! This will come in handy to so many people who are having the same problem I have.

Link to comment
Share on other sites

  • 7 months later...
  • 2 months later...

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