Created
February 21, 2018 18:55
-
-
Save anonymous/e5a36f9db07440e260df1c0493931f83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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