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

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

145 lines 4.7 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 $agent_role = get_option('wpsc_agent_role');
12
13 ?>
14 <h4>
15 <?php _e('Agent Roles','supportcandy');?>
16 <button style="margin-left:10px;" class="btn btn-success btn-sm" onclick="wpsc_get_add_agent_role();"><?php _e('+Add New','supportcandy');?></button>
17 </h4>
18
19 <div class="wpsc_padding_space"></div>
20
21 <ul class="wpsc-sortable">
22 <?php foreach ( $agent_role as $key => $val ) :?>
23 <li class="ui-state-default">
24 <div class="wpsc-flex-container" style="background-color:#1E90FF;color:#fff;">
25 <div class="wpsc-sortable-label"><?php echo esc_attr($val['label'])?></div>
26 <div class="wpsc-sortable-edit" onclick="wpsc_get_edit_agent_role(<?php echo esc_attr($key)?>);" style="margin-left:40px;"><i class="fa fa-edit"></i></div>
27 <div class="wpsc-sortable-delete" onclick="wpsc_delete_agent_role(<?php echo esc_attr($key)?>);"><i class="fa fa-trash"></i></div>
28 </div>
29 </li>
30 <?php endforeach;?>
31 </ul>
32
33 <script>
34
35 function wpsc_get_add_agent_role(){
36 wpsc_modal_open(wpsc_admin.add_new_role);
37 var data = {
38 action: 'wpsc_settings',
39 setting_action : 'get_add_agent_role'
40 };
41 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
42 jQuery('#wpsc_popup_body').html(response.body);
43 jQuery('#wpsc_popup_footer').html(response.footer);
44 jQuery('#wpsc_cat_name').focus();
45 });
46 }
47
48 function wpsc_set_add_agent_role(){
49 var label = jQuery('#wpsc_role_label').val().trim();
50 if (label.length == 0) {
51 jQuery('#wpsc_role_label').val('').focus();
52 return;
53 }
54 var dataform = new FormData(jQuery('#wpsc_frm_agent_role')[0]);
55 jQuery.ajax({
56 url: wpsc_admin.ajax_url,
57 type: 'POST',
58 data: dataform,
59 processData: false,
60 contentType: false
61 })
62 .done(function (response_str) {
63 wpsc_modal_close();
64 var response = JSON.parse(response_str);
65 if (response.sucess_status=='1') {
66 wpsc_get_agent_roles();
67 } else {
68 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
69 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
70 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
71 }
72 });
73 }
74
75 function wpsc_get_edit_agent_role(role_id){
76 wpsc_modal_open(wpsc_admin.edit_agent_role);
77 var data = {
78 action: 'wpsc_settings',
79 setting_action : 'get_edit_agent_role',
80 role_id : role_id
81 };
82 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
83 jQuery('#wpsc_popup_body').html(response.body);
84 jQuery('#wpsc_popup_footer').html(response.footer);
85 jQuery('#wpsc_priority_name').focus();
86 });
87 }
88
89 function wpsc_set_edit_agent_role(){
90 var label = jQuery('#wpsc_role_label').val().trim();
91 if (label.length == 0) {
92 jQuery('#wpsc_role_label').val('').focus();
93 return;
94 }
95 var dataform = new FormData(jQuery('#wpsc_frm_agent_role')[0]);
96 jQuery.ajax({
97 url: wpsc_admin.ajax_url,
98 type: 'POST',
99 data: dataform,
100 processData: false,
101 contentType: false
102 })
103 .done(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_agent_roles();
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_delete_agent_role(role_id){
120 var flag = confirm(wpsc_admin.are_you_sure);
121 if (flag) {
122 var data = {
123 action: 'wpsc_settings',
124 setting_action : 'delete_agent_role',
125 role_id : role_id,
126 _ajax_nonce: '<?php echo wp_create_nonce('delete_agent_role')?>'
127 };
128 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
129 var response = JSON.parse(response_str);
130 if (response.sucess_status=='1') {
131 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
132 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
133 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
134 wpsc_get_agent_roles();
135 } else {
136 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
137 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
138 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
139 }
140 });
141 }
142 }
143
144 </script>
145