Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e5a36f9db07440e260df1c0493931f83 to your computer and use it in GitHub Desktop.
Save anonymous/e5a36f9db07440e260df1c0493931f83 to your computer and use it in GitHub Desktop.
<?php
/**
* Display Client's Credit Balance in Client Area
*
* @author WHMCMS
* @link www.whmcms.com
* @since WHMCS v6.0.0+
*/
use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;
# Add Balance To Sidebar
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar){
$filename = basename($_SERVER['REQUEST_URI'], ".php");
$parseFile = explode('.', $filename);
$client = Menu::context("client");
$clientid = intval($client->id);
if ($parseFile['0']!=='clientarea' || $clientid===0){
return;
}
$primarySidebar->addChild('Client-Balance', array(
'label' => "Available Credit",
'uri' => '#',
'order' => '1',
'icon' => 'fa-money'
));
# Get Currency
$getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get();
# Retrieve the panel we just created.
$balancePanel = $primarySidebar->getChild('Client-Balance');
// Move the panel to the end of the sorting order so it's always displayed
// as the last panel in the sidebar.
$balancePanel->moveToBack();
$balancePanel->setOrder(0);
# Add Balance.
$balancePanel->addChild('balance-amount', array(
'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>',
'order' => 1
));
$fundsenabled = Capsule::table('tblconfiguration')->where('setting','AddFundsEnabled')->value('value');
if ($fundsenabled == "on") {
$balancePanel->setFooterHtml(
'<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block">
<i class="fa fa-plus"></i> '.Lang::trans('Add Funds').'</a>'
);
}
});
# Fix Six Template's Content Area
add_hook("ClientAreaHeadOutput", 1, function($vars){
return '<style type="text/css">.main-content {min-height: 600px;}</style>';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment