make the 7 day stats graph a 5 day

Moderator: crythias

Post Reply
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

make the 7 day stats graph a 5 day

Post by jjcool »

Our IT shop isn't open on the weekends so there's always a dip in the graph for Sat and Sun. I'd like to know what file to edit to get rid of the weekend values on the X-axis so it only shows the 5 day work week. Thanks in advance.
vkandersv
Znuny newbie
Posts: 36
Joined: 07 Mar 2011, 18:32
Znuny Version: 3.0.6

Re: make the 7 day stats graph a 5 day

Post by vkandersv »

You should make your own module instead of changing existing, but if you want to change it straight away its located in:

/otrs/Kernel/Output/HTML/DashboardTicketStats.pm

For our own system i made a new module, going the opposite way, showing 4 weeks moving stats, its really neat, as shown below. Have not tought about excluding saturday/sunday since we are in a 24/7-office, but guess its fairly easy

Ive been thinking about making a package of this, but are to new to OTRS to be able to do that yet:
longstats.png
You do not have the required permissions to view the files attached to this post.
--
ORTS 3.0.6, Linux, MySQL, ActiveDirectory integration for Customer.
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: make the 7 day stats graph a 5 day

Post by MichaelR »

vkandersv wrote:For our own system i made a new module, going the opposite way, showing 4 weeks moving stats, its really neat, as shown below. Have not tought about excluding saturday/sunday since we are in a 24/7-office, but guess its fairly easy

Ive been thinking about making a package of this, but are to new to OTRS to be able to do that yet:
longstats.png
Now that is impressive, either make a package for it, or just post up modifications!
If anything some insight into how you made the modules etc :D
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

vkandersv wrote: Have not tought about excluding saturday/sunday since we are in a 24/7-office
Thanks for the information. I'll look into that file, but I'm probably going to need more help with what exactly to modify. Even with your chart though you can see how the weekends drop down to 0-1 tickets. Seems like it would be a more popular modification, but I've had a hard time locating anything on this.
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

so I edited the file as shown in the code below:

Code: Select all

# --
# Kernel/Output/HTML/DashboardTicketStatsGeneric.pm
# Copyright (C) 2001-2010 xxx, http://otrs.org/
# --
# $Id: DashboardTicketStatsGeneric.pm,v 1.18 2010/11/01 15:41:28 mb Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::DashboardTicketStatsGeneric;

use strict;
use warnings;

use vars qw($VERSION);
$VERSION = qw($Revision: 1.18 $) [1];

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {%Param};
    bless( $Self, $Type );

    # get needed objects
    for (
        qw(Config Name ConfigObject LogObject DBObject LayoutObject ParamObject TicketObject 

UserID)
        )
    {
        die "Got no $_!" if !$Self->{$_};
    }

    return $Self;
}

sub Preferences {
    my ( $Self, %Param ) = @_;

    return;
}

sub Config {
    my ( $Self, %Param ) = @_;

    my $Key = $Self->{LayoutObject}->{UserLanguage} . '-' . $Self->{Name};
    return (
        %{ $Self->{Config} },
        CacheKey => 'TicketStats' . '-' . $Self->{UserID} . '-' . $Key,
    );

}

sub Run {
    my ( $Self, %Param ) = @_;

    my %Axis = (
#        '7Day' => {
#            0 => 'Sun',
#            1 => 'Mon',
#            2 => 'Tue',
#            3 => 'Wed',
#            4 => 'Thu',
#            5 => 'Fri',
#            6 => 'Sat',
#  Changed days to reflect a 5 day week instead of 7
         '5Day' => {
            0 => 'Mon',
            1 => 'Tue',
            2 => 'Wed',
            3 => 'Thu',
            4 => 'Fri',
        },
    );

    my @TicketsCreated = ();
    my @TicketsClosed  = ();
    my @TicketWeekdays = ();
    my @TicketYAxis    = ();
    my $Max            = 0;
#    for my $Key ( 0 .. 6 ) {
#  Changed from 6 to 4 to match key index when changing days to exclude weekends.

    for my $Key ( 0 .. 4 ) {

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

        unshift(
            @TicketWeekdays,
#            [ 6 - $Key, $Self->{LayoutObject}->{LanguageObject}->Get(
#$Axis{'7Day'}->{$WeekDay} ) ]
#  Changed from 6 to 4 to match key index when changing days to exclude weekends.

            [ 4 - $Key, $Self->{LayoutObject}->{LanguageObject}->Get(
$Axis{'5Day'}->{$WeekDay} ) ]

        );

        my $CountCreated = $Self->{TicketObject}->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCreateTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCreateTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountCreated > $Max ) {
            $Max = $CountCreated;
        }
#        push @TicketsCreated, [ 6 - $Key, $CountCreated ];
#  Changed from 6 to 4 to match key index when changing days to exclude weekends.
        push @TicketsCreated, [ 4 - $Key, $CountCreated ];

        my $CountClosed = $Self->{TicketObject}->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCloseTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCloseTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountClosed > $Max ) {
            $Max = $CountClosed;
        }
