| 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 |
$agent_role = get_option('wpsc_agent_role'); |
| 12 |
$notification_types = $wpscfunction->get_email_notification_types(); |
| 13 |
|
| 14 |
$rich_editing = $wpscfunction->rich_editing_status($current_user); |
| 15 |
|
| 16 |
$directionality = $wpscfunction->check_rtl(); |
| 17 |
?> |
| 18 |
<h4 style="margin-bottom:20px;"><?php _e('Add new email notification','supportcandy');?></h4> |
| 19 |
|
| 20 |
<form id="wpsc_frm_general_settings" method="post" action="javascript:wpsc_set_add_ticket_notification();"> |
| 21 |
|
| 22 |
<div class="form-group"> |
| 23 |
<label for="wpsc_en_title"><?php _e('Title','supportcandy');?></label> |
| 24 |
<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> |
| 25 |
<input type="text" class="form-control" name="wpsc_en_title" id="wpsc_en_title" value="" /> |
| 26 |
</div> |
| 27 |
|
| 28 |
<div class="form-group"> |
| 29 |
<label for="wpsc_en_type"><?php _e('Type','supportcandy');?></label> |
| 30 |
<p class="help-block"><?php _e('Select event to send this email.','supportcandy');?></p> |
| 31 |
<select class="form-control" name="wpsc_en_type" id="wpsc_en_type"> |
| 32 |
<?php foreach ($notification_types as $key => $value) : ?> |
| 33 |
<option value="<?php echo esc_attr($key)?>"><?php echo esc_attr($value)?></option> |
| 34 |
<?php endforeach;?> |
| 35 |
</select> |
| 36 |
</div> |
| 37 |
|
| 38 |
<div class="form-group"> |
| 39 |
<label for="wpsc_en_subject"><?php _e('Email Subject','supportcandy');?></label> |
| 40 |
<p class="help-block"><?php _e('Subject for email to send.','supportcandy');?></p> |
| 41 |
<input type="text" class="form-control" name="wpsc_en_subject" id="wpsc_en_subject" value="" /> |
| 42 |
</div> |
| 43 |
|
| 44 |
<div class="form-group"> |
| 45 |
<label for="wpsc_en_body"><?php _e('Email Body','supportcandy');?></label> |
| 46 |
<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> |
| 47 |
<?php if($rich_editing){?> |
| 48 |
<div class="text-right"> |
| 49 |
<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> |
| 50 |
<button id="text" class="wpsc-switch-editor" type="button" onclick="wpsc_get_textarea('wpsc_en_body')"><?php _e('Text','supportcandy');?></button> |
| 51 |
</div> |
| 52 |
<?php } ?> |
| 53 |
<textarea type="text" class="form-control" name="wpsc_en_body" id="wpsc_en_body"></textarea> |
| 54 |
<div class="row attachment_link"> |
| 55 |
<span onclick="wpsc_get_templates(); "><?php _e('Insert Macros','supportcandy') ?></span> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
|
| 59 |
<div class="form-group"> |
| 60 |
<label for=""><?php _e('Recipients','supportcandy');?></label> |
| 61 |
<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> |
| 62 |
<div class="row"> |
| 63 |
<div class="col-sm-4" style="margin-bottom:10px; display:flex;"> |
| 64 |
<div style="width:25px;"><input type="checkbox" name="wpsc_en_recipients[]" value="customer" /></div> |
| 65 |
<div style="padding-top:3px;"><?php _e('Customer','supportcandy')?></div> |
| 66 |
</div> |
| 67 |
<div class="col-sm-4" style="margin-bottom:10px; display:flex;"> |
| 68 |
<div style="width:25px;"><input type="checkbox" name="wpsc_en_recipients[]" value="assigned_agent" /></div> |
| 69 |
<div style="padding-top:3px;"><?php _e('Assigned Agent','supportcandy')?></div> |
| 70 |
</div> |
| 71 |
<?php foreach ( $agent_role as $key => $role ) : ?> |
| 72 |
<div class="col-sm-4" style="margin-bottom:10px; display:flex;"> |
| 73 |
<div style="width:25px;"><input type="checkbox" name="wpsc_en_recipients[]" value="<?php echo esc_attr($key)?>" /></div> |
| 74 |
<div style="padding-top:3px;"><?php echo esc_attr($role['label']).' '.__('(all agents)','supportcandy')?></div> |
| 75 |
</div> |
| 76 |
<?php endforeach;?> |
| 77 |
|
| 78 |
<div class="col-sm-4" style="margin-bottom:10px; display:flex;"> |
| 79 |
<div style="width:25px;"><input type="checkbox" name="wpsc_en_recipients[]" value="extra_ticket_users" /></div> |
| 80 |
<div style="padding-top:3px;"><?php _e('Additional Ticket Recipients','supportcandy')?></div> |
| 81 |
</div> |
| 82 |
|
| 83 |
<div class="col-sm-4 prev_assigned" style="margin-bottom:10px; display:none;"> |
| 84 |
<div style="width:25px;"><input type="checkbox" name="wpsc_en_recipients[]" id="previously_assign_agent" value="previously_assigned_agent" /></div> |
| 85 |
<div style="padding-top:3px;"><?php _e('Previously Assigned Agents','supportcandy')?></div> |
| 86 |
</div> |
| 87 |
|
| 88 |
<div class="col-sm-4 current_user"style="margin-bottom:10px; display:none;"> |
| 89 |
<div style="width:25px;"><input type="checkbox" name="wpsc_en_recipients[]" value="current_user"/></div> |
| 90 |
<div style="padding-top:3px;"><?php _e('Current User','supportcandy')?></div> |
| 91 |
</div> |
| 92 |
|
| 93 |
<?php do_action('wpsp_en_add_ticket_recipients');?> |
| 94 |
|
| 95 |
</div> |
| 96 |
</div> |
| 97 |
|
| 98 |
<div class="form-group"> |
| 99 |
<label for="wpsc_en_extra_recipients"><?php _e('Additional Recipients','supportcandy');?></label> |
| 100 |
<p class="help-block"><?php _e('(Optional) Enter additional recipient email address. One email per line.','supportcandy');?></p> |
| 101 |
<textarea style="height:100px !important" class="form-control" name="wpsc_en_extra_recipients" id="wpsc_en_extra_recipients"></textarea> |
| 102 |
</div> |
| 103 |
|
| 104 |
<div class="form-group"> |
| 105 |
<label for=""><?php _e('Conditions','supportcandy');?></label> |
| 106 |
<p class="help-block"><?php _e('(Optional) Email will only send when all condition matches.','supportcandy');?></p> |
| 107 |
<?php $wpscfunction->load_conditions_ui('wpsc_add_en_conditions');?> |
| 108 |
</div> |
| 109 |
|
| 110 |
<?php do_action('wpsc_get_add_ticket_notification');?> |
| 111 |
|
| 112 |
<button type="submit" class="btn btn-success"><?php _e('Save Changes','supportcandy');?></button> |
| 113 |
<img class="wpsc_submit_wait" style="display:none;" src="<?php echo esc_url(WPSC_PLUGIN_URL.'asset/images/[email protected]');?>"> |
| 114 |
<input type="hidden" name="action" value="wpsc_email_notifications" /> |
| 115 |
<input type="hidden" name="setting_action" value="set_add_ticket_notification" /> |
| 116 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce('set_add_ticket_notification')?>"> |
| 117 |
</form> |
| 118 |
|
| 119 |
<script> |
| 120 |
function wpsc_get_tinymce(selector,body_id){ |
| 121 |
|
| 122 |
jQuery('#visual_header').addClass('btn btn-primary visual_header'); |
| 123 |
jQuery('#text_header').removeClass('btn btn-primary text_header'); |
| 124 |
jQuery('#text_header').addClass('btn btn-default text_header'); |
| 125 |
jQuery('#text').removeClass('wpsc-switch-editor-active'); |
| 126 |
jQuery('#visual').addClass('wpsc-switch-editor-active'); |
| 127 |
tinymce.init({ |
| 128 |
selector:'#'+selector, |
| 129 |
body_id: body_id, |
| 130 |
menubar: false, |
| 131 |
statusbar: false, |
| 132 |
height : '200', |
| 133 |
plugins: [ |
| 134 |
'lists link image directionality' |
| 135 |
], |
| 136 |
image_advtab: true, |
| 137 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 138 |
branding: false, |
| 139 |
autoresize_bottom_margin: 20, |
| 140 |
browser_spellcheck : true, |
| 141 |
relative_urls : false, |
| 142 |
remove_script_host : false, |
| 143 |
convert_urls : true, |
| 144 |
setup: function (editor) { |
| 145 |
} |
| 146 |
}); |
| 147 |
} |
| 148 |
|
| 149 |
function wpsc_get_textarea(selector){ |
| 150 |
|
| 151 |
jQuery('#visual_body').removeClass('btn btn-primary visual_body'); |
| 152 |
jQuery('#visual_body').addClass('btn btn-default visual_body'); |
| 153 |
jQuery('#text_body').addClass('btn btn-primary text_body'); |
| 154 |
tinymce.remove('#'+selector); |
| 155 |
jQuery('#text').addClass('wpsc-switch-editor-active'); |
| 156 |
jQuery('#visual').removeClass('wpsc-switch-editor-active'); |
| 157 |
} |
| 158 |
tinymce.remove(); |
| 159 |
tinymce.init({ |
| 160 |
selector:'#wpsc_en_body', |
| 161 |
body_id: 'email_body', |
| 162 |
menubar: false, |
| 163 |
directionality : '<?php echo esc_attr($directionality); ?>' , |
| 164 |
statusbar: false, |
| 165 |
height : '200', |
| 166 |
plugins: [ |
| 167 |
'lists link image directionality' |
| 168 |
], |
| 169 |
image_advtab: true, |
| 170 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 171 |
branding: false, |
| 172 |
autoresize_bottom_margin: 20, |
| 173 |
browser_spellcheck : true, |
| 174 |
relative_urls : false, |
| 175 |
remove_script_host : false, |
| 176 |
convert_urls : true, |
| 177 |
setup: function (editor) { |
| 178 |
} |
| 179 |
}); |
| 180 |
</script> |
| 181 |
<script> |
| 182 |
jQuery('#wpsc_en_type').on('change', function(){ |
| 183 |
var en_type = jQuery('#wpsc_en_type').val(); |
| 184 |
if(en_type == 'new_ticket'){ |
| 185 |
jQuery('.prev_assigned').css({"display" : "none"}); |
| 186 |
}else{ |
| 187 |
jQuery('.prev_assigned').css({"display" : "flex"}); |
| 188 |
} |
| 189 |
|
| 190 |
var valid_types = ['new_ticket', 'ticket_rating', 'ticket_feedback', 'out_of_sla']; |
| 191 |
if(jQuery.inArray( en_type, valid_types ) > -1 ){ |
| 192 |
jQuery('.current_user').css({"display" : "none"}); |
| 193 |
}else{ |
| 194 |
jQuery('.current_user').css({"display" : "flex"}); |
| 195 |
} |
| 196 |
}); |
| 197 |
</script> |