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 / email_notifications / get_edit_ticket_notification.php

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

215 lines 10.3 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'))) {
8 exit;
9 }
10
11 $term_id = isset($_POST) && isset($_POST['term_id']) ? intval($_POST['term_id']) : 0;
12 if(!$term_id) die();
13
14 $term = get_term_by('id',$term_id,'wpsc_en');
15
16 $agent_role = get_option('wpsc_agent_role');
17 $notification_types = $wpscfunction->get_email_notification_types();
18
19 $rich_editing = $wpscfunction->rich_editing_status($current_user);
20 $directionality = $wpscfunction->check_rtl();
21
22 ?>
23 <h4 style="margin-bottom:20px;"><?php _e('Edit email notification','supportcandy');?></h4>
24
25 <form id="wpsc_frm_general_settings" method="post" action="javascript:wpsc_set_edit_ticket_notification();">
26
27 <div class="form-group">
28 <label for="wpsc_en_title"><?php _e('Title','supportcandy');?></label>
29 <p class="help-block"><?php _e('Title to show in notification list. Please make sure title you are entering is not already available in other notifications.','supportcandy');?></p>
30 <input type="text" class="form-control" name="wpsc_en_title" id="wpsc_en_title" value="<?php echo esc_attr($term->name)?>" />
31 </div>
32
33 <?php $type = get_term_meta($term_id,'type',true);?>
34 <div class="form-group">
35 <label for="wpsc_en_type"><?php _e('Type','supportcandy');?></label>
36 <p class="help-block"><?php _e('Select event to send this email.','supportcandy');?></p>
37 <select class="form-control" name="wpsc_en_type" id="wpsc_en_type">
38 <?php foreach ($notification_types as $key => $value) :
39 $selected = $key==$type?'selected':'';?>
40 <option <?php echo esc_attr($selected)?> value="<?php echo esc_attr($key)?>"><?php echo esc_attr($value)?></option>
41 <?php endforeach;?>
42 </select>
43 </div>
44
45 <?php $subject = get_term_meta($term_id,'subject',true);
46 ?>
47 <div class="form-group">
48 <label for="wpsc_en_subject"><?php _e('Email Subject','supportcandy');?></label>
49 <p class="help-block"><?php _e('Subject for email to send.','supportcandy');?></p>
50 <input type="text" class="form-control" name="wpsc_en_subject" id="wpsc_en_subject" value="<?php echo esc_attr($subject) ?>" />
51 </div>
52
53 <?php $body = get_term_meta($term_id,'body',true)?>
54 <div class="form-group">
55 <label for="wpsc_en_body"><?php _e('Email Body','supportcandy');?></label>
56 <p class="help-block"><?php _e('Body for email to send. Use macros for ticket specific details. Macros will get replaced by its value while sending an email.','supportcandy');?></p>
57 <?php if($rich_editing){?>
58 <div class="text-right">
59 <button id="visual" class="wpsc-switch-editor wpsc-switch-editor-active" type="button" onclick="wpsc_get_tinymce('wpsc_en_body','email_body');"><?php _e('Visual', 'supportcandy');?></button>
60 <button id="text" class="wpsc-switch-editor" type="button" onclick="wpsc_get_textarea('wpsc_en_body')"><?php _e('Text', 'supportcandy');?></button>
61 </div>
62 <?php } ?>
63 <textarea type="text" class="form-control" name="wpsc_en_body" id="wpsc_en_body"><?php echo wp_kses_post($body)?></textarea>
64 <div class="row attachment_link">
65 <span onclick="wpsc_get_templates(); "><?php _e('Insert Macros','supportcandy') ?></span>
66 </div>
67 </div>
68
69 <?php $recipients = get_term_meta($term_id,'recipients',true)?>
70 <div class="form-group">
71 <label for=""><?php _e('Recipients','supportcandy');?></label>
72 <p class="help-block"><?php _e('Select roles who will receive email notifications. Assigned Agent will be none if type is New Ticket. If you want to automate assign agent for new ticket, you can purchase our <strong>Assign Agent Rules</strong> add-on.','supportcandy');?></p>
73 <div class="row">
74 <div class="col-sm-4" style="margin-bottom:10px; display:flex;">
75 <div style="width:25px;"><input type="checkbox" <?php echo in_array('customer',$recipients)?'checked="checked"':''?> name="wpsc_en_recipients[]" value="customer" /></div>
76 <div style="padding-top:3px;"><?php _e('Customer','supportcandy')?></div>
77 </div>
78 <div class="col-sm-4" style="margin-bottom:10px; display:flex;">
79 <div style="width:25px;"><input type="checkbox" <?php echo in_array('assigned_agent',$recipients)?'checked="checked"':''?> name="wpsc_en_recipients[]" value="assigned_agent" /></div>
80 <div style="padding-top:3px;"><?php _e('Assigned Agent','supportcandy')?></div>
81 </div>
82 <?php foreach ( $agent_role as $key => $role ) : ?>
83 <div class="col-sm-4" style="margin-bottom:10px; display:flex;">
84 <div style="width:25px;"><input type="checkbox" <?php echo in_array($key,$recipients)?'checked="checked"':''?> name="wpsc_en_recipients[]" value="<?php echo esc_attr($key)?>" /></div>
85 <div style="padding-top:3px;"><?php echo esc_attr($role['label']).' '.__('(all agents)','supportcandy')?></div>
86 </div>
87 <?php endforeach;?>
88
89 <div class="col-sm-4" style="margin-bottom:10px; display:flex;">
90 <div style="width:25px;"><input type="checkbox" <?php echo in_array('extra_ticket_users',$recipients)?'checked="checked"':''?> name="wpsc_en_recipients[]" value="extra_ticket_users" /></div>
91 <div style="padding-top:3px;"><?php _e('Additional Ticket Recipients','supportcandy')?></div>
92 </div>
93 <?php if($type != 'new_ticket'){?>
94 <div class="col-sm-4 prev_assigned" style="margin-bottom:10px; display:flex;">
95 <div style="width:25px;"><input type="checkbox" <?php echo in_array('previously_assigned_agent',$recipients)?'checked="checked"':''?> name="wpsc_en_recipients[]" value="previously_assigned_agent" /></div>
96 <div style="padding-top:3px;"><?php _e('Previously Assigned Agents','supportcandy')?></div>
97 </div>
98 <?php }?>
99 <?php
100 $ate = ['new_ticket', 'ticket_rating', 'ticket_feedback', 'out_of_sla'];
101 if( !in_array($type, $ate) ){?>
102 <div class="col-sm-4 current_user" style="margin-bottom:10px; display:flex;">
103 <div style="width:25px;"><input type="checkbox" <?php echo in_array('current_user', $recipients)? 'checked="checked"':''?> name="wpsc_en_recipients[]" value="current_user" /></div>
104 <div style="padding-top:3px;"><?php _e('Current User', 'supportcandy')?></div>
105 </div>
106 <?php
107 }?>
108 <?php do_action('wpsp_en_after_edit_recipients',$recipients);?>
109
110 </div>
111 </div>
112
113 <?php $additional_recipients = get_term_meta($term_id,'extra_recipients',true)?>
114 <div class="form-group">
115 <label for="wpsc_en_extra_recipients"><?php _e('Additional Recipients','supportcandy');?></label>
116 <p class="help-block"><?php _e('(Optional) Enter additional recipient email address. One email per line.','supportcandy');?></p>
117 <textarea style="height:100px !important" class="form-control" name="wpsc_en_extra_recipients" id="wpsc_en_extra_recipients"><?php if($additional_recipients) echo stripcslashes(implode('\n', $additional_recipients))?></textarea>
118 </div>
119
120 <?php $conditions = get_term_meta($term_id,'conditions',true)?>
121 <div class="form-group">
122 <label for=""><?php _e('Conditions','supportcandy');?></label>
123 <p class="help-block"><?php _e('(Optional) Email will only send when all condition matches.','supportcandy');?></p>
124 <?php $wpscfunction->load_conditions_ui('wpsc_edit_en_conditions',$conditions);?>
125 </div>
126
127 <?php do_action('wpsc_get_edit_ticket_notification',$term_id);?>
128
129 <button type="submit" class="btn btn-success"><?php _e('Save Changes','supportcandy');?></button>
130 <img class="wpsc_submit_wait" style="display:none;" src="<?php echo esc_url(WPSC_PLUGIN_URL.'asset/images/[email protected]');?>">
131 <input type="hidden" name="action" value="wpsc_email_notifications" />
132 <input type="hidden" name="setting_action" value="set_edit_ticket_notification" />
133 <input type="hidden" name="term_id" value="<?php echo esc_attr($term_id) ?>" />
134 <input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce('set_edit_ticket_notification')?>">
135 </form>
136
137 <script>
138 function wpsc_get_tinymce(selector,body_id){
139
140 jQuery('#visual_header').addClass('btn btn-primary visual_header');
141 jQuery('#text_header').removeClass('btn btn-primary text_header');
142 jQuery('#text_header').addClass('btn btn-default text_header');
143 jQuery('#text').removeClass('wpsc-switch-editor-active');
144 jQuery('#visual').addClass('wpsc-switch-editor-active');
145 tinymce.init({
146 selector:'#'+selector,
147 body_id: body_id,
148 menubar: false,
149 statusbar: false,
150 height : '200',
151 plugins: [
152 'lists link image directionality'
153 ],
154 image_advtab: true,
155 toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image',
156 branding: false,
157 autoresize_bottom_margin: 20,
158 browser_spellcheck : true,
159 relative_urls : false,
160 remove_script_host : false,
161 convert_urls : true,
162 setup: function (editor) {
163 }
164 });
165 }
166
167 function wpsc_get_textarea(selector){
168
169 jQuery('#visual_body').removeClass('btn btn-primary visual_body');
170 jQuery('#visual_body').addClass('btn btn-default visual_body');
171 jQuery('#text_body').addClass('btn btn-primary text_body');
172 tinymce.remove('#'+selector);
173 jQuery('#text').addClass('wpsc-switch-editor-active');
174 jQuery('#visual').removeClass('wpsc-switch-editor-active');
175 }
176 tinymce.remove();
177 tinymce.init({
178 selector:'#wpsc_en_body',
179 body_id: 'email_body',
180 directionality : '<?php echo esc_attr($directionality); ?>',
181 menubar: false,
182 statusbar: false,
183 height : '200',
184 plugins: [
185 'lists link image directionality'
186 ],
187 image_advtab: true,
188 toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image',
189 branding: false,
190 autoresize_bottom_margin: 20,
191 browser_spellcheck : true,
192 relative_urls : false,
193 remove_script_host : false,
194 convert_urls : true,
195 setup: function (editor) {
196 }
197 });
198 </script>
199 <script>
200 jQuery('#wpsc_en_type').on('change', function(){
201 var en_type = jQuery('#wpsc_en_type').val();
202 if(en_type == 'new_ticket'){
203 jQuery('.prev_assigned').css({"display" : "none"});
204 } else{
205 jQuery('.prev_assigned').css({"display" : "flex"});
206 }
207
208 var valid_types = ['new_ticket', 'ticket_rating', 'ticket_feedback', 'out_of_sla'];
209 if(jQuery.inArray( en_type, valid_types ) > -1 ){
210 jQuery('.current_user').css({"display" : "none"});
211 }else{
212 jQuery('.current_user').css({"display" : "flex"});
213 }
214 });
215 </script>