#        push @TicketsClosed, [ 6 - $Key, $CountClosed ];
#  Changed from 6 to 4 to match key index when changing days to exclude weekends.
        push @TicketsClosed, [ 4 - $Key, $CountClosed ];

    }

    # calculate the maximum height and the tick steps of y axis
    if ( $Max <= 10 ) {
        for ( my $i = 0; $i <= 10; $i += 2 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 20 ) {
        for ( my $i = 0; $i <= 20; $i += 4 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 100 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 10 ) / 10 ) + 1 ) * 10; $i += 10 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 1000 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 100 ) / 100 ) + 1 ) * 100; $i += 100 ) {
            push @TicketYAxis, $i
        }
    }
    else {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 1000 ) / 1000 ) + 1 ) * 1000; $i += 1000 ) {
            push @TicketYAxis, $i
        }
    }
    my $ClosedText  = $Self->{LayoutObject}->{LanguageObject}->Get('Closed');
    my $CreatedText = $Self->{LayoutObject}->{LanguageObject}->Get('Created');

    my @ChartData = (
        {
            data  => \@TicketsClosed,
            label => $ClosedText,
            color => "#BF8A2F"
        },
        {
            data  => \@TicketsCreated,
            label => $CreatedText,
            color => "#6F98DF"
        }
    );

    my $ChartDataJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@ChartData,
    );

    my $TicketWeekdaysJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@TicketWeekdays,
    );

    my $TicketYAxisJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@TicketYAxis,
    );

    my $Content = $Self->{LayoutObject}->Output(
        TemplateFile => 'AgentDashboardTicketStats',
        Data         => {
            %{ $Self->{Config} },
            Key            => int rand 99999,
            ChartData      => $ChartDataJSON,
            TicketWeekdays => $TicketWeekdaysJSON,
            TicketYAxis    => $TicketYAxisJSON
        },
        KeepScriptTags => 1,
    );

    return $Content;
}

1;
I tried to change everything to reflect a 5 day week (0-4) instead of a 7 day week (0-6). However, I obviously didn't get something quite right as my chart now shows five days, but it's still showing the weekend data and it thinks today is Wednesday (when it's actually Tuesday).
Image
vkandersv
Znuny newbie
Posts: 36
Joined: 07 Mar 2011, 18:32
Znuny Version: 3.0.6

Re: make the 7 day stats graph a 5 day

Post by vkandersv »


Now that is impressive, either make a package for it, or just post up modifications!
If anything some insight into how you made the modules etc :D
Of course, and if you can do a module feel free :-)

I first made a new module; had a lot of help from this blog entry:

http://blog.otrs.org/2010/09/26/keep-an ... customers/

how to make an own xml file so that i would be able to tweak the module settings via SysConfig, i made a file called MyConfig.xml (attached), placed it into Kernel/Config/Files

then I copied the DashboardTicketStats.pm to DashboardTicketStatsLong.pm, and renamed the module to what i wanted.

Ive include both files in this message

As you can see in the attached files the big thing - and really only - is that I changed number 6 to 27, and added more days on the X-asis. One could probably make this custom really easy if one can program in perl better than i can, but this did the thing for us...

Dont just add this to your system, esp MyConfig.xml if you have made some of your own.... :-)
You do not have the required permissions to view the files attached to this post.
--
ORTS 3.0.6, Linux, MySQL, ActiveDirectory integration for Customer.
vkandersv
Znuny newbie
Posts: 36
Joined: 07 Mar 2011, 18:32
Znuny Version: 3.0.6

Re: make the 7 day stats graph a 5 day

Post by vkandersv »

