Jump to content

v8.0.1 Admin Info Stats Bar


Recommended Posts

17 hours ago, Stuart Newton said:

anyway to add "WHMCS - To-Do List" to this hook

<?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();
		$todolistitems = Capsule::table('tbltodolist')->whereNotIn('status',['Completed'])->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> |
				<a href="todolist.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$todolistitems.'</span> '.AdminLang::trans('stats.todoitemsdue').'</a> | '.$current_time.'
			</div>
		</div>';
		return $headerreturn;
	}
}
add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook");

WQtLiAU.png

Link to comment
Share on other sites

  • 3 weeks later...
20 hours ago, minadreapta said:

Can you also include the number of active clients and the number of active services to that hook?

wd2LR47.png

<?php

# Stats Info Bar for v8 Blend
# Written by brian!

use Carbon\Carbon;
use WHMCS\Billing\Invoice;
use WHMCS\Clients;
use WHMCS\Database\Capsule;
use WHMCS\User\Client;

function admin_v8_infobar_hook($vars) {
	
	if ($vars['template'] == "blend") {

		$show_active_clients = true;
		$show_active_services = true;
		$show_expired_domains = false;
		$show_overdue_invoices = true;
		$show_pending_cancels = false;
		$show_pending_orders = true;
		$show_ticket_swaiting = true;
		$show_todo_items = false;
		$show_time = true;
		
		$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;">';
				if ($show_pending_orders) {
					$pendingstatuslist = Capsule::table('tblorderstatuses')->where('showpending','1')->pluck('title');
					$pendingorders = Capsule::table('tblorders')->whereIn('status',$pendingstatuslist)->count();
					//$pendingorders = Capsule::table('tblorders')->join('tblinvoices','tblorders.invoiceid','=','tblinvoices.id')->where('tblorders.status','Pending')->where('tblinvoices.status','Paid')->count();
					$headerreturn .= '<a href="orders.php?status=Pending" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingorders.'</span> '.AdminLang::trans('stats.pendingorders').'</a> | ';
				}
				if ($show_overdue_invoices) {
					$overdueinvoices = Invoice::overdue()->count();
					$headerreturn .= '<a href="invoices.php?status=Overdue" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$overdueinvoices.'</span> '.AdminLang::trans('stats.overdueinvoices').'</a> | ';
				}
				if ($show_ticket_swaiting) {
					$awaitingreplylist = Capsule::table('tblticketstatuses')->where('showawaiting','1')->pluck('title');
					$ticketsawaiting = Capsule::table('tbltickets')->whereIn('status',$awaitingreplylist)->where('merged_ticket_id','0')->count();
					$headerreturn .= '<a href="supporttickets.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$ticketsawaiting.'</span> '.AdminLang::trans('stats.ticketsawaitingreply').'</a> | ';
				}
				if ($show_todo_items) {
					$todolistitems = Capsule::table('tbltodolist')->whereNotIn('status',['Completed'])->count();
					$headerreturn .= '<a href="todolist.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$todolistitems.'</span> '.AdminLang::trans('stats.todoitemsdue').'</a> | ';
				}
				if ($show_active_clients) {
					$activeclients = Client::where('status','Active')->count();					
					$headerreturn .= '<a href="clients.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$activeclients.'</span> '.AdminLang::trans('stats.activeclients').'</a> | ';
				}				
				if ($show_active_services) {
					$activeservices = Capsule::table('tblhosting')->where('domainstatus','Active')->count();
					$headerreturn .= '<a href="'.routePath("admin-services-index").'?status=active" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$activeservices.'</span> '.AdminLang::trans('stats.activeservices').'</a> | ';
				}
				if ($show_pending_cancels) {
					$pendingcancels = Clients::getNumberOfOpenCancellationRequests();
					$headerreturn .= '<a href="cancelrequests.php" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$pendingcancels.'</span> '.AdminLang::trans('stats.pendingcancellations').'</a> | ';
				}
				if ($show_expired_domains) {
					$expireddomains = Capsule::table('tbldomains')->where('status','Expired')->count();
					$headerreturn .= '<a href="'.routePath("admin-domains-index").'?status=expired" style="color: #fff;"><span style="font-weight: 700; color: #fc0;">'.$expireddomains.'</span> '.AdminLang::trans('stats.expireddomains').'</a> | ';
				}			
				if ($show_time) {
					$current_time = Carbon::now()->translatedFormat("l, j F Y, H:i");
					$headerreturn .= $current_time;
				}
				$headerreturn .= '</div>
		</div>';
		return $headerreturn;
	}
}
add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook");

