| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $wpdb,$wppmfunction,$current_user; |
| 6 |
$project_id = isset($_POST['id']) ? sanitize_text_field($_POST['id']) : '' ; |
| 7 |
$project_data = $wppmfunction->get_project($project_id); |
| 8 |
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); |
| 9 |
if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_project_permission('change_project_status',$project_id) || ($project_data['created_by']==$current_user->ID && $wppm_current_user_capability=='wppm_manager') || $wppm_current_user_capability=='wppm_admin')) {exit;} |
| 10 |
$statuses = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wppm_project_statuses"); |
| 11 |
$status_id = $project_data['status']; |
| 12 |
ob_start(); |
| 13 |
?> |
| 14 |
<form id="frm_get_project_change_status" method="post"> |
| 15 |
<div class="form-group"> |
| 16 |
<label for="wppm_project_status" class="wppm_project_status"><?php echo esc_html_e('Project Status','taskbuilder');?></label> |
| 17 |
<select class="form-control" name="wppm_project_status"> |
| 18 |
<?php |
| 19 |
if(!empty($statuses)){ |
| 20 |
foreach ( $statuses as $status ) : |
| 21 |
$selected = $status_id == $status->id ? 'selected="selected"' : ''; |
| 22 |
echo '<option '.esc_attr($selected).' value="'.esc_attr($status->id).'">'.esc_html($status->name).'</option>'; |
| 23 |
endforeach; |
| 24 |
} |
| 25 |
?> |
| 26 |
</select> |
| 27 |
</div> |
| 28 |
<?php do_action('wppm_after_edit_change_project_status',$project_id);?> |
| 29 |
<input type="hidden" name="action" value="wppm_set_change_project_status" /> |
| 30 |
<input type="hidden" name="_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wppm_set_change_project_status' ) ); ?>"> |
| 31 |
<input type="hidden" id="wppm_project_id" name="project_id" value="<?php echo htmlentities(esc_attr($project_id)); ?>" /> |
| 32 |
|
| 33 |
|
| 34 |
</form> |
| 35 |
<?php |
| 36 |
$body = ob_get_clean(); |
| 37 |
|
| 38 |
ob_start(); |
| 39 |
?> |
| 40 |
<button type="button" class="btn wppm_popup_close" onclick="wppm_modal_close();"><?php echo esc_html_e('Close','taskbuilder');?></button> |
| 41 |
<button type="button" class="btn wppm_popup_action" onclick="wppm_set_change_project_status(<?php echo htmlentities(esc_attr($project_id))?>);"><?php echo esc_html_e('Save','taskbuilder');?></button> |
| 42 |
<?php |
| 43 |
$footer = ob_get_clean(); |
| 44 |
|
| 45 |
$output = array( |
| 46 |
'body' => $body, |
| 47 |
'footer' => $footer |
| 48 |
); |
| 49 |
|
| 50 |
echo json_encode($output); |
| 51 |
|