PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 2.3.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v2.3.1
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / tickets / individual_ticket / load_individual_ticket.php

load_individual_ticket.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/admin/tickets/individual_ticket/load_individual_ticket.php

1,085 lines 50.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $wpdb, $current_user, $wpscfunction;
7
8 $reply_form_position = get_option('wpsc_reply_form_position');
9 $ticket = $wpscfunction->get_ticket($ticket_id);
10 $customer_email = $ticket['customer_email'];
11 $status_id = $ticket['ticket_status'];
12 $priority_id = $ticket['ticket_priority'];
13 $category_id = $ticket['ticket_category'];
14 $assigned_agents = $wpscfunction->get_ticket_meta($ticket_id,'assigned_agent');
15 $customer_name = stripcslashes($ticket['customer_name']);
16 $auth_id = $ticket['ticket_auth_code'];
17 $ticket_status = $wpscfunction->get_ticket_status($ticket_id);
18 $wpsc_allow_reply_confirmation = get_option('wpsc_allow_reply_confirmation');
19 $wpsc_thread_date_format = get_option('wpsc_thread_date_format');
20 $wpsc_redirect_to_ticket_list = get_option('wpsc_redirect_to_ticket_list');
21 $wpsc_allow_rich_text_editor = get_option('wpsc_allow_rich_text_editor');
22 $wpsc_reply_bcc = get_option('wpsc_reply_bcc_visibility');
23
24 $ticket_widgets = get_terms([
25 'taxonomy' => 'wpsc_ticket_widget',
26 'hide_empty' => false,
27 'orderby' => 'meta_value_num',
28 'order' => 'ASC',
29 'meta_query' => array('order_clause' => array('key' => 'wpsc_ticket_widget_load_order')),
30 ]);
31
32 $role_id = get_user_option('wpsc_agent_role');
33
34 include_once WPSC_ABSPATH . 'includes/admin/tickets/create_ticket/class-fields-formatting.php';
35 $fields_format = new WPSC_Ticket_Field_Formatting();
36
37 $wpsc_close_ticket_status = get_option('wpsc_close_ticket_status');
38
39 $general_appearance = get_option('wpsc_appearance_general_settings');
40
41 $create_ticket_btn_css = 'background-color:'.$general_appearance['wpsc_crt_ticket_btn_action_bar_bg_color'].' !important;color:'.$general_appearance['wpsc_crt_ticket_btn_action_bar_text_color'].' !important;';
42 $action_default_btn_css = 'background-color:'.$general_appearance['wpsc_default_btn_action_bar_bg_color'].' !important;color:'.$general_appearance['wpsc_default_btn_action_bar_text_color'].' !important;';
43
44 $wpsc_appearance_individual_ticket_page = get_option('wpsc_individual_ticket_page');
45
46 $edit_btn_css = 'background-color:'.$wpsc_appearance_individual_ticket_page['wpsc_edit_btn_bg_color'].' !important;color:'.$wpsc_appearance_individual_ticket_page['wpsc_edit_btn_text_color'].' !important;border-color:'.$wpsc_appearance_individual_ticket_page['wpsc_edit_btn_border_color'].'!important';
47
48 $wpsc_allow_rich_text_editor = get_option('wpsc_allow_rich_text_editor');
49
50 $rich_editing = $wpscfunction->rich_editing_status($current_user);
51
52 $rt_flag = false;
53 if((in_array('register_user',$wpsc_allow_rich_text_editor) && !$current_user->has_cap('wpsc_agent')) && $rich_editing){
54 $rt_flag = true;
55 }elseif($current_user->has_cap('wpsc_agent') && $rich_editing){
56 $rt_flag = true;
57 }
58
59 //check allow create ticket permission
60 $wpsc_allow_to_create_ticket = get_option('wpsc_allow_to_create_ticket');
61 $allow_create = false;
62 if ($current_user->has_cap('wpsc_agent') ){
63 $cu_role_id = get_user_option('wpsc_agent_role', $current_user->ID);
64 if(in_array($cu_role_id, $wpsc_allow_to_create_ticket)){
65 $allow_create = true;
66 }
67 }else{
68 if(in_array('customer', $wpsc_allow_to_create_ticket)){
69 $allow_create = true;
70 }
71 }
72
73 $ticket_url = get_permalink(get_option('wpsc_support_page_id')).'?support_page=open_ticket&ticket_id='.$ticket_id.'&auth_code='.$auth_id;
74 $ticket_url = apply_filters('wpsc_ticket_url',$ticket_url,$ticket_id);
75
76 $after_close_redirect = apply_filters('wpsc_after_close_redirect', true, $ticket);
77 ?>
78
79 <div class="row wpsc_tl_action_bar" style="background-color:<?php echo esc_attr($general_appearance['wpsc_action_bar_color'])?> !important;">
80
81 <div class="col-sm-12">
82 <?php if(apply_filters('wpsc_show_create_ticket_button',true) && $allow_create){?>
83 <button type="button" id="wpsc_individual_new_ticket_btn" onclick="wpsc_get_create_ticket();" class="btn btn-sm wpsc_create_ticket_btn" style="<?php echo esc_attr($create_ticket_btn_css)?>"><i class="fa fa-plus"></i> <?php _e('New Ticket','supportcandy')?></button>
84 <?php }?>
85 <?php if ($current_user->ID):?>
86 <button type="button" id="wpsc_individual_ticket_list_btn" onclick="wpsc_get_ticket_list();" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-list-ul"></i> <?php _e('Ticket List','supportcandy')?></button>
87 <?php endif;?>
88
89 <button type="button" class="btn btn-sm wpsc_action_btn" id="wpsc_individual_refresh_btn" onclick="wpsc_open_ticket(<?php echo esc_attr($ticket_id)?>);" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fas fa-sync-alt"></i> <?php _e('Refresh','supportcandy')?></button>
90
91 <?php if ($wpscfunction->has_permission('delete_ticket',$ticket_id) && !$ticket_status):?>
92 <button type="button" class="btn btn-sm wpsc_action_btn wpsc_restore_btn" id="wpsc_individual_restore_btn" onclick="get_restore_ticket(<?php echo esc_attr($ticket_id)?>);" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-window-restore"></i> <?php _e('Restore','supportcandy')?></button>
93 <?php endif;?>
94 <?php if ($wpscfunction->has_permission('delete_ticket',$ticket_id) && !$ticket_status ):?>
95 <button type="button" class="btn btn-sm wpsc_action_btn wpsc_restore_btn" id="wpsc_delete_ticket_permanently" onclick="wpsc_delete_ticket_permanently(<?php echo esc_attr($ticket_id)?>);" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-trash"></i> <?php _e('Delete Permanently','supportcandy')?></button>
96 <?php endif;?>
97 <?php
98 $allow_ug_member_ct = apply_filters('wpsc_allow_close_ticket', false, $ticket);
99 if ( ($customer_email == $current_user->user_email && get_option('wpsc_allow_customer_close_ticket')) || ($wpscfunction->has_permission('change_status',$ticket_id)) || $allow_ug_member_ct ):
100 if($ticket_status && ($status_id !=$wpsc_close_ticket_status)){?>
101 <button type="button" id="wpsc_individual_close_btn" onclick="wpsc_get_close_ticket(<?php echo esc_attr($ticket_id)?>)" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-check"></i> <?php _e('Close','supportcandy')?></button>
102 <?php
103 }?>
104 <?php endif;?>
105
106 <?php if ($wpscfunction->has_permission('delete_ticket',$ticket_id) && $ticket_status):?>
107 <button type="button" id="wpsc_individual_delete_btn" onclick="wpsc_get_delete_ticket(<?php echo esc_attr($ticket_id) ?>);" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-trash"></i> <?php _e('Delete','supportcandy')?></button>
108 <?php endif;?>
109
110 <?php if ($wpscfunction->has_permission('add_note',$ticket_id) && $ticket_status):?>
111 <button type="button" id="wpsc_individual_clone_btn" onclick="wpsc_get_clone_ticket(<?php echo esc_attr($ticket_id) ?>)" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="far fa-clone"></i> <?php _e('Clone','supportcandy')?></button>
112 <?php endif;?>
113
114 <?php do_action('wpsc_after_indidual_ticket_action_btn',$ticket_id);?>
115
116 <button type="button" id="wpsc_individual_copyurl_btn" onclick="wpsc_copy_ticket_url()" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="far fa-clipboard"></i> <?php _e('Copy URL','supportcandy')?></button>
117 <div style="display:none" id="wpsc_ticket_url"><?php echo esc_attr($ticket_url) ?></div>
118 </div>
119
120 </div>
121
122 <div class="row" style="background-color:<?php echo esc_attr($general_appearance['wpsc_bg_color'])?> !important;color:<?php echo esc_attr($general_appearance['wpsc_text_color'])?> !important;">
123
124 <div class="col-sm-8 col-md-9 wpsc_it_body">
125
126 <div class="row wpsc_it_subject_widget">
127 <h4>
128 <?php if(apply_filters('wpsc_show_hide_ticket_subject',true)){?>
129 [<?php echo esc_attr(get_option('wpsc_ticket_alice')).esc_attr($ticket_id)?>] <?php echo stripcslashes(esc_attr($ticket['ticket_subject'])); ?>
130 <?php if ($wpscfunction->has_permission('change_ticket_fields',$ticket_id) && $ticket_status):?>
131 <button id="wpsc_individual_edit_ticket_subject" onclick="wpsc_edit_ticket_subject(<?php echo esc_attr($ticket_id);?>)" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>"><i class="fas fa-edit"></i></button>
132 <?php endif;?>
133 <?php } ?>
134 </h4>
135 </div>
136
137 <?php
138 if($reply_form_position && $ticket_status){
139 include WPSC_ABSPATH . 'includes/admin/tickets/individual_ticket/reply_form.php';
140 }
141 ?>
142
143 <div class="row wpsc_threads_container">
144 <?php
145 $order = $reply_form_position ? 'DESC' : 'ASC';
146 $args = array(
147 'post_type' => 'wpsc_ticket_thread',
148 'post_status' => 'publish',
149 'orderby' => 'ID',
150 'order' => $order,
151 'posts_per_page' => -1,
152 'meta_query' => array(
153 'relation' => 'AND',
154 array(
155 'key' => 'ticket_id',
156 'value' => $ticket_id,
157 'compare' => '='
158 )
159 )
160 );
161
162 //myCred plugin conflict fix
163 remove_all_filters('parse_query');
164
165 $threads = get_posts($args);
166
167 if(apply_filters('wpsc_print_thread',true)){
168 foreach ($threads as $thread):
169 $reply = stripslashes(addslashes(htmlspecialchars_decode($thread->post_content, ENT_QUOTES)));
170 $reply = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $reply);
171
172 $thread_type = get_post_meta( $thread->ID, 'thread_type', true);
173 $customer_name = get_post_meta( $thread->ID, 'customer_name', true);
174 $customer_email = get_post_meta( $thread->ID, 'customer_email', true);
175 $attachments = get_post_meta( $thread->ID, 'attachments', true);
176 $ticket_id = get_post_meta( $thread->ID,'ticket_id',true);
177 $seen = get_post_meta( $thread->ID,'user_seen',true);
178
179 if( ( !$seen || $seen === 'null' ) && $current_user->user_email == $ticket['customer_email'] && ($thread_type == 'report' || $thread_type == 'reply') ){
180 update_post_meta($thread->ID, 'user_seen', date("Y-m-d H:i:s"));
181 }
182
183 if ($thread_type == 'report'):
184 ?>
185 <div class="wpsc_thread" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_report_thread_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_report_thread_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_report_thread_border_color'])?> !important;">
186 <div class="thread_avatar">
187 <?php echo get_avatar( $customer_email, 40 )?>
188 </div>
189 <?php
190 if($wpsc_thread_date_format == 'timestamp'){
191 $date = sprintf( __('reported %1$s','supportcandy'), $wpscfunction->time_elapsed_timestamp($thread->post_date_gmt) );
192 }else{
193 $date = sprintf( __('reported %1$s','supportcandy'), $wpscfunction->time_elapsed_string($thread->post_date_gmt) );
194 }
195 ?>
196 <div class="thread_body">
197 <div class="thread_user_name">
198 <strong><?php echo esc_attr($customer_name); ?></strong><small><i><?php echo esc_attr($date)?></i></small><br>
199 <?php if ( apply_filters('wpsc_thread_email_visibility',$current_user->has_cap('wpsc_agent')) ) {?>
200 <small><?php echo esc_attr($customer_email)?></small>
201 <?php }?>
202 <?php if ($wpscfunction->has_permission('edit_delete_ticket',$ticket_id) && $ticket_status):?>
203 <i onclick="wpsc_get_delete_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-trash thread_action_btn wpsc_delete_thread" title="<?php _e('Delete this thread','supportcandy');?>"></i>
204 <i onclick="wpsc_get_edit_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-edit thread_action_btn wpsc_edit_thread" title="<?php _e('Edit this thread','supportcandy');?>"></i>
205 <?php endif;?>
206 <?php if($current_user->has_cap('wpsc_agent')): ?>
207 <i onclick="wpsc_get_create_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-plus-square thread_action_btn wpsc_create_ticket_thread" title="<?php _e('Create new ticket from this thread','supportcandy');?>"></i>
208 <i onclick="wpsc_get_thread_info(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>,'thread');" class="fas fa-info-circle thread_action_btn wpsc_thread_info" title="<?php _e('Thread Info','supportcandy');?>"></i>
209
210 <?php endif;?>
211 </div>
212 <div class="thread_messege">
213 <?php
214 if ($rt_flag) {
215 echo wp_kses_post($reply);
216 } else {
217 echo wp_kses_post(nl2br($reply));
218 }
219 ?>
220 </div>
221 <?php
222 $wpsc_view_more = get_option('wpsc_view_more');
223 if($wpsc_view_more){?>
224 <div onclick="wpsc_ticket_thread_expander_toggle(this);" class="col-md-12 wpsc_ticket_thread_expander" style="padding: 0px; display: none;">
225 <?php _e('View More ...','supportcandy')?>
226 </div>
227 <?php
228 }?>
229 <?php if($attachments):?>
230 <br>
231 <strong class="wpsc_attachment_title"><?php _e('Attachments','supportcandy');?>:</strong><br>
232 <table class="wpsc_attachment_tbl">
233 <tbody>
234 <?php
235 foreach( $attachments as $attachment ):
236 $attach = array();
237 $attach_meta = get_term_meta($attachment);
238 foreach ($attach_meta as $key => $value) {
239 $attach[$key] = $value[0];
240 }
241 $download_url = home_url('/').'?wpsc_attachment='.$attachment.'&tid='.$ticket_id.'&tac='.$auth_id;
242 ?>
243 <tr class="wpsc_attachment_tr">
244 <td>
245 <a class="wpsc_attachment_link" href="<?php echo esc_attr($download_url)?>" target="_blank">
246 <span class="wpsc_attachment_file_name" style="padding: 7px;"><?php echo esc_attr($attach['filename']);?></span></a>
247 <?php if ($current_user->has_cap('manage_options')) { ?>
248 <i onclick="wpsc_thread_attachment_remove(this,<?php echo esc_attr($attachment); ?>,<?php echo esc_attr($thread->ID); ?>,<?php echo esc_attr($ticket_id); ?>,'<?php echo wp_create_nonce('remove_attachment')?>'); " class="fa fa-times thread_action_btn" style="padding-top:3px;" aria-hidden="true" title="<?php _e('Delete attachment','supportcandy');?>"></i>
249 <?php } ?>
250
251 </td>
252 </tr>
253 <?php endforeach;?>
254 </tbody>
255 </table>
256 <?php do_action('wpsc_after_report_attachment',$ticket_id,$thread->ID);?>
257
258 <?php endif;?>
259 <?php if( $current_user->has_cap('wpsc_agent')){?>
260 <div>
261 <?php
262 if( $seen && $seen != 'null' ){ ?>
263 <i class="fas fa-check-circle wpsc_seen_info" title="<?php echo __("Seen: ", "supportcandy") . $wpscfunction->time_elapsed_timestamp($seen);?>"></i>
264 <?php
265 } ?>
266 </div>
267 <?php } ?>
268 </div>
269 </div>
270 <?php
271 endif;
272
273 if ($thread_type == 'reply'):
274 if($wpsc_thread_date_format == 'timestamp'){
275 $date = sprintf( __('replied %1$s','supportcandy'), $wpscfunction->time_elapsed_timestamp($thread->post_date_gmt) );
276 }else{
277 $date = sprintf( __('replied %1$s','supportcandy'), $wpscfunction->time_elapsed_string($thread->post_date_gmt) );
278 }
279 $user_info=get_user_by('email',$customer_email);
280 $style = '';
281 if($user_info && $user_info->has_cap('wpsc_agent')){
282 $style = 'background-color:'.$wpsc_appearance_individual_ticket_page['wpsc_reply_thread_bg_color'].' !important;color:'.$wpsc_appearance_individual_ticket_page['wpsc_reply_thread_text_color'].' !important;border-color:'.$wpsc_appearance_individual_ticket_page['wpsc_reply_thread_border_color'].' !important';
283 }else{
284 $style = 'background-color:'.$wpsc_appearance_individual_ticket_page['wpsc_reply_thread_customer_bg_color'].' !important;color:'.$wpsc_appearance_individual_ticket_page['wpsc_reply_thread_customer_text_color'].' !important;border-color:'.$wpsc_appearance_individual_ticket_page['wpsc_reply_thread_customer_border_color'].' !important';
285 }
286 ?>
287 <div class="wpsc_thread" style="<?php echo esc_attr($style);?>">
288 <div class="thread_avatar">
289 <?php echo get_avatar( $customer_email, 40 )?>
290 </div>
291 <div class="thread_body">
292 <div class="thread_user_name">
293 <strong><?php echo esc_attr($customer_name)?></strong><small><i><?php echo esc_attr($date)?></i></small><br>
294 <?php if ( apply_filters('wpsc_thread_email_visibility',$current_user->has_cap('wpsc_agent')) ) {?>
295 <small><?php echo esc_attr($customer_email)?></small>
296 <?php }?>
297 <?php if ($wpscfunction->has_permission('edit_delete_ticket',$ticket_id) && $ticket_status):?>
298 <i onclick="wpsc_get_delete_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-trash thread_action_btn wpsc_delete_thread" title="<?php _e('Delete this thread','supportcandy');?>"></i>
299 <i onclick="wpsc_get_edit_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-edit thread_action_btn wpsc_edit_thread" title="<?php _e('Edit this thread','supportcandy');?>"></i>
300 <?php endif;?>
301 <?php if($current_user->has_cap('wpsc_agent')): ?>
302 <i onclick="wpsc_get_create_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-plus-square thread_action_btn wpsc_create_ticket_thread" title="<?php _e('Create new ticket from this thread','supportcandy');?>"></i>
303 <i onclick="wpsc_get_thread_info(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>,'thread');" class="fas fa-info-circle thread_action_btn wpsc_thread_info" title="<?php _e('Thread Info','supportcandy');?>"></i>
304 <?php endif;?>
305 </div>
306 <div class="thread_messege">
307 <?php
308 if ($rt_flag) {
309 echo wp_kses_post($reply);
310 } else {
311 echo wp_kses_post(nl2br($reply));
312 }
313 ?>
314 </div>
315 <?php
316 $wpsc_view_more = get_option('wpsc_view_more');
317 if($wpsc_view_more){?>
318 <div onclick="wpsc_ticket_thread_expander_toggle(this);" class="col-md-12 wpsc_ticket_thread_expander" style="padding: 0px; display: none;">
319 <?php _e('View More ...','supportcandy')?>
320 </div>
321 <?php
322 }?>
323 <?php if($attachments):?>
324 <strong class="wpsc_attachment_title"><?php _e('Attachments','supportcandy');?>:</strong><br>
325 <table class="wpsc_attachment_tbl">
326 <tbody>
327 <?php
328 foreach( $attachments as $attachment ):
329 $attach = array();
330 $attach_meta = get_term_meta($attachment);
331 foreach ($attach_meta as $key => $value) {
332 $attach[$key] = $value[0];
333 }
334 $download_url = home_url('/').'?wpsc_attachment='.$attachment.'&tid='.$ticket_id.'&tac='.$auth_id;
335 ?>
336 <tr class="wpsc_attachment_tr">
337 <td>
338 <a class="wpsc_attachment_link" href="<?php echo esc_attr($download_url)?>" target="_blank">
339 <span class="wpsc_attachment_file_name" style="padding: 7px;"><?php echo esc_attr($attach['filename']);?></span></a>
340 <?php if ($current_user->has_cap('manage_options')) { ?>
341 <i onclick="wpsc_thread_attachment_remove(this,<?php echo esc_attr($attachment); ?>,<?php echo esc_attr($thread->ID); ?>,<?php echo esc_attr($ticket_id); ?>,'<?php echo wp_create_nonce('remove_attachment')?>'); " class="fa fa-times thread_action_btn" style="padding-top:3px;" aria-hidden="true" title="<?php _e('Delete attachment','supportcandy');?>"></i>
342 <?php } ?>
343
344 </td>
345 </tr>
346 <?php endforeach;?>
347 </tbody>
348 </table>
349 <?php do_action('wpsc_after_reply_attachment',$ticket_id,$thread->ID);?>
350 <?php endif;?>
351 <?php if( $current_user->has_cap('wpsc_agent')){?>
352 <div>
353 <?php
354 if( $seen && $seen != 'null' ){ ?>
355 <i class="fas fa-check-circle wpsc_seen_info" title="<?php echo __("Seen: ", "supportcandy") . $wpscfunction->time_elapsed_timestamp($seen);?>"></i><?php
356 } ?>
357 </div>
358 <?php } ?>
359 </div>
360 </div>
361 <?php
362 endif;
363
364 if ( $thread_type == 'note' && apply_filters('wpsc_private_note_visibility',$current_user->has_cap('wpsc_agent'), $thread) && $wpscfunction->has_permission('view_note',$ticket_id) ):
365 ?>
366 <div class="wpsc_thread note" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_private_note_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_private_note_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_private_note_border_color'])?> !important;">
367 <div class="thread_avatar">
368 <?php echo get_avatar( $customer_email, 40 )?>
369 </div>
370 <?php
371 if($wpsc_thread_date_format == 'timestamp'){
372 $date = sprintf( __('added note %1$s','supportcandy'), $wpscfunction->time_elapsed_timestamp($thread->post_date_gmt) );
373 }else{
374 $date = sprintf( __('added note %1$s','supportcandy'), $wpscfunction->time_elapsed_string($thread->post_date_gmt) );
375 }
376 ?>
377 <div class="thread_body">
378 <div class="thread_user_name">
379 <strong><?php echo esc_attr($customer_name)?></strong><small><i><?php echo esc_attr($date)?></i></small><br>
380 <?php if ( apply_filters('wpsc_thread_email_visibility',$current_user->has_cap('wpsc_agent')) ) {?>
381 <small><?php echo esc_attr($customer_email)?></small>
382 <?php }?>
383 <?php if ($wpscfunction->has_permission('edit_delete_ticket',$ticket_id) && $ticket_status):?>
384 <i onclick="wpsc_get_delete_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-trash thread_action_btn wpsc_delete_thread"></i>
385 <i onclick="wpsc_get_edit_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-edit thread_action_btn wpsc_edit_thread"></i>
386 <?php endif;?>
387 <?php if($current_user->has_cap('wpsc_agent')): ?>
388 <i onclick="wpsc_get_create_thread(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>);" class="fa fa-plus-square thread_action_btn wpsc_create_ticket_thread" title="<?php _e('Create new ticket from this thread','supportcandy');?>"></i>
389 <?php endif;?>
390 <?php if($current_user->has_cap('wpsc_agent')):?>
391 <i onclick="wpsc_get_thread_info(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>,'thread');" class="fas fa-info-circle thread_action_btn wpsc_thread_info" title="<?php _e('Thread Info','supportcandy');?>"></i>
392
393 <?php endif;?>
394
395 </div>
396 <div class="thread_messege">
397 <?php
398 if ($rt_flag) {
399 echo wp_kses_post($reply);
400 } else {
401 echo wp_kses_post(nl2br($reply));
402 }
403 ?>
404 </div>
405 <?php
406 $wpsc_view_more = get_option('wpsc_view_more');
407 if($wpsc_view_more){?>
408 <div onclick="wpsc_ticket_thread_expander_toggle(this);" class="col-md-12 wpsc_ticket_thread_expander" style="padding: 0px; display: none;">
409 <?php _e('View More ...','supportcandy')?>
410 </div>
411 <?php
412 }?>
413 <?php if($attachments):?>
414 <strong class="wpsc_attachment_title"><?php _e('Attachments','supportcandy');?>:</strong><br>
415 <table class="wpsc_attachment_tbl">
416 <tbody>
417 <?php
418 foreach( $attachments as $attachment ):
419 $attach = array();
420 $attach_meta = get_term_meta($attachment);
421
422 foreach ($attach_meta as $key => $value) {
423 $attach[$key] = $value[0];
424 }
425 $download_url = home_url('/').'?wpsc_attachment='.$attachment.'&tid='.$ticket_id.'&tac='.$auth_id;
426
427 ?>
428 <tr class="wpsc_attachment_tr">
429 <td>
430 <a class="wpsc_attachment_link" href="<?php echo esc_attr($download_url)?>" target="_blank">
431 <span class="wpsc_attachment_file_name" style="padding: 7px;"><?php echo esc_attr($attach['filename']);?></span></a>
432 <?php if ($current_user->has_cap('manage_options')) { ?>
433 <i onclick="wpsc_thread_attachment_remove(this,<?php echo esc_attr($attachment); ?>,<?php echo esc_attr($thread->ID); ?>,<?php echo esc_attr($ticket_id); ?>,'<?php echo wp_create_nonce('remove_attachment')?>'); " class="fa fa-times thread_action_btn" style="padding-top:3px;" aria-hidden="true" title="<?php _e('Delete attachment','supportcandy');?>"></i>
434 <?php } ?>
435
436 </td>
437 </tr>
438 <?php endforeach;?>
439 </tbody>
440 </table>
441 <?php endif;?>
442 </div>
443 </div>
444 <?php
445 endif;
446
447 if ( $thread_type == 'log' && apply_filters('wpsc_thread_log_visibility',$current_user->has_cap('wpsc_agent')) && $wpscfunction->has_permission('view_log',$ticket_id)):
448 ?>
449 <div class="col-md-8 col-md-offset-2 wpsc_thread_log" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_logs_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_logs_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_logs_border_color'])?> !important;">
450 <?php
451 if($wpsc_thread_date_format == 'timestamp'){
452 $date = sprintf( __('reported %1$s','supportcandy'), $wpscfunction->time_elapsed_timestamp($thread->post_date_gmt) );
453 }else{
454 $date = sprintf( __('reported %1$s','supportcandy'), $wpscfunction->time_elapsed_string($thread->post_date_gmt) );
455 }
456 echo wp_kses_post($reply) ?> <i><small><?php echo esc_attr($date) ?></small></i>
457 </div>
458 <?php
459 endif;
460
461 do_action( 'wpsc_print_thread_type', $thread_type, $thread );
462 endforeach;
463 ?>
464 </div>
465
466 <?php
467 if( !$reply_form_position ){
468 include WPSC_ABSPATH . 'includes/admin/tickets/individual_ticket/reply_form.php';
469 }
470 ?>
471 <?php } ?>
472
473 </div>
474
475 <div class="col-sm-4 col-md-3 wpsc_sidebar individual_ticket_widget">
476
477 <?php do_action( 'wpsc_before_ticket_widget', $ticket_id, true )?>
478
479 <?php
480 foreach ($ticket_widgets as $key => $ticket_widget):
481 $wpsc_ticket_widget_type = get_term_meta( $ticket_widget->term_id, 'wpsc_ticket_widget_type', true);
482 $wpsc_ticket_widget_role = get_term_meta( $ticket_widget->term_id, 'wpsc_ticket_widget_role', true);
483 $wpsc_custom_widget_localize = get_option('wpsc_custom_widget_localize');
484 $ticket_widget_name = $wpsc_custom_widget_localize['custom_widget_'.$ticket_widget->term_id];
485
486 $flag = false;
487 if ( $wpsc_ticket_widget_type && (in_array($role_id,$wpsc_ticket_widget_role) || (!$current_user->has_cap('wpsc_agent') && in_array('customer',$wpsc_ticket_widget_role)) || (is_super_admin($current_user->ID) && is_multisite() ) ) ) {
488 $flag = true;
489 }
490 ?>
491 <?php do_action( 'wpsc_add_ticket_widget', $ticket_id, $ticket_widget, $ticket_widgets)?>
492 <?php
493 if ( $ticket_widget->slug == "status" && $flag ):
494
495 ?>
496 <div class="row" id="wpsc_status_widget" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
497 <h4 class="widget_header"><i class="fa fa-arrow-circle-right"></i> <?php echo esc_attr($ticket_widget_name);?>
498 <?php if ($wpscfunction->has_permission('change_status',$ticket_id) && $ticket_status):?>
499 <button id="wpsc_individual_change_ticket_status" onclick="wpsc_get_change_ticket_status(<?php echo esc_attr($ticket_id)?>)" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>"><i class="fas fa-edit"></i></button>
500 <?php endif;?>
501 </h4>
502 <hr class="widget_divider">
503 <?php
504 $status = get_term_by('id', $status_id, 'wpsc_statuses');
505 $status_color = get_term_meta( $status->term_id, 'wpsc_status_color', true);
506 $status_background_color = get_term_meta( $status->term_id, 'wpsc_status_background_color', true);
507 $wpsc_custom_status_localize = get_option('wpsc_custom_status_localize');
508 $wpsc_custom_category_localize = get_option('wpsc_custom_category_localize');
509 $wpsc_custom_priority_localize = get_option('wpsc_custom_priority_localize');
510 ?>
511 <div class="wpsp_sidebar_labels"><strong><?php _e('Status','supportcandy')?>:</strong> <span class="wpsp_admin_label" style="background-color:<?php echo esc_attr($status_background_color)?>;color:<?php echo esc_attr($status_color)?>;"><?php echo esc_attr($wpsc_custom_status_localize['custom_status_'.$status_id])?></span></div>
512 <?php $category = get_term_by('id', $category_id, 'wpsc_categories');?>
513 <div class="wpsp_sidebar_labels"><strong><?php _e('Category','supportcandy')?>:</strong> <?php echo esc_attr($wpsc_custom_category_localize['custom_category_'.$category_id]) ?> </div>
514 <?php
515 $wpsc_hide_show_priority = get_option('wpsc_hide_show_priority');
516 if( $current_user->has_cap('wpsc_agent') || (!$current_user->has_cap('wpsc_agent') && $wpsc_hide_show_priority)):
517 $priority = get_term_by('id', $priority_id, 'wpsc_priorities');
518 $priority_color = get_term_meta( $priority->term_id, 'wpsc_priority_color', true);
519 $priority_backgound_color = get_term_meta( $priority->term_id, 'wpsc_priority_background_color', true);
520 ?>
521 <div class="wpsp_sidebar_labels"><strong><?php _e('Priority','supportcandy')?>:</strong> <span class="wpsp_admin_label" style="background-color:<?php echo esc_attr($priority_backgound_color)?>;color:<?php echo esc_attr($priority_color)?>;"><?php echo esc_attr($wpsc_custom_priority_localize['custom_priority_'.$priority_id])?> </span></div>
522 <?php endif;
523 do_action('wpsc_after_status_widget',$ticket_id);
524 ?>
525 </div>
526 <?php
527
528 endif;?>
529
530 <?php
531 if ( $ticket_widget->slug == "raised-by" && $flag ):
532
533 ?>
534 <div class="row" id="wpsc_raised_by_widget" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
535 <h4 class="widget_header"><i class="fas fa-user-tie"></i> <?php echo esc_attr($ticket_widget_name);?>
536 <?php if ($wpscfunction->has_permission('change_raised_by',$ticket_id) && $ticket_status):?>
537 <button id="wpsc_individual_change_raised_by" onclick="wpsc_get_change_raised_by(<?php echo esc_attr($ticket_id) ?>);" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>" ><i class="fas fa-edit"></i></button>
538 <?php endif;?>
539 </h4>
540 <hr class="widget_divider">
541 <div class="wpsc_thread raised_by_div">
542 <div class="thread_avatar">
543 <?php
544 $customer_email = $ticket['customer_email'];
545 echo get_avatar( $customer_email, 30 );
546 ?>
547 </div>
548 <div class="thread_body">
549 <div class="thread_user_name"><?php $customer_name = $ticket['customer_name'];echo stripcslashes($customer_name);?> </div>
550 </div>
551 </div>
552 <?php if($current_user->has_cap('wpsc_agent')){?>
553 <div class="wpsp_sidebar_labels" id="wpsc_user_add_info" style="font-size:20px; cursor:pointer;color:#a7a9ab;">
554 <i id="wpsc_user_all_tickets" onclick="wpsc_get_all_tickets_of_user(<?php echo esc_attr($ticket_id) ?>, '<?php echo esc_attr($customer_name) ?>');" class="fas fa-envelope wpsc_raised_by_action" title="<?php _e('All Tickets','supportcandy');?>"></i>
555 <i id="wpsc_user_extra_info" onclick="wpsc_get_thread_info(<?php echo esc_attr($ticket_id) ?>,<?php echo esc_attr($thread->ID) ?>,'raised_by');" class="fas fa-info-circle wpsc_raised_by_action" title="<?php _e('Ticket Info','supportcandy');?>"></i>
556 <?php do_action('wpsc_add_info_icon_raised_by', $ticket); ?>
557 </div>
558 <?php } ?>
559 <?php do_action('wpsc_raised_by_widget_content');?>
560 </div>
561 <?php
562
563 endif;
564 ?>
565
566 <?php
567 if ($ticket_widget->slug=="additional-recepients" && $flag):
568 ?>
569 <div class="row" id="wpsc_add_people_widget" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
570 <h4 class="widget_header wpsc_add_recipients"><i class="fas fa-envelope"></i> <?php echo esc_attr($ticket_widget_name);?>
571 <button id="wpsc_individual_add_people" onclick="wpsc_get_add_ticket_users(<?php echo esc_attr($ticket_id) ?>);" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>" ><i class="fas fa-edit"></i></button>
572 </h4>
573 <hr class="widget_divider">
574
575 <div id="wpsc_additional_users">
576 <strong><small><?php _e('Emails:', 'supportcandy'); ?></small></strong>
577 <?php
578 $extra_email = false;
579 $extra_users_emails = $wpscfunction->get_ticket_meta($ticket_id , 'extra_ticket_users');
580 if($extra_users_emails){
581 foreach ($extra_users_emails as $users_emails) {
582 if($users_emails){
583 ?>
584 <div style="padding:2px 0;overflow: hidden;"><?php echo get_avatar( $users_emails, 20, '', '')?> <?php echo esc_attr($users_emails)?> </div>
585 <?php
586 }else{
587 $extra_email = true;
588 }
589 }
590 }else{
591 $extra_email = true;
592 }
593 if($extra_email){
594 ?>
595 <div class="">
596 <?php _e('None', 'supportcandy'); ?>
597 </div>
598 <?php
599 }
600 do_action('wpsc_after_extra_users',$ticket_id);
601 ?>
602 </div>
603 </div>
604 <?php
605 endif;
606 ?>
607
608 <?php
609 if ($ticket_widget->slug=="assign-agent" && $flag):
610 ?>
611 <div class="row assigned_agent" id="wpsc_assign_agent_widget" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
612 <h4 class="widget_header"><i class="fas fa-users"></i> <?php echo esc_attr($ticket_widget_name);?>
613 <?php if ($wpscfunction->has_permission('assign_agent',$ticket_id) && $ticket_status):?>
614 <button id="wpsc_individual_change_assign_agent" onclick="wpsc_get_change_assign_agent(<?php echo esc_attr($ticket_id) ?>);" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>" ><i class="fas fa-edit"></i></button>
615 <?php endif;?>
616 </h4>
617 <hr class="widget_divider">
618 <?php
619 if($assigned_agents[0]){
620 foreach ( $assigned_agents as $agent ) {
621 $user = get_term_meta($agent);
622 $user_id = isset($user['user_id'][0]) ? $user['user_id'][0] : '';
623 ?>
624 <tr>
625 <?php
626 if($user_id){
627 $user_data = get_userdata($user_id);
628 $agent_name = $user_data->display_name;
629 $agent_email = $user_data->user_email;
630 ?>
631 <td style="width:25px !important;"><div style="padding:2px 0;overflow: hidden;"><?php echo get_avatar( $agent_email, 20, '', '')?> <?php echo esc_attr($agent_name)?> </div></td>
632 <?php
633 }else{
634 do_action('wpsc_agent_name_in_individual_ticket',$agent);
635 }
636 ?>
637 </tr>
638 <?php
639 }
640 }
641 else{
642 _e('None','supportcandy');
643 }
644 ?>
645 </div>
646 <?php
647 endif;
648 ?>
649
650 <?php
651 if ( $ticket_widget->slug == "ticket-fields" && $flag ):
652
653 ?>
654 <div class="row" id="wpsc_ticket_fields_widget" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
655 <h4 class="widget_header"><i class="fab fa-wpforms"></i> <?php echo esc_attr($ticket_widget_name);?>
656 <?php if ( apply_filters('wpsc_get_user_permission',$wpscfunction->has_permission('change_ticket_fields',$ticket_id)) && $ticket_status):?>
657 <button id="wpsc_individual_change_ticket_fields" onclick="wpsc_get_change_ticket_fields(<?php echo esc_attr($ticket_id) ?>);" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>" ><i class="fas fa-edit"></i></button>
658 <?php endif;?>
659 </h4>
660 <hr class="widget_divider">
661 <div id="wpsc_ticket_fields">
662 <?php
663 $fields = get_terms([
664 'taxonomy' => 'wpsc_ticket_custom_fields',
665 'hide_empty' => false,
666 'orderby' => 'meta_value_num',
667 'meta_key' => 'wpsc_tf_load_order',
668 'order' => 'ASC',
669 'meta_query' => array(
670 array(
671 'key' => 'agentonly',
672 'value' => '0',
673 'compare' => '='
674 )
675 ),
676 ]);
677 $flag=true;
678 if($fields){
679 $flag=true;
680 $cust_flag = true;
681 foreach ($fields as $field) {
682 $wpsc_tf_type = get_term_meta( $field->term_id, 'wpsc_tf_type',true);
683 $value = $wpscfunction->get_ticket_meta($ticket_id,$field->slug,true);
684 if($value){
685 if($wpsc_tf_type!=0) {
686 $cust_flag = false;
687 }
688 $flag=false;
689 $fields_format->get_field_val($field);
690 }
691 }
692 if($cust_flag){
693 _e('No Ticket Fields','supportcandy');
694 }
695 }
696 ?>
697 </div>
698 <?php do_action( 'wpsc_after_ticket_fields_widget', $ticket_id,$fields)?>
699 </div>
700 <?php
701
702 endif;
703 ?>
704
705 <?php
706 if ( $ticket_widget->slug == "agent-only-fields" && $flag ):
707
708 ?>
709 <div class="row" id="wpsc_agent_only_fields_widget" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
710 <h4 class="widget_header"><i class="fab fa-wpforms"></i> <?php echo esc_attr($ticket_widget_name);?>
711 <?php if ($wpscfunction->has_permission('change_agentonly_fields',$ticket_id) && $ticket_status):?>
712 <button id="wpsc_individual_change_agent_fields" onclick="wpsc_get_change_agent_fields(<?php echo esc_attr($ticket_id) ?>)" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($edit_btn_css) ?>" ><i class="fas fa-edit"></i></button>
713 <?php endif;?>
714 </h4>
715 <hr class="widget_divider">
716 <div id="wpsc_ticket_aof_fields">
717 <?php
718 $fields = get_terms([
719 'taxonomy' => 'wpsc_ticket_custom_fields',
720 'hide_empty' => false,
721 'orderby' => 'meta_value_num',
722 'meta_key' => 'wpsc_tf_load_order',
723 'order' => 'ASC',
724 'meta_query' => array(
725 array(
726 'key' => 'agentonly',
727 'value' => '1',
728 'compare' => '='
729 )
730 ),
731 ]);
732 $cust_aflag = true;
733 if($fields){
734 $flag=true;
735 foreach ($fields as $field) {
736 $wpsc_tf_type = get_term_meta( $field->term_id, 'wpsc_tf_type',true);
737 $value = $wpscfunction->get_ticket_meta($ticket_id,$field->slug,true);
738 if($value){
739 $cust_aflag = false;
740 $flag=false;
741 $fields_format->get_field_val($field);
742 }
743 }
744 }
745 if($cust_aflag){
746 _e('No Agent Only Fields','supportcandy');
747 }
748 ?>
749 </div>
750 <?php do_action( 'wpsc_after_agent_only_fields_widget', $ticket_id,$fields)?>
751 </div>
752 <?php
753
754 endif;
755 ?>
756
757 <?php
758
759 if ($ticket_widget->slug=="biographical-info" && $flag):
760 ?>
761 <div class="row" id="wpsc_add_biographical_info" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_ticket_widgets_border_color'])?> !important;">
762 <h4 class="widget_header"><i class="fas fa-info-circle"></i> <?php echo esc_attr($ticket_widget_name);?> </h4>
763
764 <hr class="widget_divider">
765
766 <div id ="biographical_info">
767
768 <?php
769 $customer_email = $ticket['customer_email'];
770 $user = get_user_by('email',$customer_email);
771 if ($user) {
772 $user_description = get_user_meta($user->ID,'description',true);
773 ?>
774 <?php if ($user_description){ ?>
775 <div style="padding:2px 0;overflow: hidden;"> <?php echo wp_kses_post(nl2br($user_description)); ?> </div>
776 <?php } else {?>
777 <div style="padding:2px 0;overflow: hidden;"> <?php _e('No Biographical Info added.','supportcandy'); ?> </div>
778 <?php
779 }
780 } else {
781 ?>
782 <div style="padding:2px 0;overflow: hidden;"> <?php _e('No Biographical Info added.','supportcandy'); ?> </div>
783 <?php
784 }
785 ?>
786 </div>
787
788 </div>
789 <?php
790 endif;
791
792 endforeach;
793
794 ?>
795
796 </div>
797
798 <?php do_action( 'wpsc_after_ticket_widget', $ticket_id)?>
799
800 </div><?php
801 do_action('wpsc_load_individual_ticket');
802
803 if ($rt_flag) {
804 $wpsc_tinymce_toolbar = get_option('wpsc_tinymce_toolbar');
805 $toolbar_active = get_option('wpsc_tinymce_toolbar_active');
806 $tinymce_toolbox = array();
807 if(is_array($toolbar_active)) {
808 foreach ($toolbar_active as $key => $value) {
809 $tinymce_toolbox[] = $wpsc_tinymce_toolbar[$value]['value'];
810 if($value == 'blockquote' || $value == 'align' || $value == 'numbered_list' || $value == 'right_to_left'){
811 $tinymce_toolbox[] = ' | ';
812 }
813 }
814 }
815
816 $toolbar = implode(' ', $tinymce_toolbox);
817
818 $directionality = $wpscfunction->check_rtl();
819 ?>
820 <script>
821 tinymce.remove();
822 tinymce.init({
823 selector:'#wpsc_reply_box',
824 body_id: 'wpsc_reply_box',
825 directionality : '<?php echo esc_attr($directionality); ?>',
826 menubar: false,
827 statusbar: false,
828 autoresize_min_height: 150,
829 <?php
830 $wpsc_allow_html_pasting = get_option('wpsc_allow_html_pasting');
831 if(!$wpsc_allow_html_pasting){ ?>
832 paste_as_text: true,
833 <?php
834 }
835 ?>
836 wp_autoresize_on: true,
837 plugins: [
838 'wpautoresize lists link image directionality paste textcolor'
839 ],
840 toolbar: '<?php echo esc_attr($toolbar) ?> | wpsc_templates ',
841 file_picker_types: 'image',
842 file_picker_callback: function(cb, value, meta) {
843 var input = document.createElement('input');
844 input.setAttribute('type', 'file');
845 input.setAttribute('accept', 'image/*');
846
847 input.onchange = function() {
848 var file = this.files[0];
849 var form_data = new FormData();
850 form_data.append('file',file);
851 form_data.append('file_name',file.name);
852 form_data.append('action','wpsc_tickets');
853 form_data.append('setting_action','rb_upload_file');
854 form_data.append('_ajax_nonce', '<?php echo wp_create_nonce('rb_upload_file')?>');
855
856 jQuery.ajax({
857 type : 'post',
858 url : wpsc_admin.ajax_url,
859 cache: false,
860 contentType: false,
861 processData: false,
862 data: form_data,
863 success: function(response_data){
864 var responce = JSON.parse(response_data);
865 var reader = new FileReader();
866 reader.onload = function () {
867 var id = 'blobid' + (new Date()).getTime();
868 var blobCache = tinymce.activeEditor.editorUpload.blobCache;
869 var base64 = reader.result.split(',')[1];
870 var blobInfo = blobCache.create(id, file, base64);
871 blobCache.add(blobInfo);
872 if (responce) {
873 cb(responce, { title: 'attach' });
874 }else {
875 alert("<?php _e('Attached file type not allowed!','supportcandy')?>");
876 }
877 };
878 reader.readAsDataURL(file);
879 }
880 });
881
882 };
883
884 input.click();
885 },
886 branding: false,
887 autoresize_bottom_margin: 20,
888 browser_spellcheck : true,
889 relative_urls : false,
890 remove_script_host : false,
891 convert_urls : true
892 });
893 </script>
894 <?php } ?>
895
896 <script>
897
898 jQuery(document).ready(function(){
899 jQuery('.btn-success.dropdown-toggle').click(function(){
900 if(jQuery(this).parent().hasClass('open')){
901 jQuery(this).parent().removeClass('open');
902 } else {
903 jQuery(this).parent().addClass('open');
904 }
905 });
906 });
907
908 // Submit note
909 function wpsc_submit_reply( save_type ){
910 jQuery('.submit .btn-group').removeClass('open');<?php
911 if ($rt_flag) { ?>
912 var description = tinyMCE.activeEditor.getContent().trim();
913 <?php
914 }else {?>
915 var description = jQuery('#wpsc_reply_box').val().trim();
916 <?php
917 } ?>
918
919 if(description.length==0){
920 alert('<?php _e('Description empty!','supportcandy')?>');
921 return;
922 }
923 switch(save_type){
924 case 'note' :
925 wpsc_post_note(description);
926 break;
927 case 'reply':
928 wpsc_post_reply(description);
929 break;
930 case 'canned_reply':
931 wpsc_save_canned_reply();
932 break;
933 }
934 }
935
936 function wpsc_post_note(description){
937 validation = true;
938 <?php
939 if($wpsc_reply_bcc){
940 ?>
941 var bcc_emails = jQuery('#reply_bcc').val().trim();
942 if (bcc_emails) {
943 var emails = bcc_emails.split(",");
944
945 for (var i = 0; i < emails.length; i++) {
946 if (!validateEmail(emails[i])) {
947 validation = false;
948 }
949 }
950
951 if (!validation) {
952 alert(wpsc_admin.validate_email);
953 return false;
954 }
955 }
956 <?php
957 }
958 ?>
959 var dataform = new FormData(jQuery('#wpsc_frm_tkt_reply')[0]);
960 jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html);
961 dataform.append('action','wpsc_tickets');
962 dataform.append('setting_action','submit_note');
963 dataform.append('reply_body',description);
964 jQuery.ajax({
965 url: wpsc_admin.ajax_url,
966 type: 'POST',
967 data: dataform,
968 processData: false,
969 contentType: false
970 })
971 .done(function (response_str) {
972 wpsc_open_ticket(<?php echo esc_attr($ticket_id)?>);
973 });
974 var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden();
975 if(is_tinymce) tinyMCE.activeEditor.setContent('');
976 }
977
978 function wpsc_post_reply(description){
979 <?php if($wpsc_allow_reply_confirmation){?>
980 if(!confirm('<?php _e('Are you sure?','supportcandy')?>')) return;
981 <?php } ?>
982 validation = true;
983 <?php
984 if($wpsc_reply_bcc){
985 ?>
986 var bcc_emails = jQuery('#reply_bcc').val().trim();
987 if (bcc_emails) {
988 var emails = bcc_emails.split(",");
989
990 for (var i = 0; i < emails.length; i++) {
991 if (!validateEmail(emails[i])) {
992 validation = false;
993 }
994 }
995
996 if (!validation) {
997 alert(wpsc_admin.validate_email);
998 return false;
999 }
1000 }
1001 <?php
1002 }
1003 ?>
1004 var dataform = new FormData(jQuery('#wpsc_frm_tkt_reply')[0]);
1005 var redirect = <?php echo esc_attr($wpsc_redirect_to_ticket_list)?> ;
1006 jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html);
1007 dataform.append('action','wpsc_tickets');
1008 dataform.append('setting_action','submit_reply');
1009 dataform.append('reply_body',description);
1010 jQuery.ajax({
1011 url: wpsc_admin.ajax_url,
1012 type: 'POST',
1013 data: dataform,
1014 processData: false,
1015 contentType: false
1016 })
1017 .done(function (response_str) {
1018 redirect = redirect ? wpsc_get_ticket_list() : wpsc_open_ticket(<?php echo esc_attr($ticket_id)?>);
1019 });
1020 var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden();
1021 if(is_tinymce) tinyMCE.activeEditor.setContent('');
1022 }
1023
1024 function wpsc_copy_ticket_url(){
1025 var temp = jQuery("<input>");
1026 jQuery("body").append(temp);
1027 temp.val(jQuery('#wpsc_ticket_url').text()).select();
1028 document.execCommand("copy");
1029 temp.remove();
1030
1031 jQuery('#wpsc_alert_success .wpsc_alert_text').text('Ticket URL copied!');
1032 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
1033 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 1000);
1034 }
1035
1036 function wpsc_set_close_ticket(ticket_id){
1037
1038 if (wpsc_check_desc_empty()) {
1039 if(!confirm(wpsc_admin.warning_message)) {
1040 wpsc_modal_close();
1041 return;
1042 }
1043 }
1044 var dataform = new FormData(jQuery('#frm_close_ticket')[0]);
1045 jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html);
1046 wpsc_modal_close();
1047 jQuery.ajax({
1048 url: wpsc_admin.ajax_url,
1049 type: 'POST',
1050 data: dataform,
1051 processData: false,
1052 contentType: false
1053 })
1054 .done(function (response_str) {<?php
1055 if($after_close_redirect){?>
1056 wpsc_get_ticket_list();<?php
1057 }else{?>
1058 wpsc_open_ticket(ticket_id);<?php
1059 }
1060 ?>
1061 });
1062 }
1063
1064 jQuery(document).ready(function (){
1065 jQuery(document).find('.thread_messege').each(function(){
1066 var height = parseInt(jQuery(this).height());
1067 <?php
1068 $wpsc_view_more = get_option('wpsc_view_more');
1069 if($wpsc_view_more){?>
1070 if( height > 100){
1071 jQuery(this).height(100);
1072 jQuery(this).parent().find('.wpsc_ticket_thread_expander').text(wpsc_admin.view_more);
1073 jQuery(this).parent().find('.wpsc_ticket_thread_expander').show();
1074 }<?php
1075 } else{?>
1076 jQuery(this).parent().find('.thread_messege').height('auto');<?php
1077 } ?>
1078
1079 });
1080 jQuery('.wpsc_ticket_thread_content img').addClass('img-responsive');
1081
1082 });
1083 </script>
1084
1085 <?php do_action('wpsc_after_individual_ticket',$ticket_id) ?>