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_edit_agentonly_field.php

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

192 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
6 global $current_user, $wpscfunction;
7 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;}
8
9 $field_id = isset($_POST) && isset($_POST['field_id']) ? intval($_POST['field_id']) : 0;
10 if (!$field_id) {exit;}
11
12 $custom_field = get_term_by('id', $field_id, 'wpsc_ticket_custom_fields');
13
14 $wpsc_tf_label = get_term_meta( $custom_field->term_id, 'wpsc_tf_label', true);
15 $wpsc_tf_extra_info = get_term_meta( $custom_field->term_id, 'wpsc_tf_extra_info', true);
16 $wpsc_tf_type = get_term_meta( $custom_field->term_id, 'wpsc_tf_type', true);
17 $wpsc_tf_has_options = 0;
18 $wpsc_tf_options = get_term_meta( $custom_field->term_id, 'wpsc_tf_options', true);
19 $wpsc_tf_personal_info = get_term_meta( $custom_field->term_id, 'wpsc_tf_personal_info', true);
20 $wpsc_tf_limit = get_term_meta( $custom_field->term_id, 'wpsc_tf_limit',true);
21 $wpsc_date_range = get_term_meta($custom_field->term_id, 'wpsc_date_range', true);
22 $date_range_from = get_term_meta( $custom_field->term_id, 'date_range_from', true);
23 $date_range_to = get_term_meta( $custom_field->term_id, 'date_range_to', true);
24 $wpsc_time_format = get_term_meta($custom_field->term_id, 'wpsc_time_format', true);
25 $tf_types = array(1,5,7,8,9);
26 $style = '';
27 if(!in_array($wpsc_tf_type,$tf_types)){
28 $style = "display:none";
29 }
30
31 // date range
32 $wpsc_date_field = 0 ;
33 if($wpsc_tf_type == '6' ){
34 $wpsc_date_field = 1;
35 }
36
37 $field_types = $wpscfunction->get_custom_field_types();
38
39 //time field
40 $wpsc_time_field = 0;
41 if ($wpsc_tf_type == '21') {
42 $wpsc_time_field = 1;
43 }
44
45 ob_start();
46 ?>
47 <div class="form-group">
48 <label for="wpsc_tf_label"><?php _e('Field Label','supportcandy');?></label>
49 <p class="help-block"><?php _e('Insert field label. Please make sure label you are entering should not already exist.','supportcandy');?></p>
50 <input id="wpsc_tf_label" class="form-control" name="wpsc_tf_label" value="<?php echo esc_attr($wpsc_tf_label)?>" />
51 </div>
52 <div class="form-group">
53 <label for="wpsc_tf_extra_info"><?php _e('Extra Information','supportcandy');?></label>
54 <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>
55 <input id="wpsc_tf_extra_info" class="form-control" name="wpsc_tf_extra_info" value="<?php echo esc_attr($wpsc_tf_extra_info)?>" />
56 </div>
57 <div class="form-group">
58 <label for="wpsc_tf_personal_info"><?php _e('Personal Information','supportcandy');?></label>
59 <p class="help-block"><?php _e('Enable or disable personal information in ticket form.','supportcandy');?></p>
60 <select id="wpsc_tf_personal_info" class="form-control" name="wpsc_tf_personal_info">
61 <option <?php echo esc_attr($wpsc_tf_personal_info) == '1' ? 'selected="selected"' : ''?> value="1"><?php _e('Yes','supportcandy');?></option>
62 <option <?php echo esc_attr($wpsc_tf_personal_info) == '0' ? 'selected="selected"' : ''?> value="0"><?php _e('No','supportcandy');?></option>
63 </select>
64 </div>
65 <div class="form-group">
66 <label for="wpsc_tf_type"><?php _e('Field Type','supportcandy');?></label>
67 <p class="help-block"><?php _e('Select field type.','supportcandy');?></p>
68 <select id="wpsc_tf_type" class="form-control" name="wpsc_tf_type">
69 <?php foreach ($field_types as $key => $field) :
70 if($key == 22) continue;
71 $selected = $wpsc_tf_type == $key ? 'selected="selected"' : '';
72 if ($wpsc_tf_type == $key && $field['has_options']) {
73 $wpsc_tf_has_options = 1;
74 }
75 ?>
76 <option <?php echo esc_attr($selected)?> data-options="<?php echo esc_attr($field['has_options'])?>" value="<?php echo esc_attr($key)?>"><?php echo esc_attr($field['label'])?></option>
77 <?php endforeach;?>
78 </select>
79 </div>
80
81 <?php $display = !$wpsc_tf_has_options ?'display:none;':'';?>
82 <div class="form-group" id="wpsc_tf_options_container" style="<?php echo esc_attr($display);?>">
83 <label for="wpsc_tf_options"><?php _e('Field Options','supportcandy');?></label>
84 <p class="help-block"><?php _e('Insert field options. New option should begin on new line.','supportcandy');?></p>
85 <textarea style="height:80px !important;" id="wpsc_tf_options" class="form-control" name="wpsc_tf_options"><?php echo stripcslashes(esc_textarea(implode('\n', $wpsc_tf_options)));?></textarea>
86 </div>
87
88 <div class="form-group wpsc_edit_limit" id = "wpsc_add_limit" style = "<?php echo esc_attr($style);?>">
89 <label for="wpsc_tf_limit"><?php _e('Character Limit','supportcandy');?></label>
90 <p class="help-block"><?php _e('Limit number of characters to be accepted for this field. Enter 0 for unlimited characters.','supportcandy');?></p>
91 <input type = "number" id="wpsc_ao_limit" class="form-control" name="wpsc_ao_limit" value="<?php echo esc_attr($wpsc_tf_limit)?>" />
92 </div>
93
94 <?php $display = !$wpsc_time_field ? 'display:none;':'';?>
95 <div class="form-group" id="wpsc_time_fields_container" style="<?php echo esc_attr($display);?>">
96 <label for="wpsc_time_content"><?php _e('Time Format','supportcandy');?></label>
97 <p class="help-block"><?php _e('Please select the time format','supportcandy'); ?></p>
98 <select id="wpsc_tf_time_format" class="form-control" name="wpsc_tf_time_format">
99 <option <?php echo esc_attr($wpsc_time_format) == '12' ? 'selected="selected"' : ''?> value="12hrs"><?php _e('12 Hrs','supportcandy');?></option>
100 <option <?php echo esc_attr($wpsc_time_format) == '24' ? 'selected="selected"' : ''?> value="24hrs"><?php _e('24 Hrs','supportcandy');?></option>
101 </select>
102 </div>
103
104 <?php $display = !$wpsc_date_field ?'display:none;':'';?>
105 <div class="form-group" id="wpsc_date_range_container" style="<?php echo esc_attr($display);?>">
106 <label for="wpsc_date_range"><?php _e('Allowed Dates','supportcandy');?></label>
107 <p class="help-block"><?php _e('Please select date range.','supportcandy');?></p>
108 <select id="wpsc_date_range" class="form-control" name="wpsc_date_range">
109 <option <?php echo esc_attr($wpsc_date_range) == 'all' ? 'selected="selected"' : ''?> value="all"><?php _e('All','supportcandy');?></option>
110 <option <?php echo esc_attr($wpsc_date_range) == 'past' ? 'selected="selected"' : ''?> value="past"><?php _e('Past','supportcandy');?></option>
111 <option <?php echo esc_attr($wpsc_date_range) == 'future' ? 'selected="selected"' : ''?> value="future"><?php _e('Future','supportcandy');?></option>
112 <option <?php echo esc_attr($wpsc_date_range) == 'range' ? 'selected="selected"' : ''?> value="range"><?php _e('Date range','supportcandy');?></option>
113 </select>
114 </div>
115
116 <div class="form-group" id="wpsc_date_range_option" style="<?php echo esc_attr($wpsc_date_range) != 'range' ? 'display:none;':'';?>">
117 <label for="wpsc_date_range"><?php _e('Date Range','supportcandy');?></label>
118 <p class="help-block"><?php _e('Please select date range.','supportcandy');?></p>
119 <div class="row">
120 <div class="col-sm-6" style="padding-left:0">
121 <input type="text" autocomplete="off" class="form-control wpsc_dcf_rs" id="wpsc_dcf_from" value="<?php echo esc_attr($date_range_from) ?>" placeholder="<?php _e('From','supportcandy')?>">
122 </div>
123 <div class="col-sm-6" style="padding-right:0">
124 <input type="text" autocomplete="off" class="form-control wpsc_dcf_rs" id="wpsc_dcf_to" value="<?php echo esc_attr($date_range_to) ?>" placeholder="<?php _e('To','supportcandy')?>">
125 </div>
126 </div>
127 </div>
128
129 <script>
130 jQuery('#wpsc_tf_type').change(function(){
131 var has_options = jQuery('option:selected',this).data('options');
132 if(has_options=='1'){
133 jQuery('#wpsc_tf_options_container').show();
134 } else {
135 jQuery('#wpsc_tf_options_container').hide();
136 }
137
138 var option = Number(jQuery(this).val());
139 var opt_arr = [1,5,7,8,9];
140 if ( jQuery.inArray( option, opt_arr) >= 0) {
141 jQuery('#wpsc_ao_limit').show();
142 }else{
143 jQuery('#wpsc_ao_limit').hide();
144 }
145
146 var poption = Number(jQuery(this).val());
147 var popt_arr = [6];
148 if ( jQuery.inArray( poption, popt_arr) >= 0) {
149 jQuery('#wpsc_date_range_container').show();
150 }else{
151 jQuery('#wpsc_date_range_container').hide();
152 }
153
154 if(option == 21){
155 jQuery('#wpsc_time_fields_container').show();
156 }else{
157 jQuery('#wpsc_time_fields_container').hide();
158 }
159 });
160
161 jQuery('#wpsc_date_range').on('change', function() {
162 if(this.value == 'range'){
163 jQuery('#wpsc_date_range_option').show();
164 }else{
165 jQuery('#wpsc_date_range_option').hide();
166 }
167 });
168
169 jQuery(".wpsc_dcf_rs").datepicker({
170 dateFormat : '<?php echo esc_attr(get_option('wpsc_calender_date_format'))?>',
171 showAnim : 'slideDown',
172 changeMonth: true,
173 changeYear: true,
174 yearRange: "-100:+100"
175 });
176 </script>
177 <?php
178 $body = ob_get_clean();
179 ob_start();
180 ?>
181 <button type="button" class="btn wpsc_popup_close" onclick="wpsc_modal_close();"><?php _e('Close','supportcandy');?></button>
182 <button type="button" class="btn wpsc_popup_action" onclick="wpsc_set_edit_agentonly_field(<?php echo esc_attr($field_id)?>);"><?php _e('Submit','supportcandy');?></button>
183 <?php
184 $footer = ob_get_clean();
185
186 $output = array(
187 'body' => $body,
188 'footer' => $footer
189 );
190
191 wp_send_json($output);
192