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

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

248 lines 9.4 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 $wpscfunction, $current_user;
7
8 $fields = get_terms([
9 'taxonomy' => 'wpsc_ticket_custom_fields',
10 'hide_empty' => false,
11 ]);
12
13 foreach ($fields as $field) {
14 if($field->name=='ticket_description'){
15 $term_id=$field->term_id;
16 }
17 }
18
19 $wpsc_appearance_individual_ticket_page = get_option('wpsc_individual_ticket_page');
20 $reply_btn_css = 'background-color:'.$wpsc_appearance_individual_ticket_page['wpsc_submit_reply_btn_bg_color'].' !important;color:'.$wpsc_appearance_individual_ticket_page['wpsc_submit_reply_btn_text_color'].' !important;border-color:'.$wpsc_appearance_individual_ticket_page['wpsc_submit_reply_btn_border_color'].'!important';
21
22 $wpsc_appearance_create_ticket = get_option('wpsc_create_ticket');
23 $extra_info_css = 'color:'.$wpsc_appearance_create_ticket['wpsc_extra_info_text_color'].' !important;';
24
25 $reply_to_close_ticket = get_option('wpsc_allow_reply_to_close_ticket');
26 $wpsc_close_ticket_status = get_option('wpsc_close_ticket_status');
27 $wpsc_allow_reply_confirmation = get_option('wpsc_allow_reply_confirmation');
28 $wpsc_attachment_max_filesize = get_option('wpsc_attachment_max_filesize');
29 $wpsc_close_ticket_group = get_option('wpsc_close_ticket_group');
30
31 $allow_reply = true;
32 if(in_array($status_id, $wpsc_close_ticket_group) && !in_array('customer', $reply_to_close_ticket)){
33 $allow_reply = false;
34 }
35 if($allow_reply):
36
37 ?>
38 <div class="row wpsc_reply_widget" style="margin-top:20px;">
39 <form id="wpsc_frm_tkt_reply" action="javascript:wpsc_post_reply();" method="post">
40 <?php if(!$current_user->ID):?>
41 <div class="col-sm-6 form-group attachment" style="padding-right:3px;">
42 <label for="wpsc_guest_name"><?php _e('Your Name','supportcandy');?></label>
43 <p class="help-block" style="<?php echo esc_attr($extra_info_css) ?>"><?php _e('Please insert your name','supportcandy');?></p>
44 <input id="wpsc_guest_name" class="form-control" name="customer_name" value="" required />
45 </div>
46 <div class="col-sm-6 form-group attachment" style="padding-right:3px;">
47 <label for="wpsc_guest_email"><?php _e('Your Email','supportcandy');?></label>
48 <p class="help-block" style="<?php echo esc_attr($extra_info_css) ?>"><?php _e('Please insert your email address','supportcandy');?></p>
49 <input type="email" id="wpsc_guest_email" class="form-control" name="customer_email" value="" required />
50 </div>
51 <?php endif;?>
52 <div class="col-sm-12 attachment">
53 <textarea id="wpsc_reply_box" name="reply_body" class="wpsc_textarea"></textarea>
54 </div>
55
56 <div class="col-sm-10 attachment">
57 <div class="row attachment_link">
58 <?php
59 $notice_flag = false;
60 $wpsc_allow_attach_reply_form = get_option('wpsc_allow_attach_reply_form');
61 if( (in_array('customers',$wpsc_allow_attach_reply_form) && is_user_logged_in() && !$current_user->has_cap('wpsc_agent')) ||
62 (in_array('guests',$wpsc_allow_attach_reply_form) && !is_user_logged_in()) ){
63 $notice_flag = true;
64 ?>
65 <span onclick="wpsc_attachment_upload('<?php echo esc_attr('attach_'.$term_id)?>','desc_attachment');"><?php _e('Attach file','supportcandy')?></span>
66 <?php
67 }
68 ?>
69
70 <div class="form-group">
71 <?php
72 $wpsc_allow_attachment_type = get_option('wpsc_allow_attachment_type');
73 $max_attachment_limit = get_option('wpsc_attachment_max_filesize');
74 $wpsc_show_attachment_notice = get_option('wpsc_show_attachment_notice');
75 if($wpsc_show_attachment_notice && $notice_flag){
76 $attach_notice = get_option('wpsc_attachment_notice');
77 ?>
78 <p class="help-block"> <i> <?php echo esc_attr($attach_notice);?></i></p>
79 <?php
80 }
81 ?>
82 </div>
83
84 </div>
85 <div id="<?php echo esc_attr('attach_'.$term_id)?>" class="row attachment_container" style="padding-right:15px;"></div>
86 </div>
87
88
89 <div class="col-sm-2 submit">
90 <button type="submit" id="wpsc_guest_reply_btn" style="width:100%; <?php echo esc_attr($reply_btn_css) ?>" class="btn"><?php _e('Reply','supportcandy')?></button>
91 </div>
92 <input type="file" id="attachment_upload" class="hidden" onchange="">
93 <input type="hidden" name="ticket_id" value="<?php echo esc_attr($ticket_id)?>">
94 <input type="hidden" name="nonce" value="<?php echo wp_create_nonce($ticket_id)?>">
95 </form>
96 </div>
97
98 <script>
99 function wpsc_post_reply(){
100 var email = jQuery('#wpsc_guest_email').val().trim();
101 if(email.length>0 && !validateEmail(email)) {
102 alert("<?php _e('Incorrect email address!','supportcandy')?>");
103 return false;
104 }
105 var description = '';
106 <?php
107 $wpsc_allow_rich_text_editor = get_option('wpsc_allow_rich_text_editor');
108 $flag = false;
109 $rich_editing = $wpscfunction->rich_editing_status($current_user);
110 if((in_array('register_user',$wpsc_allow_rich_text_editor) && !$current_user->has_cap('wpsc_agent')) && $rich_editing){
111 $flag = true;
112 }elseif($current_user->has_cap('wpsc_agent') && $rich_editing){
113 $flag = true;
114 }elseif( !is_user_logged_in() && in_array('guest_user',$wpsc_allow_rich_text_editor)){
115 $flag = true;
116 }
117
118 if($flag) {
119 ?>
120 var description = tinyMCE.activeEditor.getContent().trim();
121 if(description.length==0){
122 alert('<?php _e('Description empty!','supportcandy')?>');
123 return;
124 }
125 <?php
126 }else{
127 ?>
128
129 var description = jQuery('#wpsc_reply_box').val().trim();
130 if(description.length==0){
131 alert('<?php _e('Description empty!','supportcandy')?>');
132 return;
133 }
134 <?php
135 }?>
136
137 <?php
138 if($wpsc_allow_reply_confirmation){?>
139 if(!confirm('<?php _e('Are you sure?','supportcandy')?>')) return;
140 <?php
141 }
142 ?>
143 var dataform = new FormData(jQuery('#wpsc_frm_tkt_reply')[0]);
144 dataform.append('action','wpsc_tickets');
145 dataform.append('setting_action','submit_reply');
146 dataform.append('reply_body',description);
147 jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html);
148 jQuery.ajax({
149 url: wpsc_admin.ajax_url,
150 type: 'POST',
151 data: dataform,
152 processData: false,
153 contentType: false
154 })
155 .done(function (response_str) {
156 window.location.reload();
157 });
158 }
159
160 function wpsc_attachment_upload(id,name){
161 jQuery('#attachment_upload').unbind('change');
162 jQuery('#attachment_upload').on('change', function(){
163 var flag = false;
164 var file = this.files[0];
165 jQuery('#attachment_upload').val('');
166 var file_name_split = file.name.split('.');
167 var file_extension = file_name_split[file_name_split.length-1];
168 var allowedExtension = ['exe', 'php'];
169 file_extension = file_extension.toLowerCase();
170 <?php
171 $attachment = get_option('wpsc_allow_attachment_type');
172 $attachment_data = explode(',' , $attachment);
173 $attachment_data = array_map('trim', $attachment_data);
174 $attachment_data = array_map('strtolower', $attachment_data);
175 ?>
176 var allowedExtensionSetting = [<?php echo '"'.implode('","', $attachment_data).'"' ?>];
177
178 if(!flag && (jQuery.inArray(file_extension,allowedExtensionSetting) <= -1 || jQuery.inArray(file_extension,allowedExtension) > -1)) {
179 flag = true;
180 alert("<?php _e('Attached file type not allowed!','supportcandy')?>");
181 }
182
183 var current_filesize=file.size/1000000;
184 if(current_filesize><?php echo esc_attr($wpsc_attachment_max_filesize)?>){
185 flag = true;
186 alert('<?php echo sprintf( __('File size exceeds allowed limit (%1$s MB)!','supportcandy'), $wpsc_attachment_max_filesize );?>');
187 }
188
189 if(!flag){
190
191 var html_str = '<div class="row wpsc_attachment">'+
192 '<div class="progress" style="float: none !important; width: unset !important;">'+
193 '<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%">'+
194 file.name+
195 '</div>'+
196 '</div>'+
197 '<img onclick="attachment_cancel(this);" class="attachment_cancel" src="<?php echo esc_url(WPSC_PLUGIN_URL.'asset/images/close.png')?>" style="display:none;" />'+
198 '</div>';
199
200 jQuery('#'+id).append(html_str);
201
202 var attachment = jQuery('#'+id).find('.wpsc_attachment').last();
203
204 var data = new FormData();
205 data.append('file',file);
206 data.append('arr_name',name);
207 data.append('action','wpsc_tickets');
208 data.append('setting_action','upload_file');
209 data.append('_ajax_nonce', '<?php echo wp_create_nonce('upload_file')?>');
210
211 jQuery.ajax({
212 type : 'post',
213 url : wpsc_admin.ajax_url,
214 data : data,
215 xhr : function(){
216 var xhr = new window.XMLHttpRequest();
217 xhr.upload.addEventListener("progress", function(evt){
218 if (evt.lengthComputable) {
219 var percentComplete = Math.floor((evt.loaded / evt.total) * 100);
220 jQuery(attachment).find('.progress-bar').css('width',percentComplete+'%');
221 }
222 }, false);
223 return xhr;
224 },
225 processData: false,
226 contentType: false,
227 success : function(response){
228
229 var return_obj =JSON.parse(response);
230
231 jQuery(attachment).find('.attachment_cancel').show();
232
233 if(parseInt(return_obj.id) != 0){
234 jQuery(attachment).append('<input type="hidden" name="'+name+'[]" value="'+return_obj.id+'">');
235 jQuery(attachment).find('.progress-bar').addClass('progress-bar-success');
236 }else{
237 jQuery(attachment).find('.progress-bar').addClass('.progress-bar-danger');
238 }
239 }
240 });
241 }
242 });
243 jQuery('#attachment_upload').trigger('click');
244 }
245 </script>
246 <?php
247 endif;
248 ?>