hpk Posted July 13, 2015 Share Posted July 13, 2015 Hello all, I am unable to locate the clients credit balance in the client area for the six template. Can someone guide me or if confirm if the balance is even included? Regards, Israr 0 Quote Link to comment Share on other sites More sharing options...
HarryWales Posted July 13, 2015 Share Posted July 13, 2015 It is in same place as it was in 5 - under Clients Profile/Summary - middle section "Credit Balance" 0 Quote Link to comment Share on other sites More sharing options...
HarryWales Posted October 6, 2015 Share Posted October 6, 2015 That didn't answer the question - question was about the credit balance in the CLIENT AREA - not in whmcs Admin 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 7, 2015 Share Posted October 7, 2015 here is how to implement it in Six template sidebar https://forum.whmcs.com/showthread.php?106891-Display-Credit-Balance-In-Six-Template 0 Quote Link to comment Share on other sites More sharing options...
HarryWales Posted October 7, 2015 Share Posted October 7, 2015 Many thanks - this was much needed! 0 Quote Link to comment Share on other sites More sharing options...
payless4domains Posted May 13, 2016 Share Posted May 13, 2016 Many thanks - this was much needed! Hi Sentq, I know that this is an old post, but I was hoping that you might be able to help me with a question in regard to the credit balance hook, I would like to hook it to a single product on the clientarea product details page, using a single pid, and not be shown anywhere else in the clientarea. Can this be done? if it can't can you suggest an alt. Kev 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 13, 2016 Share Posted May 13, 2016 Hi Kev, to do that open my actionhook file for editing and in line #26, right after: if ($filename!=='clientarea' || $clientid===0){ return; } add these lines: $allowedinproductids = array(6, 12, 14); $productInfo = Menu::context("service"); if (!in_array($productInfo->packageid, $allowedinproductids)){ return; } replace 6, 12, and 14 with packageids you need this actionhook to display inside. 0 Quote Link to comment Share on other sites More sharing options...
payless4domains Posted May 13, 2016 Share Posted May 13, 2016 Hi Kev, to do that open my actionhook file for editing and in line #26, right after: if ($filename!=='clientarea' || $clientid===0){ return; } add these lines: $allowedinproductids = array(6, 12, 14); $productInfo = Menu::context("service"); if (!in_array($productInfo->packageid, $allowedinproductids)){ return; } replace 6, 12, and 14 with packageids you need this actionhook to display inside. Thankyou, you are awesome By any chance, you would have a code/hook that would show the clientsproducts table on the home page would you? I know that I can copy and paste the code from the tpl, but I can't seem to work out how to get it to list the products,price,date etc in the table. Once again thankyou. Kev 0 Quote Link to comment Share on other sites More sharing options...
akust0m Posted May 14, 2016 Share Posted May 14, 2016 Hello, Thank you for this hook! I don't understand why it isn't a standard feature in the Six theme. One small request if I may, how do I only enable this hook only the primary client area page? (/clientarea.php) 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 14, 2016 Share Posted May 14, 2016 Hello, Thank you for this hook! I don't understand why it isn't a standard feature in the Six theme. One small request if I may, how do I only enable this hook only the primary client area page? (/clientarea.php) Thank you open ActionHook file for editing, after if ($filename!=='clientarea' || $clientid===0){ return; } add the following if ($_REQUEST['action']!=""){ return; } - - - Updated - - - Thankyou, you are awesome By any chance, you would have a code/hook that would show the clientsproducts table on the home page would you? I know that I can copy and paste the code from the tpl, but I can't seem to work out how to get it to list the products,price,date etc in the table. Once again thankyou. Kev Glad you like it you mean "Home Page Panel" right? http://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels 0 Quote Link to comment Share on other sites More sharing options...
payless4domains Posted July 15, 2016 Share Posted July 15, 2016 (edited) Thank you Sentq, this has been working perfectly on our clientsproductdetails.tpl page. I've had clients recently asking if they can also see it on their other client pages, go figure. So I was just wondering can this code be modified so that if the client has the product id, can the $services.product be allowed to be shown on all the clients pages. Only if they have one of the allowedproductids. <?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 if (App::getCurrentFilename() == 'clientarea') { 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; } $allowedinproductids = array(70); $productInfo = Menu::context("service"); if (!in_array($productInfo->packageid, $allowedinproductids)){ return; } $primarySidebar->addChild('Client-Balance', array( 'label' => "Account Balance", 'uri' => '#', 'order' => '1', 'icon' => 'fa-university' )); # 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->moveToFront(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( 'uri' => '#', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); }); } Thanks again in advance. Kev Edited July 15, 2016 by payless4domains 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 15, 2016 Share Posted July 15, 2016 Kev, So I was just wondering can this code be modified so that if the client has the product id, can the $services.product be allowed to be shown on all the clients pages. Only if they have one of the allowedproductids i'm slightly confused - is it a typo with regards to '$services.product' ? do you want the credit sidebar to be shown if the client has a specified product, or do you want to do something else if he has the product? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted July 15, 2016 Share Posted July 15, 2016 yes it is a little confusing, the following version will display it in clientarea.php and when client is viewing one of his services, it will only display if this product is one of the allowed products (line #17) <?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){ $allowedProductsId = array(1, 15, 20); $client = Menu::context("client"); $service = Menu::context("serviceView"); $clientid = intval($client->id); if (App::getCurrentFilename()!=='clientarea' || $clientid===0){ return; } if (!in_array($service->packageid, $allowedProductsId) && is_integer($service->packageid)){ return; } $allowedinproductids = array(70); $productInfo = Menu::context("service"); if (!in_array($productInfo->packageid, $allowedinproductids)){ return; } $primarySidebar->addChild('Client-Balance', array( 'label' => "Account Balance", 'uri' => '#', 'order' => '1', 'icon' => 'fa-university' )); # 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->moveToFront(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( 'uri' => '#', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); }); 0 Quote Link to comment Share on other sites More sharing options...
payless4domains Posted July 18, 2016 Share Posted July 18, 2016 Hi brian & sentq, Sorry for the confusion. And correct Brian "do you want the credit sidebar to be shown if the client has a specified product" My clients are asking that if they have $allowedProductsId = array(70); (specified product),can they see their credit balance on all of their clientarea.php?,submitticket.php?,knowledgebase.php?(basiclly all loggedin pages) instead of just being able to see it on their clientarea.php?action=productdetails&id=70 page. Thank you Sentq for posting the newly modified code, I think we are close to what I'm after but the code still only shows on the clientarea.php?action=productdetails&id=70 and not their other loggedin pages, due to my poor explanation at the start, is it possible to show on their pages? Thanks again guys, Kev 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 18, 2016 Share Posted July 18, 2016 Kev, you could do it by querying the database to see if the client has one of the products in your array... <?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){ $client = Menu::context("client"); $clientid = intval($client->id); $allowedinproductids = array(70); $clientproducts = Capsule::table('tblhosting') ->where('userid',$clientid) ->whereIn('packageid', $allowedinproductids) ->count(); if (App::getCurrentFilename()!=='clientarea' || $clientid===0 || $clientproducts==0){ return; } $primarySidebar->addChild('Client-Balance', array( 'label' => "Account Balance", 'uri' => '#', 'order' => '1', 'icon' => 'fa-university' )); # 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->moveToFront(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( 'uri' => '#', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); }); so this will count how many of the allowed products the client has and, if it's 1 or more, will show the sidebar on all client area pages. I suppose the way to do it through the class documentation would be to check the client -> $services array, but the above database method should work equally well. 0 Quote Link to comment Share on other sites More sharing options...
payless4domains Posted July 19, 2016 Share Posted July 19, 2016 Thanks Brian, That works excellent on all of the clientarea pages. I use a hook on all loggedin pages, clientarea.php and any other ones to show clients product data, can we link this hook in with that one so that the client's balance shows on all loggedin pages? as I understand that the reason that the above code doesn't show on cart pages,ticket pages or any custom pages etc is that the product id syntax is not linked to those pages. This is the hook to show clients product data. <?php add_hook( 'ClientAreaPage', 1, function( $vars ) { $user = Menu :: context( 'client' ); $data = array( 'showproductdata' => false ); if (! $user ) return $data; $products = localAPI( 'getclientsproducts', array( 'clientid' => $user->getAttribute( 'id' ), ), 'admin' ); if (! $products || $products['result'] != 'success' || $products['totalresults'] == 0 || count( $products['products'] ) == 0 ) return $data; $data['showproductdata'] = true; $product = $products['products']['product'][0]; $info = null; $title = $product['translated_name']; $status = $product['status']; switch( $product['pid'] ) : case '70' : $info = 'membership'; break; endswitch; $data['myproduct'] = array( 'info' => $info, 'title' => $title, 'status' => $status); return $data; }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 19, 2016 Share Posted July 19, 2016 Thanks Brian, That works excellent on all of the clientarea pages.I use a hook on all loggedin pages, clientarea.php and any other ones to show clients product data, can we link this hook in with that one so that the client's balance shows on all loggedin pages? if you wanted to show the sidebar on all pages, you could just remove the reference to the clientarea in the if statement.. e.g change... if (App::getCurrentFilename()!=='clientarea' || $clientid===0 || $clientproducts==0){ return; } to... if ($clientproducts==0){ return; } because this sidebar for you is now only showing when the client has specific product(s), I don't think we need to check that $clientid is not identical to 0 - if it were, $clientprodusts will be too... but you can put it back in if you wish. as I understand that the reason that the above code doesn't show on cart pages,ticket pages or any custom pages etc is that the product id syntax is not linked to those pages. not quite - it didn't work outside of the client area was because, logically, the original hook specified that it only worked in the client area... remove that limitation and it will work everywhere.... except the cart! and the reason why it doesn't work in the cart is a simple one - sentq's hook modifies the primary sidebar... but the cart uses the secondary sidebar only, not the primary - so it is added, but as the primary sidebar is not displayed, you never get to see it! the fix would be to use a second hook, either in one file or separately, that modifies both primary and secondary sidebars... <?php /** * Display Client's Credit Balance in Client Area * * @author WHMCMS (slightly tweaked by brian!) * @link www.whmcms.com * @since WHMCS v6.0.0+ */ use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaSidebars', 1, function () { $primarySidebar = Menu::primarySidebar(); $secondarySidebar = Menu::secondarySidebar(); $client = Menu::context("client"); $clientid = intval($client->id); $allowedinproductids = array(45); $clientproducts = Capsule::table('tblhosting') ->where('userid',$clientid) ->whereIn('packageid', $allowedinproductids) ->count(); $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get(); $clientbalance = "'label' => 'Account Balance', 'uri' => '#', 'order' => '1', 'icon' => 'fa-university'"; if ($clientproducts==0){ return; } if (App::getCurrentFilename()!=='cart'){ $primarySidebar->addChild('Client-Balance', array($clientbalance)); $balancePanel = $primarySidebar->getChild('Client-Balance'); } else { $secondarySidebar->addChild('Client-Balance', array($clientbalance)); $balancePanel = $secondarySidebar->getChild('Client-Balance'); } $balancePanel->moveToFront(); $balancePanel->setOrder(0); $balancePanel->addChild('balance-amount', array( 'uri' => '#', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); }); the above hook should use the secondary sidebar in the cart, and the primary sidebar everywhere else. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.