/
ticket_admin_edit.php
1502 lines (697 loc) · 32.6 KB
/
ticket_admin_edit.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
<?php
/**
* Copyright: dtbaker 2012
* Licence: Please check CodeCanyon.net for licence details.
* More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/
* Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
* Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
* Package Date: 2015-11-25 02:55:20
* IP Address: 67.79.165.254
*/
if(!$ticket_safe){
die('failed');
}
$ticket_id = (int)$_REQUEST['ticket_id'];
$ticket = module_ticket::get_ticket($ticket_id);
if($ticket['subject']){
$module->page_title = _l('Ticket: '.htmlspecialchars($ticket['subject']));
}
$admins_rel = module_ticket::get_ticket_staff_rel();
if(isset($admins_rel[module_security::get_loggedin_id()])) {
$admins_rel[ module_security::get_loggedin_id() ] .= ' (me)';
}
// work out if this user is an "administrator" or a "customer"
// a user will have "edit" capabilities for tickets if they are an administrator
// a user will only have "view" Capabilities for tickets if they are a "customer"
// this will decide what options they have on the page (ie: assigning tickets to people)
if($ticket_id>0 && $ticket && $ticket['ticket_id']==$ticket_id){
if(class_exists('module_security',false)){
/*module_security::check_page(array(
'module' => $module->module_name,
'feature' => 'edit',
));*/
// we want to do our own special type of form modification here
// so we don't pass it off to "check_page" which will hide all input boxes.
if(!module_ticket::can_i('edit','Tickets') && !module_ticket::can_i('create','Tickets')){
set_error('Access to editing or creating tickets is denied.');
redirect_browser(module_ticket::link_open(false));
}
}
}else{
$ticket_id = false;
if(class_exists('module_security',false)){
module_security::check_page(array(
'module' => $module->module_name,
'feature' => 'create',
));
}
}
if(module_ticket::can_edit_tickets()){
module_ticket::mark_as_read($ticket_id,true);
}
//$module->pre_menu(); // so the links are re-build and the correct "unread" count is at the top.
if(!module_security::can_access_data('ticket',$ticket)){
echo 'Ticket access denied';
exit;
}
$ticket_messages = module_ticket::get_ticket_messages($ticket['ticket_id'],true);
if(!isset($logged_in_user) || !$logged_in_user){
// we assume the user is on the public side.
// use the creator id as the logged in id.
$logged_in_user = module_security::get_loggedin_id();
}
$ticket_creator = $ticket['user_id'];
if($ticket_creator == $logged_in_user){
// we are sending a reply back to the admin, from the end user.
$to_user_id = $ticket['assigned_user_id'] ? $ticket['assigned_user_id'] : 1;
$from_user_id = $logged_in_user;
}else{
// we are sending a reply back to the ticket user.
$to_user_id = $ticket['user_id'];
$from_user_id = $logged_in_user;
}
$to_user_a = module_user::get_user($to_user_id,false);
$from_user_a = module_user::get_user($from_user_id,false);
if(isset($ticket['ticket_account_id']) && $ticket['ticket_account_id']){
$ticket_account = module_ticket::get_ticket_account($ticket['ticket_account_id']);
}else{
$ticket_account = false;
}
if($ticket_account && $ticket_account['email']){
$reply_to_address = $ticket_account['email'];
$reply_to_name = $ticket_account['name'];
}else{
// reply to creator.
$reply_to_address = $from_user_a['email'];
$reply_to_name = $from_user_a['name'];
}
if($ticket_creator == $logged_in_user){
$send_as_name = $from_user_a['name'];
$send_as_address = $from_user_a['email'];
}else{
$send_as_address = $reply_to_address;
$send_as_name = $reply_to_name;
}
$last_response_from = 'admin'; // or customer.
// find the prev/next tickets.
$temp_prev = $prev_ticket = $next_ticket = false;
$temp_tickets = isset($_SESSION['_ticket_nextprev']) ? $_SESSION['_ticket_nextprev'] : array();
foreach($temp_tickets as $key=>$val){
if($prev_ticket && !$next_ticket){
$next_ticket = $val;
}
if($val==$ticket_id){
$prev_ticket = ($temp_prev)?$temp_prev:true;
}
$temp_prev = $val;
}
$form_actions = array(
'class' => 'action_bar action_bar_center action_bar_single',
'elements' => array(
array(
'type' => 'save_button',
'name' => 'butt_save',
'value' => _l('Save details'),
),
array(
'ignore' => !((int)$ticket_id && module_ticket::can_i('delete','Tickets')),
'type' => 'delete_button',
'name' => 'butt_del',
'value' => _l('Delete'),
),
array(
'type' => 'button',
'name' => 'cancel',
'value' => _l('Cancel'),
'class' => 'submit_button',
'onclick' => "window.location.href='".module_ticket::link_open(false)."';",
),
),
);
if((int)$ticket_id && module_ticket::can_edit_tickets()){
$form_actions['elements'][] = array(
'type' => 'submit',
'name' => 'mark_as_unread',
'value' => _l('Mark as unread'),
);
}
if($prev_ticket && $prev_ticket!==true){
array_unshift($form_actions['elements'],array(
'type' => 'button',
'onclick' => "window.location.href='".module_ticket::link_open($prev_ticket)."';",
'name' => 'prev_ticket',
'value' => _l('Prev Ticket'),
));
}
if($next_ticket){
$form_actions['elements'][] = array(
'type' => 'button',
'onclick' => "window.location.href='".module_ticket::link_open($next_ticket)."';",
'name' => 'next_ticket',
'value' => _l('Next Ticket'),
);
}
$action_buttons = module_form::generate_form_actions($form_actions);
?>
<script type="text/javascript">
ucm.ticket.ticket_message_text_is_html = <?php echo module_config::c('ticket_message_text_or_html','html')=='html' ? 'true' : 'false'; ?>;
ucm.ticket.ticket_url = '<?php echo module_ticket::link_open($ticket_id, false);?>';
$(function(){
ucm.ticket.init();
});
</script>
<form action="" method="post" id="ticket_form" enctype="multipart/form-data">
<input type="hidden" name="_process" value="save_ticket" />
<input type="hidden" name="ticket_id" value="<?php echo $ticket['ticket_id']; ?>" />
<?php
echo $action_buttons;
$fields = array(
'fields' => array(
'subject' => 'Subject',
));
module_form::set_required(
$fields
);
module_form::prevent_exit(array(
'valid_exits' => array(
// selectors for the valid ways to exit this form.
'.submit_button',
'.save_task',
'.notify',
'.delete',
'.attachment_link',
))
);
hook_handle_callback('layout_column_half',1,'35');
/** TICKET DETAILS */
$responsive_summary = array();
$responsive_summary[] = '#'.module_ticket::ticket_number($ticket['ticket_id']);
if(($ticket['status_id'] == 2 || $ticket['status_id'] == 3 || $ticket['status_id'] == 5)){
$responsive_summary[] = ordinal($ticket['position']);
}
$responsive_summary[] = htmlspecialchars($ticket['subject']);
$fieldset_data = array(
'heading' => array(
'title' => _l('Ticket Details'),
'type' => 'h3',
'responsive' => array(
'summary' => implode(', ',$responsive_summary),
),
),
'elements' => array(
array(
'title' => _l('Ticket Number'),
'fields' => array(
function() use($ticket){
?>
<span class="ticket_status_<?php echo (int)$ticket['status_id'];?>"><?php echo module_ticket::ticket_number($ticket['ticket_id']);?></span>
<?php
if($ticket['status_id'] == 2 || $ticket['status_id'] == 3 || $ticket['status_id'] == 5){
echo _l('(%s out of %s tickets)',ordinal($ticket['position']),$ticket['total_pending']);
}
?>
<input type="hidden" name="status_id" value="<?php echo $ticket['status_id'];?>">
<?php
}
),
),
),
);
if($ticket['last_message_timestamp']){
$fieldset_data['elements'][] = array(
'title' => _l('Date/Time'),
'fields' => array(
function() use ($ticket,$limit_time){
if($ticket['last_message_timestamp'] < $limit_time){
echo '<span class="important">';
}
echo print_date($ticket['last_message_timestamp'],true);
// how many days ago was this?
echo ' ';
$days = ceil((($ticket['last_message_timestamp']+1) - time())/86400);
if(abs($days) == 0){
_e('(today)');
}else{
_e(' (%s days ago)',abs($days));
}
if($ticket['last_message_timestamp'] < $limit_time){
echo '</span>';
}
}
)
);
}
$fieldset_data['elements'][] = array(
'title' => _l('Subject'),
'fields' => array(
function() use ($ticket){
if($ticket['subject']){
echo htmlspecialchars($ticket['subject']);
}else{ ?>
<input type="text" name="subject" id="subject" value="<?php echo htmlspecialchars($ticket['subject']); ?>" />
<?php }
}
)
);
$fieldset_data['elements'][] = array(
'title' => _l('Assigned Staff'),
'fields' => array(
function() use ($ticket,$admins_rel){
if(module_ticket::can_edit_tickets()){
echo print_select_box($admins_rel,'assigned_user_id',$ticket['assigned_user_id']);
echo _h('This is anyone with ticket EDIT permissions.');
?>
<input type="submit" name="butt_notify_staff" value="<?php _e('Notify');?>" class="notify small_button">
<?php
}else{
echo friendly_key($admins_rel,$ticket['assigned_user_id']);
}
}
)
);
$fieldset_data['elements'][] = array(
'title' => _l('Assigned Contact'),
'fields' => array(
function() use ($ticket, $ticket_id){
$create_user = module_user::get_user($ticket['user_id'],false);
if(module_ticket::can_edit_tickets() && !(int)$ticket_id){
$c = array();
if($ticket['customer_id']){
$res = module_user::get_contacts(array('customer_id'=>$ticket['customer_id']));
}else{
$res = array();
}
while($row = array_shift($res)){
$c[$row['user_id']] = $row['name'].' '.$row['last_name'];
}
if($ticket['user_id'] && !isset($c[$ticket['user_id']])){
// this option isn't in the listing. add it in.
$c[$ticket['user_id']] = $create_user['name'].' '.$create_user['last_name'];
if($create_user['customer_id']>=0) $c[$ticket['user_id']] .= ' '._l('(under different customer)');
else{
// user not assigned to a customer.
}
}
echo print_select_box($c,'change_user_id',$ticket['user_id']);
}else{
//
if($create_user['customer_id']){
echo module_user::link_open_contact($ticket['user_id'],true,array(),true);
}else{
echo module_user::link_open($ticket['user_id'],true,array(),true);
}
echo ' ' .htmlspecialchars($create_user['email']);
}
}
)
);
$fieldset_data['elements'][] = array(
'title' => _l('Type/Department'),
'fields' => array(
array(
'type' => 'select',
'name' => 'ticket_type_id',
'value' => $ticket['ticket_type_id'],
'options' => module_ticket::get_types(),
'blank' => module_ticket::can_edit_tickets(),
'options_array_id' => 'name',
)
)
);
if(class_exists('module_faq',false) && module_config::c('ticket_faq_link',1) && module_faq::get_faq_products()>0) {
$fieldset_data['elements'][] = array(
'title' => _l( 'Product' ),
'fields' => array(
function () use ( $ticket, $ticket_id ) {
if(module_ticket::can_edit_tickets()){
echo print_select_box(module_faq::get_faq_products_rel(),'faq_product_id',$ticket['faq_product_id']);
_h('Use this to link a ticket to a product. Set products in Settings > FAQ. This allows you to have different FAQ items for different products. Users are shown the FAQ items before submitting a support ticket.');
}else{
echo friendly_key(module_faq::get_faq_products_rel(),$ticket['faq_product_id']);
}
// show a button that does a jquery popup with the list of faq items and an option to create new one.
//if(module_faq::can_i('edit','FAQ')){ echo ' ';
echo popup_link('<a href="'.module_faq::link_open_list($ticket['faq_product_id']).'">'._l('FAQ').'</a>',array(
'force'=>true,
'width'=>1100,
'height'=>600,
));
//}
}
)
);
}
if(module_config::c('ticket_support_accounts',1) && module_ticket::get_accounts_rel()) {
$fieldset_data['elements'][] = array(
'title' => _l( 'Account' ),
'fields' => array(
array(
'type' => module_ticket::can_edit_tickets() ? 'select' : 'html',
'name' => 'ticket_account_id',
'value' => module_ticket::can_edit_tickets() ? $ticket['ticket_account_id'] : friendly_key(module_ticket::get_accounts_rel(),$ticket['ticket_account_id']),
'options' => module_ticket::get_accounts_rel(),
)
)
);
}
$fieldset_data['elements'][] = array(
'title' => _l( 'Status' ),
'fields' => array(
array(
'type' => module_ticket::can_edit_tickets() ? 'select' : 'html',
'name' => 'status_id',
'value' => module_ticket::can_edit_tickets() ? $ticket['status_id'] : friendly_key(module_ticket::get_statuses(),$ticket['status_id']),
'options' => module_ticket::get_statuses(),
)
)
);
if (module_ticket::can_edit_tickets() || module_config::c('ticket_allow_priority_selection',0)) {
$priorities = module_ticket::get_ticket_priorities();
if ( ! module_ticket::can_edit_tickets() && isset( $priorities[ _TICKET_PRIORITY_STATUS_ID ] ) && $ticket['priority'] != _TICKET_PRIORITY_STATUS_ID ) {
unset( $priorities[ _TICKET_PRIORITY_STATUS_ID ] );
}
$fieldset_data['elements'][] = array(
'title' => _l( 'Priority' ),
'fields' => array(
array(
'type' => 'select',
'name' => 'priority',
'value' => $ticket['priority'],
'blank' => false,
'options' => $priorities,
)
)
);
}
$fieldset_data['extra_settings'] = array(
'owner_table' => 'ticket',
'owner_key' => 'ticket_id',
'owner_id' => $ticket['ticket_id'],
'layout' => 'table_row',
'allow_new' => module_extra::can_i('create','Tickets'),
'allow_edit' => module_extra::can_i('edit','Tickets'),
);
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$done_messages = false;
if(class_exists('module_mobile',false)) {
if ( module_mobile::is_mobile_browser() ) {
// we're on mobile, display the ticket messages here:
$tickets_in_reverse = false;
include module_theme::include_ucm('includes/plugin_ticket/pages/ticket_admin_edit_messages.php');
$done_messages = true;
}
}
if($ticket['user_id']){
if(module_config::c('ticket_other_list_by','user') == 'user'){
$other_tickets = module_ticket::get_tickets(array('user_id'=>$ticket['user_id']));
}else if(module_config::c('ticket_other_list_by','user') == 'customer' && $ticket['customer_id']){
$other_tickets = module_ticket::get_tickets(array('customer_id'=>$ticket['customer_id']));
}else{
$other_tickets = false;
}
if($other_tickets !== false && mysql_num_rows($other_tickets)>1){
$other_status = array();
ob_start();
?>
<table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tableclass_full tbl_fixed">
<tbody>
<?php while($other_ticket = mysql_fetch_assoc($other_tickets)){ ?>
<tr>
<td style="width:55px;">
<?php echo $other_ticket['ticket_id'] == $ticket_id ? '»':'';?>
<?php echo module_ticket::link_open($other_ticket['ticket_id'],true);?>
</td>
<td>
<?php if($other_ticket['priority']==_TICKET_PRIORITY_STATUS_ID){ echo '$'; } ?>
<?php echo htmlspecialchars($other_ticket['subject']);?>
</td>
<td style="width:100px;">
<?php echo htmlspecialchars(module_ticket::$ticket_statuses[$other_ticket['status_id']]);
if(!isset($other_status[module_ticket::$ticket_statuses[$other_ticket['status_id']]])){
$other_status[module_ticket::$ticket_statuses[$other_ticket['status_id']]] = 0;
}
$other_status[module_ticket::$ticket_statuses[$other_ticket['status_id']]]++;
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
$responsive_summary = array();
foreach($other_status as $status=>$count){
$responsive_summary[] = $count.' '.$status;
}
$fieldset_data = array(
'heading' => array(
'title' => _l('%s Other Support Tickets',mysql_num_rows($other_tickets)),
'type' => 'h3',
'responsive' => array(
'summary' => htmlspecialchars(implode(', ',$responsive_summary)),
)
),
'elements_before' => ob_get_clean(),
);
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
}
}
//(int)$ticket_id > 0 &&
if(file_exists(dirname(__FILE__).'/../inc/ticket_extras_sidebar.php')){
include(dirname(__FILE__).'/../inc/ticket_extras_sidebar.php');
}
if(file_exists(dirname(__FILE__).'/../inc/ticket_billing.php')){
include(dirname(__FILE__).'/../inc/ticket_billing.php');
}
if((int)$ticket_id > 0 && file_exists(dirname(__FILE__).'/../inc/ticket_priority_sidebar.php')){
//if($ticket['priority'] == _TICKET_PRIORITY_STATUS_ID || (isset($ticket['invoice_id']) && $ticket['invoice_id'])){
include(dirname(__FILE__).'/../inc/ticket_priority_sidebar.php');
// }
}
if(isset($ticket['ticket_id']) && (int)$ticket['ticket_id']>0 && module_ticket::can_edit_tickets()){
if(class_exists('module_note',false) && module_note::is_plugin_enabled() && module_config::c('ticket_enable_notes',1)){
module_note::display_notes(array(
'title' => 'Ticket Notes',
'owner_table' => 'ticket',
'owner_id' => $ticket_id,
'view_link' => module_ticket::link_open($ticket['ticket_id']),
)
);
}
if(class_exists('module_group',false) && module_config::c('ticket_enable_groups',1)){
module_group::display_groups(array(
'title' => 'Ticket Groups',
'owner_table' => 'ticket',
'owner_id' => $ticket['ticket_id'],
'view_link' => module_ticket::link_open($ticket['ticket_id']),
));
}
}
if(module_ticket::can_edit_tickets()){
/** RELATED TO */
$responsive_summary = array();
$responsive_summary[] = module_customer::link_open($ticket['customer_id'],true);
$fieldset_data = array(
'heading' => array(
'title' => _l('Related to'),
'type' => 'h3',
'responsive' => array(
'summary' => implode(', ',$responsive_summary),
),
),
'elements' => array(),
);
$fieldset_data['elements'][] = array(
'title' => _l('Customer'),
'fields' => array(
function() use ($ticket_id, $ticket, $done_in_ticket_billing){
// moved to ticket billing..?
if(module_ticket::can_edit_tickets() && !isset($done_in_ticket_billing)){
$c = array();
$res = module_customer::get_customers();
while($row = array_shift($res)){
$c[$row['customer_id']] = $row['customer_name'];
}
if($ticket['customer_id']<0)$ticket['customer_id']=false;
echo print_select_box($c,'change_customer_id',$ticket['customer_id'],'',_l(' - No Customer -'));
if(module_customer::can_i('create','Customers') && $ticket['user_id'] && (int)$ticket_id>0){
// is this a user, or a staff member. don't allow moving of staff members. (or maybe later we will)
//$user_temp = module_user::get_user($ticket['user_id'],false);
//if($user_temp['customer_id']<=0){
?>
<input type="button" name="new_customer" value="<?php _e('New');?>" onclick="window.location.href='<?php echo module_customer::link_open('new',false);?>&move_user_id=<?php echo $ticket['user_id'];?>';" class="small_button"><?php _h('Create a new customer and move this "Assigned Contact" to this new customer.'); ?>
<?php
//}
} ?>
<!-- <script type="text/javascript">
$(function(){
$('#change_customer_id').change(function(){
// change our customer id.
var new_customer_id = $(this).val();
$.ajax({
type: 'POST',
url: '<?php echo module_customer::link_open(false);?>',
data: {
'_process': 'ajax_contact_list',
'customer_id': new_customer_id
},
dataType: 'json',
success: function(newOptions){
var currentuser_key = $('#change_user_id').val();
var currentuser_val = '';
if(currentuser_key){
currentuser_val =$('#change_user_id').find('option[value="'+currentuser_key+'"]').html();
}
$('#change_user_id').find('option:gt(0)').remove();
$.each(newOptions, function(value, key) {
$('#change_user_id').append($("<option></option>")
.attr("value", value).text(key));
});
if(currentuser_key){
$('#change_user_id').append($("<option></option>")
.attr("value", currentuser_key).text(currentuser_val));
$('#change_user_id').val(currentuser_key);
}
},
fail: function(){
alert('Changing customer failed, please refresh and try again.');
}
});
});
});
</script> -->
<?php
}else{
echo module_customer::link_open($ticket['customer_id'],true);
}
/*$c = array();
$res = module_customer::get_customers();
while($row = array_shift($res)){
$c[$row['customer_id']] = $row['customer_name'];
}
if(false && module_ticket::can_i('edit','Related to','Tickets')){
echo print_select_box($c,'customer_id',$ticket['customer_id']);
}else if($ticket['customer_id']){
echo isset($c[$ticket['customer_id']]) ? $c[$ticket['customer_id']] : 'N/A';
}*/
}
)
);
if($ticket['customer_id'] && $ticket_id > 0){
$fieldset_data['elements'][] = array(
'title' => _l('Contact'),
'fields' => array(
function() use ($ticket_id, $ticket){
if(module_ticket::can_edit_tickets() && isset($_REQUEST['show_change_contact'])){
$c = array();
if($ticket['customer_id']){
$res = module_user::get_contacts(array('customer_id'=>$ticket['customer_id']));
}else{
$res = array();
}
while($row = array_shift($res)){
$c[$row['user_id']] = $row['name'].' '.$row['last_name'];
}
if($ticket['user_id'] && !isset($c[$ticket['user_id']])){
// this option isn't in the listing. add it in.
$user_temp = module_user::get_user($ticket['user_id'],false);
$c[$ticket['user_id']] = $user_temp['name'].' '.$user_temp['last_name'];
if($user_temp['customer_id']>=0) $c[$ticket['user_id']] .= ' '._l('(under different customer)');
else{
// user not assigned to a customer.
}
}
echo '<a name="#change_contact"></a>';
echo print_select_box($c,'change_user_id',$ticket['user_id']);
}else{
echo module_user::link_open_contact($ticket['user_id'],true);
if(module_ticket::can_edit_tickets()){
echo ' ';
echo '<a href="'.module_ticket::link_open($ticket_id).'&show_change_contact#change_contact">'._l('Change').'</a>';
}
}
/*
$c = array();
$res = module_user::get_users(array('customer_id'=>$ticket['customer_id']));
while($row = array_shift($res)){
$c[$row['user_id']] = $row['name'];
}
if(false && module_ticket::can_i('edit','Related to')){
echo print_select_box($c,'user_id',$ticket['user_id']);
}else if($ticket['user_id']){
echo isset($c[$ticket['user_id']]) ? $c[$ticket['user_id']] : 'N/A';
}*/
}
)
);
}
$res = module_website::get_websites(array('customer_id'=>$ticket['customer_id']));
if(count($res)) {
$fieldset_data['elements'][] = array(
'title' => _l(''.module_config::c('project_name_single','Website')),
'fields' => array(
function() use ($res, $ticket){
$c = array();
while($row = array_shift($res)){
$c[$row['website_id']] = $row['name'];
}
echo print_select_box($c,'website_id',$ticket['website_id']);
}
)
);
}
if((int)$ticket_id>0) {
$fieldset_data['elements'][] = array(
'title' => _l( 'Public link' ),
'fields' => array(
function () use ( $ticket_id ) {
?> <a href="<?php echo module_ticket::link_public($ticket_id);?>" target="_blank"><?php _e('click here');?></a> <?php
}
)
);
}
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
handle_hook('ticket_sidebar',$ticket_id);
} // end can edit
hook_handle_callback('layout_column_half',2,'65');
if($ticket_id > 0 && module_ticket::can_edit_tickets() && !$ticket['assigned_user_id']){
ob_start();
?>
<div class="content_box_wheader" style="padding-bottom: 20px">
<p>
<?php _e('This ticket is not assigned to anyone.');?><br/>
<?php _e('If you are able to solve this ticket please assign it to yourself.');?>
</p>
<input type="button" name="butt_assign_me" value="<?php _e('Assign this ticket to me');?>" class="submit_button btn btn-success" onclick="$('#assigned_user_id').val(<?php echo module_security::get_loggedin_id();?>); this.form.submit();">
<p>
<?php _e('If you cannot solve this ticket please assign it to someone else in the drop down list.');?>
</p>
</div>
<?php
$fieldset_data = array(
'heading' => array(
'title' => _l('Unassigned Ticket'),
'type' => 'h3',
),
'elements_before' => ob_get_clean(),
);
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
}
/** TICKET MESSAGES */
if(!$done_messages){
$tickets_in_reverse = module_config::c('ticket_messages_in_reverse',0);
include module_theme::include_ucm('includes/plugin_ticket/pages/ticket_admin_edit_messages.php');
}
hook_handle_callback('layout_column_half','end');
echo $action_buttons;
?>
</form>
<?php
if(($last_response_from == 'customer' || $last_response_from == 'autoreply') && $ticket['status_id'] != _TICKET_STATUS_RESOLVED_ID ){ // don't do this for resolved tickets
// only set the default field if the last respose was from the customer.
module_form::set_default_field('new_ticket_message');
}
?>