| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $wpdb,$wppmfunction,$current_user; |
| 7 |
$task_id = isset($_POST['task_id']) ? intval(sanitize_text_field($_POST['task_id'])) : '' ; |
| 8 |
$proj_id = isset($_POST['proj_id']) ? intval(sanitize_text_field($_POST['proj_id'])) : '' ; |
| 9 |
if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_permission('change_task_details',$task_id))) {exit;} |
| 10 |
$task_data = $wppmfunction->get_task($task_id); |
| 11 |
$project_data = $wppmfunction->get_project(intval(sanitize_text_field($task_data['project']))); |
| 12 |
$priority_id = sanitize_text_field($task_data['priority']); |
| 13 |
$project_id = sanitize_text_field($task_data['project']); |
| 14 |
|
| 15 |
$priorities = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wppm_task_priorities"); |
| 16 |
ob_start(); |
| 17 |
?> |
| 18 |
<form id="frm_get_edit_task_deatils" method="post"> |
| 19 |
<div class="row" style="padding-left:2px;"> |
| 20 |
<div class="col-sm-12"> |
| 21 |
<label class="wppm_edit_task_label" for="wppm_edit_task_label"><?php echo esc_html_e('Task','taskbuilder') ?> </label> |
| 22 |
</div> |
| 23 |
</div> |
| 24 |
<div class="row" style="padding-left:2px;"> |
| 25 |
<div class="col-sm-12"> |
| 26 |
<input type="text" class="wppm_edit_task_label form-control" name="wppm_edit_task_label" id="wppm_edit_task_label" value="<?php echo isset($task_data['task_name']) ? esc_attr($task_data['task_name']) :"" ?>"> |
| 27 |
</div> |
| 28 |
</div> |
| 29 |
<div class="row" style="padding-left:2px;"> |
| 30 |
<div class="col-sm-12"> |
| 31 |
<label class="wppm_edit_project_label" for="wppm_edit_project_label"><?php esc_html_e('Project:','taskbuilder') ?> </label> |
| 32 |
</div> |
| 33 |
</div> |
| 34 |
<div class="row" style="padding-left:2px;padding-bottom: 10px;"> |
| 35 |
<div class="col-sm-12"> |
| 36 |
<input type="text" class="wppm_edit_project_label form-control" value="<?php echo isset($project_data['project_name']) ? esc_attr($project_data['project_name']):"" ?>" readonly> |
| 37 |
</div> |
| 38 |
</div> |
| 39 |
<div class="row" style="padding-left:2px;"> |
| 40 |
<div class="col-sm-12"> |
| 41 |
<label class="wppm_edit_task_start_date" for="wppm_edit_task_start_date"><?php echo esc_html_e('Start Date','taskbuilder') ?> </label> |
| 42 |
</div> |
| 43 |
</div> |
| 44 |
<div class="row" style="padding-left:2px;"> |
| 45 |
<div class="col-sm-12"> |
| 46 |
<input name="wppm_edit_task_start_date" class="form-control" id="wppm_edit_task_start_date" type="text" value="<?php echo isset($task_data['start_date'])? esc_attr($task_data['start_date']):""?>" size="40" aria-required="true"><br> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
<div class="row" style="padding-left:2px;"> |
| 50 |
<div class="col-sm-12"> |
| 51 |
<label class="wppm_edit_task_end_date" for="wppm_edit_task_end_date"><?php echo esc_html_e('End Date','taskbuilder') ?> </label> |
| 52 |
</div> |
| 53 |
</div> |
| 54 |
<div class="row" style="padding-left:2px;"> |
| 55 |
<div class="col-sm-12"> |
| 56 |
<input name="wppm_edit_task_end_date" class="form-control" id="wppm_edit_task_end_date" type="text" value="<?php echo isset($task_data['end_date']) ? esc_attr($task_data['end_date']):"" ?>" size="40" aria-required="true"><br> |
| 57 |
</div> |
| 58 |
</div> |
| 59 |
<div class="row" style="padding-left:2px;"> |
| 60 |
<div class="col-sm-12"> |
| 61 |
<label class="wppm_edit_task_priority_label" for="wppm_edit_task_priority_label" id="wppm_edit_task_priority_label"><?php echo esc_html_e('Task Priority','taskbuilder');?></label> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
<div class="row" style="padding-left:2px;"> |
| 65 |
<div class="col-sm-12"> |
| 66 |
<select class="form-control" name="wppm_edit_task_priority" id="wppm_edit_task_priority"> |
| 67 |
<option></option> |
| 68 |
<?php |
| 69 |
if(!empty($priorities)){ |
| 70 |
foreach ( $priorities as $priority ) : |
| 71 |
$selected = $priority_id == $priority->id ? 'selected="selected"' : ''; |
| 72 |
echo '<option '.esc_attr($selected).' value="'.esc_attr($priority->id).'">'.esc_html($priority->name).'</option>'; |
| 73 |
endforeach; |
| 74 |
} |
| 75 |
?> |
| 76 |
</select> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
<div class="row" style="padding-left:2px;"> |
| 80 |
<div class="col-sm-12"> |
| 81 |
<label class="wppm_edit_task_description_label" id="wppm_edit_task_description_label"> |
| 82 |
<?php echo esc_html_e('Description','taskbuilder');?> |
| 83 |
</label> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
<div class="row" style="padding-left:2px;"> |
| 87 |
<div class="col-sm-12"> |
| 88 |
<textarea id="wppm_edit_task_description" class="form-control" name="wppm_edit_task_description"> |
| 89 |
<?php echo isset($task_data['description']) ? stripslashes(htmlspecialchars_decode(esc_textarea($task_data['description']),ENT_QUOTES)) :""?> |
| 90 |
</textarea> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
<?php do_action('wppm_edit_task_details',$task_id,$project_id);?> |
| 94 |
<input type="hidden" name="action" value="wppm_set_change_task_details" /> |
| 95 |
<input type="hidden" name="user_id" id="user_id" value=""> |
| 96 |
<input type="hidden" name="task_id" value="<?php echo esc_attr($task_id) ?>" /> |
| 97 |
</form> |
| 98 |
<script> |
| 99 |
jQuery( document ).ready( function( jQuery ) { |
| 100 |
jQuery("#wppm_edit_task_start_date").flatpickr({ |
| 101 |
enableTime: true, |
| 102 |
dateFormat: "Y-m-d H:i", |
| 103 |
}); |
| 104 |
jQuery("#wppm_edit_task_end_date").flatpickr({ |
| 105 |
enableTime: true, |
| 106 |
dateFormat: "Y-m-d H:i" |
| 107 |
//minDate: startdate |
| 108 |
}); |
| 109 |
tinymce.remove(); |
| 110 |
tinymce.init({ |
| 111 |
selector:'#wppm_edit_task_description', |
| 112 |
body_id: 'wppm_edit_task_description', |
| 113 |
directionality : '<?php //echo 'rtl'; ?>', |
| 114 |
menubar: false, |
| 115 |
statusbar: false, |
| 116 |
height : '200', |
| 117 |
width : '100%', |
| 118 |
plugins: [ |
| 119 |
'lists link image directionality paste' |
| 120 |
], |
| 121 |
image_advtab: true, |
| 122 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 123 |
branding: false, |
| 124 |
autoresize_bottom_margin: 20, |
| 125 |
browser_spellcheck : true, |
| 126 |
relative_urls : false, |
| 127 |
remove_script_host : false, |
| 128 |
convert_urls : true, |
| 129 |
paste_as_text: true, |
| 130 |
setup: function (editor) { |
| 131 |
} |
| 132 |
}); |
| 133 |
}); |
| 134 |
|
| 135 |
jQuery('#wppm_edit_project_label').select2(); |
| 136 |
|
| 137 |
</script> |
| 138 |
<?php |
| 139 |
$body = ob_get_clean(); |
| 140 |
|
| 141 |
ob_start(); |
| 142 |
?> |
| 143 |
<button type="button" class="btn wppm_popup_close" onclick="wppm_modal_close();"><?php echo esc_html_e('Close','taskbuilder');?></button> |
| 144 |
<button type="button" class="btn wppm_popup_action" onclick="wppm_set_change_task_details(<?php echo esc_attr($task_id)?>,<?php echo esc_attr($proj_id) ?>);"><?php echo esc_html_e('Save','taskbuilder');?></button> |
| 145 |
<?php |
| 146 |
$footer = ob_get_clean(); |
| 147 |
|
| 148 |
$output = array( |
| 149 |
'body' => $body, |
| 150 |
'footer' => $footer |
| 151 |
); |
| 152 |
echo json_encode($output); |
| 153 |
?> |
| 154 |
|