Jump to content

v8.0.1 Admin Info Stats Bar


Recommended Posts

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)...

VsBpdTX.png

<?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).

Link to comment
Share on other sites

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...

0BhXtNs.png

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");

ElonmcY.png

Link to comment
Share on other sites

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") ;

 

Link to comment
Share on other sites

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.

4FtzAkD.png

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.

Link to comment
Share on other sites

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...

0BhXtNs.png

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");

ElonmcY.png

Hey Brian, I`m just stopping by to say THANK YOU for this hook. It is so helpful, I`m back in the game!

Screenshot.png

Link to comment
Share on other sites

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
	}
	
}

 

Link to comment
Share on other sites

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 by brian!
Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 🙂

 

Link to comment
Share on other sites

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)...

VsBpdTX.png


<?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

Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated