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 / reply_form.php

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

191 lines 8.9 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 global $wpscfunction,$current_user;
6 $wpsc_close_ticket_status = get_option('wpsc_close_ticket_status');
7 $status_id = $wpscfunction->get_ticket_fields($ticket_id,'ticket_status');
8
9 $fields = get_terms([
10 'taxonomy' => 'wpsc_ticket_custom_fields',
11 'hide_empty' => false,
12 ]);
13
14 foreach ($fields as $field) {
15 if($field->name=='ticket_description'){
16 $term_id=$field->term_id;
17 }
18 }
19
20 $wpsc_appearance_individual_ticket_page = get_option('wpsc_individual_ticket_page');
21 $reply_to_close_ticket = get_option('wpsc_allow_reply_to_close_ticket');
22 $wpsc_close_ticket_group = get_option('wpsc_close_ticket_group');
23 $wpsc_allow_reply_to_public_tickets = get_option('wpsc_allow_reply_to_public_tickets');
24 $allow_reply = true;
25 if(($current_user->has_cap('wpsc_agent') && !$current_user->has_cap('manage_options') && in_array($status_id, $wpsc_close_ticket_group) && !in_array('agents', $reply_to_close_ticket) )){
26 $allow_reply = false;
27 }elseif((!$current_user->has_cap('wpsc_agent') && in_array($status_id, $wpsc_close_ticket_group) && !in_array('customer', $reply_to_close_ticket) )){
28 $allow_reply = false;
29 }elseif(!$wpsc_allow_reply_to_public_tickets && ($current_user->user_email != $customer_email) && !($current_user->has_cap('wpsc_agent')) && !($current_user->has_cap('manage_options'))){
30 $allow_reply = false;
31 }
32
33 $allow_reply = apply_filters('wpsc_show_ticket_reply_editor',$allow_reply,$ticket_id);
34 $wpsc_allow_attach_reply_form = get_option('wpsc_allow_attach_reply_form');
35 $wpsc_attachment_max_filesize = get_option('wpsc_attachment_max_filesize');
36 if($allow_reply){
37 ?>
38 <div class="row wpsc_reply_widget">
39 <form id="wpsc_frm_tkt_reply" action="index.html" method="post">
40 <textarea id="wpsc_reply_box" name="reply_body" class="wpsc_textarea"></textarea>
41 <?php
42 $wpsc_reply_bcc = get_option('wpsc_reply_bcc_visibility');
43 if($wpsc_reply_bcc && apply_filters('wpsc_show_hide_bcc_field',true)){?>
44 <input class="form-control" style="margin-top:10px;" type="text" name="reply_bcc" id="reply_bcc" placeholder="<?php _e('BCC (Comma separated list)','supportcandy');?>" />
45 <?php
46 } ?>
47 <div class="col-sm-6 attachment">
48 <div class="row attachment_link">
49 <?php
50 $notice_flag = false;
51 if( (in_array('customers',$wpsc_allow_attach_reply_form) && is_user_logged_in() && !$current_user->has_cap('wpsc_agent')) ||
52 (in_array('agents',$wpsc_allow_attach_reply_form) && $current_user->has_cap('wpsc_agent')) || $current_user->has_cap('manage_options') ){
53 $notice_flag = true;
54 ?>
55 <span onclick="wpsc_attachment_upload('<?php echo esc_attr('attach_'.$term_id)?>','desc_attachment');"><?php _e('Attach file','supportcandy')?></span>
56 <?php
57 } ?>
58 <?php if ($wpscfunction->has_permission('add_note',$ticket_id)):?>
59 <span id="wpsc_insert_macros" onclick="wpsc_get_templates()" ><?php _e('Insert Macros','supportcandy')?></span>
60 <?php endif;?>
61 <?php do_action('wpsc_add_addon_tab_after_macro');?>
62 <div class="form-group">
63 <?php
64 $wpsc_allow_attachment_type = get_option('wpsc_allow_attachment_type');
65 $max_attachment_limit = get_option('wpsc_attachment_max_filesize');
66 $wpsc_show_attachment_notice = get_option('wpsc_show_attachment_notice');
67 if($wpsc_show_attachment_notice && $notice_flag){
68 $attach_notice = get_option('wpsc_attachment_notice');
69 ?>
70 <p class="help-block"> <i> <?php echo esc_attr($attach_notice);?></i></p>
71 <?php }?>
72 </div>
73
74 </div>
75 <div id="<?php echo esc_attr('attach_'.$term_id)?>" class="row attachment_container"></div>
76
77 <?php do_action('wpsc_rf_attachment_container',$ticket_id); ?>
78
79 </div>
80 <div class="col-sm-6 submit">
81
82 <?php if ($wpscfunction->has_permission('reply_ticket',$ticket_id)):?>
83 <button type="button" id="wpsc_individual_submit_reply_btn" onclick="javascript:wpsc_submit_reply('reply');" class="btn" style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_submit_reply_btn_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_submit_reply_btn_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_submit_reply_btn_border_color'])?> !important;">
84 <i class="fa fa-reply"></i> <?php _e('Submit Reply','supportcandy')?>
85 </button>
86 <?php endif;?>
87 <?php if ($wpscfunction->has_permission('add_note',$ticket_id)):?>
88 <button type="button" id="wpsc_individual_add_note_btn" onclick="javascript:wpsc_submit_reply('note');" class="btn"style="background-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_other_reply_form_btn_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_other_reply_form_btn_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_individual_ticket_page['wpsc_other_reply_form_btn_border_color'])?> !important;">
89 <i class="far fa-comment"></i> <?php _e('Add Note','supportcandy')?>
90 </button>
91 <?php endif;?>
92 <?php do_action('wpsc_add_addon_reply_tab');?>
93 </div>
94 <input type="file" id="attachment_upload" class="hidden" onchange="">
95 <input type="hidden" name="ticket_id" value="<?php echo esc_attr($ticket_id)?>">
96 <input type="hidden" id="wpsc_nonce" name="nonce" value="<?php echo wp_create_nonce($ticket_id);?>">
97 <input type="hidden" name="action" value="wpsc_tickets">
98 </form>
99 </div>
100 <?php } ?>
101
102 <script type="text/javascript">
103
104 function wpsc_attachment_upload(id,name){
105 jQuery('#attachment_upload').unbind('change');
106 jQuery('#attachment_upload').on('change', function(){
107 var flag = false;
108 var file = this.files[0];
109 jQuery('#attachment_upload').val('');
110 var allowedExtension = ['exe','php'];
111 var file_name_split = file.name.split('.');
112 var file_extension = file_name_split[file_name_split.length-1];
113 file_extension = file_extension.toLowerCase();
114 <?php
115 $attachment = get_option('wpsc_allow_attachment_type');
116 $attachment_data = explode(',' , $attachment );
117 $attachment_data = array_map('trim', $attachment_data);
118 $attachment_data = array_map('strtolower', $attachment_data);
119 ?>;
120 var allowedExtensionSetting = [<?php echo '"'.implode('","', $attachment_data).'"' ?>];
121
122 if(!flag && (jQuery.inArray(file_extension,allowedExtensionSetting) <= -1 || jQuery.inArray(file_extension,allowedExtension) > -1)) {
123 flag = true;
124 alert("<?php _e('Attached file type not allowed!','supportcandy')?>");
125 }
126
127 var current_filesize=file.size/1000000;
128 if(current_filesize><?php echo esc_attr($wpsc_attachment_max_filesize)?>){
129 flag = true;
130 alert('<?php echo sprintf( __('File size exceeds allowed limit (%1$s MB)!','supportcandy'), $wpsc_attachment_max_filesize );?>');
131 }
132
133 if(!flag){
134
135 var html_str = '<div class="row wpsc_attachment">'+
136 '<div class="progress" style="float: none !important; width: unset !important;">'+
137 '<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%">'+
138 file.name+
139 '</div>'+
140 '</div>'+
141 '<img onclick="attachment_cancel(this);" class="attachment_cancel" src="<?php echo esc_url(WPSC_PLUGIN_URL.'asset/images/close.png')?>" style="display:none;" />'+
142 '</div>';
143
144 jQuery('#'+id).append(html_str);
145
146 var attachment = jQuery('#'+id).find('.wpsc_attachment').last();
147
148 var data = new FormData();
149 data.append('file',file);
150 data.append('arr_name',name);
151 data.append('action','wpsc_tickets');
152 data.append('setting_action','upload_file');
153 data.append('_ajax_nonce', '<?php echo wp_create_nonce('upload_file')?>');
154
155 jQuery.ajax({
156 type : 'post',
157 url : wpsc_admin.ajax_url,
158 data : data,
159 xhr : function(){
160 var xhr = new window.XMLHttpRequest();
161 xhr.upload.addEventListener("progress", function(evt){
162 if (evt.lengthComputable) {
163 var percentComplete = Math.floor((evt.loaded / evt.total) * 100);
164 jQuery(attachment).find('.progress-bar').css('width',percentComplete+'%');
165 }
166 }, false);
167 return xhr;
168 },
169 processData: false,
170 contentType: false,
171 success : function(response){
172
173 var return_obj =JSON.parse(response);
174
175 jQuery(attachment).find('.attachment_cancel').show();
176
177 if(parseInt(return_obj.id) != 0){
178 jQuery(attachment).append('<input type="hidden" name="'+name+'[]" value="'+return_obj.id+'">');
179 jQuery(attachment).find('.progress-bar').addClass('progress-bar-success');
180 }else{
181 jQuery(attachment).find('.progress-bar').addClass('.progress-bar-danger');
182 }
183 }
184
185 });
186
187 }
188 });
189 jQuery('#attachment_upload').trigger('click');
190 }
191 </script>