jjcool wrote:
I tried to change everything to reflect a 5 day week (0-4) instead of a 7 day week (0-6). However, I obviously didn't get something quite right as my chart now shows five days, but it's still showing the weekend data and it thinks today is Wednesday (when it's actually Tuesday).
Could it be that day 0 is sunday (not monday as one expect?), so probably its day 0 and day 6 you want to hide?

what happens if you change the counters from 0..4 to 1..5 ?

# for my $Key ( 0 .. 6 ) {
# Changed from 6 to 4 to match key index when changing days to exclude weekends.

for my $Key ( 0 .. 4 ) {
--
ORTS 3.0.6, Linux, MySQL, ActiveDirectory integration for Customer.
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

vkandersv wrote:what happens if you change the counters from 0..4 to 1..5 ?
somehow that managed to make the dashboard page not even load. I changed everything back to default and only changed the counters to 1..5 and then the dashboard page would no longer load. I rebooted the server just to be sure something kooky wasn't going on and it still wouldn't load. When I reverted back to the original file it immediately loaded.
vkandersv
Znuny newbie
Posts: 36
Joined: 07 Mar 2011, 18:32
Znuny Version: 3.0.6

Re: make the 7 day stats graph a 5 day

Post by vkandersv »

jjcool wrote:
vkandersv wrote:what happens if you change the counters from 0..4 to 1..5 ?
somehow that managed to make the dashboard page not even load. I changed everything back to default and only changed the counters to 1..5 and then the dashboard page would no longer load. I rebooted the server just to be sure something kooky wasn't going on and it still wouldn't load. When I reverted back to the original file it immediately loaded.
Just thinking loud right now, having counter 1..5 would make this line invalid:

            [ 4 - $Key, $Self->{LayoutObject}->{LanguageObject}->Get(
$Axis{'5Day'}->{$WeekDay} ) ]

since at one point key would be = 5 and 4 - 5 is -1, and its not an valid index.

try doing this instead; having the key count from 0..4, but leaving the '7Day'-axis untouched, then change this line to:
      if ($Key) {
            $TimeNow = $TimeNow - ( 60 * 60 * 24 * $Key );
        }

to

60 * 60 * 24 * ($Key + 1)

then the index would be correct and when starting with key = 0 (originally sunday) it would return the ticket count for monday. Perhaps... havent tried this at all.. will probably be anything =)
--
ORTS 3.0.6, Linux, MySQL, ActiveDirectory integration for Customer.
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

Image
so that made it five days and Wednesday is missing, but it's still showing Sat and Sun data. Now I just need a way to remove the data for Sat and Sun and figure out where Wed went.
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

if it helps any, it wasn't just that wednesday was missing, but that the previous day is always missing. Like today Sunday is missing, which is good. The problem is I want it to always be Sat and Sun missing and not just the previous day. Any ideas?
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: make the 7 day stats graph a 5 day

Post by MichaelR »

I ended up building an opm for ya.
It's got vkandersv's name in it, and I changed a few things around to make it 100% english

Let me know if it fail's epicly or not...
(It's in a zip file because OTRS Forums don't allow us to upload .opm's?)
You do not have the required permissions to view the files attached to this post.
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

MichaelR wrote:I ended up building an opm for ya.
It's got vkandersv's name in it, and I changed a few things around to make it 100% english

Let me know if it fail's epicly or not...
(It's in a zip file because OTRS Forums don't allow us to upload .opm's?)
Thanks so much for the opm. I installed it and now I have the normal weekly stats graph as well as a monthly graph below that. Unfortunately they both still have Saturday and Sunday's data on them. I'll try to look through the monthly stats code and see if I can learn anything from it about how to remove Sat and Sun from the graph.
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: make the 7 day stats graph a 5 day

Post by MichaelR »

Ohh, I left them in, I will poke around and try remove them :) Will update it if I can remove them!
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

MichaelR wrote:Ohh, I left them in, I will poke around and try remove them :) Will update it if I can remove them!
thanks so much.
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

MichaelR, did you ever have any luck removing the weekends from this graph?
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: make the 7 day stats graph a 5 day

Post by MichaelR »

I had a poke around, and couldn't figure it out initially! It's getting pretty busy over here and I don't really have time to be spending on this. It probably can be done, I just need to spend an hour or so figuring out how it works.
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: make the 7 day stats graph a 5 day

Post by crythias »

Here's how to do it.

Code: Select all

    my $Max            = 0;
    my $FakeKey = 0;
    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,
            );

        if ($WeekDay == "0") { next };
        if ($WeekDay == "6") { next };
        $FakeKey++;
        unshift(
            @TicketWeekdays,
            [ 6 - $FakeKey, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
        );

 
Also, find and modify:

push @TicketsCreated, [ 6 - $FakeKey, $CountCreated ];

push @TicketsClosed, [ 6 - $FakeKey, $CountClosed ];

"What's with the Fake Key?"
It's just an index. You don't have to use it, but it keeps count of when you skip weekends.
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
jjcool
Znuny newbie
Posts: 10
Joined: 09 May 2011, 22:54
Znuny Version: 3.0.5
Real Name: Josh
Company: Mutual Distributing

Re: make the 7 day stats graph a 5 day

Post by jjcool »

that works great! and it was super easy to change. I wish the graph still had seven days instead of dropping to five so we could see some of the previous week, but I'm not going to be picky now. I'm so thankful the weekends are finally gone.
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: make the 7 day stats graph a 5 day

Post by crythias »

jjcool wrote:I wish the graph still had seven days instead of dropping to five so we could see some of the previous week,
You may (?) be successful in changing the 0..6 to 0..8 for this purpose.
in a 7 day period (0..6) you'll have 2 weekend days.
In a 9 day period (0..8) you *could* (on Sunday) only have 5 visible days. On Monday, 6, and Tuesday, 7.

ssmtwtfsSm
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
SuperDOS
Znuny newbie
Posts: 93
Joined: 17 Apr 2012, 16:16
Znuny Version: 6.0.3
Real Name: A!

Re: make the 7 day stats graph a 5 day

Post by SuperDOS »

Hi,

I've tried to implement this by adding a copy of DashboardTicketStatsGeneric.pm in \opt\otrs\Custom\Kernel\Output\HTML
and replaced the code that crythias wrote but I still see 7 days. Any ideas what I'm doing wrong?

I use OTRS Helpdesk 3.1.12
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: make the 7 day stats graph a 5 day

Post by reneeb »

Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Sayannara
Znuny advanced
Posts: 118
Joined: 22 May 2012, 12:37
Znuny Version: OTRS 7.06
Real Name: Yann
Company: FVE
Contact:

Re: make the 7 day stats graph a 5 day

Post by Sayannara »

Thanks a lot for this post!

I tried to install MonthlyStats-1.0.0.opm with OTRS 3.1.9 and I got an error because it was created for Framework 3.0.x. So I changed those line:

Code: Select all

<Framework>3.1.x</Framework>
<Framework>3.1.x</Framework>
and it seems to work! Should I expect that something goes wrong ?
Centos 7 / OTRS::ITSM 6 Business Solutions / MariaDB / Apache
Sayannara
Znuny advanced
Posts: 118
Joined: 22 May 2012, 12:37
Znuny Version: OTRS 7.06
Real Name: Yann
Company: FVE
Contact:

Re: make the 7 day stats graph a 5 day

Post by Sayannara »

Sorry for my lack of experience with modules and my poor English.

Is there somebody who can tell me more about how a module works ?

I tried to change this file => Kernel/Config/Files/DashboardTicketStatsMonthly.xml to renam the monthly graph "Statistics" with "1 Month Stats".
I also changed the group for "admin" instead of "ticket", restart services (win) but my modification in this xml file does not change anything. Then I deleted the file to see what would happen and nothing. So it makes me feel that xml config is not necessary.

Is there information hard-coded ? Is this file used by the package ?

Any hellp would be appreciate.
Thank you.
Centos 7 / OTRS::ITSM 6 Business Solutions / MariaDB / Apache
Sayannara
Znuny advanced
Posts: 118
Joined: 22 May 2012, 12:37
Znuny Version: OTRS 7.06
Real Name: Yann
Company: FVE
Contact:

Re: make the 7 day stats graph a 5 day

Post by Sayannara »

OK.. Please not all in the same time...

1. Change the configuration as you want.
2. Go to Admin > Package Manager > Local Repository > click monthlystates package
3. Check the column STATUS at the row with the XML file, it should has a red cross.
4. At the top left use the "Rebuild package" - download the file.
5. Reinstall this package with the downloaded opm file.
Centos 7 / OTRS::ITSM 6 Business Solutions / MariaDB / Apache
RodrigoPetter
Znuny newbie
Posts: 51
Joined: 10 Aug 2015, 20:02
Znuny Version: 5.0.0

Re: make the 7 day stats graph a 5 day

Post by RodrigoPetter »

crythias wrote:
jjcool wrote:I wish the graph still had seven days instead of dropping to five so we could see some of the previous week,
You may (?) be successful in changing the 0..6 to 0..8 for this purpose.
in a 7 day period (0..6) you'll have 2 weekend days.
In a 9 day period (0..8 ) you *could* (on Sunday) only have 5 visible days. On Monday, 6, and Tuesday, 7.

ssmtwtfsSm
When I changed to 0..8 I also needed to change the "$FakeKey++;" to the end of the loop or initialize it with -1. Without this the descriptions when you put the mouse over the nodes will be one day behind the day in the X axis.

EDIT:Nevermind... i saw what i was doing wrong. I'll change the "for loop" for a "while ($FakeKey < 7)" and increment $Key manually inside so i'll always get a 7 days graph without weekends. Thanks everybody.
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

Hi,

I have inserted the information crythias said would work, but as Rodrigo said, when you hover the X Axis, it is one day behind.

Rodrigo, can you show me the code you have in place that resolved this?
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
RodrigoPetter
Znuny newbie
Posts: 51
Joined: 10 Aug 2015, 20:02
Znuny Version: 5.0.0

Re: make the 7 day stats graph a 5 day

Post by RodrigoPetter »

tupson wrote:Hi,

I have inserted the information crythias said would work, but as Rodrigo said, when you hover the X Axis, it is one day behind.

Rodrigo, can you show me the code you have in place that resolved this?

Code: Select all

	
    my $Max     = 0;
    my $FakeKey = 0;
    my $Key     = -1;

    # get ticket object
    my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');

    while ( $FakeKey < 7) {
        $Key++;

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

        if ($WeekDay == "0") { next };
        if ($WeekDay == "6") { next };
		 unshift(
            @TicketWeekdays,
            [ 6 - $FakeKey, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
        );
...		
       $FakeKey++; #the last row inside the while
    }
    
The rest of the code stays the same.
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

Thank you!
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

I am receiving the following error when I add your code:

syntax error at /usr/share/otrs//Kernel/Output/HTML/DashboardTicketStatsGeneric.pm line 118, near "$FakeKey"

This is line 118

$FakeKey++;



Also, Crythias mentioned the following: (is this not required as well?)

Also, find and modify:

push @TicketsCreated, [ 6 - $FakeKey, $CountCreated ];

push @TicketsClosed, [ 6 - $FakeKey, $CountClosed ];
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
RodrigoPetter
Znuny newbie
Posts: 51
Joined: 10 Aug 2015, 20:02
Znuny Version: 5.0.0

Re: make the 7 day stats graph a 5 day

Post by RodrigoPetter »

look at the 3º row.

Code: Select all

my $FakeKey = 0;
Do you have this in your code?

And yes, the Crythias code is required.
Here is the entire code, I don't know if there is any diference between otrs versions, but the mine is 4.0.x

Code: Select all

# --
# Kernel/Output/HTML/DashboardTicketStatsGeneric.pm
# Copyright (C) 2001-2015 xxx, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::DashboardTicketStatsGeneric;

use strict;
use warnings;

our $ObjectManagerDisabled = 1;

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {%Param};
    bless( $Self, $Type );

    # get needed parameters
    for my $Needed (qw(Config Name UserID)) {
        die "Got no $Needed!" if !$Self->{$Needed};
    }

    return $Self;
}

sub Preferences {
    my ( $Self, %Param ) = @_;

    return;
}

sub Config {
    my ( $Self, %Param ) = @_;

    return (
        %{ $Self->{Config} },

        # Don't cache this globally as it contains JS that is not inside of the HTML.
        CacheTTL => undef,
        CacheKey => undef,
    );
}

sub Run {
    my ( $Self, %Param ) = @_;

    # get layout object
    my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');

    my $Key      = $LayoutObject->{UserLanguage} . '-' . $Self->{Name};
    my $CacheKey = 'TicketStats' . '-' . $Self->{UserID} . '-' . $Key;

    my $Cache = $Self->{CacheObject}->Get(
        Type => 'Dashboard',
        Key  => $CacheKey,
    );

    if ( ref $Cache ) {
        return $LayoutObject->Output(
            TemplateFile   => 'AgentDashboardTicketStats',
            Data           => $Cache,
            KeepScriptTags => $Param{AJAX},
        );
    }

    my %Axis = (
        '7Day' => {
            0 => 'Sun',
            1 => 'Mon',
            2 => 'Tue',
            3 => 'Wed',
            4 => 'Thu',
            5 => 'Fri',
            6 => 'Sat',
        },
    );

    my @TicketsCreated = ();
    my @TicketsClosed  = ();
    my @TicketWeekdays = ();
    my @TicketYAxis    = ();
    my $Max     = 0;
    my $FakeKey = 0;
    my $Key     = -1;

    # get ticket object
    my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');

    while ( $FakeKey < 7) {
        $Key++;

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

        if ($WeekDay == "0") { next };
        if ($WeekDay == "6") { next };
       unshift(
            @TicketWeekdays,
            [ 6 - $FakeKey, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
        );

        my $CountCreated = $TicketObject->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCreateTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCreateTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountCreated && $CountCreated > $Max ) {
            $Max = $CountCreated;
        }
        push @TicketsCreated, [ 6 - $FakeKey, $CountCreated ];

        my $CountClosed = $TicketObject->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCloseTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCloseTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
           Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountClosed && $CountClosed > $Max ) {
            $Max = $CountClosed;
        }
        push @TicketsClosed, [ 6 - $FakeKey, $CountClosed ];
		
		$FakeKey++; #the last row inside the while
    }

    # calculate the maximum height and the tick steps of y axis
    if ( $Max <= 10 ) {
        for ( my $i = 0; $i <= 10; $i += 2 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 20 ) {
        for ( my $i = 0; $i <= 20; $i += 4 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 100 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 10 ) / 10 ) + 1 ) * 10; $i += 10 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 1000 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 100 ) / 100 ) + 1 ) * 100; $i += 100 ) {
            push @TicketYAxis, $i
        }
    }
  else {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 1000 ) / 1000 ) + 1 ) * 1000; $i += 1000 ) {
            push @TicketYAxis, $i
        }
    }
    my $ClosedText  = $LayoutObject->{LanguageObject}->Translate('Closed');
    my $CreatedText = $LayoutObject->{LanguageObject}->Translate('Created');

    my @ChartData = (
        {
            data  => \@TicketsClosed,
            label => $ClosedText,
            color => "#BF8A2F"
        },
        {
            data  => \@TicketsCreated,
            label => $CreatedText,
            color => "#6F98DF"
        }
    );

    my $ChartDataJSON = $LayoutObject->JSONEncode(
        Data => \@ChartData,
    );

    my $TicketWeekdaysJSON = $LayoutObject->JSONEncode(
        Data => \@TicketWeekdays,
    );

    my $TicketYAxisJSON = $LayoutObject->JSONEncode(
        Data => \@TicketYAxis,
    );

    my %Data = (
        %{ $Self->{Config} },
        Key            => int rand 99999,
        ChartData      => $ChartDataJSON,
        TicketWeekdays => $TicketWeekdaysJSON,
        TicketYAxis    => $TicketYAxisJSON
    );

    if ( $Self->{Config}->{CacheTTLLocal} ) {
        $Self->{CacheObject}->Set(
            Type  => 'Dashboard',
            Key   => $CacheKey,
            Value => \%Data,
            TTL   => $Self->{Config}->{CacheTTLLocal} * 60,
        );
    }

    my $Content = $LayoutObject->Output(
        TemplateFile   => 'AgentDashboardTicketStats',
        Data           => \%Data,
        KeepScriptTags => $Param{AJAX},
    );

    return $Content;
}

