/
ticket-view.inc.php
1442 lines (1398 loc) · 70.2 KB
/
ticket-view.inc.php
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
//Note that ticket obj is initiated in tickets.php.
if(!defined('OSTSCPINC') || !$thisstaff || !is_object($ticket) || !$ticket->getId()) die('Invalid path');
//Make sure the staff is allowed to access the page.
if(!@$thisstaff->isStaff() || !$ticket->checkStaffPerm($thisstaff)) die('Access Denied');
//Re-use the post info on error...savekeyboards.org (Why keyboard? -> some people care about objects than users!!)
$info=($_POST && $errors)?Format::input($_POST):array();
$type = array('type' => 'viewed');
Signal::send('object.view', $ticket, $type);
//Get the goodies.
$dept = $ticket->getDept(); //Dept
$role = $ticket->getRole($thisstaff);
$staff = $ticket->getStaff(); //Assigned or closed by..
$user = $ticket->getOwner(); //Ticket User (EndUser)
$team = $ticket->getTeam(); //Assigned team.
$sla = $ticket->getSLA();
$lock = $ticket->getLock(); //Ticket lock obj
$children = $ticket->getChildren();
$thread = $ticket->getThread();
if (!$lock && $cfg->getTicketLockMode() == Lock::MODE_ON_VIEW)
$lock = $ticket->acquireLock($thisstaff->getId());
$mylock = ($lock && $lock->getStaffId() == $thisstaff->getId()) ? $lock : null;
$id = $ticket->getId(); //Ticket ID.
$isManager = $dept->isManager($thisstaff); //Check if Agent is Manager
$canRelease = ($isManager || $role->hasPerm(Ticket::PERM_RELEASE)); //Check if Agent can release tickets
$blockReply = $ticket->isChild() && $ticket->getMergeType() != 'visual';
$canMarkAnswered = ($isManager || $role->hasPerm(Ticket::PERM_MARKANSWERED)); //Check if Agent can mark as answered/unanswered
//Useful warnings and errors the user might want to know!
if ($ticket->isClosed() && !$ticket->isReopenable())
$warn = sprintf(
__('Current ticket status (%s) does not allow the end user to reply.'),
$ticket->getStatus());
elseif ($blockReply)
$warn = __('Child Tickets do not allow the end user or agent to reply.');
elseif ($ticket->isAssigned()
&& (($staff && $staff->getId()!=$thisstaff->getId())
|| ($team && !$team->hasMember($thisstaff))
))
$warn.= sprintf(' <span class="Icon assignedTicket">%s</span>',
sprintf(__('Ticket is assigned to %s'),
implode('/', $ticket->getAssignees())
));
if (!$errors['err']) {
if ($lock && $lock->getStaffId()!=$thisstaff->getId())
$errors['err'] = sprintf(__('%s is currently locked by %s'),
__('This ticket'),
$lock->getStaffName());
elseif (($emailBanned=Banlist::isBanned($ticket->getEmail())))
$errors['err'] = __('Email is in banlist! Must be removed before any reply/response');
elseif (!Validator::is_valid_email($ticket->getEmail()))
$errors['err'] = __('EndUser email address is not valid! Consider updating it before responding');
}
$unbannable=($emailBanned) ? BanList::includes($ticket->getEmail()) : false;
if($ticket->isOverdue())
$warn.=' <span class="Icon overdueTicket">'.__('Marked overdue!').'</span>';
?>
<div>
<div id="msg_notice" style="display: none;"><span id="msg-txt"><?php echo $msg ?: ''; ?></span></div>
<div class="sticky bar">
<div class="content">
<div class="pull-right flush-right">
<?php
if ($thisstaff->hasPerm(Email::PERM_BANLIST)
|| $role->hasPerm(Ticket::PERM_EDIT)
|| ($dept && $dept->isManager($thisstaff))) { ?>
<span class="action-button pull-right" data-placement="bottom" data-dropdown="#action-dropdown-more" data-toggle="tooltip" title="<?php echo __('More');?>">
<i class="icon-caret-down pull-right"></i>
<span ><i class="icon-cog"></i></span>
</span>
<?php
}
if ($role->hasPerm(Ticket::PERM_EDIT)) { ?>
<a class="action-button pull-right" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Edit'); ?>" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit"><i class="icon-edit"></i></a>
<?php
} ?>
<span class="action-button pull-right" data-placement="bottom" data-dropdown="#action-dropdown-print" data-toggle="tooltip" title="<?php echo __('Print'); ?>">
<i class="icon-caret-down pull-right"></i>
<a id="ticket-print" aria-label="<?php echo __('Print'); ?>" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print"><i class="icon-print"></i></a>
</span>
<div id="action-dropdown-print" class="action-dropdown anchor-right">
<ul>
<li title="PDF File"><a class="no-pjax" target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print¬es=0&events=0"><i
class="icon-file-text-alt"></i> <?php echo __('Ticket Thread'); ?></a>
<li title="PDF File"><a class="no-pjax" target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print¬es=1&events=0"><i
class="icon-file-text-alt"></i> <?php echo __('Thread + Internal Notes'); ?></a>
<li title="PDF File"><a class="no-pjax" target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print¬es=1&events=1"><i
class="icon-file-text-alt"></i> <?php echo __('Thread + Internal Notes + Events'); ?></a>
<?php if (extension_loaded('zip')) { ?>
<li title="ZIP Archive"><a class="no-pjax" target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=zip¬es=1"><i
class="icon-folder-close-alt"></i> <?php echo __('Thread + Internal Notes + Attachments'); ?></a>
<li title="ZIP Archive"><a class="no-pjax" target="_blank" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=zip¬es=1&tasks=1"><i
class="icon-folder-close-alt"></i> <?php echo __('Thread + Internal Notes + Attachments + Tasks'); ?></a>
<?php } ?>
</ul>
</div>
<?php
// Transfer
if ($role->hasPerm(Ticket::PERM_TRANSFER)) {?>
<a class="action-button pull-right ticket-action" id="ticket-transfer" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Transfer'); ?>"
data-redirect="tickets.php"
href="#tickets/<?php echo $ticket->getId(); ?>/transfer"><i class="icon-share"></i></a>
<?php
} ?>
<?php
// Assign
if ($ticket->isOpen() && $role->hasPerm(Ticket::PERM_ASSIGN)) {?>
<span class="action-button pull-right"
data-dropdown="#action-dropdown-assign"
data-placement="bottom"
data-toggle="tooltip"
title=" <?php echo $ticket->isAssigned() ? __('Assign') : __('Reassign'); ?>"
>
<i class="icon-caret-down pull-right"></i>
<a class="ticket-action" id="ticket-assign"
data-redirect="tickets.php"
href="#tickets/<?php echo $ticket->getId(); ?>/assign"><i class="icon-user"></i></a>
</span>
<div id="action-dropdown-assign" class="action-dropdown anchor-right">
<ul>
<?php
// Agent can claim team assigned ticket
if (!$ticket->getStaff()
&& (!$dept->assignMembersOnly()
|| $dept->isMember($thisstaff))
) { ?>
<li><a class="no-pjax ticket-action"
data-redirect="tickets.php?id=<?php echo
$ticket->getId(); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/claim"><i
class="icon-chevron-sign-down"></i> <?php echo __('Claim'); ?></a>
<?php
} ?>
<li><a class="no-pjax ticket-action"
data-redirect="tickets.php"
href="#tickets/<?php echo $ticket->getId(); ?>/assign/agents"><i
class="icon-user"></i> <?php echo __('Agent'); ?></a>
<li><a class="no-pjax ticket-action"
data-redirect="tickets.php"
href="#tickets/<?php echo $ticket->getId(); ?>/assign/teams"><i
class="icon-group"></i> <?php echo __('Team'); ?></a>
</ul>
</div>
<?php
} ?>
<div id="action-dropdown-more" class="action-dropdown anchor-right">
<ul>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) { ?>
<li><a class="change-user" href="#tickets/<?php
echo $ticket->getId(); ?>/change-user"
onclick="javascript:
saveDraft();"
><i class="icon-user"></i> <?php
echo __('Change Owner'); ?></a></li>
<?php
}
if ($role->hasPerm(Ticket::PERM_MERGE) && !$ticket->isChild()) { ?>
<li><a href="#ajax.php/tickets/<?php echo $ticket->getId();
?>/merge" onclick="javascript:
$.dialog($(this).attr('href').substr(1), 201);
return false"
><i class="icon-code-fork"></i> <?php echo __('Merge Tickets'); ?></a></li>
<?php
}
if ($role->hasPerm(Ticket::PERM_LINK) && $ticket->getMergeType() == 'visual') { ?>
<li><a href="#ajax.php/tickets/<?php echo $ticket->getId();
?>/link" onclick="javascript:
$.dialog($(this).attr('href').substr(1), 201);
return false"
><i class="icon-link"></i> <?php echo __('Link Tickets'); ?></a></li>
<?php
}
if ($ticket->isAssigned() && $canRelease) { ?>
<li><a href="#tickets/<?php echo $ticket->getId();
?>/release" class="ticket-action"
data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>" >
<i class="icon-unlock"></i> <?php echo __('Release (unassign) Ticket'); ?></a></li>
<?php
}
if($ticket->isOpen() && $isManager) {
if(!$ticket->isOverdue()) { ?>
<li><a class="confirm-action" id="ticket-overdue" href="#overdue"><i class="icon-bell"></i> <?php
echo __('Mark as Overdue'); ?></a></li>
<?php
}
}
if($ticket->isOpen() && $canMarkAnswered) {
if($ticket->isAnswered()) { ?>
<li><a href="#tickets/<?php echo $ticket->getId();
?>/mark/unanswered" class="ticket-action"
data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>">
<i class="icon-circle-arrow-left"></i> <?php
echo __('Mark as Unanswered'); ?></a></li>
<?php
} else { ?>
<li><a href="#tickets/<?php echo $ticket->getId();
?>/mark/answered" class="ticket-action"
data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>">
<i class="icon-circle-arrow-right"></i> <?php
echo __('Mark as Answered'); ?></a></li>
<?php
}
} ?>
<?php
if ($role->hasPerm(Ticket::PERM_REFER)) { ?>
<li><a href="#tickets/<?php echo $ticket->getId();
?>/referrals" class="ticket-action"
data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>" >
<i class="icon-exchange"></i> <?php echo __('Manage Referrals'); ?></a></li>
<?php
} ?>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) { ?>
<li><a href="#ajax.php/tickets/<?php echo $ticket->getId();
?>/forms/manage" onclick="javascript:
$.dialog($(this).attr('href').substr(1), 201);
return false"
><i class="icon-paste"></i> <?php echo __('Manage Forms'); ?></a></li>
<?php
}
if ($role->hasPerm(Ticket::PERM_REPLY) && $thread && $ticket->getId() == $thread->getObjectId()) {
?>
<li>
<?php
$recipients = __(' Manage Collaborators');
echo sprintf('<a class="collaborators manage-collaborators"
href="#thread/%d/collaborators/1"><i class="icon-group"></i>%s</a>',
$ticket->getThreadId(),
$recipients);
?>
</li>
<?php
} ?>
<?php if ($thisstaff->hasPerm(Email::PERM_BANLIST)
&& $role->hasPerm(Ticket::PERM_REPLY)) {
if(!$emailBanned) {?>
<li><a class="confirm-action" id="ticket-banemail"
href="#banemail"><i class="icon-ban-circle"></i> <?php echo sprintf(
Format::htmlchars(__('Ban Email <%s>')),
$ticket->getEmail()); ?></a></li>
<?php
} elseif($unbannable) { ?>
<li><a class="confirm-action" id="ticket-banemail"
href="#unbanemail"><i class="icon-undo"></i> <?php echo sprintf(
Format::htmlchars(__('Unban Email <%s>')),
$ticket->getEmail()); ?></a></li>
<?php
}
}
Signal::send('ticket.view.more', $ticket, $extras);
if ($role->hasPerm(Ticket::PERM_DELETE)) {
?>
<li class="danger"><a class="ticket-action" href="#tickets/<?php
echo $ticket->getId(); ?>/status/delete"
data-redirect="tickets.php"><i class="icon-trash"></i> <?php
echo __('Delete Ticket'); ?></a></li>
<?php
}
?>
</ul>
</div>
<?php
if (count($children) != 0)
echo sprintf('<span style="font-weight: 700; line-height: 26px;">%s</span>', __('PARENT'));
elseif ($ticket->isChild())
echo sprintf('<span style="font-weight: 700; line-height: 26px;">%s</span>', __('CHILD'));
if ($role->hasPerm(Ticket::PERM_REPLY)) { ?>
<a href="#post-reply" class="post-response action-button"
data-placement="bottom" data-toggle="tooltip"
title="<?php echo __('Post Reply'); ?>"><i class="icon-mail-reply"></i></a>
<?php
} ?>
<a href="#post-note" id="post-note" class="post-response action-button"
data-placement="bottom" data-toggle="tooltip"
title="<?php echo __('Post Internal Note'); ?>"><i class="icon-file-text"></i></a>
<?php // Status change options
echo TicketStatus::status_options();
?>
</div>
<div class="flush-left">
<h2><a href="tickets.php?id=<?php echo $ticket->getId(); ?>"
title="<?php echo __('Reload'); ?>"><i class="icon-refresh"></i>
<?php echo sprintf(__('Ticket #%s'), $ticket->getNumber()); ?></a>
</h2>
</div>
</div>
</div>
</div>
<div class="clear tixTitle has_bottom_border">
<h3>
<?php $subject_field = TicketForm::getInstance()->getField('subject');
echo $subject_field ? $subject_field->display($ticket->getSubject())
: Format::htmlchars($ticket->getSubject()); ?>
</h3>
</div>
<table class="ticket_info" cellspacing="0" cellpadding="0" width="940" border="0">
<tr>
<td width="50%">
<table border="0" cellspacing="" cellpadding="4" width="100%">
<tr>
<th width="100"><?php echo __('Status');?>:</th>
<?php
if ($role->hasPerm(Ticket::PERM_CLOSE)) {?>
<td>
<a class="tickets-action" data-dropdown="#action-dropdown-statuses" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Change Status'); ?>"
data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>"
href="#statuses"
onclick="javascript:
saveDraft();"
>
<?php echo $ticket->getStatus(); ?>
</a>
</td>
<?php } else { ?>
<td><?php echo ($S = $ticket->getStatus()) ? $S->display() : ''; ?></td>
<?php } ?>
</tr>
<tr>
<th><?php echo __('Priority');?>:</th>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)
&& ($pf = $ticket->getPriorityField())) { ?>
<td>
<a class="inline-edit" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Update'); ?>"
href="#tickets/<?php echo $ticket->getId();?>/field/<?php echo $pf->getId();?>/edit">
<span id="field_<?php echo $pf->getId(); ?>"><?php echo $pf->getAnswer()->display(); ?></span>
</a>
</td>
<?php } else { ?>
<td><?php echo $ticket->getPriority(); ?></td>
<?php } ?>
</tr>
<tr>
<th><?php echo __('Department');?>:</th>
<?php
if ($role->hasPerm(Ticket::PERM_TRANSFER)) {?>
<td>
<a class="ticket-action" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Transfer'); ?>"
data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/transfer"
onclick="javascript:
saveDraft();"
><?php echo Format::htmlchars($ticket->getDeptName()); ?>
</a>
</td>
<?php
}else {?>
<td><?php echo Format::htmlchars($ticket->getDeptName()); ?></td>
<?php } ?>
</tr>
<tr>
<th><?php echo __('Create Date');?>:</th>
<td><?php echo Format::datetime($ticket->getCreateDate()); ?></td>
</tr>
</table>
</td>
<td width="50%" style="vertical-align:top">
<table border="0" cellspacing="" cellpadding="4" width="100%">
<tr>
<th width="100"><?php echo __('User'); ?>:</th>
<td><a href="#tickets/<?php echo $ticket->getId(); ?>/user"
onclick="javascript:
saveDraft();
$.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/user',
function (user) {
$('#user-'+user.id+'-name').text(user.name);
$('#user-'+user.id+'-email').text(user.email);
$('#user-'+user.id+'-phone').text(user.phone);
$('select#emailreply option[value=1]').text(user.name+' <'+user.email+'>');
});
return false;
"><i class="icon-user"></i> <span id="user-<?php echo $ticket->getOwnerId(); ?>-name"
><?php echo Format::htmlchars($ticket->getName());
?></span></a>
<?php
if ($user) { ?>
<a href="tickets.php?<?php echo Http::build_query(array(
'status'=>'open', 'a'=>'search', 'uid'=> $user->getId()
)); ?>" title="<?php echo __('Related Tickets'); ?>"
data-dropdown="#action-dropdown-stats">
(<b><?php echo $user->getNumTickets(); ?></b>)
</a>
<div id="action-dropdown-stats" class="action-dropdown anchor-right">
<ul>
<?php
if(($open=$user->getNumOpenTickets()))
echo sprintf('<li><a href="tickets.php?a=search&status=open&uid=%s"><i class="icon-folder-open-alt icon-fixed-width"></i> %s</a></li>',
$user->getId(), sprintf(_N('%d Open Ticket', '%d Open Tickets', $open), $open));
if(($closed=$user->getNumClosedTickets()))
echo sprintf('<li><a href="tickets.php?a=search&status=closed&uid=%d"><i
class="icon-folder-close-alt icon-fixed-width"></i> %s</a></li>',
$user->getId(), sprintf(_N('%d Closed Ticket', '%d Closed Tickets', $closed), $closed));
?>
<li><a href="tickets.php?a=search&uid=<?php echo $ticket->getOwnerId(); ?>"><i class="icon-double-angle-right icon-fixed-width"></i> <?php echo __('All Tickets'); ?></a></li>
<?php if ($thisstaff->hasPerm(User::PERM_DIRECTORY)) { ?>
<li><a href="users.php?id=<?php echo
$user->getId(); ?>"><i class="icon-user
icon-fixed-width"></i> <?php echo __('Manage User'); ?></a></li>
<?php } ?>
</ul>
</div>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT) && $thread && $ticket->getId() == $thread->getObjectId()) {
if ($thread) {
$numCollaborators = $thread->getNumCollaborators();
if ($thread->getNumCollaborators())
$recipients = sprintf(__('%d'),
$numCollaborators);
} else
$recipients = 0;
echo sprintf('<span><a class="manage-collaborators preview"
href="#thread/%d/collaborators/1"><span id="t%d-recipients"><i class="icon-group"></i> (%s)</span></a></span>',
$ticket->getThreadId(),
$ticket->getThreadId(),
$recipients);
}?>
<?php } # end if ($user) ?>
</td>
</tr>
<tr>
<th><?php echo __('Email'); ?>:</th>
<td>
<span id="user-<?php echo $ticket->getOwnerId(); ?>-email"><?php echo $ticket->getEmail(); ?></span>
</td>
</tr>
<?php if ($user->getOrganization()) { ?>
<tr>
<th><?php echo __('Organization'); ?>:</th>
<td><i class="icon-building"></i>
<?php echo Format::htmlchars($user->getOrganization()->getName()); ?>
<a href="tickets.php?<?php echo Http::build_query(array(
'status'=>'open', 'a'=>'search', 'orgid'=> $user->getOrgId()
)); ?>" title="<?php echo __('Related Tickets'); ?>"
data-dropdown="#action-dropdown-org-stats">
(<b><?php echo $user->getNumOrganizationTickets(); ?></b>)
</a>
<div id="action-dropdown-org-stats" class="action-dropdown anchor-right">
<ul>
<?php if ($open = $user->getNumOpenOrganizationTickets()) { ?>
<li><a href="tickets.php?<?php echo Http::build_query(array(
'a' => 'search', 'status' => 'open', 'orgid' => $user->getOrgId()
)); ?>"><i class="icon-folder-open-alt icon-fixed-width"></i>
<?php echo sprintf(_N('%d Open Ticket', '%d Open Tickets', $open), $open); ?>
</a></li>
<?php }
if ($closed = $user->getNumClosedOrganizationTickets()) { ?>
<li><a href="tickets.php?<?php echo Http::build_query(array(
'a' => 'search', 'status' => 'closed', 'orgid' => $user->getOrgId()
)); ?>"><i class="icon-folder-close-alt icon-fixed-width"></i>
<?php echo sprintf(_N('%d Closed Ticket', '%d Closed Tickets', $closed), $closed); ?>
</a></li>
<li><a href="tickets.php?<?php echo Http::build_query(array(
'a' => 'search', 'orgid' => $user->getOrgId()
)); ?>"><i class="icon-double-angle-right icon-fixed-width"></i> <?php echo __('All Tickets'); ?></a></li>
<?php }
if ($thisstaff->hasPerm(User::PERM_DIRECTORY)) { ?>
<li><a href="orgs.php?id=<?php echo $user->getOrgId(); ?>"><i
class="icon-building icon-fixed-width"></i> <?php
echo __('Manage Organization'); ?></a></li>
<?php } ?>
</ul>
</div>
</td>
</tr>
<?php } # end if (user->org) ?>
<tr>
<th><?php echo __('Source'); ?>:</th>
<td>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) {
$source = $ticket->getField('source');?>
<a class="inline-edit" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Update'); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/field/source/edit">
<span id="field_source">
<?php echo Format::htmlchars($ticket->getSource());
?></span>
</a>
<?php
} else {
echo Format::htmlchars($ticket->getSource());
}
if (!strcasecmp($ticket->getSource(), 'Web') && $ticket->getIP())
echo ' <span class="faded">('.Format::htmlchars($ticket->getIP()).')</span>';
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table class="ticket_info" cellspacing="0" cellpadding="0" width="940" border="0">
<tr>
<td width="50%">
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<?php
if($ticket->isOpen()) { ?>
<tr>
<th width="100"><?php echo __('Assigned To');?>:</th>
<?php
if ($role->hasPerm(Ticket::PERM_ASSIGN)) {?>
<td>
<a class="inline-edit" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Update'); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/assign">
<span id="field_assign">
<?php if($ticket->isAssigned())
echo Format::htmlchars(implode('/', $ticket->getAssignees()));
else
echo '<span class="faded">— '.__('Unassigned').' —</span>';
?></span>
</a>
</td>
<?php
} else { ?>
<td>
<?php
if($ticket->isAssigned())
echo Format::htmlchars(implode('/', $ticket->getAssignees()));
else
echo '<span class="faded">— '.__('Unassigned').' —</span>';
?>
</td>
<?php
} ?>
</tr>
<?php
} else { ?>
<tr>
<th width="100"><?php echo __('Closed By');?>:</th>
<td>
<?php
if(($staff = $ticket->getStaff()))
echo Format::htmlchars($staff->getName());
else
echo '<span class="faded">— '.__('Unknown').' —</span>';
?>
</td>
</tr>
<?php
} ?>
<tr>
<th><?php echo __('SLA Plan');?>:</th>
<td>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) {
$slaField = $ticket->getField('sla'); ?>
<a class="inline-edit" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Update'); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/field/sla/edit">
<span id="field_sla"><?php echo $sla ?: __('None'); ?></span>
</a>
<?php } else { ?>
<span id="field_sla"><?php echo $sla ?: __('None'); ?></span>
<?php } ?>
</td>
</tr>
<?php
if($ticket->isOpen()){ ?>
<tr>
<th><?php echo __('Due Date');?>:</th>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) {
$duedate = $ticket->getField('duedate'); ?>
<td>
<a class="inline-edit" data-placement="bottom"
href="#tickets/<?php echo $ticket->getId();
?>/field/duedate/edit">
<span id="field_duedate"><?php echo Format::datetime($ticket->getEstDueDate()); ?></span>
</a>
<td>
<?php } else { ?>
<td><?php echo Format::datetime($ticket->getEstDueDate()); ?></td>
<?php } ?>
</tr>
<?php
}else { ?>
<tr>
<th><?php echo __('Close Date');?>:</th>
<td><?php echo Format::datetime($ticket->getCloseDate()); ?></td>
</tr>
<?php
}
?>
</table>
</td>
<td width="50%">
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
<th width="100"><?php echo __('Help Topic');?>:</th>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) {
$topic = $ticket->getField('topic'); ?>
<td>
<a class="inline-edit" data-placement="bottom"
data-toggle="tooltip" title="<?php echo __('Update'); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/field/topic/edit">
<span id="field_topic">
<?php echo $ticket->getHelpTopic() ?: __('None'); ?>
</span>
</a>
</td>
<?php } else { ?>
<td><?php echo Format::htmlchars($ticket->getHelpTopic()); ?></td>
<?php } ?>
</tr>
<tr>
<th nowrap><?php echo __('Last Message');?>:</th>
<td><?php echo Format::datetime($ticket->getLastMsgDate()); ?></td>
</tr>
<tr>
<th nowrap><?php echo __('Last Response');?>:</th>
<td><?php echo Format::datetime($ticket->getLastRespDate()); ?></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<?php
foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) {
$form->addMissingFields();
//Find fields to exclude if disabled by help topic
$disabled = Ticket::getMissingRequiredFields($ticket, true);
// Skip core fields shown earlier in the ticket view
// TODO: Rewrite getAnswers() so that one could write
// ->getAnswers()->filter(not(array('field__name__in'=>
// array('email', ...))));
$answers = $form->getAnswers()->exclude(Q::any(array(
'field__flags__hasbit' => DynamicFormField::FLAG_EXT_STORED,
'field__name__in' => array('subject', 'priority'),
'field__id__in' => $disabled,
)));
$displayed = array();
foreach($answers as $a) {
if (!$a->getField()->isVisibleToStaff())
continue;
$displayed[] = $a;
}
if (count($displayed) == 0)
continue;
?>
<table class="ticket_info custom-data" cellspacing="0" cellpadding="0" width="940" border="0">
<thead>
<th colspan="2"><?php echo Format::htmlchars($form->getTitle()); ?></th>
</thead>
<tbody>
<?php
foreach ($displayed as $a) {
$id = $a->getLocal('id');
$label = $a->getLocal('label');
$field = $a->getField();
$config = $field->getConfiguration();
$html = isset($config['html']) ? $config['html'] : false;
$v = $html ? Format::striptags($a->display()) : $a->display();
$class = (Format::striptags($v)) ? '' : 'class="faded"';
$clean = (Format::striptags($v))
? ($html ? Format::striptags($v) : $v)
: '—' . __('Empty') . '—';
$isFile = ($field instanceof FileUploadField);
$url = "#tickets/".$ticket->getId()."/field/".$id;
?>
<tr>
<td width="200"><?php echo Format::htmlchars($label); ?>:</td>
<td id="<?php echo sprintf('inline-answer-%s', $field->getId()); ?>">
<?php if ($role->hasPerm(Ticket::PERM_EDIT)
&& $field->isEditableToStaff()) {
$isEmpty = strpos($v, 'Empty') || ($v == '');
if ($isFile && !$isEmpty) {
echo sprintf('<span id="field_%s" %s >%s</span><br>', $id,
$class,
$clean);
}
$title = ($html && !$isEmpty) ? __('View Content') : __('Update');
$href = $url.(($html && !$isEmpty) ? '/view' : '/edit');
?>
<a class="inline-edit" data-placement="bottom" data-toggle="tooltip" title="<?php echo $title; ?>"
href="<?php echo $href; ?>">
<?php
if ($isFile && !$isEmpty) {
echo "<i class=\"icon-edit\"></i>";
} elseif (strlen($v) > 200) {
$clean = Format::truncate($v, 200);
echo sprintf('<span id="field_%s" %s >%s</span>', $id, $class, $clean);
echo "<br><i class=\"icon-edit\"></i>";
} else
echo sprintf('<span id="field_%s" %s >%s</span>', $id, $class, $clean);
$a = $field->getAnswer();
$hint = ($field->isRequiredForClose() && $a && !$a->getValue() && get_class($field) != 'BooleanField') ?
sprintf('<i class="icon-warning-sign help-tip warning field-label" data-title="%s" data-content="%s"
/></i>', __('Required to close ticket'),
__('Data is required in this field in order to close the related ticket')) : '';
echo $hint;
?>
</a>
<?php
} else {
echo $clean;
} ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
<div class="clear"></div>
<?php
$tcount = $ticket->getThreadEntries($types) ? $ticket->getThreadEntries($types)->count() : 0;
?>
<ul class="tabs clean threads" id="ticket_tabs" >
<li class="active"><a id="ticket-thread-tab" href="#ticket_thread"><?php
echo sprintf(__('Ticket Thread (%d)'), $tcount); ?></a></li>
<li><a id="ticket-tasks-tab" href="#tasks"
data-url="<?php
echo sprintf('#tickets/%d/tasks', $ticket->getId()); ?>"><?php
echo __('Tasks');
if ($ticket->getNumTasks())
echo sprintf(' (<span id="ticket-tasks-count">%d</span>)', $ticket->getNumTasks());
?></a></li>
<?php
if ((count($children) != 0 || $ticket->isChild())) { ?>
<li><a href="#relations" id="ticket-relations-tab"
data-url="<?php
echo sprintf('#tickets/%d/relations', $ticket->getId()); ?>"
><?php echo __('Related Tickets');
if (count($children))
echo sprintf(' (<span id="ticket-relations-count">%d</span>)', count($children));
elseif ($ticket->isChild())
echo sprintf(' (<span id="ticket-relations-count">%d</span>)', 1);
?></a></li>
<?php
}
?>
</ul>
<div id="ticket_tabs_container">
<div id="ticket_thread" class="tab_content">
<?php
// Render ticket thread
if ($thread)
$thread->render(
array('M', 'R', 'N'),
array(
'html-id' => 'ticketThread',
'mode' => Thread::MODE_STAFF,
'sort' => $thisstaff->thread_view_order
)
);
?>
<div class="clear"></div>
<?php
if ($errors['err'] && isset($_POST['a'])) {
// Reflect errors back to the tab.
$errors[$_POST['a']] = $errors['err'];
} elseif($warn) { ?>
<div id="msg_warning"><?php echo $warn; ?></div>
<?php
} ?>
<div class="sticky bar stop actions" id="response_options"
>
<ul class="tabs" id="response-tabs">
<?php
if ($role->hasPerm(Ticket::PERM_REPLY) && !($blockReply)) { ?>
<li class="active <?php
echo isset($errors['reply']) ? 'error' : ''; ?>"><a
href="#reply" id="post-reply-tab"><?php echo __('Post Reply');?></a></li>
<?php
}
if (!($blockReply)) { ?>
<li><a href="#note" <?php
echo isset($errors['postnote']) ? 'class="error"' : ''; ?>
id="post-note-tab"><?php echo __('Post Internal Note');?></a></li>
<?php
} ?>
</ul>
<?php
if ($role->hasPerm(Ticket::PERM_REPLY) && !($blockReply)) {
$replyTo = $_POST['reply-to'] ?: 'all';
$emailReply = ($replyTo != 'none');
?>
<form id="reply" class="tab_content spellcheck exclusive save"
data-lock-object-id="ticket/<?php echo $ticket->getId(); ?>"
data-lock-id="<?php echo $mylock ? $mylock->getId() : ''; ?>"
action="tickets.php?id=<?php
echo $ticket->getId(); ?>#reply" name="reply" method="post" enctype="multipart/form-data">
<?php csrf_token(); ?>
<input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>">
<input type="hidden" name="msgId" value="<?php echo $msgId; ?>">
<input type="hidden" name="a" value="reply">
<input type="hidden" name="lockCode" value="<?php echo $mylock ? $mylock->getCode() : ''; ?>">
<table style="width:100%" border="0" cellspacing="0" cellpadding="3">
<?php
if ($errors['reply']) {?>
<tr><td width="120"> </td><td class="error"><?php echo $errors['reply']; ?> </td></tr>
<?php
}?>
<tbody id="to_sec">
<tr>
<td width="120">
<label><strong><?php echo __('From'); ?>:</strong></label>
</td>
<td>
<select id="from_email_id" name="from_email_id">
<?php
// Department email (default).
if (($e=$dept->getEmail())) {
echo sprintf('<option value="%s" selected="selected">%s</option>',
$e->getId(),
Format::htmlchars($e->getAddress()));
}
$staffDepts = $thisstaff->getDepts();
// Optional SMTP addreses user can send email via
if (($emails = Email::getAddresses(array('smtp' => true,
'depts' => $staffDepts), false)) && count($emails)) {
echo '<option value=""
disabled="disabled"> </option>';
$emailId = $_POST['from_email_id'] ?: 0;
foreach ($emails as $e) {
if ($dept->getEmail()->getId() == $e->getId())
continue;
echo sprintf('<option value="%s" %s>%s</option>',
$e->getId(),
$e->getId() == $emailId ?
'selected="selected"' : '',
Format::htmlchars($e->getAddress()));
}
}
?>
</select>
</td>
</tr>
</tbody>
<tbody id="recipients">
<tr id="user-row">
<td width="120">
<label><strong><?php echo __('Recipients'); ?>:</strong></label>
</td>
<td><a href="#tickets/<?php echo $ticket->getId(); ?>/user"
onclick="javascript:
$.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/user',
function (user) {
window.location = 'tickets.php?id='<?php $ticket->getId(); ?>
});
return false;
"><span ><?php
echo Format::htmlchars($ticket->getOwner()->getEmail()->getAddress());
?></span></a>
</td>
</tr>
<tr><td> </td>
<td>
<div style="margin-bottom:2px;">
<?php
if ($ticket->getThread()->getNumCollaborators())
$recipients = sprintf(__('(%d of %d)'),
$ticket->getThread()->getNumActiveCollaborators(),
$ticket->getThread()->getNumCollaborators());
echo sprintf('<span"><a id="show_ccs">
<i id="arrow-icon" class="icon-caret-right"></i> %s </a>
<a class="manage-collaborators
collaborators preview noclick %s"
href="#thread/%d/collaborators/1">
%s</a></span>',
__('Collaborators'),
$ticket->getNumCollaborators()
? '' : 'hidden',
$ticket->getThreadId(),
sprintf('<span id="t%d-recipients">%s</span></a></span>',
$ticket->getThreadId(),
$recipients)
);
?>
</div>
<div id="ccs" class="hidden">
<div>
<span style="margin: 10px 5px 1px 0;" class="faded pull-left"><?php echo __('Select or Add New Collaborators'); ?> </span>
<?php
if ($role->hasPerm(Ticket::PERM_REPLY) && $thread && $ticket->getId() == $thread->getObjectId()) { ?>
<span class="action-button pull-left" style="margin: 2px 0 5px 20px;"
data-dropdown="#action-dropdown-collaborators"
data-placement="bottom"
data-toggle="tooltip"
title="<?php echo __('Manage Collaborators'); ?>"
>
<i class="icon-caret-down pull-right"></i>
<a class="ticket-action" id="collabs-button"
data-redirect="tickets.php?id=<?php echo
$ticket->getId(); ?>"
href="#thread/<?php echo
$ticket->getThreadId(); ?>/collaborators/1">
<i class="icon-group"></i></a>
</span>
<?php
} ?>
<span class="error"> <?php echo $errors['ccs']; ?></span>
</div>
<?php
if ($role->hasPerm(Ticket::PERM_REPLY) && $thread && $ticket->getId() == $thread->getObjectId()) { ?>
<div id="action-dropdown-collaborators" class="action-dropdown anchor-right">
<ul>
<li><a class="manage-collaborators"
href="#thread/<?php echo
$ticket->getThreadId(); ?>/add-collaborator/addcc"><i
class="icon-plus"></i> <?php echo __('Add New'); ?></a>
<li><a class="manage-collaborators"
href="#thread/<?php echo
$ticket->getThreadId(); ?>/collaborators/1"><i
class="icon-cog"></i> <?php echo __('Manage Collaborators'); ?></a>
</ul>
</div>
<?php
} ?>
<div class="clear">
<select id="collabselection" name="ccs[]" multiple="multiple"
data-placeholder="<?php
echo __('Select Active Collaborators'); ?>">
<?php
if ($collabs = $ticket->getCollaborators()) {
foreach ($collabs as $c) {
echo sprintf('<option value="%s" %s class="%s">%s</option>',
$c->getUserId(),
$c->isActive() ?
'selected="selected"' : '',
$c->isActive() ?
'active' : 'disabled',
$c->getName());
}
}
?>
</select>
</div>
</div>
</td>
</tr>
<tr>
<td width="120">
<label><?php echo __('Reply To'); ?>:</label>
</td>
<td>
<?php
// Supported Reply Types
$replyTypes = array(
'all' => __('All Active Recipients'),
'user' => sprintf('%s (%s)',
__('Ticket Owner'),
Format::htmlchars($ticket->getOwner()->getEmail())),
'none' => sprintf('— %s —',
__('Do Not Email Reply'))
);
$replyTo = $_POST['reply-to'] ?: 'all';
$emailReply = ($replyTo != 'none');
?>
<select id="reply-to" name="reply-to">
<?php
foreach ($replyTypes as $k => $v) {
echo sprintf('<option value="%s" %s>%s</option>',
$k,
($k == $replyTo) ?
'selected="selected"' : '',
$v);
}
?>
</select>
<i class="help-tip icon-question-sign" href="#reply_types"></i>
</td>
</tr>
</tbody>
<tbody id="resp_sec">
<tr><td colspan="2"> </td></tr>