ST4R Posted August 17, 2017 Share Posted August 17, 2017 Hi. I want to make Unpaid Invoices's Panel sticky, in other words, I want to change its conditions for display to "always display" instead of "At least one unpaid". So it must show even if there's no unpaid invoices. Also if there's no unpaid invoices, it should return "There's no unpaid invoice, Thanks". Please help me. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 17, 2017 Share Posted August 17, 2017 I want to make Unpaid Invoices's Panel sticky, in other words, I want to change its conditions for display to "always display" instead of "At least one unpaid". So it must show even if there's no unpaid invoices.Also if there's no unpaid invoices, it should return "There's no unpaid invoice, Thanks". quick answer is that you can't make it sticky - because you can't edit the conditions under which the panel is shown. therefore, I suspect your only realistic option would be to delete the panel (using an action hook) and recreate it again with your own conditions (e.g always shown). recreating the panel could be done in one of two ways - either via an action hook (query the database or using the API to determine if there are unpaid invoices, their number and values), or potentially in the template... doing it in the template would be complicated, but you should already have access to the variables you require to do this. however, of the two methods, the better way would be the action hook. https://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels 0 Quote Link to comment Share on other sites More sharing options...
ST4R Posted August 17, 2017 Author Share Posted August 17, 2017 Yes, I got same idea. I'd rather go with the action hook I've read your mentioned article. To recreate it, how can I define the conditions? (If there are unpaid invoices show them as regular ELSE return "There's no unpaid invoice, Thanks") 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 17, 2017 Share Posted August 17, 2017 well you won't need conditions to show the panel (as you always want to show it), so it'll be a case of getting the number of unpaid invoices and if > 0, to output one message in the panel body... else output "there's no unpaid invoices". 0 Quote Link to comment Share on other sites More sharing options...
ST4R Posted August 17, 2017 Author Share Posted August 17, 2017 I don't mean the Panel Conditions for display! How can I do the following for a new Panel? IF there are unpaid invoices show the number of unpaid invoices and the total amount (Ex: You have $number unpaid invoices. please pay $total_amount) ELSE return "There's no unpaid invoice" Can you please help me with that? I'm not a seasoned programmer. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 17, 2017 Share Posted August 17, 2017 when you say help, you mean you want me to write it for you? well just this once as the variables already exist... <?php use WHMCS\View\Menu\Item as Item; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { GLOBAL $smarty; $numunpaidinvoices = $smarty->getVariable('clientsstats')->value['numunpaidinvoices']; $unpaidinvoicesamount = $smarty->getVariable('clientsstats')->value['unpaidinvoicesamount']; $numoverdueinvoices = $smarty->getVariable('clientsstats')->value['numoverdueinvoices']; $overdueinvoicesbalance = $smarty->getVariable('clientsstats')->value['overdueinvoicesbalance']; if ($numunpaidinvoices > 0) { $bodyhtml = '<p>You have '.$numunpaidinvoices.' unpaid invoice(s) with a total balance due of '.$unpaidinvoicesamount.'</p>'; } elseif ($numoverdueinvoices > 0) { $bodyhtml = '<p>You have '.$numoverdueinvoices.' overdue invoice(s) with a total balance due of '.$overdueinvoicesbalance.' - Pay them now to avoid any interruptions in service.</p>'; } else { $bodyhtml = '<p>You have no unpaid or overdue invoices!</p>'; } $creditPanel = $homePagePanels->addChild( 'Invoices', array( 'label' => Lang::trans('invoices'), 'icon' => 'fa-money', 'extras' => array( 'color' => 'red', 'btn-link' => 'clientarea.php?action=invoices', 'btn-text' => Lang::trans('viewAll'), 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml )); }); you'll still need to remove the default panel with a hook, but you can do that via code in the documentation or code i've previously posted. 0 Quote Link to comment Share on other sites More sharing options...
ST4R Posted August 17, 2017 Author Share Posted August 17, 2017 when you say help, you mean you want me to write it for you? I think yeah! It worked perfectly. Thank you, brian! 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.