1;
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

Thanks, I'll try the full code and let you know. I am running v3.3.9 (Debian 8).
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

Using your code straight up... breaks the page for sure (I assume since it is written for v4.0.x).

Here is the v3.3.9 code, if you can figure out how I can adjust it with your changes to get it to possibly work.

Thanks in advance:

Code: Select all

# --
# Kernel/Output/HTML/DashboardTicketStatsGeneric.pm
# Copyright (C) 2001-2014 xxx, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::DashboardTicketStatsGeneric;

use strict;
use warnings;

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {%Param};
    bless( $Self, $Type );

    # get needed objects
    for (
        qw(Config Name ConfigObject LogObject DBObject LayoutObject ParamObject TicketObject UserID)
        )
    {
        die "Got no $_!" if !$Self->{$_};
    }

    return $Self;
}

sub Preferences {
    my ( $Self, %Param ) = @_;

    return;
}

sub Config {
    my ( $Self, %Param ) = @_;

    my $Key = $Self->{LayoutObject}->{UserLanguage} . '-' . $Self->{Name};
    return (
        %{ $Self->{Config} },
        CacheKey => 'TicketStats' . '-' . $Self->{UserID} . '-' . $Key,
    );

}

sub Run {
    my ( $Self, %Param ) = @_;

    my %Axis = (
        '7Day' => {
            0 => 'Sun',
            1 => 'Mon',
            2 => 'Tue',
            3 => 'Wed',
            4 => 'Thu',
            5 => 'Fri',
            6 => 'Sat',
        },
    );

    my @TicketsCreated = ();
    my @TicketsClosed  = ();
    my @TicketWeekdays = ();
    my @TicketYAxis    = ();
    my $Max            = 0;
    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,
            );

        unshift(
            @TicketWeekdays,
            [ 6 - $Key, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
        );

        my $CountCreated = $Self->{TicketObject}->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCreateTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCreateTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountCreated && $CountCreated > $Max ) {
            $Max = $CountCreated;
        }
        push @TicketsCreated, [ 6 - $Key, $CountCreated ];

        my $CountClosed = $Self->{TicketObject}->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCloseTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCloseTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountClosed && $CountClosed > $Max ) {
            $Max = $CountClosed;
        }
        push @TicketsClosed, [ 6 - $Key, $CountClosed ];
    }

    # calculate the maximum height and the tick steps of y axis
    if ( $Max <= 10 ) {
        for ( my $i = 0; $i <= 10; $i += 2 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 20 ) {
        for ( my $i = 0; $i <= 20; $i += 4 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 100 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 10 ) / 10 ) + 1 ) * 10; $i += 10 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 1000 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 100 ) / 100 ) + 1 ) * 100; $i += 100 ) {
            push @TicketYAxis, $i
        }
    }
    else {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 1000 ) / 1000 ) + 1 ) * 1000; $i += 1000 ) {
            push @TicketYAxis, $i
        }
    }
    my $ClosedText  = $Self->{LayoutObject}->{LanguageObject}->Get('Closed');
    my $CreatedText = $Self->{LayoutObject}->{LanguageObject}->Get('Created');

    my @ChartData = (
        {
            data  => \@TicketsClosed,
            label => $ClosedText,
            color => "#BF8A2F"
        },
        {
            data  => \@TicketsCreated,
            label => $CreatedText,
            color => "#6F98DF"
        }
    );

    my $ChartDataJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@ChartData,
    );

    my $TicketWeekdaysJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@TicketWeekdays,
    );

    my $TicketYAxisJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@TicketYAxis,
    );

    my $Content = $Self->{LayoutObject}->Output(
        TemplateFile => 'AgentDashboardTicketStats',
        Data         => {
            %{ $Self->{Config} },
            Key            => int rand 99999,
            ChartData      => $ChartDataJSON,
            TicketWeekdays => $TicketWeekdaysJSON,
            TicketYAxis    => $TicketYAxisJSON
        },
        KeepScriptTags => 1,
    );

    return $Content;
}

