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
|
# --
# Kernel/Modules/AgentTicketCustomerFollowUp.pm - to handle customer messages
# if the agent is customer
# Copyright (C) 2001-2005 Martin Edenhofer <martin+code@otrs.org>
# --
# $Id: AgentTicketCustomerFollowUp.pm,v 1.4 2005/06/20 19:29:26 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::AgentTicketCustomerFollowUp;
use strict;
use Kernel::System::SystemAddress;
use Kernel::System::Queue;
use Kernel::System::State;
use vars qw($VERSION);
$VERSION = '$Revision: 1.4 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
sub new {
my $Type = shift;
my %Param = @_;
# allocate new hash for object
my $Self = {};
bless ($Self, $Type);
# get common objects
foreach (keys %Param) {
$Self->{$_} = $Param{$_};
}
# check needed Opjects
foreach (qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject)) {
if (!$Self->{$_}) {
$Self->{LayoutObject}->FatalError(Message => "Got no $_!");
}
}
# needed objects
$Self->{StateObject} = Kernel::System::State->new(%Param);
$Self->{SystemAddress} = Kernel::System::SystemAddress->new(%Param);
$Self->{QueueObject} = Kernel::System::Queue->new(%Param);
return $Self;
}
# --
sub Run {
my $Self = shift;
my %Param = @_;
my $Output;
if ($Self->{Subaction} eq '' || !$Self->{Subaction}) {
# --
# if there is no ticket id!
# --
if (!$Self->{TicketID}) {
return $Self->{LayoutObject}->ErrorScreen(
Message => 'No TicketID!',
Comment => 'Please contact your admin',
);
}
else {
# header
$Output .= $Self->{LayoutObject}->Header();
# get user lock data
my %LockedData = $Self->{TicketObject}->GetLockedCount(UserID => $Self->{UserID});
# build NavigationBar
$Output .= $Self->{LayoutObject}->NavigationBar(LockData => \%LockedData);
my %Ticket = $Self->{TicketObject}->TicketGet(TicketID => $Self->{TicketID});
# next stats
my %NextStates = $Self->{TicketObject}->StateList(
Type => 'CustomerPanelDefaultNextCompose',
TicketID => $Self->{TicketID},
Action => $Self->{Action},
CustomerUserID => $Self->{UserID},
);
$Param{'NextStatesStrg'} = $Self->{LayoutObject}->OptionStrgHashRef(
Data => \%NextStates,
Name => 'StateID',
Selected => $Self->{ConfigObject}->Get('CustomerPanelDefaultNextComposeType')
);
# get output back
$Output .= $Self->{LayoutObject}->Notify(
Info =>
$Self->{LayoutObject}->{LanguageObject}->Get('You are the customer user of this message - customer modus!'),
);
# show spell check
if ($Self->{ConfigObject}->Get('SpellChecker')) {
$Self->{LayoutObject}->Block(
Name => 'SpellCheck',
Data => {},
);
}
# show calendar lookup
if ($Self->{ConfigObject}->Get('CalendarLookup')) {
$Self->{LayoutObject}->Block(
Name => 'CalendarLookup',
Data => {},
);
}
$Output .= $Self->{LayoutObject}->Output(
TemplateFile => 'AgentTicketCustomerMessage',
Data => { %Param, %Ticket },
);
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
}
elsif ($Self->{Subaction} eq 'Store') {
# get ticket data
my %Ticket = $Self->{TicketObject}->TicketGet(
TicketID => $Self->{TicketID},
);
# get follow up option (possible or not)
my $FollowUpPossible = $Self->{QueueObject}->GetFollowUpOption(
QueueID => $Ticket{QueueID},
);
if ($FollowUpPossible =~ /(new ticket|reject)/i && $Ticket{StateType} =~ /^close/i) {
$Output = $Self->{LayoutObject}->Header(Title => 'Error');
$Output .= $Self->{LayoutObject}->Warning(
Message => 'Can\'t reopen ticket, not possible in this queue!',
Comment => 'Create a new ticket!',
);
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
my $Subject = $Self->{ParamObject}->GetParam(Param => 'Subject') || 'Follow up!';
my $Text = $Self->{ParamObject}->GetParam(Param => 'Body');
my $StateID = $Self->{ParamObject}->GetParam(Param => 'StateID');
my $From = "$Self->{UserFirstname} $Self->{UserLastname} <$Self->{UserEmail}>";
if (my $ArticleID = $Self->{TicketObject}->ArticleCreate(
TicketID => $Self->{TicketID},
ArticleType => $Self->{ConfigObject}->Get('CustomerPanelArticleType'),
SenderType => $Self->{ConfigObject}->Get('CustomerPanelSenderType'),
From => $From,
Subject => $Subject,
Body => $Text,
ContentType => "text/plain; charset=$Self->{LayoutObject}->{'UserCharset'}",
UserID => $Self->{UserID},
OrigHeader => {
From => $From,
To => 'System',
Subject => $Subject,
Body => $Text,
},
HistoryType => $Self->{ConfigObject}->Get('CustomerPanelHistoryType'),
HistoryComment => $Self->{ConfigObject}->Get('CustomerPanelHistoryComment') || '%%',
)) {
# --
# set state
# --
my %StateData = $Self->{TicketObject}->{StateObject}->StateGet(
ID => $StateID,
);
my $NextState = $StateData{Name} ||
$Self->{ConfigObject}->Get('CustomerPanelDefaultNextComposeType') || 'open';;
$Self->{TicketObject}->StateSet(
TicketID => $Self->{TicketID},
ArticleID => $ArticleID,
State => $NextState,
UserID => $Self->{UserID},
);
# get attachment
my %UploadStuff = $Self->{ParamObject}->GetUploadAll(
Param => 'file_upload',
Source => 'String',
);
if (%UploadStuff) {
$Self->{TicketObject}->ArticleWriteAttachment(
%UploadStuff,
ArticleID => $ArticleID,
UserID => $Self->{UserID},
);
}
# redirect to zoom view
return $Self->{LayoutObject}->Redirect(OP => $Self->{LastScreenView});
}
else {
return $Self->{LayoutObject}->ErrorScreen();
}
}
else {
return $Self->{LayoutObject}->ErrorScreen(
Message => 'No Subaction!!',
Comment => 'Please contact your admin',
);
}
}
# --
1;
|