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 / settings / get_status_settings.php

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

197 lines 7.1 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, $wpdb;
7 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {
8 exit;
9 }
10
11 $statuses = get_terms([
12 'taxonomy' => 'wpsc_statuses',
13 'hide_empty' => false,
14 'orderby' => 'meta_value_num',
15 'order' => 'ASC',
16 'meta_query' => array('order_clause' => array('key' => 'wpsc_status_load_order')),
17 ]);
18
19 ?>
20 <h4>
21 <?php _e('Ticket Statuses','supportcandy');?>
22 <button style="margin-left:10px;" class="btn btn-success btn-sm" onclick="wpsc_get_add_status();"><?php _e('+Add New','supportcandy');?></button>
23 </h4>
24
25 <div class="wpsc_padding_space"></div>
26
27 <ul class="wpsc-sortable">
28 <?php foreach ( $statuses as $status ) :
29 $color = get_term_meta( $status->term_id, 'wpsc_status_color', true);
30 $backgound_color = get_term_meta( $status->term_id, 'wpsc_status_background_color', true);
31 ?>
32 <li class="ui-state-default" data-id="<?php echo esc_attr($status->term_id)?>">
33 <div class="wpsc-flex-container" style="background-color:<?php echo esc_attr($backgound_color)?>;color:<?php echo esc_attr($color)?>;">
34 <div class="wpsc-sortable-handle"><i class="fa fa-bars"></i></div>
35 <div class="wpsc-sortable-label"><?php echo esc_attr($status->name)?></div>
36 <div class="wpsc-sortable-edit" onclick="wpsc_get_edit_status(<?php echo esc_attr($status->term_id)?>);"><i class="fa fa-edit"></i></div>
37 <div class="wpsc-sortable-delete" onclick="wpsc_delete_status(<?php echo esc_attr($status->term_id)?>);"><i class="fa fa-trash"></i></div>
38 </div>
39 </li>
40 <?php endforeach;?>
41 </ul>
42
43 <script>
44
45 jQuery(function(){
46 jQuery( ".wpsc-sortable" ).sortable({ handle: '.wpsc-sortable-handle' });
47 jQuery( ".wpsc-sortable" ).on("sortupdate",function(event,ui){
48 var ids = jQuery(this).sortable( "toArray", {attribute: 'data-id'} );
49 var data = {
50 action: 'wpsc_settings',
51 setting_action : 'set_status_order',
52 status_ids : ids,
53 _ajax_nonce: '<?php echo wp_create_nonce('set_status_order')?>'
54 };
55 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
56 var response = JSON.parse(response_str);
57 if (response.sucess_status=='1') {
58 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
59 }
60 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
61 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
62 });
63 });
64 });
65
66 function wpsc_get_add_status(){
67 wpsc_modal_open(wpsc_admin.add_new_status);
68 var data = {
69 action: 'wpsc_settings',
70 setting_action : 'get_add_status'
71 };
72 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
73 jQuery('#wpsc_popup_body').html(response.body);
74 jQuery('#wpsc_popup_footer').html(response.footer);
75 jQuery('#wpsc_cat_name').focus();
76 });
77 }
78
79 function wpsc_set_add_status(){
80 var status_name = jQuery('#wpsc_status_name').val().trim();
81 if (status_name.length == 0) {
82 jQuery('#wpsc_status_name').val('').focus();
83 return;
84 }
85 var status_color = jQuery('#wpsc_status_color').val().trim();
86 if (status_color.length == 0) {
87 status_color = '#ffffff';
88 }
89 var status_bg_color = jQuery('#wpsc_status_bg_color').val().trim();
90 if (status_bg_color.length == 0) {
91 status_bg_color = '#1E90FF';
92 }
93 jQuery('.wpsc_popup_action').text('<?php _e('Please wait ...','supportcandy')?>');
94 jQuery('.wpsc_popup_action, #wpsc_popup_body input').attr("disabled", "disabled");
95 var data = {
96 action: 'wpsc_settings',
97 setting_action : 'set_add_status',
98 status_name : status_name,
99 status_color: status_color,
100 status_bg_color: status_bg_color,
101 _ajax_nonce: '<?php echo wp_create_nonce('set_add_status')?>'
102 };
103 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
104 wpsc_modal_close();
105 var response = JSON.parse(response_str);
106 if (response.sucess_status=='1') {
107 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
108 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
109 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
110 wpsc_get_status_settings();
111 } else {
112 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
113 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
114 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
115 }
116 });
117 }
118
119 function wpsc_get_edit_status(status_id){
120 wpsc_modal_open(wpsc_admin.edit_status);
121 var data = {
122 action: 'wpsc_settings',
123 setting_action : 'get_edit_status',
124 status_id : status_id
125 };
126 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
127 jQuery('#wpsc_popup_body').html(response.body);
128 jQuery('#wpsc_popup_footer').html(response.footer);
129 jQuery('#wpsc_status_name').focus();
130 });
131 }
132
133 function wpsc_set_edit_status(status_id){
134 var status_name = jQuery('#wpsc_status_name').val().trim();
135 if (status_name.length == 0) {
136 jQuery('#wpsc_status_name').val('').focus();
137 return;
138 }
139 var status_color = jQuery('#wpsc_status_color').val().trim();
140 if (status_color.length == 0) {
141 status_color = '#ffffff';
142 }
143 var status_bg_color = jQuery('#wpsc_status_bg_color').val().trim();
144 if (status_bg_color.length == 0) {
145 status_bg_color = '#1E90FF';
146 }
147 jQuery('.wpsc_popup_action').text('<?php _e('Please wait ...','supportcandy')?>');
148 jQuery('.wpsc_popup_action, #wpsc_popup_body input').attr("disabled", "disabled");
149 var data = {
150 action: 'wpsc_settings',
151 setting_action : 'set_edit_status',
152 status_id : status_id,
153 status_name : status_name,
154 status_color: status_color,
155 status_bg_color: status_bg_color,
156 _ajax_nonce: '<?php echo wp_create_nonce('set_edit_status')?>'
157 };
158 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
159 wpsc_modal_close();
160 var response = JSON.parse(response_str);
161 if (response.sucess_status=='1') {
162 wpsc_get_status_settings();
163 } else {
164 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
165 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
166 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
167 }
168 });
169 }
170
171 function wpsc_delete_status(status_id){
172 var flag = confirm(wpsc_admin.are_you_sure);
173 if (flag) {
174 var data = {
175 action: 'wpsc_settings',
176 setting_action : 'delete_status',
177 status_id : status_id,
178 _ajax_nonce: '<?php echo wp_create_nonce('delete_status')?>'
179 };
180 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
181 var response = JSON.parse(response_str);
182 if (response.sucess_status=='1') {
183 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
184 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
185 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
186 wpsc_get_status_settings();
187 } else {
188 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
189 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
190 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
191 }
192 });
193 }
194 }
195
196 </script>
197