1;
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
RodrigoPetter
Znuny newbie
Posts: 51
Joined: 10 Aug 2015, 20:02
Znuny Version: 5.0.0

Re: make the 7 day stats graph a 5 day

Post by RodrigoPetter »

try this

Code: Select all

 # --
# Kernel/Output/HTML/DashboardTicketStatsGeneric.pm
# Copyright (C) 2001-2014 xxx, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::DashboardTicketStatsGeneric;

use strict;
use warnings;



sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {%Param};
    bless( $Self, $Type );

    # get needed objects
    for (
        qw(Config Name ConfigObject LogObject DBObject LayoutObject ParamObject TicketObject UserID)
        )
    {
        die "Got no $_!" if !$Self->{$_};
    }

    return $Self;
}

sub Preferences {
    my ( $Self, %Param ) = @_;

    return;
}

sub Config {
    my ( $Self, %Param ) = @_;

    my $Key = $Self->{LayoutObject}->{UserLanguage} . '-' . $Self->{Name};
    return (
        %{ $Self->{Config} },
        CacheKey => 'TicketStats' . '-' . $Self->{UserID} . '-' . $Key,
    );
}

sub Run {
    my ( $Self, %Param ) = @_;

    my %Axis = (
        '7Day' => {
            0 => 'Sun',
            1 => 'Mon',
            2 => 'Tue',
            3 => 'Wed',
            4 => 'Thu',
            5 => 'Fri',
            6 => 'Sat',
        },
    );

    my @TicketsCreated = ();
    my @TicketsClosed  = ();
    my @TicketWeekdays = ();
    my @TicketYAxis    = ();
    my $Max            = 0;

    my $FakeKey = 0;
    my $Key     = -1;

    while ( $FakeKey < 7 ) {

	$Key++;
	
        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,
            );


	if ($WeekDay == "0") { next };
        if ($WeekDay == "6") { next };
        unshift(
            @TicketWeekdays,
            [ 6 - $FakeKey, $Self->{LayoutObject}->{LanguageObject}->Get( $Axis{'7Day'}->{$WeekDay} ) ]
        );

        my $CountCreated = $Self->{TicketObject}->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCreateTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCreateTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountCreated && $CountCreated > $Max ) {
            $Max = $CountCreated;
        }
        push @TicketsCreated, [ 6 - $FakeKey, $CountCreated ];

        my $CountClosed = $Self->{TicketObject}->TicketSearch(

            # cache search result 30 min
            CacheTTL => 60 * 30,

            # tickets with create time after ... (ticket newer than this date) (optional)
            TicketCloseTimeNewerDate => "$Year-$Month-$Day 00:00:00",

            # tickets with created time before ... (ticket older than this date) (optional)
            TicketCloseTimeOlderDate => "$Year-$Month-$Day 23:59:59",

            CustomerID => $Param{Data}->{UserCustomerID},
            Result     => 'COUNT',

            # search with user permissions
            Permission => $Self->{Config}->{Permission} || 'ro',
            UserID => $Self->{UserID},
        );
        if ( $CountClosed && $CountClosed > $Max ) {
            $Max = $CountClosed;
        }
        push @TicketsClosed, [ 6 - $FakeKey, $CountClosed ];

	 $FakeKey++; #the last row inside the while
    }

    # calculate the maximum height and the tick steps of y axis
    if ( $Max <= 10 ) {
        for ( my $i = 0; $i <= 10; $i += 2 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 20 ) {
        for ( my $i = 0; $i <= 20; $i += 4 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 100 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 10 ) / 10 ) + 1 ) * 10; $i += 10 ) {
            push @TicketYAxis, $i
        }
    }
    elsif ( $Max <= 1000 ) {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 100 ) / 100 ) + 1 ) * 100; $i += 100 ) {
            push @TicketYAxis, $i
        }
    }
    else {
        for ( my $i = 0; $i <= ( ( ( $Max - $Max % 1000 ) / 1000 ) + 1 ) * 1000; $i += 1000 ) {
            push @TicketYAxis, $i
        }
    }
    my $ClosedText  = $Self->{LayoutObject}->{LanguageObject}->Get('Closed');
    my $CreatedText = $Self->{LayoutObject}->{LanguageObject}->Get('Created');

    my @ChartData = (
        {
            data  => \@TicketsClosed,
            label => $ClosedText,
            color => "#BF8A2F"
        },
        {
            data  => \@TicketsCreated,
            label => $CreatedText,
            color => "#6F98DF"
        }
    );

    my $ChartDataJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@ChartData,
    );

    my $TicketWeekdaysJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@TicketWeekdays,
    );

    my $TicketYAxisJSON = $Self->{LayoutObject}->JSONEncode(
        Data => \@TicketYAxis,
    );

    my $Content = $Self->{LayoutObject}->Output(
        TemplateFile => 'AgentDashboardTicketStats',
        Data         => {

            %{ $Self->{Config} },
            Key            => int rand 99999,
            ChartData      => $ChartDataJSON,
            TicketWeekdays => $TicketWeekdaysJSON,
            TicketYAxis    => $TicketYAxisJSON
        },
        KeepScriptTags => 1,















    );

    return $Content;
}