i've slightly changed the hook so that each element can now be disabled/enabled in the settings, e.g if you didn't want to show 'Pending Orders', then you would change...

$show_pending_orders = true;

to...

$show_pending_orders = false;
Link to comment
Share on other sites

1 hour ago, hoya8 said:

We also hate that when we search , INative clients do not show up until we have to "click" off button again

that a v7.7 issue from over a year ago, e.g the default hiding of inactive clients...

with regards to searching, gary posted a working solution in the thread below...

before changes to template - inactive clients not shown in results....

jcB71nt.png

after the template changes, inactive clients will be shown in results...

muV73k9.png

almost certainly, these values can be reset using JavaScript rather than template edits, so i'll take a look at that when I get the chance.

1 hour ago, hoya8 said:

seriously , what is wrong with WHMCS? seems going backward on every version

users complained about this during the v7.7 beta and ever since.... it's one of those numerous situations where WHMCS have convinced themselves that they know best.

Link to comment
Share on other sites

  • 4 months later...
  • 2 months later...

Thank you very much for this brilliant hook, @brian!. We're using it now. You saved us time as this new v8 is so unorganized and we're annoyed at the amount of steps we have to now take to manage the admin area. We honestly can't stand the admin area like this so this helps. We tried installing v7's Blend and another theme called "v4" that we have in another WHMCS installation but we found some bugs, such as the inability to change the status of tickets instantly and other issues. There might be more issues so we'd rather avoid that, unfortunately.

We're working on bringing back the whole menu from v7 to v8 instead of having them buried in a silly menu (System Settings) where you then have to search for what you want because they're all placed in 2 unorganized and uncategorized columns.

@brian! - do you have any way to bring back the v7 menu easily while integrating it with v8's template?

Also, do you have the search bar ready so that we don't have to click its icon first?

 

Here are issues we found with this hook:

1. In mobile mode, the left menu doesn't display correctly. In all "hooks" tried in this thread. Turns out this only happens when viewed on a large screen and then resize the browser to mobile view. If you refresh, it gets fixed. Should be fine on mobile.

2. Expired domains says 21. The page itself says  0 records found and 19 inactive records found by inactive customers. Total should be 19, or perhaps 0 if it's showing active only.

 

Changes we've done. Might help some:

1. To get the date to appear at the top right and to stay there, modify the row of where $current_time appears in the hook to:

$headerreturn .= '<div class="pull-right date hidden-xs"> '.$current_time.' </div> ';

 

2. @ahwaznoname and others who'd like the top left menu links (Client Area, My Notes, My Account, Log out).

Notes:

  • We took and edited this from our other WHMCS v7 admin area.
  • Removed "Home" since we can click on the logo.
  • Added System Settings link.
  • Renamed Logout to Log out.
  • Removed the | character.
  • max-height has been disabled as it limited the number of links shown in mobile mode.
  • You can edit the CSS in there.

Replace the following code where the first $headerreturn is (below the first mention of $show_time):

$headerreturn = '
				<div class="top-left-admin-quicklinks">
					<div class="pull-left" style="color: #aaa;">
						<a href="../">Client Area</a>
						<a href="#" data-toggle="modal" data-target="#modalMyNotes">My Notes</a>
						<a href="myaccount.php">My Account</a>
						<a href="'.routePath('admin-setup-index').'">System Settings</a>
						<a id="logout" href="logout.php">Log out</a>
					</div>
				</div>
				
				<style>
					.top-left-admin-quicklinks a {
						color: #ccc;
						font-size: .8em;
						margin-right: 7px;
					}
				</style>
				
				<div style="margin: 0; padding: 5px; background-color: #1a4d80; display: block; width: 100%; /*max-height: 20px;*/">
				<div style="text-align: center; color: #ccc; font-size: .8em; margin: 0;">';

We hope this helps!

Edited by Ramouz
Link to comment
Share on other sites

  • 1 year later...

Sorry to reboot an old thread, but I've only now just updated to 8.7.3 and was still using an old WHMCS, only upgraded now due to wanting sendgrid  integration.

 

However I cant stand the missing links on top of the page, I've tried this hook and it is not working.

Can anyone confirm if this is still working and if so, explain how I enable this hook?

 

Thanks

 

Walter

Link to comment
Share on other sites

3 hours ago, AgilitySquared said:

Can anyone confirm if this is still working and if so, explain how I enable this hook?

It works for me still.. I am using this hook (below). Might you be using a custom admin template perhaps?

 

<?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>
			</div>
		</div>';
		return $headerreturn;
	}
}
add_hook("AdminAreaHeaderOutput",1,"admin_v8_infobar_hook");

 

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