
I have created new stats in this way: - create a new stats module in '..\OTRS\OTRS\Kernel\System\Stats\Static' with a name shorter than 15 char because if you use a name longer than 15 you will not be able to select your stats in panel ' Overview: Stats' - create a new stats in panel 'Edit: Stat# New' selecting your stats in the listbox 'Static-File:' Example of my Code: ---------------------------------------------------------------------------- # -- # Kernel/System/Stats/StateAction.pm - stats module # Copyright (C) 2001-2009 OTRS AG, http://otrs.org/ # -- # $Id: StateAction.pm,v 1.2 2009/03/27 17:35:32 mh 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::System::Stats::Static::LDPStats05; use strict; use warnings; use Date::Pcalc qw(Days_in_Month Day_of_Week Day_of_Week_Abbreviation); use Kernel::System::DB; use vars qw($VERSION); $VERSION = '$Revision: 1.2 $ '; sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {%Param}; bless( $Self, $Type ); # check all needed objects for (qw(DBObject ConfigObject LogObject)) { die "Got no $_" if !$Self->{$_}; } return $Self; } sub Param { my $Self = shift; # get current time my ( $s, $m, $h, $D, $M, $Y ) = $Self->{TimeObject}->SystemTime2Date( SystemTime => $Self->{TimeObject}->SystemTime(), ); # get one month before my $SelectedYear = $M == 1 ? $Y - 1 : $Y; my $SelectedMonth = $M == 1 ? 12 : $M - 1; # create possible time selections my %Year = map { $_ => $_; } ( $Y - 10 .. $Y ); my %Month = map { $_ => sprintf( "%02d", $_ ); } ( 1 .. 12 ); my %ToMonth = map { $_ => sprintf( "%02d", $_ ); } ( 1 .. 12 ); my @Params = ( { Frontend => 'Year', Name => 'Year', Multiple => 0, Size => 0, SelectedID => $SelectedYear, Data => \%Year, }, { Frontend => 'From Month', Name => 'Month', Multiple => 0, Size => 0, SelectedID => $SelectedMonth, Data => \%Month, }, { Frontend => 'To Month', Name => 'ToMonth', Multiple => 0, Size => 0, SelectedID => $SelectedMonth, Data => \%ToMonth, }, ); return @Params; } sub Run { my ( $Self, %Param ) = @_; my $Year = $Param{Year}; my $Month = sprintf( "%02d", $Param{Month}); my $ToMonth = sprintf( "%02d", $Param{ToMonth}); my $Title = "- Year $Year from Month $Month to $ToMonth"; my @HeadData = ('LTTS' ,'LASR', 'LMS', 'VoxNauta', 'Licensing'); my @Stats = (); my $SQL = "SELECT " . "SUM(IF(name like '%TTS%', 1, 0)) AS LTTS, " . "SUM(IF(name like '%ASR%', 1, 0)) AS LASR, " . "SUM(IF(name like '%LMS%', 1, 0)) AS LMS, " . "SUM(IF(name like '%VoxNauta%', 1, 0)) AS VoxNauta, " . "SUM(IF(name like '%Licensing%', 1, 0)) AS Licensing " . "FROM loq_ticketstat " . "WHERE closed_yyyymm >= '$Year$Month' AND closed_yyyymm <= '$Year$ToMonth' " ; $Self->{DBObject}->Prepare( SQL => $SQL ); my %Stats; while ( my @Row = $Self->{DBObject}->FetchrowArray() ) { push (@Stats, \@Row); } return ([$Title],[@HeadData], @Stats); } sub _GetDBDataPerDay { my ( $Self, %Param ) = @_; my $Start = "$Param{Year}-$Param{Month}-$Param{Day} 00:00:01"; my $End = "$Param{Year}-$Param{Month}-$Param{Day} 23:59:59"; my $SQL = 'SELECT count(*) FROM ticket_history ' . 'WHERE history_type_id = ? AND create_time >= ? AND create_time <= ?'; $Self->{DBObject}->Prepare( SQL => $SQL, Bind => [ \$Param{StateID}, \$Start, \$End ] ); my $DayData = 0; while ( my @Row = $Self->{DBObject}->FetchrowArray() ) { $DayData = $Row[0]; } return $DayData; } 1;