1;
Last edited by RodrigoPetter on 23 Oct 2015, 12:19, edited 1 time in total.
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

better - at least its not erroring out, however it is only showing 1 day - and that day was yesterday:

Image
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
RodrigoPetter
Znuny newbie
Posts: 51
Joined: 10 Aug 2015, 20:02
Znuny Version: 5.0.0

Re: make the 7 day stats graph a 5 day

Post by RodrigoPetter »

tupson wrote:better - at least its not erroring out, however it is only showing 1 day - and that day was yesterday:
...
Sorry tupson, I forgot to change the most important part hehe '-'

Check the edited code now: viewtopic.php?f=62&t=9639&p=123992#p123992
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

Ok,

I updated the file and it appears to look identical to the default view. What is different with this graph now?

Image
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
tupson
Znuny advanced
Posts: 133
Joined: 07 Oct 2015, 05:54
Znuny Version: 7.0.2
Real Name: Tony
Company: Upson Productions, LLC
Location: DC

Re: make the 7 day stats graph a 5 day

Post by tupson »

nevermind, it took awhile for the graphic to update correctly, Sat and Sun are now removed from the display!

thanks a lot.
Tony :mrgreen:
OTRS version installed: v7.0.2 (.rpm)
OS: CENTOS7 (latest updates via -yum install)
OS: Ubuntu 20.04.3 (latest apt-get upgrades)
GURU: Microsoft & VMware Environments
Post Reply