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 / custom_fields / get_add_form_field.php

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

330 lines 12.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 $current_user, $wpscfunction;
7 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;}
8
9 $field_types = $wpscfunction->get_custom_field_types();
10 $conditional_types = array();
11 foreach ($field_types as $key => $field) {
12 if ($field['has_options']) {
13 $conditional_types[]=$key;
14 }
15 }
16
17 $rich_editing = $wpscfunction->rich_editing_status($current_user);
18 $directionality = $wpscfunction->check_rtl();
19
20 ob_start();
21 ?>
22 <div class="form-group">
23 <label for="wpsc_tf_label"><?php _e('Field Label','supportcandy');?></label>
24 <p class="help-block"><?php _e('Insert field label. Please make sure label you are entering should not already exist.','supportcandy');?></p>
25 <input id="wpsc_tf_label" class="form-control" name="wpsc_tf_label" value="" />
26 </div>
27 <div class="form-group">
28 <label for="wpsc_tf_extra_info"><?php _e('Extra Information','supportcandy');?></label>
29 <p class="help-block"><?php _e('Extra information about the field. Useful if you want to give instructions or information about the field in create ticket from. Keep this empty if not needed.','supportcandy');?></p>
30 <input id="wpsc_tf_extra_info" class="form-control" name="wpsc_tf_extra_info" value="" />
31 </div>
32 <div class="form-group">
33 <label for="wpsc_tf_personal_info"><?php _e('Personal Information','supportcandy');?></label>
34 <p class="help-block"><?php _e('Enable or disable personal information in ticket form.','supportcandy');?></p>
35 <select id="wpsc_tf_personal_info" class="form-control" name="wpsc_tf_personal_info">
36 <option value="0"><?php _e('No','supportcandy');?></option>
37 <option value="1"><?php _e('Yes','supportcandy');?></option>
38 </select>
39 </div>
40 <div class="form-group">
41 <label for="wpsc_tf_type"><?php _e('Field Type','supportcandy');?></label>
42 <p class="help-block"><?php _e('Select field type.','supportcandy');?></p>
43 <select id="wpsc_tf_type" class="form-control" name="wpsc_tf_type">
44 <?php foreach ($field_types as $key => $field) :?>
45 <option data-options="<?php echo esc_attr($field['has_options'])?>" value="<?php echo esc_attr($key)?>"><?php echo esc_attr($field['label'])?></option>
46 <?php endforeach;?>
47 </select>
48 </div>
49 <div id= "wpsc_placeholder_text" class="form-group" >
50 <label for="wpsc_tf_type"><?php _e('Placeholder Text','supportcandy');?></label>
51 <p class="help-block"><?php _e('Enter the placeholder text.','supportcandy');?></p>
52 <input id="wpsc_tf_placeholder_text" class="form-control" name="wpsc_tf_placeholder_text" value="" />
53 </div>
54 <div class="form-group" id="wpsc_tf_options_container" style="display:none;">
55 <label for="wpsc_tf_options"><?php _e('Field Options','supportcandy');?></label>
56 <p class="help-block"><?php _e('Insert field options. New option should begin on new line.','supportcandy');?></p>
57 <textarea style="height:80px !important;" id="wpsc_tf_options" class="form-control" name="wpsc_tf_options"></textarea>
58 </div>
59
60 <div class="form-group" id="wpsc_html_fields_container" style="display:none;">
61 <label for="wpsc_html_content"><?php _e('Content','supportcandy');?></label>
62 <p class="help-block"></p>
63 <?php if($rich_editing){?>
64 <div class="text-right">
65 <button id="visual" class="wpsc-switch-editor wpsc-switch-editor-active " type="button" onclick="wpsc_get_tinymce('wpsc_html_content','html_body');"><?php _e('Visual','supportcandy');?></button>
66 <button id="text" class="wpsc-switch-editor" type="button" onclick="wpsc_get_textarea('wpsc_html_content')"><?php _e('Text','supportcandy');?></button>
67 </div>
68 <?php } ?>
69
70 <textarea type="text" style="height:80px !important;" id="wpsc_html_content" class="form-control" name="wpsc_html_content"></textarea>
71 </div>
72
73 <div class="form-group" id="wpsc_time_fields_container" style="display:none;">
74 <label for="wpsc_time_content"><?php _e('Time Format','supportcandy');?></label>
75 <p class="help-block"><?php _e('Please select the time format','supportcandy'); ?></p>
76 <select id="wpsc_tf_time_format" class="form-control" name="wpsc_tf_time_format">
77 <option value="12"><?php _e('12 Hrs','supportcandy');?></option>
78 <option value="24"><?php _e('24 Hrs','supportcandy');?></option>
79 </select>
80 </div>
81
82 <div class="form-group" id="wpsc_required_field_container">
83 <label for="wpsc_tf_required"><?php _e('Required','supportcandy');?></label>
84 <p class="help-block"><?php _e('Whether this field is mandatory or optional. Yes indicates mandatory whereas no indicates optional.','supportcandy');?></p>
85 <select id="wpsc_tf_required" class="form-control" name="wpsc_tf_required">
86 <option value="1"><?php _e('Yes','supportcandy');?></option>
87 <option value="0"><?php _e('No','supportcandy');?></option>
88 </select>
89 </div>
90 <div class="form-group">
91 <label for="wpsc_tf_width"><?php _e('Width','supportcandy');?></label>
92 <p class="help-block"><?php _e('Please select width of the field in create ticket form.','supportcandy');?></p>
93 <select id="wpsc_tf_width" class="form-control" name="wpsc_tf_width">
94 <option value="1/3"><?php _e('1/3 width of Row','supportcandy');?></option>
95 <option value="1/2"><?php _e('Half width of Row','supportcandy');?></option>
96 <option value="1"><?php _e('Full width of Row','supportcandy');?></option>
97 </select>
98 </div>
99 <div class="form-group" id="wpsc_date_range_container" style="display:none;">
100 <label for="wpsc_date_range"><?php _e('Allowed Dates','supportcandy');?></label>
101 <p class="help-block"><?php _e('Please select Date range.','supportcandy');?></p>
102 <select id="wpsc_date_range" class="form-control" name="wpsc_date_range">
103 <option value="all"><?php _e('All','supportcandy');?></option>
104 <option value="past"><?php _e('Past','supportcandy');?></option>
105 <option value="future"><?php _e('Future','supportcandy');?></option>
106 <option value="range"><?php _e('Date range','supportcandy');?></option>
107 </select>
108 </div>
109
110 <div class="form-group" id="wpsc_date_range_option" style="display:none">
111 <label for="wpsc_date_range"><?php _e('Date Range','supportcandy');?></label>
112 <p class="help-block"><?php _e('Please select date range.','supportcandy');?></p>
113 <div class="row">
114 <div class="col-sm-6" style="padding-left:0">
115 <input type="text" autocomplete="off" class="form-control wpsc_dcf_rs" id="wpsc_dcf_from" value="" placeholder="<?php _e('From','supportcandy')?>">
116 </div>
117 <div class="col-sm-6" style="padding-right:0">
118 <input type="text" autocomplete="off" class="form-control wpsc_dcf_rs" id="wpsc_dcf_to" value="" placeholder="<?php _e('To','supportcandy')?>">
119 </div>
120 </div>
121 </div>
122
123 <div class="form-group" id = "wpsc_add_limit">
124 <label for="wpsc_tf_add_limit"><?php _e('Character Limit','supportcandy');?></label>
125 <p class="help-block"><?php _e('Limit number of characters to be accepted for this field. Enter 0 for unlimited characters.','supportcandy');?></p>
126 <input type = "number" id="wpsc_tf_add_limit" class="form-control" name="wpsc_tf_add_limit" value="" />
127 </div>
128 <div class="form-group">
129 <label for="wpsc_tf_form_visibility"><?php _e('Visibility','supportcandy');?></label>
130 <p class="help-block"><?php _e('Select conditions to show this field in create ticket form. Visible if no conditions set. Visible if any one of added conditions matches while creating ticket.','supportcandy');?></p>
131 <div class="row">
132 <ul id="wpsc_tf_condition_container" class="wpsp_filter_display_container"></ul>
133 </div>
134 <div class="row" style="background-color:#CCD1D1;padding-top:15px;padding-bottom:15px;">
135 <div class="col-sm-5">
136 <select id="wpsc_tf_vcf" class="form-control" onchange="wpsc_get_conditional_options(this);" name="wpsc_tf_vcf">
137 <option value=""><?php _e('Select field','supportcandy');?></option>
138 <?php
139 $fields = get_terms([
140 'taxonomy' => 'wpsc_ticket_custom_fields',
141 'hide_empty' => false,
142 'orderby' => 'meta_value_num',
143 'meta_key' => 'wpsc_tf_load_order',
144 'order' => 'ASC',
145 'meta_query' => array(
146 'relation' => 'AND',
147 array(
148 'key' => 'agentonly',
149 'value' => '0',
150 'compare' => '='
151 ),
152 array(
153 'relation' => 'OR',
154 array(
155 'key' => 'wpsc_tf_type',
156 'value' => $conditional_types,
157 'compare' => 'IN'
158 ),
159 array(
160 'key' => 'wpsc_tf_conditional',
161 'value' => '1',
162 'compare' => '='
163 )
164 )
165 ),
166 ]);
167 foreach ($fields as $field) {
168 $label = get_term_meta( $field->term_id, 'wpsc_tf_label', true);
169 ?>
170 <option value="<?php echo esc_attr($field->term_id)?>"><?php echo esc_attr($label)?></option>
171 <?php
172 }
173 ?>
174 </select>
175 </div>
176 <div class="col-sm-5">
177 <select id="wpsc_tf_vco" class="form-control" name="wpsc_tf_vco">
178 <option value=""><?php _e('Select option','supportcandy');?></option>
179 </select>
180 </div>
181 <div class="col-sm-2">
182 <button type="button" class="form-control btn btn-success" onclick="wpsc_add_field_condition();"><?php _e('Add','supportcandy');?></button>
183 </div>
184 </div>
185 </div>
186 <script>
187 jQuery('#wpsc_tf_type').change(function(){
188 var has_options = jQuery('option:selected',this).data('options');
189 var option = Number(jQuery(this).val());
190
191 if(has_options=='1'){
192 jQuery('#wpsc_tf_options_container').show();
193 } else {
194 jQuery('#wpsc_tf_options_container').hide();
195 }
196
197 if(option == 22){
198 jQuery('#wpsc_html_fields_container').show();
199 jQuery('#wpsc_required_field_container').hide();
200 }else{
201 jQuery('#wpsc_html_fields_container').hide();
202 }
203
204 if(option == 21){
205 jQuery('#wpsc_time_fields_container').show();
206 }else{
207 jQuery('#wpsc_time_fields_container').hide();
208 }
209
210 var opt_arr = [1,5,7,8,9];
211 if ( jQuery.inArray( option, opt_arr) >= 0) {
212 jQuery('#wpsc_add_limit').show();
213 }else{
214 jQuery('#wpsc_add_limit').hide();
215 }
216
217 var poption = Number(jQuery(this).val());
218 var popt_arr = [1,5,6,7,8,9,18];
219 if ( jQuery.inArray( poption, popt_arr) >= 0) {
220 jQuery('#wpsc_placeholder_text').show();
221 }else{
222 jQuery('#wpsc_placeholder_text').hide();
223 }
224 var poption = Number(jQuery(this).val());
225 var popt_arr = [6];
226 if ( jQuery.inArray( poption, popt_arr) >= 0) {
227 jQuery('#wpsc_date_range_container').show();
228 }else{
229 jQuery('#wpsc_date_range_container').hide();
230 }
231
232
233 });
234 </script>
235
236 <?php if($rich_editing){ ?>
237 <script>
238 tinymce.remove();
239 tinymce.init({
240 selector:'#wpsc_html_content',
241 body_id: 'html_body',
242 menubar: false,
243 statusbar: false,
244 height : '200',
245 plugins: [
246 'lists link image directionality'
247 ],
248 image_advtab: true,
249 toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image',
250 branding: false,
251 autoresize_bottom_margin: 20,
252 browser_spellcheck : true,
253 relative_urls : false,
254 remove_script_host : false,
255 convert_urls : true,
256 setup: function (editor) {
257 }
258 });
259 function wpsc_get_tinymce(selector,body_id){
260
261 jQuery('#visual_header').addClass('btn btn-primary visual_header');
262 jQuery('#text_header').removeClass('btn btn-primary text_header');
263 jQuery('#text_header').addClass('btn btn-default text_header');
264 jQuery('#text').removeClass('wpsc-switch-editor-active');
265 jQuery('#visual').addClass('wpsc-switch-editor-active');
266 tinymce.init({
267 selector:'#'+selector,
268 body_id: body_id,
269 menubar: false,
270 statusbar: false,
271 height : '200',
272 plugins: [
273 'lists link image directionality'
274 ],
275 image_advtab: true,
276 toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image',
277 branding: false,
278 autoresize_bottom_margin: 20,
279 browser_spellcheck : true,
280 relative_urls : false,
281 remove_script_host : false,
282 convert_urls : true,
283 setup: function (editor) {
284 }
285 });
286 }
287
288 function wpsc_get_textarea(selector){
289
290 jQuery('#visual_body').removeClass('btn btn-primary visual_body');
291 jQuery('#visual_body').addClass('btn btn-default visual_body');
292 jQuery('#text_body').addClass('btn btn-primary text_body');
293 tinymce.remove('#'+selector);
294 jQuery('#text').addClass('wpsc-switch-editor-active');
295 jQuery('#visual').removeClass('wpsc-switch-editor-active');
296 }
297
298 jQuery('#wpsc_date_range').on('change', function() {
299 if(this.value == 'range'){
300 jQuery('#wpsc_date_range_option').show();
301 }else{
302 jQuery('#wpsc_date_range_option').hide();
303 }
304 });
305
306 jQuery(".wpsc_dcf_rs").datepicker({
307 dateFormat : '<?php echo esc_attr(get_option('wpsc_calender_date_format'))?>',
308 showAnim : 'slideDown',
309 changeMonth: true,
310 changeYear: true,
311 yearRange: "-100:+100"
312 });
313 </script>
314 <?php }?>
315 <?php
316 $body = ob_get_clean();
317 ob_start();
318 ?>
319 <button type="button" class="btn wpsc_popup_close" onclick="wpsc_modal_close();"><?php _e('Close','supportcandy');?></button>
320 <button type="button" class="btn wpsc_popup_action" onclick="wpsc_set_add_form_field();"><?php _e('Submit','supportcandy');?></button>
321 <?php
322 $footer = ob_get_clean();
323
324 $output = array(
325 'body' => $body,
326 'footer' => $footer
327 );
328
329 wp_send_json($output);
330