brian! Posted October 3, 2020 Share Posted October 3, 2020 in v8, the summary stats were removed from the admin display - e.g Pending Orders, Overdue Invoices and Tickets Awaiting Reply - the simple hook below adds them back to the output in a similar location (top of the page)... <?php # Stats Info Bar for v8 Blend # Written by brian! use WHMCS\Database\Capsule; use WHMCS\Billing\Invoice; function admin_v8_infobar_hook($vars) { $pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title'); $pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count(); $overdueinvoices = Invoice::overdue()->count(); $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->count(); $headerreturn = '<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; max-height: 20px;"> <div style="text-align: center; color: #fff; font-size: .8em; margin: 0;"> <a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | <a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | <a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> </div> </div>'; return $headerreturn; } add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook"); this was originally written for v8.0.0 betas, but the code has now been updated for v8.0.1 (where the $sidebarstats array no longer exists and the values now have to be calculated from database queries). 15 Quote Link to comment Share on other sites More sharing options...
hostingarg Posted October 3, 2020 Share Posted October 3, 2020 It works perfect! Thanks for your work and dedication! 0 Quote Link to comment Share on other sites More sharing options...
Faizal1 Posted October 3, 2020 Share Posted October 3, 2020 Thanks as always @brian!. Works great. 🤩 0 Quote Link to comment Share on other sites More sharing options...
JofleyUK Posted October 3, 2020 Share Posted October 3, 2020 We are not worthy 😉 Thanks for a more sane, cleaner looking version of my ugly effort 😉 U rock Brian! 0 Quote Link to comment Share on other sites More sharing options...
sonuyos Posted October 4, 2020 Share Posted October 4, 2020 Any way to roll back to old theme? this one doesnt even have time 😕 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 4, 2020 Author Share Posted October 4, 2020 4 hours ago, sonuyos said: Any way to roll back to old theme? the blend from v7.10.2 would work - so you could upload it from a v7.10.2 zip, rename it to blend7 (or something other than blend to prevent WHMCS overwriting it during an update) - it would need some changes, and I wouldn't view it as a long-term option.... 4 hours ago, sonuyos said: this one doesn't even have time 😕 the original hook I wrote during the first beta did include date & time - but I took it out to keep the layout simpler for mobile solutions... you can easily put it back in if you want to - e.g if you just want it next to the stats... <?php # Stats Info Bar for v8 Blend # Written by brian! use WHMCS\Database\Capsule; use WHMCS\Billing\Invoice; use Carbon\Carbon; function admin_v8_infobar_hook($vars) { $pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title'); $pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count(); $overdueinvoices = Invoice::overdue()->count(); $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->count(); $current_time = Carbon::now()->translatedFormat("l, j F Y, H:i"); $headerreturn = '<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; max-height: 20px;"> <div style="text-align: center; color: #fff; font-size: .8em; margin: 0;"> <a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | <a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | <a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> | '.$current_time.' </div> </div>'; return $headerreturn; } add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook"); 0 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted October 4, 2020 Share Posted October 4, 2020 thanks @brian! once again a true community warrier 🙂 One issue I have is that my "awaiting reply" section now shows: 118 Ticket(s) Awaiting Reply !!!! Argghh This is not accurate - as I only have 23 tickets in open queue. I have a custom status of "Customer-Reply" and also "Awaiting Technician" - how to limit only to both of those statuses only ? Something like this but I don't know $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1') && -> where ('title' == "Customer-Reply" || 'title' == "Awaiting-tech") ; 0 Quote Link to comment Share on other sites More sharing options...
theozsnowman Posted October 4, 2020 Share Posted October 4, 2020 excuse my stupidity on this one but does this get added as a file to the hooks folder or into the template somewhere? 0 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted October 4, 2020 Share Posted October 4, 2020 5 minutes ago, theozsnowman said: excuse my stupidity on this one but does this get added as a file to the hooks folder or into the template somewhere? No you add this to the includes folder e.g. whmcs/includes/hooks/yourfilename.php 0 Quote Link to comment Share on other sites More sharing options...
theozsnowman Posted October 4, 2020 Share Posted October 4, 2020 1 minute ago, sol2010 said: No you add this to the includes folder e.g. whmcs/includes/hooks/yourfilename.php thanks.... got it sorted 🙂 0 Quote Link to comment Share on other sites More sharing options...
slim Posted October 5, 2020 Share Posted October 5, 2020 Thanks- Works great 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 5, 2020 Author Share Posted October 5, 2020 10 hours ago, sol2010 said: This is not accurate - as I only have 23 tickets in open queue. it's accurate - but just not the figure you want to see. 😲 10 hours ago, sol2010 said: I have a custom status of "Customer-Reply" and also "Awaiting Technician" - how to limit only to both of those statuses only ? the hook tries to mirror how the feature works in v7 - and so the Tickets Awaiting Reply figure is not just a count of those with only "Open" ticket status, it's a count of the tickets with the statuses defined to be included in the Awaiting Reply column in Ticket Statuses. now in v7, you could get to the page via the menu... setup -> support -> ticket statuses; in v8, I don't think there is a direct link to it in the menu - but there's one hidden in the sidebar or you could search the System Settings page - but basically, you'll need to go to configticketstatuses.php. on that page, you can define which ticket statuses are included in the "Awaiting Reply" count - so if you don't want "Open" tickets to be included, then you can edit that status and untick the "Include in Awaiting Reply" checkbox. 10 hours ago, sol2010 said: I have a custom status of "Customer-Reply" and also "Awaiting Technician" - how to limit only to both of those statuses only ? the above method would be the non-programming way to do it - but perhaps not an option if say you didn't want to include "Open" in the awaiting reply ticket count, but still wanted to include it when viewing awaiting replies in the support ticket section. the programming way to do it would be to just define your list of ticket statuses to be included in the count... $awaitingreplylist = array("Customer-Reply","Awaiting-tech"); the original line of code is just querying the database to get a list of the statuses included in the Awaiting Reply column. 1 Quote Link to comment Share on other sites More sharing options...
Creative Yadley Posted October 5, 2020 Share Posted October 5, 2020 21 hours ago, brian! said: the blend from v7.10.2 would work - so you could upload it from a v7.10.2 zip, rename it to blend7 (or something other than blend to prevent WHMCS overwriting it during an update) - it would need some changes, and I wouldn't view it as a long-term option.... the original hook I wrote during the first beta did include date & time - but I took it out to keep the layout simpler for mobile solutions... you can easily put it back in if you want to - e.g if you just want it next to the stats... <?php # Stats Info Bar for v8 Blend # Written by brian! use WHMCS\Database\Capsule; use WHMCS\Billing\Invoice; use Carbon\Carbon; function admin_v8_infobar_hook($vars) { $pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title'); $pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count(); $overdueinvoices = Invoice::overdue()->count(); $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->count(); $current_time = Carbon::now()->translatedFormat("l, j F Y, H:i"); $headerreturn = '<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; max-height: 20px;"> <div style="text-align: center; color: #fff; font-size: .8em; margin: 0;"> <a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | <a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | <a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> | '.$current_time.' </div> </div>'; return $headerreturn; } add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook"); Hey Brian, I`m just stopping by to say THANK YOU for this hook. It is so helpful, I`m back in the game! 2 Quote Link to comment Share on other sites More sharing options...
(Amr) Posted October 5, 2020 Share Posted October 5, 2020 Great Job Brian :) Just a small addition, to ensure that this hook will only work with blend, and will not conflict with other themes .. wink-wink :) function admin_v8_infobar_hook($vars) { if ($vars['template'] == "blend"){ //The actuall function code } } 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 5, 2020 Author Share Posted October 5, 2020 (edited) 3 hours ago, (Amr) said: Just a small addition, to ensure that this hook will only work with blend, and will not conflict with other themes .. wink-wink 🙂 I think I was assuming only those using Blend would install it, and those who later switch to Lara would delete the hook. 🙂 I can't edit the original post, so next time I have reason to update the code, i'll add that in. Edited October 5, 2020 by brian! 1 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted October 5, 2020 Share Posted October 5, 2020 10 hours ago, brian! said: the above method would be the non-programming way to do it - but perhaps not an option if say you didn't want to include "Open" in the awaiting reply ticket count, but still wanted to include it when viewing awaiting replies in the support ticket section. the programming way to do it would be to just define your list of ticket statuses to be included in the count... $awaitingreplylist = array("Customer-Reply","Awaiting-tech"); the original line of code is just querying the database to get a list of the statuses included in the Awaiting Reply column. Hi @brian! Thanks for that. Well, that did not work for me. I put in the following line of code: //$awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $awaitingreplylist = array("Open","Customer-Reply","In Progress","Awaiting Client Response","Awaiting Tech"); And it still shows 118 tickets in my queue - but I went through all of the above statuses individually and there are only 24 tickets combined in those. Something is not right. 0 Quote Link to comment Share on other sites More sharing options...
theozsnowman Posted October 6, 2020 Share Posted October 6, 2020 i noticed when i added the code too that the number doesnt match the actual complete total of open tickets... the numbers dont seem to add up 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 6, 2020 Author Share Posted October 6, 2020 15 hours ago, sol2010 said: And it still shows 118 tickets in my queue - but I went through all of the above statuses individually and there are only 24 tickets combined in those. Something is not right. indeed. 10 hours ago, theozsnowman said: i noticed when i added the code too that the number doesn't match the actual complete total of open tickets... the numbers don't seem to add up I think the issue might be that the existing query is counting merged tickets and that's inflating the count... when I ran a test of the results, the WHMCS sidebar was telling me there were 37 tickets awaiting replies... the infobar was telling me 38 - and the one ticket that wasn't included in the sidebar was a merged ticket. <?php # Stats Info Bar for v8 Blend # Written by brian! use WHMCS\Database\Capsule; use WHMCS\Billing\Invoice; use Carbon\Carbon; function admin_v8_infobar_hook($vars) { if ($vars['template'] == "blend") { $pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title'); $pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count(); $overdueinvoices = Invoice::overdue()->count(); $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->where('merged_ticket_id','0')->count(); $current_time = Carbon::now()->translatedFormat("l, j F Y, H:i"); $headerreturn = '<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; max-height: 20px;"> <div style="text-align: center; color: #fff; font-size: .8em; margin: 0;"> <a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | <a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | <a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> | '.$current_time.' </div> </div>'; return $headerreturn; } } add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook"); if you tell me that works, i'll delete this thread and repost to avoid confusion for others about which version to use. 3 Quote Link to comment Share on other sites More sharing options...
theozsnowman Posted October 7, 2020 Share Posted October 7, 2020 10 hours ago, brian! said: indeed. I think the issue might be that the existing query is counting merged tickets and that's inflating the count... when I ran a test of the results, the WHMCS sidebar was telling me there were 37 tickets awaiting replies... the infobar was telling me 38 - and the one ticket that wasn't included in the sidebar was a merged ticket. <?php # Stats Info Bar for v8 Blend # Written by brian! use WHMCS\Database\Capsule; use WHMCS\Billing\Invoice; use Carbon\Carbon; function admin_v8_infobar_hook($vars) { if ($vars['template'] == "blend") { $pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title'); $pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count(); $overdueinvoices = Invoice::overdue()->count(); $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->where('merged_ticket_id','0')->count(); $current_time = Carbon::now()->translatedFormat("l, j F Y, H:i"); $headerreturn = '<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; max-height: 20px;"> <div style="text-align: center; color: #fff; font-size: .8em; margin: 0;"> <a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | <a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | <a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> | '.$current_time.' </div> </div>'; return $headerreturn; } } add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook"); if you tell me that works, i'll delete this thread and repost to avoid confusion for others about which version to use. Brian thats great...works perfectly thanks for that 🙂 1 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted October 7, 2020 Share Posted October 7, 2020 10 hours ago, brian! said: if you tell me that works, i'll delete this thread and repost to avoid confusion for others about which version to use. Hi @brian! Yes, that is exactly it - well done and thanks 🙂 Also nice to get the time and date back 😉 0 Quote Link to comment Share on other sites More sharing options...
Magicklug Posted October 7, 2020 Share Posted October 7, 2020 On 10/3/2020 at 11:58 PM, brian! said: in v8, the summary stats were removed from the admin display - e.g Pending Orders, Overdue Invoices and Tickets Awaiting Reply - the simple hook below adds them back to the output in a similar location (top of the page)... <?php # Stats Info Bar for v8 Blend # Written by brian! use WHMCS\Database\Capsule; use WHMCS\Billing\Invoice; function admin_v8_infobar_hook($vars) { $pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title'); $pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count(); $overdueinvoices = Invoice::overdue()->count(); $awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title'); $ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->count(); $headerreturn = '<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; max-height: 20px;"> <div style="text-align: center; color: #fff; font-size: .8em; margin: 0;"> <a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | <a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | <a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> </div> </div>'; return $headerreturn; } add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook"); this was originally written for v8.0.0 betas, but the code has now been updated for v8.0.1 (where the $sidebarstats array no longer exists and the values now have to be calculated from database queries). You just saved my day sir! I love you and this site. <3 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 7, 2020 Author Share Posted October 7, 2020 i'm glad we got it working accurately! 😅 I won't bother deleting/recreating the thread as there are multiple other threads linking to it. 0 Quote Link to comment Share on other sites More sharing options...
akarweb Posted October 7, 2020 Share Posted October 7, 2020 Hi, It doesnt work on 8.0.2. Please help 😞 Thanks. 0 Quote Link to comment Share on other sites More sharing options...
xyzulu Posted October 22, 2020 Share Posted October 22, 2020 It works on 8.0.2 and 8.0.3 for me. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 22, 2020 Author Share Posted October 22, 2020 On 07/10/2020 at 23:57, akarweb said: It doesnt work on 8.0.2. Please help you're going to have to tell me more - specific error messages, screenshots etc... and also ensure that you're using the latest version. i've used it on v8.0.2 and v8.0.3 Blend and am not seeing any issues. 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.