How to exclude Sunday from 7 Day Stats

English! place to talk about development, programming and coding
Post Reply
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

How to exclude Sunday from 7 Day Stats

Post by HervE »

Hello,

I was asked by a customer to exclude Sunday from "7 Day Stats" pane of the Dashboard, because their service doesn't manage tickets on Sundays, and they find it useless to see the curves at zero on this closed day.

If anybody is interested, here is how I succeeded to modify the graph.

First, I made a copy of otrs\OTRS\Kernel\Output\HTML\DashboardTicketStatsGeneric.pm into otrs\OTRS\Custom\Kernel\Output\HTML.

Then I modified the code of sub Run this way.
I had to redefine the %Axis table with no Sunday:

Code: Select all

    my %Axis = (
        '7Day' => {
            0 => 'Mon',
            1 => 'Tue',
            2 => 'Wed',
            3 => 'Thu',
            4 => 'Fri',
            5 => 'Sat',
        },
    );
(You may rename it '6Day' if you feel like ;-) )

Then I needed a new variable to adjust the $Key in order to skip the Sunday while counting from today until (today -6).

Code: Select all

	my $AdjustKey      = 0;	#HvL
    for my $Key ( 0 .. 6 ) {

        my $TimeNow = $Self->{TimeObject}->SystemTime();
        if ($Key) {
            $TimeNow = $TimeNow - ( 60 * 60 * 24 * $Key );
        }
        my ( $Sec, $Min, $Hour, $Day, $Month, $Year, $WeekDay )
            = $Self->{TimeObject}->SystemTime2Date(
            SystemTime => $TimeNow,
            );
			
		# HvL Adjust $WeekDay
		if ($WeekDay == 0) {
			$AdjustKey = 1;
		}
		else {
			$WeekDay -= 1;
		
			unshift(
				@TicketWeekdays,
	#HvL            [ 6 - $Key, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
				[ 5 - $Key + $AdjustKey, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
			);
The following is the same.
Except naturally this:

Code: Select all

push @TicketsCreated, [ 5 - $Key + $AdjustKey, $CountCreated ];
and that:

Code: Select all

push @TicketsClosed, [ 5 - $Key + $AdjustKey, $CountClosed ];
and of course close the (new) if-block before closing the for-block.

And here is the result:
7 Day Stats (no Sunday).png
Best regards,
HervE
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How to exclude Sunday from 7 Day Stats

Post by crythias »

Somewhat similar to my 5 day post.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

Re: How to exclude Sunday from 7 Day Stats

Post by HervE »

Exactly.

(Except I didn't know about the "next" instruction of Perl language. Hence my big "if".)

Regards,
HervE
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
Post Reply