Jump to content

Show active tickets count at top of page


123host

Recommended Posts

Hey there

 

At the top of the page we have something like:

 

1 Pending Orders | 7 Overdue Invoices | 0 Ticket(s) Awaiting Reply

 

I want to extend that and have

 

1 Pending Orders | 7 Overdue Invoices | 0 Ticket(s) Awaiting Reply | 10 Active Tickets

 

I am part of the way there and need some help with the variable

 

In the top part of the attachment is a screenshot from the home page. The $ticketsallactive variable doesn't seem to be available. Add to that, the $sidebarstats.tickets.active value is wrong. I have no idea where it gets 22 from when it is actually 6

 

In the middle of the attachment is my HTML from header.tpl

 

The bottom of the screenshot is from the support page. In this case the variable is available, is correct and is displayed, this is what I am after globally.

 

What variable should I be using instead of $ticketsallactive or $sidebarstats.tickets.active to show me the active ticket count anywhere in WHMCS?

 

Thanks in advance

whmcs1.png

Link to comment
Share on other sites

I am part of the way there and need some help with the variable

 

In the top part of the attachment is a screenshot from the home page. The $ticketsallactive variable doesn't seem to be available. Add to that, the $sidebarstats.tickets.active value is wrong. I have no idea where it gets 22 from when it is actually 6

well not all variables are available to every page - some variables are only available on certain pages. :)

 

if memory serves, $sidebarstats.tickets.active simply counts how many tickets are not CLOSED... any ticket that isn't closed, is considered "active"... I assume that's why you're seeing 22 - hopefully if you can count them, you have 22 tickets that are not closed. :?:

 

The bottom of the screenshot is from the support page. In this case the variable is available, is correct and is displayed, this is what I am after globally.

 

What variable should I be using instead of $ticketsallactive or $sidebarstats.tickets.active to show me the active ticket count anywhere in WHMCS?

if the variable that you want doesn't exist (where you want to use it), then you'd need to create it - in the admin area, the simplest way would be using an action hook.

 

however, before you do that, you need to decide what you consider an "Active" ticket to be, e.g which Ticket Statuses do you want to apply it to?

 

as I said previously, $sidebarstats considers tickets that aren't closed as active - you want to be more specific and only count certain statuses in your total.

 

if you create a file in /includes/hooks and call in adminticketstatus.php, then add the following code to it...

 

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function hook_ticket_status_active($vars) 
{
   $ticketsactive = Capsule::table('tbltickets')
               ->whereIn('status', array('Open','In Progress'))
               ->count();

   return array("ticketsactive" => $ticketsactive);
}
add_hook("AdminAreaPage", 1, "hook_ticket_status_active");
?>

the above hook will create a new variable {$ticketsactive} that you can use in header.tpl to show how many tickets are "Active" (by your definition of active).

 

            <a href="supporttickets.php">
               <span class="stat">{$ticketsactive}</span>
               Active Tickets
           </a> |

to define further ticket statuses to the calculation, just add them to the array part of the code, e.g if you wanted to add 'Customer-Reply'...

 

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function hook_ticket_status_active($vars) 
{
   $ticketsactive = Capsule::table('tbltickets')
               ->whereIn('status', array('Open','In Progress','Customer-Reply'))
               ->count();

   return array("ticketsactive" => $ticketsactive);
}
add_hook("AdminAreaPage", 1, "hook_ticket_status_active");
?>

in passing, I should almost mention that you can define which ticket statuses are considered "Active" in the Support Tickets pages by reading the documentation below - there is a checkbox for each status that allows you to add it to the "Active Tickets" and/or "Awaiting Reply" counts.

 

http://docs.whmcs.com/Support_Ticket_Statuses

 

as I said before, $sidebarstats doesn't take this into account - though I suppose you could expand the hook to query the statuses table (to find those defined as active) and then use those values in the second query... but as there are only 6 default defined ticket statuses, it's probably easier to alter the array in the original hook! :idea:

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