This knowledge base is for WHMCS v5 only. Please refer to the following GIT repository for the new approach.
https://github.com/WebuddhaInc/whmcs.wbtimelog.client-sidebar
You can create a custom experience by adding the following code to any portion of your WHMCS client area template.
The display will be a box indicating to your cleint that more hours will need to be purchased before they continue receiving premium support.
{if $loggedin}
{php}
$clientId = $this->_tpl_vars['clientsdetails']['id'];
$dbh =& wbDatabase::getInstance();
$dbh->runQuery("
SELECT (SELECT SUM(`log`.`hours`) FROM `tbladdon_wbclientstimelog` AS `log` WHERE `log`.`userid` = '$clientId') AS `total_hours`
, (SELECT SUM(`credit`.`hours`) FROM `tbladdon_wbclientstimelog_credits` AS `credit` WHERE `credit`.`userid` = '$clientId') AS `total_credits`
");
$report = $dbh->getRow();
$this->_tpl_vars['wbtimelog_report'] = array();
$this->_tpl_vars['wbtimelog_report']['total_hours'] = round($report['total_hours'],2);
$this->_tpl_vars['wbtimelog_report']['total_credits'] = round($report['total_credits'],2);
$report['total_balance'] = $report['total_credits'] - $report['total_hours'];
$this->_tpl_vars['wbtimelog_report']['total_balance'] = round($report['total_balance'],2);
$this->_tpl_vars['wbtimelog_report']['total_balance_formatted'] = ($report['total_balance'] >= 0 ? round($report['total_balance'],2) : '<font color=red>('.abs(round($report['total_balance'],2)).')</font>');
{/php}
<div class="wbtimelog_widget">
<p>You have <b>{$wbtimelog_report.total_balance_formatted} hours</b> remaining of premium support.</p>
<button>Click here to purchase more hours</button>
</div>
{literal}
<style>
.wbtimelog_widget {
text-align:center;
padding:10px;
margin:10px;
border:1px solid #999;
background:#f6f6f6;
border-radius:6px;
}
</style>
{/literal}
{/if}