1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
|
# --
# Kernel/Modules/AgentTicketPrint.pm - to get a closer view
# Copyright (C) 2001-2005 Martin Edenhofer <martin+code@otrs.org>
# --
# $Id: AgentTicketPrint.pm,v 1.22 2005/09/18 13:35:00 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::Modules::AgentTicketPrint;
use strict;
use Kernel::System::CustomerUser;
use Kernel::System::LinkObject;
use vars qw($VERSION);
$VERSION = '$Revision: 1.22 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
sub new {
my $Type = shift;
my %Param = @_;
# allocate new hash for object
my $Self = {};
bless ($Self, $Type);
foreach (keys %Param) {
$Self->{$_} = $Param{$_};
}
# check needed Opjects
foreach (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject UserObject)) {
if (!$Self->{$_}) {
$Self->{LayoutObject}->FatalError(Message => "Got no $_!");
}
}
# customer user object
$Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
# link object
$Self->{LinkObject} = Kernel::System::LinkObject->new(%Param);
return $Self;
}
# --
sub Run {
my $Self = shift;
my %Param = @_;
my $Output;
my $QueueID = $Self->{TicketObject}->TicketQueueID(TicketID => $Self->{TicketID});
# check needed stuff
if (!$Self->{TicketID} || !$QueueID) {
return $Self->{LayoutObject}->Error(Message => 'Need TicketID!');
}
# check permissions
if (!$Self->{TicketObject}->Permission(
Type => 'ro',
TicketID => $Self->{TicketID},
UserID => $Self->{UserID})) {
# --
# error screen, don't show ticket
# --
return $Self->{LayoutObject}->NoPermission(WithHeader => 'yes');
}
# get linked objects
my %Links = $Self->{LinkObject}->AllLinkedObjects(
Object => 'Ticket',
ObjectID => $Self->{TicketID},
UserID => $Self->{UserID},
);
foreach my $LinkType (sort keys %Links) {
my %ObjectType = %{$Links{$LinkType}};
foreach my $Object (sort keys %ObjectType) {
my %Data = %{$ObjectType{$Object}};
foreach my $Item (sort keys %Data) {
$Self->{LayoutObject}->Block(
Name => "Link$LinkType",
Data => $Data{$Item},
);
}
}
}
# get content
my %Ticket = $Self->{TicketObject}->TicketGet(TicketID => $Self->{TicketID});
my @ArticleBox = $Self->{TicketObject}->ArticleContentIndex(TicketID => $Self->{TicketID});
$Ticket{TicketTimeUnits} = $Self->{TicketObject}->TicketAccountedTimeGet(TicketID => $Ticket{TicketID});
# article attachments
foreach my $Article (@ArticleBox) {
my %AtmIndex = $Self->{TicketObject}->ArticleAttachmentIndex(
ContentPath => $Article->{ContentPath},
ArticleID => $Article->{ArticleID},
);
$Article->{Atms} = \%AtmIndex;
}
# user info
my %UserInfo = $Self->{UserObject}->GetUserData(
User => $Ticket{Owner},
Cached => 1
);
# customer info
my %CustomerData = ();
if ($Ticket{CustomerUserID}) {
%CustomerData = $Self->{CustomerUserObject}->CustomerUserDataGet(
User => $Ticket{CustomerUserID},
);
}
elsif ($Ticket{CustomerID}) {
%CustomerData = $Self->{CustomerUserObject}->CustomerUserDataGet(
CustomerID => $Ticket{CustomerID},
);
}
if (%CustomerData) {
$Param{CustomerTable} = $Self->{LayoutObject}->AgentCustomerViewTable(
Data => \%CustomerData,
Max => 100,
);
}
# genterate output
$Output .= $Self->{LayoutObject}->PrintHeader(Value => $Ticket{TicketNumber});
# do some html quoting
$Ticket{Age} = $Self->{LayoutObject}->CustomerAge(Age => $Ticket{Age}, Space => ' ');
if ($Ticket{UntilTime}) {
$Ticket{PendingUntil} = $Self->{LayoutObject}->CustomerAge(Age => $Ticket{UntilTime}, Space => ' ');
}
else {
$Ticket{PendingUntil} = '-';
}
# prepare escalation time (if needed)
if ($Ticket{TicketOverTime}) {
$Ticket{TicketOverTime} = $Self->{LayoutObject}->CustomerAge(
Age => $Ticket{TicketOverTime},
Space => ' ',
);
}
else {
$Ticket{TicketOverTime} = '-';
}
# show ticket
$Output .= $Self->_Mask(
TicketID => $Self->{TicketID},
QueueID => $QueueID,
ArticleBox => \@ArticleBox,
%Param,
%UserInfo,
%Ticket,
);
# add footer
$Output .= $Self->{LayoutObject}->PrintFooter();
# return output
return $Output;
}
# --
sub _Mask {
my $Self = shift;
my %Param = @_;
# build article stuff
my $SelectedArticleID = $Param{ArticleID} || '';
my @ArticleBox = @{$Param{ArticleBox}};
# get last customer article
my $Output = '';
foreach my $ArticleTmp (@ArticleBox) {
my %Article = %{$ArticleTmp};
# get attacment string
my %AtmIndex = ();
if ($Article{Atms}) {
%AtmIndex = %{$Article{Atms}};
}
$Param{"Article::ATM"} = '';
foreach my $FileID (keys %AtmIndex) {
my %File = %{$AtmIndex{$FileID}};
$File{Filename} = $Self->{LayoutObject}->Ascii2Html(Text => $File{Filename});
$Param{"Article::ATM"} .= '<a href="$Env{"Baselink"}Action=AgentTicketAttachment&'.
"ArticleID=$Article{ArticleID}&FileID=$FileID\" target=\"attachment\" ".
"onmouseover=\"window.status='\$Text{\"Download\"}: $File{Filename}';".
' return true;" onmouseout="window.status=\'\';">'.
"$File{Filename}</a> $File{Filesize}<br>";
}
# check if just a only html email
if (my $MimeTypeText = $Self->{LayoutObject}->CheckMimeType(%Param, %Article, Action => 'AgentTicketZoom')) {
$Param{"TextNote"} = $MimeTypeText;
$Article{"Body"} = '';
}
else {
# html quoting
$Article{Body} = $Self->{LayoutObject}->Ascii2Html(
NewLine => $Self->{ConfigObject}->Get('DefaultViewNewLine') || 85,
Text => $Article{Body},
VMax => $Self->{ConfigObject}->Get('DefaultViewLines') || 5000,
);
# do charset check
if (my $CharsetText = $Self->{LayoutObject}->CheckCharset(
Action => 'AgentTicketZoom',
ContentCharset => $Article{ContentCharset},
TicketID => $Param{TicketID},
ArticleID => $Article{ArticleID} )) {
$Param{"Article::TextNote"} = $CharsetText;
}
}
# select the output template
if ($Article{ArticleType} ne 'email-notification-int') {
$Self->{LayoutObject}->Block(
Name => 'Article',
Data => {%Param,%Article},
);
}
# do some strips && quoting
foreach (qw(From To Cc Subject)) {
if ($Article{$_}) {
$Self->{LayoutObject}->Block(
Name => 'Row',
Data => {
Key => $_,
Value => $Article{$_},
},
);
}
}
# show accounted article time
if ($Self->{ConfigObject}->Get('Ticket::ZoomTimeDisplay')) {
my $ArticleTime = $Self->{TicketObject}->ArticleAccountedTimeGet(
ArticleID => $Article{ArticleID},
);
$Self->{LayoutObject}->Block(
Name => "Row",
Data => {
Key => 'Time',
Value => $ArticleTime,
},
);
}
# show article free text
foreach (qw(1 2 3 4 5)) {
if ($Article{"FreeText$_"}) {
$Self->{LayoutObject}->Block(
Name => 'ArticleFreeText',
Data => {
Key => $Article{"FreeKey$_"},
Value => $Article{"FreeText$_"},
},
);
}
}
}
# return output
return $Self->{LayoutObject}->Output(TemplateFile => 'AgentTicketPrint', Data => {%Param});
}
# --
1;
|