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