| 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 |
if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_project_permission('change_project_raised_by',$project_id))) {exit;} |
| 8 |
$project_data = $wppmfunction->get_project($project_id); |
| 9 |
$project_creator = get_userdata($project_data['created_by']); |
| 10 |
ob_start(); |
| 11 |
?> |
| 12 |
<form id="frm_get_project_creator" method="post"> |
| 13 |
<div class="row" style="padding-left:2px;"> |
| 14 |
<div class="col-sm-12"> |
| 15 |
<label class="wppm_ct_field_label" for="user_name"><?php echo esc_html_e('Project Creator Name','taskbuilder') ?> </label> |
| 16 |
<input type="text" id="project_creator_name" class="form-control wppm_regi_user_autocomplete ui-autocomplete-input" name="wppm_project_creator_name" autocomplete="off" value="<?php echo htmlentities(stripcslashes(esc_attr($project_creator->display_name)))?>"> |
| 17 |
</div> |
| 18 |
</div> |
| 19 |
<input type="hidden" name="action" value="wppm_set_change_project_raised_by" /> |
| 20 |
<input type="hidden" name="wppm_user_id" id="wppm_user_id" value="<?php echo esc_attr($project_creator->ID) ?>"> |
| 21 |
<input type="hidden" name="project_id" value="<?php echo htmlentities(esc_attr($project_id)) ?>" /> |
| 22 |
</form> |
| 23 |
<script type="text/javascript"> |
| 24 |
jQuery(document).ready(function(){ |
| 25 |
jQuery( ".wppm_regi_user_autocomplete" ).autocomplete({ |
| 26 |
minLength: 1, |
| 27 |
appendTo: jQuery('.wppm_regi_user_autocomplete').parent(), |
| 28 |
source: function( request, response ) { |
| 29 |
var term = request.term; |
| 30 |
request = { |
| 31 |
action : 'wppm_filter_autocomplete', |
| 32 |
term : term, |
| 33 |
field : 'project_creator_name' |
| 34 |
} |
| 35 |
jQuery.getJSON( wppm_admin.ajax_url, request, function( data, status, xhr ) { |
| 36 |
response(data); |
| 37 |
}); |
| 38 |
}, |
| 39 |
minLength: 2, |
| 40 |
select: function (event, ui) { |
| 41 |
jQuery('#wppm_project_creator_name').val(ui.item.value); |
| 42 |
jQuery('#wppm_user_id').val(ui.item.user_id); |
| 43 |
} |
| 44 |
}); |
| 45 |
|
| 46 |
}); |
| 47 |
</script> |
| 48 |
<?php |
| 49 |
$body = ob_get_clean(); |
| 50 |
ob_start(); |
| 51 |
?> |
| 52 |
<button type="button" class="btn wppm_popup_close" onclick="wppm_modal_close();"><?php echo esc_html_e('Close','taskbuilder');?></button> |
| 53 |
<button type="button" class="btn wppm_popup_action" onclick="wppm_set_change_project_raised_by(<?php echo esc_attr($project_id) ?>);"><?php echo esc_html_e('Save','taskbuilder');?></button> |
| 54 |
<?php |
| 55 |
$footer = ob_get_clean(); |
| 56 |
|
| 57 |
$output = array( |
| 58 |
'body' => $body, |
| 59 |
'footer' => $footer |
| 60 |
); |
| 61 |
|
| 62 |
echo json_encode($output); |