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 / tickets / ticket_list / load_list.php

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

252 lines 16.2 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 $wpdb, $current_user, $wpscfunction;
7
8 $blog_id = get_current_blog_id();
9
10 $filter = $wpscfunction->get_current_filter();
11 $saved_filters = get_user_meta($current_user->ID, $blog_id.'_wpsc_filter',true);
12 $saved_filters = $saved_filters ? $saved_filters : array();
13 $general_appearance = get_option('wpsc_appearance_general_settings');
14
15 $create_ticket_btn_css = 'background-color:'.$general_appearance['wpsc_crt_ticket_btn_action_bar_bg_color'].' !important;color:'.$general_appearance['wpsc_crt_ticket_btn_action_bar_text_color'].' !important;';
16 $action_default_btn_css = 'background-color:'.$general_appearance['wpsc_default_btn_action_bar_bg_color'].' !important;color:'.$general_appearance['wpsc_default_btn_action_bar_text_color'].' !important;';
17 $logout_btn_css = 'background-color:'.$general_appearance['wpsc_sign_out_bg_color'].' !important;color:'.$general_appearance['wpsc_sign_out_text_color'].' !important;';
18 $wpsc_show_and_hide_filters = get_option('wpsc_show_and_hide_filters');
19 $wpsc_appearance_ticket_list = get_option('wpsc_appearance_ticket_list');
20
21 $wpsc_on_and_off_auto_refresh = get_option('wpsc_on_and_off_auto_refresh');
22
23 //check allow create ticket permission
24 $wpsc_allow_to_create_ticket = get_option('wpsc_allow_to_create_ticket');
25 $allow_create = false;
26 if ($current_user->has_cap('wpsc_agent') ){
27 $cu_role_id = get_user_option('wpsc_agent_role', $current_user->ID);
28 if(in_array($cu_role_id, $wpsc_allow_to_create_ticket)){
29 $allow_create = true;
30 }
31 }else{
32 if(in_array('customer', $wpsc_allow_to_create_ticket)){
33 $allow_create = true;
34 }
35 }
36
37 include WPSC_ABSPATH.'includes/admin/tickets/ticket_list/filters/get_label_count.php';
38 ?>
39 <div class="row wpsc_tl_action_bar" style="background-color:<?php echo esc_attr($general_appearance['wpsc_action_bar_color'])?> !important;">
40 <div class="col-sm-12">
41 <?php if(apply_filters('wpsc_show_create_ticket_button',$flag = true) && $allow_create){?>
42 <button type="button" id="wpsc_load_list_new_ticket_btn" onclick="wpsc_get_create_ticket();" class="btn btn-sm wpsc_create_ticket_btn" style="<?php echo esc_attr($create_ticket_btn_css)?>"><i class="fa fa-plus"></i> <?php _e('New Ticket','supportcandy')?></button>
43 <?php }
44 if ($current_user->has_cap('wpsc_agent') && apply_filters('wpsc_show_agent_setting_button',true)):?>
45 <button type="button" id="wpsc_load_list_agent_setting_btn" onclick="wpsc_get_agent_setting();" class="btn btn-sm wpsc_action_btn" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fas fa-user-cog"></i> <?php _e('Agent Settings','supportcandy')?></button>
46 <?php endif;?>
47 <button type="button" class="btn btn-sm visible-xs visible-sm wpsc_action_btn" id="wpsc_load_list_show_filters_btn" onclick="toggle_wpsc_sm_filters(this);" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-filter"></i> <?php _e('Show Filters','supportcandy')?></button>
48 <?php if($wpsc_show_and_hide_filters){?>
49 <button type="button" class="btn btn-sm hidden-xs hidden-sm wpsc_action_btn" id="wpsc_load_list_hide_filters_btn" onclick="toggle_wpsc_md_filters(this);" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-filter"></i> <?php _e('Hide Filters','supportcandy')?></button>
50 <?php }else{?>
51 <button type="button" class="btn btn-sm hidden-xs hidden-sm wpsc_action_btn" id="wpsc_load_list_hide_filters_btn" onclick="toggle_wpsc_md_filters(this);" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-filter"></i> <?php _e('Show Filters','supportcandy')?></button>
52 <?php } ?>
53 <?php
54 //Set agent default filter
55 $blog_id = get_current_blog_id();
56 $default_filter = get_user_meta($current_user->ID,$blog_id.'_wpsc_user_default_filter',true);
57 $default_filter = ( $default_filter!='' && ($default_filter || $default_filter == 0) && $current_user->has_cap('wpsc_agent') ) ? $default_filter : 'all';
58 $reset_type = $default_filter;
59 ?>
60 <button type="button" class="btn btn-sm wpsc_action_btn" id="wpsc_load_list_reset_filters_btn" onclick="wpsc_set_default_filter('<?php echo esc_attr($reset_type)?>','<?php echo wp_create_nonce('set_default_filter')?>');" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-retweet"></i> <?php _e('Reset Filters','supportcandy')?></button>
61 <?php if ($current_user->has_cap('wpsc_agent')):?>
62 <button type="button" class="btn btn-sm wpsc_action_btn" id="wpsc_load_list_auto_refresh_btn" onclick="wpsc_set_toggle_auto_refresh();" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fas fa-sync-alt"></i> <span id="wpsc_autorefresh_btn_lbl"><?php _e('Auto Refresh : Off','supportcandy')?></span></button>
63 <?php endif;?>
64 <?php do_action('wpsc_add_btn_after_default_filter');?>
65 <?php if ($wpscfunction->has_permission('assign_agent')):?>
66 <button type="button" class="btn btn-sm wpsc_btn_bulk_action wpsc_action_btn checkbox_depend hidden" id="btn_assign_agents" onclick="wpsc_get_bulk_assign_agent();" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fas fa-users"></i> <?php _e('Assign Agent','supportcandy')?></button>
67 <?php endif;?>
68 <?php if ($wpscfunction->has_permission('change_status')):?>
69 <button type="button" class="btn btn-sm wpsc_btn_bulk_action wpsc_action_btn checkbox_depend hidden" id="btn_change_statuses" onclick="wpsc_get_bulk_change_status()" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-arrow-circle-right"></i> <?php _e('Change Status','supportcandy')?></button>
70 <?php endif;?>
71 <?php if ($wpscfunction->has_permission('delete_ticket')):?>
72 <button type="button" class="btn btn-sm wpsc_btn_bulk_action wpsc_action_btn checkbox_depend hidden" id="btn_delete_tickets" onclick="wpsc_get_delete_bulk_ticket()" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-trash"></i> <?php _e('Delete Tickets','supportcandy')?></button>
73 <button type="button" class="btn btn-sm wpsc_btn_bulk_action wpsc_action_btn checkbox_depend hidden" id="btn_restore_tickets" onclick="wpsc_get_restore_bulk_ticket()" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-window-restore"></i> <?php _e('Restore Ticket','supportcandy')?></button>
74 <button type="button" class="btn btn-sm wpsc_btn_bulk_action wpsc_action_btn checkbox_depend hidden" id="btn_delete_permanently_bulk_ticket" onclick="wpsc_get_delete_permanently_bulk_ticket();" style="<?php echo esc_attr($action_default_btn_css)?>"><i class="fa fa-trash"></i> <?php _e('Delete Tickets Permanently','supportcandy')?></button>
75 <?php endif;?>
76 <?php
77 $wpsc_support_page_id = get_option('wpsc_support_page_id');
78 $support_page_url = get_permalink($wpsc_support_page_id);
79 $wpsc_allow_sign_out = get_option('wpsc_sign_out');
80 if($wpsc_allow_sign_out){?>
81 <button class="btn btn-sm pull-right" type="button" id="wpsc_sign_out" onclick="window.location.href='<?php echo wp_logout_url($support_page_url) ?>'" style=" <?php echo esc_attr($logout_btn_css) ?>"><i class="fas fa-sign-out-alt"></i> <?php _e('Log Out','supportcandy')?></button>
82 <?php }?>
83 </div>
84 </div>
85
86 <div class="row" style="background-color:<?php echo esc_attr($general_appearance['wpsc_bg_color'])?> !important;color:<?php echo esc_attr($general_appearance['wpsc_text_color'])?> !important;">
87 <div id="wpsc_md_filters" class="col-md-2 hidden-xs hidden-sm <?php echo esc_attr($wpsc_show_and_hide_filters)==0 ?'hidden':'visible'?> wpsc_sidebar">
88 <div class="row" style="background-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_border_color'])?> !important;">
89 <h4 class="widget_header"><i class="fa fa-filter"></i> <?php _e('Filters','supportcandy')?></h4>
90 <hr class="widget_divider">
91 <?php
92 $labels = $wpscfunction->get_ticket_filter_labels();
93 foreach ($labels as $key => $label) {
94 if ( ($current_user->has_cap('wpsc_agent') && $label['visibility']=='agent') || (!$current_user->has_cap('wpsc_agent') && $label['visibility']=='customer') || $label['visibility']=='both' ) {
95 $active = $filter['label'] == $key ? 'active':'';?>
96 <div onclick="wpsc_set_default_filter('<?php echo esc_attr($key)?>','<?php echo wp_create_nonce('set_default_filter')?>');" class="wpsp_sidebar_labels <?php echo esc_attr($key)?> <?php echo esc_attr($active) ?>">
97 <?php echo esc_attr($label['label']);
98 $badge_count = 0;
99 if($key == 'unresolved_agent'){
100 $badge_count = $label_counts['unresolved_agent'];
101 }
102 echo ($label['has_badge'] && $current_user->has_cap('wpsc_agent'))?' <span class="badge">'.esc_attr($badge_count).'</span>':''?>
103 </div>
104 <?php
105 }
106 }
107 ?>
108 </div>
109 <div class="row wpsc_edit_custom_filter" style="background-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_border_color'])?> !important;">
110 <h4 class="widget_header"><i class="fa fa-filter"></i> <?php _e('Saved Filters','supportcandy')?></h4>
111 <hr class="widget_divider">
112 <?php
113 foreach ($saved_filters as $key => $label) {
114 ?>
115 <div class="wpsp_sidebar_labels" style="display:flex;align-items: center;">
116 <div style="flex-grow: 8">
117 <span onclick="wpsc_set_saved_filter('<?php echo esc_attr($key)?>','<?php echo wp_create_nonce('set_saved_filter')?>');"class="wpsp_sidebar_labels <?php echo esc_attr($key)?> <?php echo isset($filter['save_label']) && $filter['save_label'] ==$label['save_label']?'active':''?>"><?php echo esc_attr($label['save_label'])?></span>
118 </div>
119 <div class='wpsc_list_filter_edit' style="flex-grow: 1; padding-right:2px;"><i class="far fa-edit" onclick="wpsc_edit_saved_filter('<?php echo esc_attr($key)?>');"></i></div>
120 <div class='wpsc_list_filter_delete' style="flex-grow: 1"><i class="fa fa-trash" onclick="wpsc_delete_saved_filter('<?php echo esc_attr($key)?>', '<?php echo wp_create_nonce('delete_saved_filter')?>');"></i></div>
121 </div>
122 <?php
123 }
124 if(!$saved_filters) echo __('No filters found!','supportcandy').'<br><br>';
125 ?>
126 </div>
127 </div>
128 <div id="wpsc_sm_filters" class="col-sm-12 col-md-2 hidden wpsc_sidebar">
129 <div class="row" style="background-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_border_color'])?> !important;">
130 <h4 class="widget_header"><i class="fa fa-filter"></i> <?php _e('Filters','supportcandy')?></h4>
131 <hr class="widget_divider">
132 <?php
133 foreach ($labels as $key => $label) {
134 if ( ($current_user->has_cap('wpsc_agent') && $label['visibility']=='agent') || (!$current_user->has_cap('wpsc_agent') && $label['visibility']=='customer') || $label['visibility']=='both' ) {
135 $active = $filter['label'] == $key ? 'active':'';?>
136 <div onclick="wpsc_set_default_filter('<?php echo esc_attr($key)?>','<?php echo wp_create_nonce('set_default_filter')?>');" class="wpsp_sidebar_labels <?php echo esc_attr($key)?> <?php echo esc_attr($active)?>">
137 <?php echo esc_attr($label['label']);
138 $badge_count = 0;
139 if($key == 'unresolved_agent'){
140 $badge_count = $label_counts['unresolved_agent'];
141 }
142
143 echo ($label['has_badge'])?' <span class="badge">'.$badge_count.'</span>':''?>
144 </div>
145 <?php
146 }
147 }
148 ?>
149 </div>
150 <div class="row" style="background-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_text_color'])?> !important;border-color:<?php echo esc_attr($wpsc_appearance_ticket_list['wpsc_filter_widgets_border_color'])?> !important;">
151 <h4 class="widget_header"><i class="fa fa-filter"></i> <?php _e('Saved Filters','supportcandy')?></h4>
152 <hr class="widget_divider">
153 <?php
154 foreach ($saved_filters as $key => $label) {
155 ?>
156 <div class="wpsp_sidebar_labels" style="display:flex;align-items: center;">
157 <div style="flex-grow: 8">
158 <span onclick="wpsc_set_saved_filter('<?php echo esc_attr($key)?>','<?php echo wp_create_nonce('set_saved_filter')?>');"class="wpsp_sidebar_labels <?php echo esc_attr($key)?> <?php echo isset($filter['save_label']) && $filter['save_label'] ==$label['save_label']?'active':''?>"><?php echo esc_attr($label['save_label'])?></span>
159 </div>
160 <div>
161 <i class="far fa-edit wpsc_list_filter_edit" onclick="wpsc_edit_saved_filter('<?php echo esc_attr($key)?>');"></i>
162 <i class="fa fa-trash wpsc_list_filter_delete" onclick="wpsc_delete_saved_filter('<?php echo esc_attr($key)?>', '<?php echo wp_create_nonce('delete_saved_filter')?>');"></i>
163 </div>
164 </div>
165 <?php
166 }
167 if(!$saved_filters) echo __('No filters found!','supportcandy').'<br><br>';
168 ?>
169 </div>
170 </div>
171
172 <?php if(!$wpsc_show_and_hide_filters){ ?>
173 <div class="col-sm-12 col-md-12 wpsc_ticket_list_container table-responsive" >
174 <?php include WPSC_ABSPATH . 'includes/admin/tickets/ticket_list/get_ticket_list.php';?>
175 </div>
176 <?php }
177 else{?>
178 <div class="col-sm-12 col-md-10 wpsc_ticket_list_container table-responsive" >
179 <?php include WPSC_ABSPATH . 'includes/admin/tickets/ticket_list/get_ticket_list.php';?>
180 </div>
181 <?php } ?>
182 </div>
183 <?php do_action('wpsc_load_ticket_list'); ?>
184
185 <script>
186 var wpsc_autorefresh_status = false;
187 var wpsc_default_refresh_option = <?php echo esc_attr($wpsc_on_and_off_auto_refresh) ?>;
188 if (wpsc_default_refresh_option){
189 jQuery(document).ready(function() {
190 wpsc_set_toggle_auto_refresh();
191 });
192 }
193
194 function toggle_wpsc_sm_filters(e){
195 if(jQuery('#wpsc_sm_filters').hasClass('hidden')){
196 jQuery('#wpsc_sm_filters').removeClass('hidden');
197 jQuery('#wpsc_sm_filters').addClass('visible-xs');
198 jQuery('#wpsc_sm_filters').addClass('visible-sm');
199 jQuery(e).html('<i class="fa fa-filter"></i> <?php _e('Hide Filters','supportcandy')?>');
200 } else {
201 jQuery('#wpsc_sm_filters').removeClass('visible-xs');
202 jQuery('#wpsc_sm_filters').removeClass('visible-sm');
203 jQuery('#wpsc_sm_filters').addClass('hidden');
204 jQuery(e).html('<i class="fa fa-filter"></i> <?php _e('Show Filters','supportcandy')?>');
205 }
206 }
207
208 function toggle_wpsc_md_filters(e){
209 if(jQuery('#wpsc_md_filters').hasClass('hidden')){
210 jQuery('#wpsc_md_filters').removeClass('hidden');
211 jQuery('#wpsc_md_filters').addClass('hidden-xs');
212 jQuery('#wpsc_md_filters').addClass('hidden-sm');
213 jQuery('.wpsc_ticket_list_container').removeClass('col-md-12');
214 jQuery('.wpsc_ticket_list_container').addClass('col-md-10');
215 jQuery(e).html('<i class="fa fa-filter"></i> <?php _e('Hide Filters','supportcandy')?>');
216 } else {
217 jQuery('#wpsc_md_filters').removeClass('hidden-xs');
218 jQuery('#wpsc_md_filters').removeClass('hidden-sm');
219 jQuery('#wpsc_md_filters').addClass('hidden');
220 jQuery('.wpsc_ticket_list_container').removeClass('col-md-10');
221 jQuery('.wpsc_ticket_list_container').addClass('col-md-12');
222 jQuery(e).html('<i class="fa fa-filter"></i> <?php _e('Show Filters','supportcandy')?>');
223 }
224 }
225
226 function wpsc_set_toggle_auto_refresh(){
227 if(wpsc_autorefresh_status){
228 wpsc_autorefresh_status = false;
229 jQuery('#wpsc_autorefresh_btn_lbl').text('<?php _e('Auto Refresh : Off','supportcandy')?>');
230 } else {
231 wpsc_autorefresh_status = true;
232 jQuery('#wpsc_autorefresh_btn_lbl').text('<?php _e('Auto Refresh : On','supportcandy')?>');
233 wpsc_refresh_ticket_list();
234 }
235 }
236
237 function wpsc_refresh_ticket_list(){
238
239 if(wpsc_autorefresh_status && jQuery(".wpsp_custom_filter_container").is(':hidden') && !jQuery('.chk_ticket_list_item:checked').length){
240
241 var data = {
242 action: 'wpsc_tickets',
243 setting_action : 'get_ticket_list'
244 };
245 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
246 jQuery('.wpsc_ticket_list_container').html(response);
247 toggle_ticket_list_actions();
248 });
249 }
250 setTimeout(wpsc_refresh_ticket_list,60000);
251 }
252 </script>