81
81
# check needed stuff
82
82
foreach (qw(TicketID UserID ArticleTypeID SenderTypeID HistoryType HistoryComment)) {
84
$Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
84
$Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
88
# add 'no body found!' if there is no body there!
88
# add 'no body' if there is no body there!
89
89
if (!$Param{Body}) {
90
$Param{Body} = 'no body found!';
90
$Param{Body} = 'No body';
92
92
# if body isn't text, attach body as attachment (mostly done by OE) :-/
93
93
elsif ($Param{ContentType} && $Param{ContentType} !~ /\btext\b/i) {
127
127
my $SQL = "INSERT INTO article ".
128
" (ticket_id, article_type_id, article_sender_type_id, a_from, a_reply_to, a_to, " .
129
" a_cc, a_subject, a_message_id, a_body, a_content_type, content_path, ".
130
" valid_id, incoming_time, create_time, create_by, change_time, change_by) " .
132
" ($DBParam{TicketID}, $DBParam{ArticleTypeID}, $DBParam{SenderTypeID}, ".
133
" '$DBParam{From}', '$DBParam{ReplyTo}', '$DBParam{To}', '$DBParam{Cc}', ".
134
" '$DBParam{Subject}', ".
135
" '$DBParam{MessageID}', ?, '$DBParam{ContentType}', ?, ".
136
" $ValidID, $IncomingTime, " .
137
" current_timestamp, $DBParam{UserID}, current_timestamp, $DBParam{UserID})";
128
" (ticket_id, article_type_id, article_sender_type_id, a_from, a_reply_to, a_to, " .
129
" a_cc, a_subject, a_message_id, a_body, a_content_type, content_path, ".
130
" valid_id, incoming_time, create_time, create_by, change_time, change_by) " .
132
" ($DBParam{TicketID}, $DBParam{ArticleTypeID}, $DBParam{SenderTypeID}, ".
133
" '$DBParam{From}', '$DBParam{ReplyTo}', '$DBParam{To}', '$DBParam{Cc}', ".
134
" '$DBParam{Subject}', ".
135
" '$DBParam{MessageID}', ?, '$DBParam{ContentType}', ?, ".
136
" $ValidID, $IncomingTime, " .
137
" current_timestamp, $DBParam{UserID}, current_timestamp, $DBParam{UserID})";
138
138
if (!$Self->{DBObject}->Do(SQL => $SQL, Bind => [\$Param{Body}, \$Self->{ArticleContentPath}])) {
142
142
my $ArticleID = $Self->_ArticleGetId(
143
143
TicketID => $Param{TicketID},
144
MessageID => $Param{MessageID},
144
MessageID => $Param{MessageID},
145
145
From => $Param{From},
146
146
Subject => $Param{Subject},
147
147
IncomingTime => $IncomingTime
183
183
TicketID => $Param{TicketID},
184
184
UserID => $Param{UserID},
186
# reset escalation if needed
187
if (!$Param{SenderType}) {
188
$Param{SenderType} = $Self->ArticleSenderTypeLookup(SenderTypeID => $Param{SenderTypeID});
190
if (!$Param{ArticleType}) {
191
$Param{ArticleType} = $Self->ArticleTypeLookup(ArticleTypeID => $Param{ArticleTypeID});
193
# reset escalation time if customer send an update
194
if ($Param{SenderType} eq 'customer') {
195
# check if latest article comes from customer
197
my $SQL .= "SELECT ast.name ".
199
" article at, article_sender_type ast ".
201
" at.ticket_id = $Param{TicketID} ".
203
" at.id NOT IN ($ArticleID) ".
205
" at.article_sender_type_id = ast.id ORDER BY at.create_time ASC";
206
$Self->{DBObject}->Prepare(SQL => $SQL);
207
while (my @Row = $Self->{DBObject}->FetchrowArray()) {
208
if ($Row[0] ne 'system') {
209
$LastSender = $Row[0];
212
if ($LastSender eq 'agent') {
213
$Self->TicketEscalationStartUpdate(
214
EscalationStartTime => $Self->{TimeObject}->SystemTime(),
215
TicketID => $Param{TicketID},
216
UserID => $Param{UserID},
218
$Self->TicketUnlockTimeoutUpdate(
219
UnlockTimeout => $Self->{TimeObject}->SystemTime(),
220
TicketID => $Param{TicketID},
221
UserID => $Param{UserID},
225
elsif ($Param{SenderType} eq 'agent' && $Param{ArticleType} =~ /email-ext|phone|fax|sms|note-ext/) {
226
# check if latest article is sent to customer
227
$Self->TicketEscalationStartUpdate(
228
EscalationStartTime => $Self->{TimeObject}->SystemTime(),
229
TicketID => $Param{TicketID},
230
UserID => $Param{UserID},
232
$Self->TicketUnlockTimeoutUpdate(
233
UnlockTimeout => $Self->{TimeObject}->SystemTime(),
234
TicketID => $Param{TicketID},
235
UserID => $Param{UserID},
186
238
# send auto response
187
239
my %Ticket = $Self->TicketGet(TicketID => $Param{TicketID});
188
240
my %State = $Self->{StateObject}->StateGet(ID => $Ticket{StateID});
261
314
TicketID => $Param{TicketID},
262
315
HistoryType => 'Misc',
263
316
Name => "Sent no auto-response because the sender doesn't want ".
264
"a auto-response (e. g. loop or precedence header)",
317
"a auto-response (e. g. loop or precedence header)",
265
318
CreateUserID => $Param{UserID},
267
320
$Self->{LogObject}->Log(
268
321
Priority => 'notice',
269
322
Message => "Sent no '$Param{AutoResponseType}' for Ticket [".
270
"$Ticket{TicketNumber}] ($OrigHeader{From}) because the ".
271
"sender doesn't want a auto-response (e. g. loop or precedence header)"
323
"$Ticket{TicketNumber}] ($OrigHeader{From}) because the ".
324
"sender doesn't want a auto-response (e. g. loop or precedence header)"
276
329
# send no agent notification!?
278
330
if ($Param{NoAgentNotify}) {
279
331
# return ArticleID
280
332
return $ArticleID;
283
335
# send agent notification!?
337
my %AlreadySent = ();
286
338
if ($Param{HistoryType} =~ /^(EmailAgent|EmailCustomer|PhoneCallCustomer|WebRequestCustomer|SystemRequest)$/i) {
287
339
foreach ($Self->GetSubscribedUserIDsByQueueID(QueueID => $Ticket{QueueID})) {
288
my %UserData = $Self->{UserObject}->GetUserData(
293
if ($UserData{UserSendNewTicketNotification}) {
295
$Self->SendAgentNotification(
296
Type => $Param{HistoryType},
297
UserData => \%UserData,
298
CustomerMessageParams => \%Param,
299
TicketID => $Param{TicketID},
300
Queue => $Param{Queue},
301
UserID => $Param{UserID},
340
if (!$AlreadySent{$_}) {
341
$AlreadySent{$_} = 1;
342
my %UserData = $Self->{UserObject}->GetUserData(
347
if ($UserData{UserSendNewTicketNotification}) {
349
$Self->SendAgentNotification(
350
Type => $Param{HistoryType},
351
UserData => \%UserData,
352
CustomerMessageParams => \%Param,
353
TicketID => $Param{TicketID},
354
Queue => $Param{Queue},
355
UserID => $Param{UserID},
306
361
elsif ($Param{HistoryType} =~ /^AddNote$/i) {
307
# send agent notification to agent
308
if ($Ticket{OwnerID} ne 1 && $Ticket{OwnerID} ne $Param{UserID}) {
309
my %UserData = $Self->{UserObject}->GetUserData(
310
UserID => $Ticket{OwnerID},
315
$Self->SendAgentNotification(
316
Type => $Param{HistoryType},
317
UserData => \%UserData,
318
CustomerMessageParams => \%Param,
319
TicketID => $Param{TicketID},
320
Queue => $Param{Queue},
321
UserID => $Param{UserID},
362
# send owner/responsible notification to agent
363
foreach (qw(OwnerID ResponsibleID)) {
364
if ($Ticket{$_} && $Ticket{$_} ne 1 && $Ticket{$_} ne $Param{UserID}) {
365
if (!$AlreadySent{$Ticket{$_}}) {
366
$AlreadySent{$Ticket{$_}} = 1;
367
my %UserData = $Self->{UserObject}->GetUserData(
368
UserID => $Ticket{$_},
373
$Self->SendAgentNotification(
374
Type => $Param{HistoryType},
375
UserData => \%UserData,
376
CustomerMessageParams => \%Param,
377
TicketID => $Param{TicketID},
378
Queue => $Param{Queue},
379
UserID => $Param{UserID},
326
385
elsif ($Param{HistoryType} =~ /^FollowUp$/i) {
327
386
# send agent notification to all agents
334
393
@OwnerIDs = $Self->GetSubscribedUserIDsByQueueID(QueueID => $Ticket{QueueID});
336
395
foreach (@OwnerIDs) {
337
my %UserData = $Self->{UserObject}->GetUserData(
342
if ($UserData{UserSendFollowUpNotification}) {
344
$Self->SendAgentNotification(
345
Type => $Param{HistoryType},
346
UserData => \%UserData,
347
CustomerMessageParams => \%Param,
348
TicketID => $Param{TicketID},
349
Queue => $Param{Queue},
350
UserID => $Param{UserID},
396
if (!$AlreadySent{$_}) {
397
$AlreadySent{$_} = 1;
398
my %UserData = $Self->{UserObject}->GetUserData(
403
if ($UserData{UserSendFollowUpNotification}) {
405
$Self->SendAgentNotification(
406
Type => $Param{HistoryType},
407
UserData => \%UserData,
408
CustomerMessageParams => \%Param,
409
TicketID => $Param{TicketID},
410
Queue => $Param{Queue},
411
UserID => $Param{UserID},
355
# send agent notification the agents who locked the ticket
417
# send owner/responsible notification the agents who locked the ticket
357
my %UserData = $Self->{UserObject}->GetUserData(UserID => $Ticket{OwnerID});
358
if ($UserData{UserSendFollowUpNotification}) {
360
$Self->SendAgentNotification(
361
Type => $Param{HistoryType},
362
UserData => \%UserData,
363
CustomerMessageParams => \%Param,
364
TicketID => $Param{TicketID},
365
Queue => $Param{Queue},
366
UserID => $Param{UserID},
419
foreach (qw(OwnerID ResponsibleID)) {
421
if (!$AlreadySent{$Ticket{$_}}) {
422
$AlreadySent{$Ticket{$_}} = 1;
423
my %UserData = $Self->{UserObject}->GetUserData(UserID => $Ticket{$_});
424
if ($Ticket{$_} ne 1 && $UserData{UserSendFollowUpNotification}) {
426
$Self->SendAgentNotification(
427
Type => $Param{HistoryType},
428
UserData => \%UserData,
429
CustomerMessageParams => \%Param,
430
TicketID => $Param{TicketID},
431
Queue => $Param{Queue},
432
UserID => $Param{UserID},
369
438
# send the rest of agents follow ups
370
439
foreach ($Self->GetSubscribedUserIDsByQueueID(QueueID => $Ticket{QueueID})) {
371
my %UserData = $Self->{UserObject}->GetUserData(
376
if ($UserData{UserSendFollowUpNotification} && $UserData{UserSendFollowUpNotification} == 2 && $Ticket{OwnerID} ne 1 && $Ticket{OwnerID} ne $Param{UserID} && $Ticket{OwnerID} ne $UserData{UserID}) {
378
$Self->SendAgentNotification(
379
Type => $Param{HistoryType},
380
UserData => \%UserData,
381
CustomerMessageParams => \%Param,
382
TicketID => $Param{TicketID},
383
Queue => $Param{Queue},
384
UserID => $Param{UserID},
440
if (!$AlreadySent{$_}) {
441
my %UserData = $Self->{UserObject}->GetUserData(
446
if ($UserData{UserSendFollowUpNotification} &&
447
$UserData{UserSendFollowUpNotification} == 2 &&
448
$Ticket{OwnerID} ne 1 &&
449
$Ticket{OwnerID} ne $Param{UserID} &&
450
$Ticket{OwnerID} ne $UserData{UserID}
452
$AlreadySent{$_} = 1;
454
$Self->SendAgentNotification(
455
Type => $Param{HistoryType},
456
UserData => \%UserData,
457
CustomerMessageParams => \%Param,
458
TicketID => $Param{TicketID},
459
Queue => $Param{Queue},
460
UserID => $Param{UserID},
390
467
# send forced notifications
391
468
if ($Param{ForceNotificationToUserID} && ref($Param{ForceNotificationToUserID}) eq 'ARRAY') {
392
my %AlreadySent = ();
393
469
foreach (@{$Param{ForceNotificationToUserID}}) {
394
470
if (!$AlreadySent{$_}) {
395
471
$AlreadySent{$_} = 1;
575
651
if ($Self->{"ArticleSenderTypeLookup::$Param{$Param{Key}}"}) {
576
652
return $Self->{"ArticleSenderTypeLookup::$Param{$Param{Key}}"};
579
foreach (keys %Param) {
580
$Param{$_} = $Self->{DBObject}->Quote($Param{$_});
584
656
if ($Param{SenderType}) {
658
foreach (qw(SenderType)) {
659
$Param{$_} = $Self->{DBObject}->Quote($Param{$_});
585
661
$SQL = "SELECT id FROM article_sender_type WHERE name = '$Param{SenderType}'";
665
foreach (qw(SenderTypeID)) {
666
$Param{$_} = $Self->{DBObject}->Quote($Param{$_}, 'Integer');
588
668
$SQL = "SELECT name FROM article_sender_type WHERE id = $Param{SenderTypeID}";
590
670
$Self->{DBObject}->Prepare(SQL => $SQL);
637
717
if ($Self->{"ArticleTypeLookup::$Param{$Param{Key}}"}) {
638
718
return $Self->{"ArticleTypeLookup::$Param{$Param{Key}}"};
641
foreach (keys %Param) {
642
$Param{$_} = $Self->{DBObject}->Quote($Param{$_});
646
722
if ($Param{ArticleType}) {
724
foreach (qw(ArticleType)) {
725
$Param{$_} = $Self->{DBObject}->Quote($Param{$_});
647
727
$SQL = "SELECT id FROM article_type WHERE name = '$Param{ArticleType}'",
731
foreach (qw(ArticleTypeID)) {
732
$Param{$_} = $Self->{DBObject}->Quote($Param{$_}, 'Integer');
650
734
$SQL = "SELECT name FROM article_type WHERE id = $Param{ArticleTypeID}",
652
736
$Self->{DBObject}->Prepare(SQL => $SQL);
667
751
return $Self->{"ArticleTypeLookup::$Param{$Param{Key}}"};
754
=item ArticleTypeList()
756
get a article type list
758
my @ArticleTypeList = $TicketObject->ArticleTypesList();
760
# to get just customer shown article types
761
my @ArticleTypeList = $TicketObject->ArticleTypesList(
767
sub ArticleTypeList {
774
$Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
778
my $SQL = "SELECT id, name FROM article_type ".
779
" WHERE valid_id IN (${\(join ', ', $Self->{DBObject}->GetValidIDs())}) ";
780
$Self->{DBObject}->Prepare(SQL => $SQL);
781
while (my @Row = $Self->{DBObject}->FetchrowArray()){
782
if ($Param{Type} && $Param{Type} eq 'Customer') {
783
if ($Row[1] !~ /int/i){
784
push (@List, $Row[1]);
788
push (@List, $Row[1]);
795
=item ArticleFreeTextGet()
797
get _possible_ article free text options
799
Note: the current value is accessible over ArticleGet()
801
my $HashRef = $TicketObject->ArticleFreeTextGet(
802
Type => 'ArticleFreeText3',
804
UserID => 123, # or CustomerUserID
807
my $HashRef = $TicketObject->ArticleFreeTextGet(
808
Type => 'ArticleFreeText3',
809
UserID => 123, # or CustomerUserID
812
# fill up with existing values
813
my $HashRef = $TicketObject->ArticleFreeTextGet(
814
Type => 'ArticleFreeText3',
816
UserID => 123, # or CustomerUserID
821
sub ArticleFreeTextGet {
824
my $Value = $Param{Value} || '';
825
my $Key = $Param{Key} || '';
829
$Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
833
if (!$Param{UserID} && !$Param{CustomerUserID}) {
834
$Self->{LogObject}->Log(Priority => 'error', Message => "Need UserID or CustomerUserID!");
839
if (ref($Self->{ConfigObject}->Get($Param{Type})) eq 'HASH') {
840
%Data = %{$Self->{ConfigObject}->Get($Param{Type})};
843
if ($Param{FillUp}) {
844
my $Counter = $Param{Type};
845
$Counter =~ s/^.*(\d)$/$1/;
846
if (%Data && $Param{Type} =~ /text/i) {
847
$Self->{DBObject}->Prepare(SQL => "SELECT distinct(a_freetext$Counter) FROM article");
848
while (my @Row = $Self->{DBObject}->FetchrowArray()) {
849
if ($Row[0] && !$Data{$Row[0]}) {
850
$Data{$Row[0]} = $Row[0];
855
$Self->{DBObject}->Prepare(SQL => "SELECT distinct(a_freekey$Counter) FROM article");
856
while (my @Row = $Self->{DBObject}->FetchrowArray()) {
857
if ($Row[0] && !$Data{$Row[0]}) {
858
$Data{$Row[0]} = $Row[0];
864
if ($Self->TicketAcl(
866
ReturnType => 'Ticket',
867
ReturnSubType => $Param{Type},
870
my %Hash = $Self->TicketAclData();
670
882
=item ArticleFreeTextSet()
672
884
set article free text
674
886
$TicketObject->ArticleFreeTextSet(
701
914
if ($Self->{DBObject}->Do(
702
915
SQL => "UPDATE article SET a_freekey$Param{Counter} = '$Param{Key}', " .
703
" a_freetext$Param{Counter} = '$Param{Value}', " .
704
" change_time = current_timestamp, change_by = $Param{UserID} " .
705
" WHERE id = $Param{ArticleID}",
916
" a_freetext$Param{Counter} = '$Param{Value}', " .
917
" change_time = current_timestamp, change_by = $Param{UserID} " .
918
" WHERE id = $Param{ArticleID}",
708
921
$Self->TicketEventHandlerPost(
709
Event => 'ArticleFreeTextSet',
922
Event => 'ArticleFreeTextUpdate',
710
923
TicketID => $Param{TicketID},
711
924
UserID => $Param{UserID},
836
1049
if ($Param{SenderType}) {
837
1050
$SQL .= "SELECT at.id".
839
" article at, article_sender_type ast ".
841
" at.ticket_id = $Param{TicketID} ".
843
" at.article_sender_type_id = ast.id ".
845
" ast.name = '$Param{SenderType}' ";
1052
" article at, article_sender_type ast ".
1054
" at.ticket_id = $Param{TicketID} ".
1056
" at.article_sender_type_id = ast.id ".
1058
" ast.name = '$Param{SenderType}' ";
848
1061
$SQL = "SELECT at.id".
852
" at.ticket_id = $Param{TicketID} ";
1065
" at.ticket_id = $Param{TicketID} ";
854
1067
$SQL .= " ORDER BY at.id";
855
1068
$Self->{DBObject}->Prepare(SQL => $SQL);
947
1157
" st.create_time_unix, st.ticket_state_id, st.queue_id, sa.create_time, ".
948
1158
" sa.a_content_type, sa.create_by, st.tn, article_sender_type_id, st.customer_id, ".
949
1159
" st.until_time, st.ticket_priority_id, st.customer_user_id, st.user_id, ".
950
" su.$Self->{ConfigObject}->{DatabaseUserTableUser}, sa.article_type_id, ".
1160
" st.responsible_user_id, sa.article_type_id, ".
951
1161
" sa.a_freekey1, sa.a_freetext1, sa.a_freekey2, sa.a_freetext2, ".
952
1162
" sa.a_freekey3, sa.a_freetext3, st.ticket_answered, ".
953
1163
" sa.incoming_time, sa.id, st.freekey1, st.freetext1, st.freekey2, st.freetext2,".
954
1164
" st.freekey3, st.freetext3, st.freekey4, st.freetext4,".
955
1165
" st.freekey5, st.freetext5, st.freekey6, st.freetext6,".
956
1166
" st.freekey7, st.freetext7, st.freekey8, st.freetext8, ".
1167
" st.freekey9, st.freetext9, st.freekey10, st.freetext10, ".
1168
" st.freekey11, st.freetext11, st.freekey12, st.freetext12, ".
1169
" st.freekey13, st.freetext13, st.freekey14, st.freetext14, ".
1170
" st.freekey15, st.freetext15, st.freekey16, st.freetext16, ".
957
1171
" st.ticket_lock_id, st.title, st.escalation_start_time, ".
958
1172
" st.freetime1 , st.freetime2 ".
960
" article sa, ticket st, ".
961
" $Self->{ConfigObject}->{DatabaseUserTable} su ".
1174
" article sa, ticket st ".
963
1176
if ($Param{ArticleID}) {
964
1177
$SQL .= " sa.id = $Param{ArticleID}";
1025
1236
$Data{MimeType} = '';
1027
$Ticket{CustomerID} = $Row[16];
1238
$Data{CustomerUserID} = $Row[19];
1028
1239
$Ticket{CustomerUserID} = $Row[19];
1029
1240
$Data{CustomerID} = $Row[16];
1030
$Data{CustomerUserID} = $Row[19];
1031
$Data{UserID} = $Row[20];
1032
$Ticket{UserID} = $Row[20];
1033
$Data{Owner} = $Row[21];
1241
$Ticket{CustomerID} = $Row[16];
1242
$Data{OwnerID} = $Row[20];
1243
$Ticket{OwnerID} = $Row[20];
1244
$Data{ResponsibleID} = $Row[21];
1245
$Ticket{ResponsibleID} = $Row[21];
1034
1246
$Data{ArticleTypeID} = $Row[22];
1035
$Data{FreeKey1} = $Row[23];
1036
$Data{FreeText1} = $Row[24];
1037
$Data{FreeKey2} = $Row[25];
1038
$Data{FreeText2} = $Row[26];
1039
$Data{FreeKey3} = $Row[27];
1040
$Data{FreeText3} = $Row[28];
1247
$Data{ArticleFreeKey1} = $Row[23];
1248
$Data{ArticleFreeText1} = $Row[24];
1249
$Data{ArticleFreeKey2} = $Row[25];
1250
$Data{ArticleFreeText2} = $Row[26];
1251
$Data{ArticleFreeKey3} = $Row[27];
1252
$Data{ArticleFreeText3} = $Row[28];
1041
1253
$Data{TicketFreeKey1} = $Row[32];
1042
1254
$Data{TicketFreeText1} = $Row[33];
1043
1255
$Data{TicketFreeKey2} = $Row[34];
1054
1266
$Data{TicketFreeText7} = $Row[45];
1055
1267
$Data{TicketFreeKey8} = $Row[46];
1056
1268
$Data{TicketFreeText8} = $Row[47];
1057
$Data{TicketFreeTime1} = $Row[51];
1058
$Data{TicketFreeTime2} = $Row[52];
1269
$Data{TicketFreeKey9} = $Row[48];
1270
$Data{TicketFreeText9} = $Row[49];
1271
$Data{TicketFreeKey10} = $Row[50];
1272
$Data{TicketFreeText10} = $Row[51];
1273
$Data{TicketFreeKey11} = $Row[52];
1274
$Data{TicketFreeText11} = $Row[53];
1275
$Data{TicketFreeKey12} = $Row[54];
1276
$Data{TicketFreeText12} = $Row[55];
1277
$Data{TicketFreeKey13} = $Row[56];
1278
$Data{TicketFreeText13} = $Row[57];
1279
$Data{TicketFreeKey14} = $Row[58];
1280
$Data{TicketFreeText14} = $Row[59];
1281
$Data{TicketFreeKey15} = $Row[60];
1282
$Data{TicketFreeText15} = $Row[61];
1283
$Data{TicketFreeKey16} = $Row[62];
1284
$Data{TicketFreeText16} = $Row[63];
1285
$Data{TicketFreeTime1} = $Row[67];
1286
$Data{TicketFreeTime2} = $Row[68];
1060
1288
$Data{IncomingTime} = $Row[30];
1061
1289
$Data{RealTillTimeNotUsed} = $Row[17];
1062
$Ticket{LockID} = $Row[48];
1290
$Ticket{LockID} = $Row[64];
1063
1291
# strip not wanted stuff
1064
1292
foreach (qw(From To Cc Subject)) {
1065
1293
$Data{$_} =~ s/\n|\r//g if ($Data{$_});
1067
1295
push (@Content, {%Data, %Ticket});
1070
# $Ticket{SLAAge} = $Self->{TimeObject}->SLATime(StartTime => $Ticket{CreateTimeUnix});
1298
$Ticket{Owner} = $Self->{UserObject}->UserLookup(UserID => $Ticket{OwnerID});
1300
$Ticket{Responsible} = $Self->{UserObject}->UserLookup(UserID => $Ticket{ResponsibleID} || 1);
1072
1302
$Ticket{Priority} = $Self->PriorityLookup(ID => $Ticket{PriorityID});
1073
1304
$Ticket{Lock} = $Self->{LockObject}->LockLookup(ID => $Ticket{LockID});
1074
1305
# get queue name and other stuff
1075
1306
my %Queue = $Self->{QueueObject}->QueueGet(ID => $Ticket{QueueID}, Cache => 1);
1106
1343
my $CountedTime = $Self->{TimeObject}->WorkingTime(
1107
1344
StartTime => $Ticket{EscalationStartTime},
1108
1345
StopTime => $Self->{TimeObject}->SystemTime(),
1109
Queue => $Queue{Name},
1111
$LastCustomerCreateTime = ($Queue{EscalationTime}*60) - $CountedTime;
1346
Calendar => $Queue{Calendar},
1348
$EscalationTime = ($Queue{EscalationTime}*60) - $CountedTime;
1349
my $CountedTime1 = $Self->{TimeObject}->DestinationTime(
1350
StartTime => $Ticket{EscalationStartTime},
1351
Time => $Queue{EscalationTime}*60,
1352
Calendar => $Queue{Calendar},
1354
$EscalationDate = $Self->{TimeObject}->SystemTime2TimeStamp(SystemTime => $CountedTime1);
1355
$EscalationTimeLong = $CountedTime1 - $Self->{TimeObject}->SystemTime();
1113
1357
foreach my $Part (@Content) {
1114
$Part->{TicketOverTime} = $LastCustomerCreateTime;
1358
$Part->{TicketOverTime} = $EscalationTime;
1359
$Part->{TicketOverTimeLong} = $EscalationTimeLong;
1360
$Part->{TicketOverDate} = $EscalationDate;
1116
1362
if ($Param{ArticleID}) {
1117
1363
return %{$Content[0]};
1285
1531
foreach my $Tmp (@{$Param{Attachment}}) {
1286
1532
my %Upload = %{$Tmp};
1287
1533
if ($Upload{Content} && $Upload{Filename}) {
1288
# add attachments to article
1289
$Self->ArticleWriteAttachment(
1291
ArticleID => $Param{ArticleID},
1292
UserID => $Param{UserID},
1534
# add attachments to article
1535
$Self->ArticleWriteAttachment(
1537
ArticleID => $Param{ArticleID},
1538
UserID => $Param{UserID},
1470
1722
# replace config options
1471
1723
$Notification{Body} =~ s{<OTRS_CONFIG_(.+?)>}{$Self->{ConfigObject}->Get($1)}egx;
1472
1724
$Notification{Subject} =~ s{<OTRS_CONFIG_(.+?)>}{$Self->{ConfigObject}->Get($1)}egx;
1726
$Notification{Subject} =~ s/<OTRS_CONFIG_.+?>/-/gi;
1727
$Notification{Body} =~ s/<OTRS_CONFIG_.+?>/-/gi;
1474
1729
# get owner data and replace it with <OTRS_OWNER_...
1475
my %Preferences = $Self->{UserObject}->GetUserData(UserID => $Article{UserID});
1476
foreach (keys %Preferences) {
1477
if ($Preferences{$_}) {
1478
$Notification{Body} =~ s/<OTRS_OWNER_$_>/$Preferences{$_}/gi;
1479
$Notification{Subject} =~ s/<OTRS_OWNER_$_>/$Preferences{$_}/gi;
1730
my %OwnerPreferences = $Self->{UserObject}->GetUserData(UserID => $Article{OwnerID});
1731
foreach (keys %OwnerPreferences) {
1732
if ($OwnerPreferences{$_}) {
1733
$Notification{Body} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
1734
$Notification{Subject} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
1738
$Notification{Subject} =~ s/<OTRS_OWNER_.+?>/-/gi;
1739
$Notification{Body} =~ s/<OTRS_OWNER_.+?>/-/gi;
1741
# get owner data and replace it with <OTRS_RESPONSIBLE_...
1742
my %ResponsiblePreferences = $Self->{UserObject}->GetUserData(UserID => $Article{ResponsibleID});
1743
foreach (keys %ResponsiblePreferences) {
1744
if ($ResponsiblePreferences{$_}) {
1745
$Notification{Body} =~ s/<OTRS_RESPONSIBLE_$_>/$ResponsiblePreferences{$_}/gi;
1746
$Notification{Subject} =~ s/<OTRS_RESPONSIBLE_$_>/$ResponsiblePreferences{$_}/gi;
1750
$Notification{Subject} =~ s/<OTRS_RESPONSIBLE_.+?>/-/gi;
1751
$Notification{Body} =~ s/<OTRS_RESPONSIBLE_.+?>/-/gi;
1482
1753
# get current user data
1483
1754
my %CurrentUser = $Self->{UserObject}->GetUserData(UserID => $Param{UserID});
1484
1755
foreach (keys %CurrentUser) {
1506
$Notification{Body} =~ s/<OTRS_TICKET_ID>/$Param{TicketID}/g;
1507
$Notification{Body} =~ s/<OTRS_TICKET_NUMBER>/$Article{TicketNumber}/g;
1508
$Notification{Body} =~ s/<OTRS_QUEUE>/$Article{Queue}/g;
1509
$Notification{Body} =~ s/<OTRS_COMMENT>/$GetParam{Comment}/g if (defined $GetParam{Comment});
1782
$Notification{Body} =~ s/<OTRS_TICKET_ID>/$Param{TicketID}/gi;
1783
$Notification{Body} =~ s/<OTRS_TICKET_NUMBER>/$Article{TicketNumber}/gi;
1784
$Notification{Body} =~ s/<OTRS_QUEUE>/$Article{Queue}/gi;
1785
$Notification{Body} =~ s/<OTRS_COMMENT>/$GetParam{Comment}/gi if (defined $GetParam{Comment});
1787
$Notification{Subject} =~ s/<OTRS_TICKET_.+?>/-/gi;
1788
$Notification{Body} =~ s/<OTRS_TICKET_.+?>/-/gi;
1511
1790
# prepare subject (insert old subject)
1512
1791
$GetParam{Subject} = $Self->TicketSubjectClean(
1577
1848
chomp $NewOldBody;
1578
1849
$Notification{Body} =~ s/<OTRS_CUSTOMER_EMAIL\[.+?\]>/$NewOldBody/g;
1851
# cleanup all not needed <OTRS_CUSTOMER_ tags
1852
$Notification{Body} =~ s/<OTRS_CUSTOMER_.+?>/-/gi;
1853
$Notification{Subject} =~ s/<OTRS_CUSTOMER_.+?>/-/gi;
1582
1856
$Self->{SendmailObject}->Send(
1583
1857
From => $Self->{ConfigObject}->Get('NotificationSenderName').
1584
' <'.$Self->{ConfigObject}->Get('NotificationSenderEmail').'>',
1858
' <'.$Self->{ConfigObject}->Get('NotificationSenderEmail').'>',
1585
1859
To => $User{UserEmail},
1586
1860
Subject => $Notification{Subject},
1587
'Reply-To' => $Self->{ConfigObject}->Get('NotificationSenderEmail'),
1588
1861
Type => 'text/plain',
1589
1862
Charset => $Notification{Charset},
1590
1863
Body => $Notification{Body},
1711
1984
# replace config options
1712
1985
$Notification{Body} =~ s{<OTRS_CONFIG_(.+?)>}{$Self->{ConfigObject}->Get($1)}egx;
1713
1986
$Notification{Subject} =~ s{<OTRS_CONFIG_(.+?)>}{$Self->{ConfigObject}->Get($1)}egx;
1988
$Notification{Subject} =~ s/<OTRS_CONFIG_.+?>/-/gi;
1989
$Notification{Body} =~ s/<OTRS_CONFIG_.+?>/-/gi;
1716
$Notification{Body} =~ s/<OTRS_TICKET_ID>/$Param{TicketID}/g;
1717
$Notification{Body} =~ s/<OTRS_TICKET_NUMBER>/$Article{TicketNumber}/g;
1718
$Notification{Body} =~ s/<OTRS_QUEUE>/$Param{Queue}/g if ($Param{Queue});
1992
$Notification{Body} =~ s/<OTRS_TICKET_ID>/$Param{TicketID}/gi;
1993
$Notification{Body} =~ s/<OTRS_TICKET_NUMBER>/$Article{TicketNumber}/gi;
1994
$Notification{Body} =~ s/<OTRS_QUEUE>/$Param{Queue}/gi if ($Param{Queue});
1720
1996
my %Ticket = $Self->TicketGet(TicketID => $Param{TicketID});
1721
1997
foreach (keys %Ticket) {
1728
2004
$Notification{Subject} =~ s/<OTRS_TICKET_.+?>/-/gi;
1729
2005
$Notification{Body} =~ s/<OTRS_TICKET_.+?>/-/gi;
1732
my ($OwnerID, $Owner) = $Self->OwnerCheck(TicketID => $Param{TicketID});
1733
my %Preferences = $Self->{UserObject}->GetUserData(UserID => $OwnerID);
1734
foreach (keys %Preferences) {
1735
if ($Preferences{$_}) {
1736
$Notification{Body} =~ s/<OTRS_OWNER_$_>/$Preferences{$_}/gi;
1737
$Notification{Subject} =~ s/<OTRS_OWNER_$_>/$Preferences{$_}/gi;
1741
$Notification{Subject} =~ s/<OTRS_OWNER_.+?>/-/gi;
1742
$Notification{Body} =~ s/<OTRS_OWNER_.+?>/-/gi;
1744
2007
# get current user data
1745
2008
my %CurrentPreferences = $Self->{UserObject}->GetUserData(UserID => $Param{UserID});
1746
2009
foreach (keys %CurrentPreferences) {
1753
2016
$Notification{Subject} =~ s/<OTRS_CURRENT_.+?>/-/gi;
1754
2017
$Notification{Body} =~ s/<OTRS_CURRENT_.+?>/-/gi;
2020
my %OwnerPreferences = $Self->{UserObject}->GetUserData(
2021
UserID => $Article{OwnerID},
2023
foreach (keys %OwnerPreferences) {
2024
if ($OwnerPreferences{$_}) {
2025
$Notification{Body} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
2026
$Notification{Subject} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
2030
$Notification{Subject} =~ s/<OTRS_OWNER_.+?>/-/gi;
2031
$Notification{Body} =~ s/<OTRS_OWNER_.+?>/-/gi;
2033
# get responsible data
2034
my %ResponsiblePreferences = $Self->{UserObject}->GetUserData(
2035
UserID => $Article{ResponsibleID},
2037
foreach (keys %ResponsiblePreferences) {
2038
if ($ResponsiblePreferences{$_}) {
2039
$Notification{Body} =~ s/<OTRS_RESPONSIBLE_$_>/$ResponsiblePreferences{$_}/gi;
2040
$Notification{Subject} =~ s/<OTRS_RESPONSIBLE_$_>/$ResponsiblePreferences{$_}/gi;
2044
$Notification{Subject} =~ s/<OTRS_RESPONSIBLE_.+?>/-/gi;
2045
$Notification{Body} =~ s/<OTRS_RESPONSIBLE_.+?>/-/gi;
1756
2047
# get ref of email params
1757
2048
my %GetParam = %{$Param{CustomerMessageParams}};
1758
2049
foreach (keys %GetParam) {
1923
2217
$Param{Body} =~ s/<OTRS_CUSTOMER_$_>/$GetParam{$_}/gi;
2221
# get current user data
2222
my %CurrentPreferences = $Self->{UserObject}->GetUserData(UserID => $Param{UserID});
2223
foreach (keys %CurrentPreferences) {
2224
if ($CurrentPreferences{$_}) {
2225
$Param{Body} =~ s/<OTRS_CURRENT_$_>/$CurrentPreferences{$_}/gi;
2226
$Param{Subject} =~ s/<OTRS_CURRENT_$_>/$CurrentPreferences{$_}/gi;
2230
$Param{Subject} =~ s/<OTRS_CURRENT_.+?>/-/gi;
2231
$Param{Body} =~ s/<OTRS_CURRENT_.+?>/-/gi;
2234
my %OwnerPreferences = $Self->{UserObject}->GetUserData(
2235
UserID => $Article{OwnerID},
2237
foreach (keys %OwnerPreferences) {
2238
if ($OwnerPreferences{$_}) {
2239
$Param{Body} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
2240
$Param{Subject} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
2244
$Param{Subject} =~ s/<OTRS_OWNER_.+?>/-/gi;
2245
$Param{Body} =~ s/<OTRS_OWNER_.+?>/-/gi;
2247
# get responsible data
2248
my %ResponsiblePreferences = $Self->{UserObject}->GetUserData(
2249
UserID => $Article{ResponsibleID},
2251
foreach (keys %ResponsiblePreferences) {
2252
if ($ResponsiblePreferences{$_}) {
2253
$Param{Body} =~ s/<OTRS_RESPONSIBLE_$_>/$ResponsiblePreferences{$_}/gi;
2254
$Param{Subject} =~ s/<OTRS_RESPONSIBLE_$_>/$ResponsiblePreferences{$_}/gi;
2259
$Param{Subject} =~ s/<OTRS_RESPONSIBLE_.+?>/-/gi;
2260
$Param{Body} =~ s/<OTRS_RESPONSIBLE_.+?>/-/gi;
2263
my %Ticket = $Self->TicketGet(TicketID => $Param{TicketID});
2264
foreach (keys %Ticket) {
2265
if (defined($Ticket{$_})) {
2266
$Param{Body} =~ s/<OTRS_TICKET_$_>/$Ticket{$_}/gi;
2267
$Param{Subject} =~ s/<OTRS_TICKET_$_>/$Ticket{$_}/gi;
1926
2270
# replace some special stuff
1927
2271
$Param{Body} =~ s/<OTRS_TICKET_NUMBER>/$Article{TicketNumber}/gi;
1928
2272
$Param{Body} =~ s/<OTRS_TICKET_ID>/$Param{TicketID}/gi;
2274
$Param{Subject} =~ s/<OTRS_TICKET_.+?>/-/gi;
2275
$Param{Body} =~ s/<OTRS_TICKET_.+?>/-/gi;
2277
# get customer data and replace it with <OTRS_CUSTOMER_DATA_...
2278
if ($Article{CustomerUserID}) {
2279
my %CustomerUser = $Self->{CustomerUserObject}->CustomerUserDataGet(
2280
User => $Article{CustomerUserID},
2282
# replace customer stuff with tags
2283
foreach (keys %CustomerUser) {
2284
if ($CustomerUser{$_}) {
2285
$Param{Body} =~ s/<OTRS_CUSTOMER_DATA_$_>/$CustomerUser{$_}/gi;
2286
$Param{Subject} =~ s/<OTRS_CUSTOMER_DATA_$_>/$CustomerUser{$_}/gi;
2290
# cleanup all not needed <OTRS_CUSTOMER_DATA_ tags
2291
$Param{Body} =~ s/<OTRS_CUSTOMER_DATA_.+?>/-/gi;
2292
$Param{Subject} =~ s/<OTRS_CUSTOMER_DATA_.+?>/-/gi;
2294
# replace config options
2295
$Param{Body} =~ s{<OTRS_CONFIG_(.+?)>}{$Self->{ConfigObject}->Get($1)}egx;
2296
$Param{Subject} =~ s{<OTRS_CONFIG_(.+?)>}{$Self->{ConfigObject}->Get($1)}egx;
1929
2297
# prepare customer realname
1930
2298
if ($Param{Body} =~ /<OTRS_CUSTOMER_REALNAME>/) {
2153
2526
" time_accounting " .
2155
" article_id = $Param{ArticleID} " .
2528
" article_id = $Param{ArticleID}";
2157
2529
$Self->{DBObject}->Prepare(SQL => $SQL);
2158
2530
while (my @Row = $Self->{DBObject}->FetchrowArray()) {
2159
2532
$AccountedTime = $AccountedTime + $Row[0];
2161
2534
return $AccountedTime;
2537
=item ArticleAccountedTimeDelete()
2539
delete accounted time of article
2541
$TicketObject->ArticleAccountedTimeDelete(
2542
ArticleID => $ArticleID,
2547
sub ArticleAccountedTimeDelete {
2550
# check needed stuff
2551
if (!$Param{ArticleID}) {
2552
$Self->{LogObject}->Log(Priority => 'error', Message => "Need ArticleID!");
2556
foreach (qw(ArticleID UserID)) {
2557
$Param{$_} = $Self->{DBObject}->Quote($Param{$_}, 'Integer');
2560
my $SQL = "DELETE FROM time_accounting " .
2562
" article_id = $Param{ArticleID}";
2563
return $Self->{DBObject}->Do(SQL => $SQL);
2166
2566
# the following is the pod for Kernel/System/Ticket/ArticleStorage*.pm
2168
2568
=item ArticleDelete()