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 / support_agents / get_support_agents.php

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

173 lines 5.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, $wpdb;
7 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {
8 exit;
9 }
10
11 $agents = get_terms([
12 'taxonomy' => 'wpsc_agents',
13 'hide_empty' => false,
14 'meta_query' => array(
15 array(
16 'key' => 'agentgroup',
17 'value' => '0',
18 'compare' => '='
19 )
20 )
21 ]);
22
23 $agent_role = get_option('wpsc_agent_role');
24
25 ?>
26 <h4>
27 <?php _e('Support Agents','supportcandy');?>
28 <button style="margin-left:10px;" class="btn btn-success btn-sm" id="wpsc_add_new_support_agent_btn" onclick="wpsc_get_add_support_agent();"><?php _e('+Add New','supportcandy');?></button>
29 </h4>
30
31 <div class="wpsc_padding_space"></div>
32
33 <table class="table table-striped table-hover">
34 <tr>
35 <th><?php _e('Agent Name','supportcandy')?></th>
36 <th><?php _e('Email','supportcandy')?></th>
37 <th><?php _e('Role','supportcandy')?></th>
38 <th><?php _e('Actions','supportcandy')?></th>
39 </tr>
40 <?php foreach ( $agents as $agent ) :
41 $agent_name = get_term_meta( $agent->term_id, 'label', true);
42 $role_id = get_term_meta( $agent->term_id, 'role', true);
43 $email = get_term_meta( $agent->term_id, 'email', true);
44 ?>
45 <tr>
46 <td><?php echo esc_attr($agent_name)?></td>
47 <td><?php echo esc_attr($email);?></td>
48 <td><?php echo esc_attr($agent_role[$role_id]['label'])?></td>
49 <td>
50 <div class="wpsc_flex">
51 <div onclick="wpsc_get_edit_support_agent(<?php echo esc_attr($agent->term_id);?>);" style="cursor:pointer;"><i class="fa fa-edit"></i></div>
52 <div onclick="wpsc_delete_support_agent(<?php echo esc_attr($agent->term_id);?>);" style="cursor:pointer; padding-left: 10px;"><i class="fa fa-trash"></i></div>
53 <?php do_action('wpsc_support_agent_add_action', $agent); ?>
54 </div>
55 </td>
56 </tr>
57 <?php endforeach;?>
58 </table>
59
60 <script>
61
62 function wpsc_get_add_support_agent(){
63 wpsc_modal_open(wpsc_admin.add_new_agent);
64 var data = {
65 action: 'wpsc_support_agents',
66 setting_action : 'get_add_support_agent'
67 };
68 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
69 jQuery('#wpsc_popup_body').html(response.body);
70 jQuery('#wpsc_popup_footer').html(response.footer);
71 jQuery('#wpsc_cat_name').focus();
72 });
73 }
74
75 function wpsc_set_add_support_agent(){
76 var agent_name = jQuery('#wpsc_agent_name').val().trim();
77 if (agent_name.length == 0) {
78 jQuery('#wpsc_agent_name').val('').focus();
79 return;
80 }
81 var agent_id = jQuery('#wpsc_agent_id').val().trim();
82 if (!agent_id) {
83 jQuery('#wpsc_agent_name').focus();
84 return;
85 }
86 var agent_role = jQuery('#wpsc_agent_role').val();
87
88 jQuery('.wpsc_popup_action').text('<?php _e('Please wait ...','supportcandy')?>');
89 jQuery('.wpsc_popup_action, #wpsc_popup_body input').attr("disabled", "disabled");
90 var data = {
91 action: 'wpsc_support_agents',
92 setting_action : 'set_add_support_agent',
93 agent_name : agent_name,
94 agent_id : agent_id,
95 agent_role : agent_role,
96 _ajax_nonce: '<?php echo wp_create_nonce('set_add_support_agent')?>'
97 };
98 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
99 wpsc_modal_close();
100 var response = JSON.parse(response_str);
101 if (response.sucess_status=='1') {
102 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
103 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
104 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
105 wpsc_get_support_agents();
106 } else {
107 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
108 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
109 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
110 }
111 });
112 }
113
114 function wpsc_get_edit_support_agent(agent_id){
115 wpsc_modal_open(wpsc_admin.edit_agent);
116 var data = {
117 action: 'wpsc_support_agents',
118 setting_action : 'get_edit_support_agent',
119 agent_id : agent_id
120 };
121 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
122 jQuery('#wpsc_popup_body').html(response.body);
123 jQuery('#wpsc_popup_footer').html(response.footer);
124 jQuery('#wpsc_cat_name').focus();
125 });
126 }
127
128 function wpsc_set_edit_support_agent(agent_id){
129 var agent_role = jQuery('#wpsc_agent_role').val();
130 jQuery('.wpsc_popup_action').text('<?php _e('Please wait ...','supportcandy')?>');
131 jQuery('.wpsc_popup_action, #wpsc_popup_body input').attr("disabled", "disabled");
132 var data = {
133 action: 'wpsc_support_agents',
134 setting_action : 'set_edit_support_agent',
135 agent_id : agent_id,
136 agent_role : agent_role,
137 _ajax_nonce: '<?php echo wp_create_nonce('set_edit_support_agent')?>'
138 };
139 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
140 wpsc_modal_close();
141 wpsc_get_support_agents();
142 });
143 }
144
145 function wpsc_delete_support_agent(agent_id){
146
147 var flag = confirm(wpsc_admin.are_you_sure);
148 if (flag) {
149 var data = {
150 action: 'wpsc_support_agents',
151 setting_action : 'delete_support_agent',
152 agent_id : agent_id,
153 _ajax_nonce: '<?php echo wp_create_nonce('delete_support_agent')?>'
154 };
155 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
156 var response = JSON.parse(response_str);
157 if (response.sucess_status=='1') {
158 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
159 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
160 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
161 wpsc_get_support_agents();
162 } else {
163 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
164 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
165 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
166 }
167 });
168 }
169 }
170
171 <?php do_action( "wpsc_add_extra_script_support_agent" ); ?>
172 </script>
173