actionhosting Posted January 6, 2021 Share Posted January 6, 2021 Hello All, As whmcs removed the toolbar from v8, and thanks to Brian's hook I am able to adjust it and add back overdue invoices to just the admin home page. In the image attached, you will see it above the panel badges (by default the 4 whmcs provided badges). I am able to adjust the css to add a 5th panel badge as the image will show. Question does any knows how I can hook into the panel badges, as whmcs support does not have an answer. All I want to do is a) from the image remove Brian's modified hook, and hook into the panel badge as display total overdue invoices. Thanks in advance. Brian 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 8, 2021 Share Posted January 8, 2021 (edited) On 06/01/2021 at 16:23, actionhosting said: Question does any knows how I can hook into the panel badges, as whmcs support does not have an answer. wow! 🙄 On 06/01/2021 at 16:23, actionhosting said: All I want to do is a) from the image remove Brian's modified hook just rename the extension on the hook from .php to .php9 and that will stop it from loading (or delete the file if you think you'll never need it again). On 06/01/2021 at 16:23, actionhosting said: and hook into the panel badge as display total overdue invoices. the simplest way to do this would be to... duplicate the Badges.php file in /modules/widgets and call it Badges2.php - do not edit the original Badges.php file as your changes would get overwritten during an update. in Badges2.php, insert the following code... <?php namespace WHMCS\Module\Widget; use WHMCS\Carbon; use WHMCS\Clients; use WHMCS\Module\AbstractWidget; use WHMCS\Module\Queue as ModuleQueue; use WHMCS\Orders; use WHMCS\Billing\Invoice; /** * Badges Widget. * * @copyright Copyright (c) WHMCS Limited 2005-2018 * @license https://www.whmcs.com/license/ WHMCS Eula */ class Badges2 extends AbstractWidget { protected $title = 'Badges (Modified)'; protected $description = ''; protected $columns = 3; protected $weight = 0; protected $wrapper = false; protected $cache = true; protected $cacheExpiry = 120; protected $draggable = false; public function getData() { $clients = new Clients(); $orders = new Orders(); $ticketCounts = localApi('GetTicketCounts', array()); return array( 'pendingOrders' => $orders->getPendingCount(), 'ticketsAwaitingReply' => $ticketCounts['awaitingReply'], 'cancellations' => $clients->getNumberOfOpenCancellationRequests(), 'moduleQueueCount' => ModuleQueue::incomplete()->count(), ); } public function generateOutput($data) { $pendingOrders = (int) $data['pendingOrders']; $awaitingReply = (int) $data['ticketsAwaitingReply']; $pendingCancellations = (int) $data['cancellations']; $moduleQueueCount = (int) $data['moduleQueueCount']; $overdueinvoices = Invoice::overdue()->count(); return <<<EOF <div class="row home-status-badge-row"> <div class="col-sm-2"> <div class="health-status-block status-badge-green clearfix"> <div class="icon"> <a href="orders.php"> <i class="fas fa-shopping-cart"></i> </a> </div> <div class="detail"> <a href="orders.php?status=Pending"> <span class="count">{$pendingOrders}</span> <span class="desc">Pending Orders</span> </a> </div> </div> </div> <div class="col-sm-2"> <div class="health-status-block status-badge-pink clearfix"> <div class="icon"> <a href="supporttickets.php"> <i class="fas fa-comment"></i> </a> </div> <div class="detail"> <a href="supporttickets.php"> <span class="count">{$awaitingReply}</span> <span class="desc">Tickets Waiting</span> </a> </div> </div> </div> <div class="col-sm-2"> <div class="health-status-block status-badge-orange clearfix"> <div class="icon"> <a href="cancelrequests.php"> <i class="fas fa-ban"></i> </a> </div> <div class="detail"> <a href="cancelrequests.php"> <span class="count">{$pendingCancellations}</span> <span class="desc">Pending Cancellations</span> </a> </div> </div> </div> <div class="col-sm-2"> <div class="health-status-block status-badge-cyan clearfix"> <div class="icon"> <a href="modulequeue.php"> <i class="fas fa-exclamation-triangle"></i> </a> </div> <div class="detail"> <a href="modulequeue.php"> <span class="count">{$moduleQueueCount}</span> <span class="desc">Pending Module Actions</span> </a> </div> </div> </div> <div class="col-sm-2"> <div class="health-status-block status-badge-pink clearfix"> <div class="icon"> <a href="invoices.php?status=Overdue"> <i class="fas fa-sack-dollar"></i> </a> </div> <div class="detail"> <a href="modulequeue.php"> <span class="count">{$overdueinvoices}</span> <span class="desc">Overdue Invoices</span> </a> </div> </div> </div> </div> EOF; } } save the file. in the admin area, disable the original Badges widget. the screenshot below shows the default Badges widget on top, and the modified one below it.... then it's just a case of disabling the Badges widget and either playing with the CSS of the badges, or adding a 6th to fill the space. there is a way to do this as a hook and put the file in /includes/hooks instead, but I always prefer to put widget code in the widgets folder. Edited January 8, 2021 by brian! 0 Quote Link to comment Share on other sites More sharing options...
actionhosting Posted January 8, 2021 Author Share Posted January 8, 2021 Brian, you are awesome, many many thanks. The only change was i replace col-sm-2 to a custom class and set width to 20% Once again thanks Brian 0 Quote Link to comment Share on other sites More sharing options...
tangogc Posted January 9, 2021 Share Posted January 9, 2021 I discovered a little bug in this hook look the screenshot if you click on the red circle it go to modulequeue if you click on the red arrow it work correctly 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 11, 2021 Share Posted January 11, 2021 On 09/01/2021 at 09:52, tangogc said: I discovered a little bug in this hook look the screenshot if you click on the red circle it go to modulequeue if you click on the red arrow it work correctly yeah good spot - it was just a quick copy&paste job to give @actionhosting a starting point from which to work from.... I can't edit the code in my original post. 0 Quote Link to comment Share on other sites More sharing options...
tangogc Posted January 11, 2021 Share Posted January 11, 2021 I cant edit too 🙂 could you post again the correct code please 0 Quote Link to comment Share on other sites More sharing options...
actionhosting Posted January 11, 2021 Author Share Posted January 11, 2021 Thanks Brian, I did notice it and fixed it. I didnt advise as the pending module action is similar. Here is my updated code . <?php namespace WHMCS\Module\Widget; use WHMCS\Carbon; use WHMCS\Clients; use WHMCS\Module\AbstractWidget; use WHMCS\Module\Queue as ModuleQueue; use WHMCS\Orders; use WHMCS\Billing\Invoice; /** * Badges Widget. * * @copyright Copyright (c) WHMCS Limited 2005-2018 * @license https://www.whmcs.com/license/ WHMCS Eula */ class WSIBadges extends AbstractWidget { protected $title = 'WSIBadges'; protected $description = ''; protected $columns = 3; protected $weight = 0; protected $wrapper = false; protected $cache = true; protected $cacheExpiry = 120; protected $draggable = false; public function getData() { $clients = new Clients(); $orders = new Orders(); $ticketCounts = localApi('GetTicketCounts', array()); return array( 'pendingOrders' => $orders->getPendingCount(), 'ticketsAwaitingReply' => $ticketCounts['awaitingReply'], 'cancellations' => $clients->getNumberOfOpenCancellationRequests(), 'moduleQueueCount' => ModuleQueue::incomplete()->count(), ); } public function generateOutput($data) { $pendingOrders = (int) $data['pendingOrders']; $awaitingReply = (int) $data['ticketsAwaitingReply']; $pendingCancellations = (int) $data['cancellations']; $moduleQueueCount = (int) $data['moduleQueueCount']; $overdueinvoices = Invoice::overdue()->count(); return <<<EOF <div class="row home-status-badge-row"> <div class="col-wsm-2"> <div class="health-status-block status-badge-green clearfix"> <div class="icon"> <a href="orders.php"> <i class="fas fa-shopping-cart"></i> </a> </div> <div class="detail"> <a href="orders.php?status=Pending"> <span class="count">{$pendingOrders}</span> <span class="desc">Pending Orders</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-pink clearfix"> <div class="icon"> <a href="supporttickets.php"> <i class="fas fa-comment"></i> </a> </div> <div class="detail"> <a href="supporttickets.php"> <span class="count">{$awaitingReply}</span> <span class="desc">Tickets Waiting</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-orange clearfix"> <div class="icon"> <a href="cancelrequests.php"> <i class="fas fa-ban"></i> </a> </div> <div class="detail"> <a href="cancelrequests.php"> <span class="count">{$pendingCancellations}</span> <span class="desc">Pending Cancellations</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-cyan clearfix"> <div class="icon"> <a href="modulequeue.php"> <i class="fas fa-exclamation-triangle"></i> </a> </div> <div class="detail"> <a href="modulequeue.php"> <span class="count">{$moduleQueueCount}</span> <span class="desc">Pending Module Actions</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-red clearfix"> <div class="icon"> <a href="invoices.php?status=Overdue"> <i class="fas fa-sack-dollar"></i> </a> </div> <div class="detail"> <a href="invoices.php?status=Overdue"> <span class="count">{$overdueinvoices}</span> <span class="desc">Overdue Invoices</span> </a> </div> </div> </div> </div> EOF; } } .col-wsm-2 { width: 20%; float: left; padding: 0 5px; } .status-badge-red { background-color: #ff0000; } .status-badge-red .icon { background-color: #e40707; } .health-status-block .detail { float: left; display: inline-block; padding: 8px 15px; width: 79%; height: 70px; border-radius: 0 4px 4px 0; text-align: center; } .health-status-block .icon { float: left; display: inline-block; width: 20%; height: 70px; font-size: 2em; line-height: 70px; text-align: center; border-radius: 4px 0 0 4px; } But I will also revert back to badges,.php and remove the pending module action as it is duplicated in the system health widget and use that location for the overdue invoice. So no css changes will be needed. With the above this is how it looks at this time. 0 Quote Link to comment Share on other sites More sharing options...
tangogc Posted January 11, 2021 Share Posted January 11, 2021 (edited) 18 minutes ago, actionhosting said: Thanks Brian, I did notice it and fixed it. I didnt advise as the pending module action is similar. Here is my updated code . <?php namespace WHMCS\Module\Widget; use WHMCS\Carbon; use WHMCS\Clients; use WHMCS\Module\AbstractWidget; use WHMCS\Module\Queue as ModuleQueue; use WHMCS\Orders; use WHMCS\Billing\Invoice; /** * Badges Widget. * * @copyright Copyright (c) WHMCS Limited 2005-2018 * @license https://www.whmcs.com/license/ WHMCS Eula */ class WSIBadges extends AbstractWidget { protected $title = 'WSIBadges'; protected $description = ''; protected $columns = 3; protected $weight = 0; protected $wrapper = false; protected $cache = true; protected $cacheExpiry = 120; protected $draggable = false; public function getData() { $clients = new Clients(); $orders = new Orders(); $ticketCounts = localApi('GetTicketCounts', array()); return array( 'pendingOrders' => $orders->getPendingCount(), 'ticketsAwaitingReply' => $ticketCounts['awaitingReply'], 'cancellations' => $clients->getNumberOfOpenCancellationRequests(), 'moduleQueueCount' => ModuleQueue::incomplete()->count(), ); } public function generateOutput($data) { $pendingOrders = (int) $data['pendingOrders']; $awaitingReply = (int) $data['ticketsAwaitingReply']; $pendingCancellations = (int) $data['cancellations']; $moduleQueueCount = (int) $data['moduleQueueCount']; $overdueinvoices = Invoice::overdue()->count(); return <<<EOF <div class="row home-status-badge-row"> <div class="col-wsm-2"> <div class="health-status-block status-badge-green clearfix"> <div class="icon"> <a href="orders.php"> <i class="fas fa-shopping-cart"></i> </a> </div> <div class="detail"> <a href="orders.php?status=Pending"> <span class="count">{$pendingOrders}</span> <span class="desc">Pending Orders</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-pink clearfix"> <div class="icon"> <a href="supporttickets.php"> <i class="fas fa-comment"></i> </a> </div> <div class="detail"> <a href="supporttickets.php"> <span class="count">{$awaitingReply}</span> <span class="desc">Tickets Waiting</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-orange clearfix"> <div class="icon"> <a href="cancelrequests.php"> <i class="fas fa-ban"></i> </a> </div> <div class="detail"> <a href="cancelrequests.php"> <span class="count">{$pendingCancellations}</span> <span class="desc">Pending Cancellations</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-cyan clearfix"> <div class="icon"> <a href="modulequeue.php"> <i class="fas fa-exclamation-triangle"></i> </a> </div> <div class="detail"> <a href="modulequeue.php"> <span class="count">{$moduleQueueCount}</span> <span class="desc">Pending Module Actions</span> </a> </div> </div> </div> <div class="col-wsm-2"> <div class="health-status-block status-badge-red clearfix"> <div class="icon"> <a href="invoices.php?status=Overdue"> <i class="fas fa-sack-dollar"></i> </a> </div> <div class="detail"> <a href="invoices.php?status=Overdue"> <span class="count">{$overdueinvoices}</span> <span class="desc">Overdue Invoices</span> </a> </div> </div> </div> </div> EOF; } } .col-wsm-2 { width: 20%; float: left; padding: 0 5px; } .status-badge-red { background-color: #ff0000; } .status-badge-red .icon { background-color: #e40707; } .health-status-block .detail { float: left; display: inline-block; padding: 8px 15px; width: 79%; height: 70px; border-radius: 0 4px 4px 0; text-align: center; } .health-status-block .icon { float: left; display: inline-block; width: 20%; height: 70px; font-size: 2em; line-height: 70px; text-align: center; border-radius: 4px 0 0 4px; } But I will also revert back to badges,.php and remove the pending module action as it is duplicated in the system health widget and use that location for the overdue invoice. So no css changes will be needed. With the above this is how it looks at this time. thanks but it not work on my 8.0.4 installation Badges3 failed to load. Could not include file: D:\inetpub\vhosts\gamesclan.net\httpdocs\billing/modules/widgets/Badges3.php. Error: syntax error, unexpected '.', expecting end of file Edited January 11, 2021 by tangogc 0 Quote Link to comment Share on other sites More sharing options...
actionhosting Posted January 11, 2021 Author Share Posted January 11, 2021 @tangogc if you add me to skype we can chat my skpe is ACTIONHOSTING. Note I have not tested this on 8.0.x the code is running on 8.1 Brian 0 Quote Link to comment Share on other sites More sharing options...
tangogc Posted January 11, 2021 Share Posted January 11, 2021 thanks to @actionhosting all done 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 12, 2021 Share Posted January 12, 2021 21 hours ago, actionhosting said: But I will also revert back to badges,.php and remove the pending module action as it is duplicated in the system health widget and use that location for the overdue invoice. So no css changes will be needed. With the above this is how it looks at this time. if you've edited the original badges.php file, then it will likely get overwritten during an update. 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.