| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wppmfunction; |
| 7 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
$id = isset($_POST) && isset($_POST['id']) ? intval(sanitize_text_field($_POST['id'])) : 0; |
| 11 |
if(!$id) die(); |
| 12 |
$user_role = get_option('wppm_user_role'); |
| 13 |
$wppm_email_notificatins = get_option('wppm_email_notification'); |
| 14 |
$notification_types = $wppmfunction->get_email_notification_types(); |
| 15 |
$directionality = $wppmfunction->check_rtl(); |
| 16 |
if(!empty($wppm_email_notificatins)){ |
| 17 |
foreach($wppm_email_notificatins as $key=>$email){ |
| 18 |
if($id==$key){ |
| 19 |
$type = $email['type']; |
| 20 |
$subject = $email['subject']; |
| 21 |
$body = $email['body']; |
| 22 |
$recipients = $email['recipients']; |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
?> |
| 27 |
<h4 style="margin-bottom:20px;"><?php echo esc_html_e('Edit email notification','taskbuilder');?></h4> |
| 28 |
<form id="wppm_edit_email_notification_settings" method="post" action="javascript:wppm_set_edit_email_notification();"> |
| 29 |
<div class="form-group"> |
| 30 |
<label for="wppm_en_type"><?php echo esc_html_e('Type','taskbuilder');?></label> |
| 31 |
<p class="help-block"><?php echo esc_html_e('Select event to send this email.','taskbuilder');?></p> |
| 32 |
<select class="form-control" name="wppm_en_type" id="wppm_en_type"> |
| 33 |
<?php foreach ($notification_types as $key => $value) :?> |
| 34 |
<option <?php echo esc_attr($key)==esc_attr($type) ?'selected="selected"':''?> value="<?php echo esc_attr($key)?>"><?php echo (esc_attr($value))?></option> |
| 35 |
<?php endforeach;?> |
| 36 |
</select> |
| 37 |
</div> |
| 38 |
<div class="form-group"> |
| 39 |
<label for="wppm_en_subject"><?php echo esc_html_e('Email Subject','taskbuilder');?></label> |
| 40 |
<p class="help-block"><?php echo esc_html_e('Subject for email to send.','taskbuilder');?></p> |
| 41 |
<input type="text" class="form-control" name="wppm_en_subject" id="wppm_en_subject" value="<?php echo (stripcslashes(esc_attr($subject))) ?>" /> |
| 42 |
</div> |
| 43 |
<div class="form-group"> |
| 44 |
<label for="wppm_en_body"><?php echo esc_html_e('Email Body','taskbuilder');?></label> |
| 45 |
<p class="help-block"><?php echo esc_html_e('Body for email to send. Use macros for project and task specific details. Macros will get replaced by its value while sending an email.','taskbuilder');?></p> |
| 46 |
<div class="text-right"> |
| 47 |
<button id="visual" class="btn btn-primary btn-xs" type="button" onclick="wppm_get_tinymce('wppm_en_body','email_body');"><?php echo esc_html_e('Visual', 'taskbuilder');?></button> |
| 48 |
<button id="text" class="btn btn-default btn-xs" type="button" onclick="wppm_get_textarea()"><?php echo esc_html_e('Text', 'taskbuilder');?></button> |
| 49 |
</div> |
| 50 |
<?php $allowed_tags = array( 'br' => array(), 'abbr' => array('title' => array(),), 'p' => array(), 'strong' => array(), 'a' => array('href' => array(), 'title' => array(),'target'=> array(), 'rel'=>array()),'em' =>array(),'span' =>array(), 'blockquote'=>array('cite' => array(),),'div' => array('class' => array(),'title' => array(),'style' => array(),),'ul'=>array(),'li'=>array(),'ol'=>array(),'img' => array( 'alt'=> array(),'class' => array(),'height' => array(),'src'=> array(),'width'=> array(),)); ?> |
| 51 |
<textarea type="text" class="form-control" name="wppm_en_body" id="wppm_en_body"><?php echo htmlentities(wp_kses($body,$allowed_tags))?></textarea> |
| 52 |
<div class="row attachment_link"> |
| 53 |
<span onclick="wppm_get_templates(); "><?php echo esc_html_e('Insert Macros','taskbuilder') ?></span> |
| 54 |
</div> |
| 55 |
</div> |
| 56 |
<div class="form-group"> |
| 57 |
<label for=""><?php echo esc_html_e('Recipients','taskbuilder');?></label> |
| 58 |
<p class="help-block"><?php echo esc_html_e('Select roles who will receive email notifications.','taskbuilder');?></p> |
| 59 |
<div class="row"> |
| 60 |
<?php foreach ($user_role as $key => $role ) : ?> |
| 61 |
<div class="col-sm-4" style="margin-bottom:10px; display:flex;"> |
| 62 |
<div style="width:25px;"><input type="checkbox" <?php echo esc_attr(in_array($key,$recipients))?'checked="checked"':''?> name="wppm_en_recipients[]" value="<?php echo esc_attr($key) ?>" /></div> |
| 63 |
<div style="padding-top:3px;"><?php echo esc_html($role['label']) ?></div> |
| 64 |
</div> |
| 65 |
<?php endforeach;?> |
| 66 |
<?php if($type=='new_project' || $type=='new_task'){ |
| 67 |
$style='display:none'; |
| 68 |
} else{ |
| 69 |
$style='display:flex'; |
| 70 |
}?> |
| 71 |
<div class="col-sm-4 prev_assigned" style="margin-bottom:10px;<?php echo esc_attr($style) ?>"> |
| 72 |
<div style="width:25px;"><input type="checkbox" <?php echo esc_attr(in_array('previously_assigned_user',$recipients))?'checked="checked"':''?> name="wppm_en_recipients[]" value="previously_assigned_user" /></div> |
| 73 |
<div style="padding-top:3px;"><?php echo esc_html_e('Previously Assigned Users','taskbuilder')?></div> |
| 74 |
</div> |
| 75 |
<?php do_action('wppm_en_after_edit_recipients',$recipients);?> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
<?php do_action('wppm_get_edit_email_notification',$id);?> |
| 79 |
|
| 80 |
<button type="submit" class="wppm-submit-btn"><?php echo esc_html_e('Save Changes','taskbuilder');?></button> |
| 81 |
<img class="wppm_submit_wait" style="display:none;" src="<?php echo WPPM_PLUGIN_URL.'asset/images/[email protected]';?>"> |
| 82 |
<input type="hidden" name="action" value="wppm_set_edit_email_notification" /> |
| 83 |
<input type="hidden" name="id" value="<?php echo htmlentities(esc_attr($id)) ?>" /> |
| 84 |
</form> |
| 85 |
|
| 86 |
<script> |
| 87 |
tinymce.remove(); |
| 88 |
tinymce.init({ |
| 89 |
selector:'#wppm_en_body', |
| 90 |
body_id: 'email_body', |
| 91 |
menubar: false, |
| 92 |
statusbar: false, |
| 93 |
height : '200', |
| 94 |
plugins: [ |
| 95 |
'lists link image directionality' |
| 96 |
], |
| 97 |
image_advtab: true, |
| 98 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 99 |
branding: false, |
| 100 |
autoresize_bottom_margin: 20, |
| 101 |
browser_spellcheck : true, |
| 102 |
relative_urls : false, |
| 103 |
remove_script_host : false, |
| 104 |
convert_urls : true, |
| 105 |
setup: function (editor) { |
| 106 |
} |
| 107 |
}); |
| 108 |
</script> |
| 109 |
<script> |
| 110 |
jQuery('#wppm_en_type').on('change', function(){ |
| 111 |
if(jQuery('#wppm_en_type').val() == 'new_ticket'){ |
| 112 |
jQuery('.prev_assigned').css({"display" : "none"}); |
| 113 |
} else{ |
| 114 |
jQuery('.prev_assigned').css({"display" : "flex"}); |
| 115 |
} |
| 116 |
}); |
| 117 |
</script> |