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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
|
# --
# Kernel/Output/HTML/Agent.pm - provides generic agent HTML output
# Copyright (C) 2001-2005 Martin Edenhofer <martin+code@otrs.org>
# --
# $Id: Agent.pm,v 1.160 2005/09/11 13:33: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::Output::HTML::Agent;
use strict;
use vars qw($VERSION);
$VERSION = '$Revision: 1.160 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
sub TicketStdResponseString {
my $Self = shift;
my %Param = @_;
# check needed stuff
foreach (qw(StdResponsesRef TicketID ArticleID)) {
if (!$Param{$_}) {
return "Need $_ in TicketStdResponseString()";
}
}
# get StdResponsesStrg
if ($Self->{ConfigObject}->Get('Ticket::Frontend::StdResponsesMode') eq 'Form') {
# build html string
$Param{StdResponsesStrg} .= '<form action="'.$Self->{CGIHandle}.'" method="post">'.
'<input type="hidden" name="Action" value="AgentTicketCompose">'.
'<input type="hidden" name="ArticleID" value="'.$Param{ArticleID}.'">'.
'<input type="hidden" name="TicketID" value="'.$Param{TicketID}.'">'.
$Self->OptionStrgHashRef(
Name => 'ResponseID',
Data => $Param{StdResponsesRef},
).
'<input class="button" type="submit" value="$Text{"Compose"}"></form>';
}
else {
my %StdResponses = %{$Param{StdResponsesRef}};
foreach (sort { $StdResponses{$a} cmp $StdResponses{$b} } keys %StdResponses) {
# build html string
$Param{StdResponsesStrg} .= "\n<li><a href=\"$Self->{Baselink}"."Action=AgentTicketCompose&".
"ResponseID=$_&TicketID=$Param{TicketID}&ArticleID=$Param{ArticleID}\" ".
'onmouseover="window.status=\'$Text{"Compose"}\'; return true;" '.
'onmouseout="window.status=\'\';">'.
# html quote
$Self->Ascii2Html(Text => $StdResponses{$_})."</A></li>\n";
}
}
return $Param{StdResponsesStrg};
}
# --
sub AgentCustomerView {
my $Self = shift;
my %Param = @_;
$Param{Table} = $Self->AgentCustomerViewTable(%Param);
# create & return output
return $Self->Output(TemplateFile => 'AgentCustomerView', Data => \%Param);
}
# --
sub AgentCustomerViewTable {
my $Self = shift;
my %Param = @_;
my $ShownType = 1;
if (ref($Param{Data}) ne 'HASH') {
$Self->FatalError(Message => 'Need Hash ref in Data param');
}
elsif (ref($Param{Data}) eq 'HASH' && !%{$Param{Data}}) {
return '$Text{"none"}';
}
my $Map = $Param{Data}->{Config}->{Map};
if ($Param{Type} && $Param{Type} eq 'Lite') {
$ShownType = 2;
# check if min one lite view item is configured, if not, use
# the normal view also
my $Used = 0;
foreach my $Field (@{$Map}) {
if ($Field->[3] == 2) {
$Used = 1;
}
}
if (!$Used) {
$ShownType = 1;
}
}
# build html table
foreach my $Field (@{$Map}) {
if ($Field->[3] && $Field->[3] >= $ShownType && $Param{Data}->{$Field->[0]}) {
my %Record = ();
if ($Field->[6]) {
$Record{LinkStart} = "<a href=\"$Field->[6]\">";
$Record{LinkStop} = "</a>";
}
if ($Field->[0]) {
$Record{ValueShort} = $Self->Ascii2Html(Text => $Param{Data}->{$Field->[0]}, Max => $Param{Max});
}
$Self->Block(
Name => 'CustomerRow',
Data => {
%{$Param{Data}},
Key => $Field->[1],
Value => $Param{Data}->{$Field->[0]},
%Record,
},
);
}
}
# create & return output
return $Self->Output(TemplateFile => 'AgentCustomerTableView', Data => \%Param);
}
# --
sub TicketLocked {
my $Self = shift;
my %Param = @_;
return $Self->Output(TemplateFile => 'AgentTicketLocked', Data => \%Param);
}
# --
sub AgentQueueListOption {
my $Self = shift;
my %Param = @_;
my $Size = defined($Param{Size}) ? "size='$Param{Size}'" : '';
my $MaxLevel = defined($Param{MaxLevel}) ? $Param{MaxLevel} : 10;
my $SelectedID = defined($Param{SelectedID}) ? $Param{SelectedID} : '';
my $Selected = defined($Param{Selected}) ? $Param{Selected} : '';
my $SelectedIDRefArray = $Param{SelectedIDRefArray} || '';
my $Multiple = $Param{Multiple} ? 'multiple' : '';
my $OnChangeSubmit = defined($Param{OnChangeSubmit}) ? $Param{OnChangeSubmit} : 0;
if ($OnChangeSubmit) {
$OnChangeSubmit = " onchange=\"submit()\"";
}
if ($Param{OnChange}) {
$OnChangeSubmit = " onchange=\"$Param{OnChange}\"";
}
# just show a simple list
if ($Self->{ConfigObject}->Get('Ticket::Frontend::QueueListType') eq 'list') {
$Param{'MoveQueuesStrg'} = $Self->OptionStrgHashRef(
%Param,
HTMLQuote => 0,
# OnChangeSubmit => 1,
);
return $Param{MoveQueuesStrg};
}
# build tree list
$Param{MoveQueuesStrg} = '<select name="'.$Param{Name}."\" $Size $Multiple $OnChangeSubmit>";
my %UsedData = ();
my %Data = ();
if ($Param{Data} && ref($Param{Data}) eq 'HASH') {
%Data = %{$Param{Data}};
}
else {
return 'Need Data Ref in AgentQueueListOption()!';
}
# add suffix for correct sorting
foreach (sort {$Data{$a} cmp $Data{$b}} keys %Data) {
$Data{$_} .= '::';
}
# build selection string
foreach (sort {$Data{$a} cmp $Data{$b}} keys %Data) {
my @Queue = split(/::/, $Param{Data}->{$_});
$UsedData{$Param{Data}->{$_}} = 1;
my $UpQueue = $Param{Data}->{$_};
$UpQueue =~ s/^(.*)::.+?$/$1/g;
if (! $Queue[$MaxLevel] && $Queue[$#Queue] ne '') {
$Queue[$#Queue] = $Self->Ascii2Html(Text => $Queue[$#Queue], Max => 50-$#Queue);
my $Space = '';
for (my $i = 0; $i < $#Queue; $i++) {
$Space .= ' ';
}
# check if SelectedIDRefArray exists
if ($SelectedIDRefArray) {
foreach my $ID (@{$SelectedIDRefArray}) {
if ($ID eq $_) {
$Param{SelectedIDRefArrayOK}->{$_} = 1;
}
}
}
# build select string
if ($UsedData{$UpQueue}) {
if ($SelectedID eq $_ || $Selected eq $Param{Data}->{$_} || $Param{SelectedIDRefArrayOK}->{$_}) {
$Param{MoveQueuesStrg} .= '<option selected value="'.$_.'">'.
$Space.$Queue[$#Queue].'</option>';
}
else {
$Param{MoveQueuesStrg} .= '<option value="'.$_.'">'.
$Space.$Queue[$#Queue].'</option>';
}
}
}
}
$Param{MoveQueuesStrg} .= '</select>';
return $Param{MoveQueuesStrg};
}
# --
sub AgentFreeText {
my $Self = shift;
my %Param = @_;
my %NullOption = ();
my %SelectData = ();
my %Ticket = ();
my %Config = ();
if ($Param{NullOption}) {
# $NullOption{''} = '-';
$SelectData{Size} = 3;
$SelectData{Multiple} = 1;
}
if ($Param{Ticket}) {
%Ticket = %{$Param{Ticket}};
}
if ($Param{Config}) {
%Config = %{$Param{Config}};
}
my %Data = ();
foreach (1..10) {
# key
if (ref($Config{"TicketFreeKey$_"}) eq 'HASH' && %{$Config{"TicketFreeKey$_"}}) {
my $Counter = 0;
my $LastKey = '';
foreach (keys %{$Config{"TicketFreeKey$_"}}) {
$Counter++;
$LastKey = $_;
}
if ($Counter == 1 && $Param{NullOption}) {
if ($LastKey) {
$Data{"TicketFreeKeyField$_"} = $Config{"TicketFreeKey$_"}->{$LastKey};
}
}
elsif ($Counter > 1) {
$Data{"TicketFreeKeyField$_"} = $Self->OptionStrgHashRef(
Data => {
%NullOption,
%{$Config{"TicketFreeKey$_"}},
},
Name => "TicketFreeKey$_",
SelectedID => $Ticket{"TicketFreeKey$_"},
SelectedIDRefArray => $Ticket{"TicketFreeKey$_"},
LanguageTranslation => 0,
HTMLQuote => 1,
%SelectData,
);
}
else {
if ($LastKey) {
$Data{"TicketFreeKeyField$_"} = $Config{"TicketFreeKey$_"}->{$LastKey}.
'<input type="hidden" name="TicketFreeKey'.$_.'" value="'.$Self->{LayoutObject}->Ascii2Html(Text => $LastKey).'">';
}
}
}
else {
if (defined($Ticket{"TicketFreeKey$_"})) {
if (ref($Ticket{"TicketFreeKey$_"}) eq 'ARRAY') {
if ($Ticket{"TicketFreeKey$_"}->[0]) {
$Ticket{"TicketFreeKey$_"} = $Ticket{"TicketFreeKey$_"}->[0];
}
else {
$Ticket{"TicketFreeKey$_"} = '';
}
}
$Data{"TicketFreeKeyField$_"} = '<input type="text" name="TicketFreeKey'.$_.'" value="'.$Self->{LayoutObject}->Ascii2Html(Text => $Ticket{"TicketFreeKey$_"}).'" size="20">';
}
else {
$Data{"TicketFreeKeyField$_"} = '<input type="text" name="TicketFreeKey'.$_.'" value="" size="20">';
}
}
# value
if (ref($Config{"TicketFreeText$_"}) eq 'HASH') {
$Data{"TicketFreeTextField$_"} = $Self->OptionStrgHashRef(
Data => {
%NullOption,
%{$Config{"TicketFreeText$_"}},
},
Name => "TicketFreeText$_",
SelectedID => $Ticket{"TicketFreeText$_"},
SelectedIDRefArray => $Ticket{"TicketFreeText$_"},
LanguageTranslation => 0,
HTMLQuote => 1,
%SelectData,
);
}
else {
if (defined($Ticket{"TicketFreeText$_"})) {
if (ref($Ticket{"TicketFreeText$_"}) eq 'ARRAY') {
if ($Ticket{"TicketFreeText$_"}->[0]) {
$Ticket{"TicketFreeText$_"} = $Ticket{"TicketFreeText$_"}->[0];
}
else {
$Ticket{"TicketFreeText$_"} = '';
}
}
$Data{"TicketFreeTextField$_"} = '<input type="text" name="TicketFreeText'.$_.'" value="'.$Self->{LayoutObject}->Ascii2Html(Text => $Ticket{"TicketFreeText$_"}).'" size="30">';
}
else {
$Data{"TicketFreeTextField$_"} = '<input type="text" name="TicketFreeText'.$_.'" value="" size="30">';
}
}
}
return %Data;
}
# --
sub AgentFreeDate {
my $Self = shift;
my %Param = @_;
my %NullOption = ();
my %SelectData = ();
my %Ticket = ();
my %Config = ();
if ($Param{NullOption}) {
# $NullOption{''} = '-';
$SelectData{Size} = 3;
$SelectData{Multiple} = 1;
}
if ($Param{Ticket}) {
%Ticket = %{$Param{Ticket}};
}
if ($Param{Config}) {
%Config = %{$Param{Config}};
}
my %Data = ();
foreach my $Count (1..2) {
$Data{'TicketFreeTime'.$Count} = $Self->BuildDateSelection(
%Param,
%Ticket,
Prefix => 'TicketFreeTime'.$Count,
Format => 'DateInputFormatLong',
DiffTime => $Self->{ConfigObject}->Get('TicketFreeTimeDiff'.$Count) || 0,
);
}
return %Data;
}
# --
1;
|