WHMCS余额整合版
今天一口尽写了三个HOOK插件。。(我的说法不是很对。。HOOK不算插件)不过想与大家分享个余额显示HOOK,代码就贴在这里好了,只有一个PHP文件,丢GITHUB太麻烦了。。毕竟Github在这不是那么好上对吧?
下面是代码:
<?php
use WHMCS\View\Menu\Item as MenuItem;
if (App::getCurrentFilename() == 'clientarea' && $_SESSION['uid']) {
add_hook('ClientAreaPrimarySidebar', 10, function(MenuItem $primarySidebar) {
$client = getClientsDetails();
if($client) {
$newMenu = $primarySidebar->addChild(
'account-info',
array(
'name' => 'Home',
'label' => '账户详情',
'order' => 10,
'icon' => 'fa-balance-scale',
)
);
$newMenu->addChild(
'account_balance',
array(
'name' => 'account_balance',
'label' => "当前余额: ".formatCurrency($client['credit']),
'order' => 0,
)
);
}
});
}
add_hook('ClientAreaFooterOutput', 1, function($vars)
{
$command = "getclientsdetails";
$adminuser = "tanyuliang";
$values["clientid"] = $_SESSION['uid'];
$results = localAPI($command,$values,$adminuser);
if($_SESSION['uid']) {
$footer_return = '
<script>jQuery(document).ready(function() {
$($(".pull-right.nav")[1]).after(\'<div class="pull-right nav"><a href="#" class="quick-nav" " id="credit" style="text-decoration: none;"><i class="fa fa-money"></i> 余额:¥'.$results['credit'].'RMB</a></div>\')
})</script>';
return $footer_return;
}
}
);