*/ class Admission_App_Manager_Public { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $admission_app_manager The ID of this plugin. */ private $admission_app_manager; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $admission_app_manager The name of the plugin. * @param string $version The version of this plugin. */ public function __construct($admission_app_manager, $version) { $this->admission_app_manager = $admission_app_manager; $this->version = $version; add_shortcode('applications_list', array(&$this, 'client_applications')); add_shortcode('application', array(&$this, 'client_application')); add_shortcode('aam_edit_profile', array(&$this, 'aam_edit_profile')); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Admission_App_Manager_Loader as all of the hooks are defined * in that particular class. * * The Admission_App_Manager_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style($this->admission_app_manager, plugin_dir_url(__FILE__) . 'css/admission-app-manager-public.css', array(), $this->version, 'all'); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Admission_App_Manager_Loader as all of the hooks are defined * in that particular class. * * The Admission_App_Manager_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_script($this->admission_app_manager, plugin_dir_url(__FILE__) . 'js/admission-app-manager-public.js', array('jquery'), $this->version, false); } public function client_applications() { $applications = new WP_Query(array( 'post_type' => 'application', 'meta_key' => '_aam_application_client', 'meta_value' => get_current_user_id() )); $settings = get_option('aam_settings'); if (!isset($settings['applications_page'])) { _e('No single application page selected', 'admission-app-manager'); exit; } if ($applications->have_posts()) { ?> have_posts()) { $applications->the_post(); $combination_data = get_post_meta(get_the_ID(), '_aam_application_combination', true); $school = get_post($combination_data['school']); $intake = get_term($combination_data['intake'], 'intake'); ?>
School Program Intake Round Completed Actions
post_title; ?> name; ?>
0) { $post_errors['file'] = 'Please select document for upload'; } if (!isset($application_id) || !isset($document_id) || !isset($step_id)) { $post_errors['error'] = 'Something is wrong, please try again'; } if (empty($post_errors)) { require_once(ABSPATH . 'wp-admin/includes/image.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); $new_document_data = array( 'post_author' => get_current_user_id(), 'post_title' => wp_strip_all_tags($title), 'post_type' => 'document', 'post_content' => '', 'post_status' => 'publish' ); $new_document_id = wp_insert_post($new_document_data); $attach_id = media_handle_upload('file', $new_document_id); update_post_meta($new_document_id, '_aam_document_application_id', $application_id); update_post_meta($new_document_id, '_aam_document_step_id', $step_id); update_post_meta($new_document_id, '_aam_document_document_id', $document_id); update_post_meta($new_document_id, '_aam_document_document', wp_get_attachment_url($attach_id)); send_notification($new_document_id); $notification = __('New document is added!'); } } $steps = $this->get_steps($application_id); $combination_data = get_post_meta($application_id, '_aam_application_combination', true); $school = get_post($combination_data['school']); $application = get_post($application_id); $consultant = get_userdata($application->post_author); $intake = get_term($combination_data['intake'], 'intake'); $completion = $this->get_completion($steps); if ($steps && !$document_id && !$step_id) { ?>

Consultant: display_name; ?>
School: post_name; ?>
Program:
Intake: name; ?>
Round:
Completed: %

$step) : ?>
get_document_completion($steps, $sk); ?>%
get_last_document($item->document_id, $item->step_id); ?> post_author) : null; ?> deadline); ?>
name; ?> format(get_option('date_format')); ?> display_name : '-'; ?> completion; ?>%
get_documents($application_id, $document_id, $step_id); echo $notification ? '

' . $notification . '

' : ''; //var_dump($steps[$document_id]['items']); $step = $steps[$document_id]['items'][$this->_find_step($step_id, $steps[$document_id]['items'])]; ?>

Consultant: display_name; ?>
School: post_name; ?>
Program:
Intake: name; ?>
Round:
Completed: %

Step name: name; ?>
Prompt: prompt; ?>
Deadline: deadline)); ?>
Completed: done . '%'; ?>

Step documents

ID, '_aam_document_document', true)); ?> ID, '_aam_document_final', true); ?> post_author); ?>
Document name Date Author Final
post_title; ?> post_date)); ?> display_name; ?>

New document

$v) { if ($v->step_id == $step_id) { return $k; } } return false; } public function get_steps($application_id = 0) { global $wpdb; $table_name = $wpdb->prefix . 'aam_applications'; $steps = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table_name AS apps LEFT JOIN wp_posts AS posts ON posts.ID = apps.document_type WHERE apps.application_id = %d AND apps.active = 1 ORDER BY apps.sort", $application_id ) ); $sorted = array(); if ($steps) { $current = null; foreach ($steps as $step) { if (!isset($sorted[$step->document_id])) { $sorted[$step->document_id] = array( 'id' => $step->id, 'document' => $step->post_title, 'prompt' => $step->prompt, 'type' => $step->document_type, 'weight' => $step->document_weight, 'required' => $step->required, 'active' => $step->active, 'items' => array() ); } $step->completion = $this->get_step_completion($step->status); $sorted[$step->document_id]['items'][] = $step; } } return $sorted; } public function get_step_completion($status = 0) { if ($status) { $status = get_option('status_' . $status); return $status['percent']; } return 0; } public function get_completion($steps = array()) { $total = 0; $document_total = 0; foreach ($steps as $step) { foreach ($step['items'] as $item) { $done = $item->step_weight * $item->completion / 100; $document_total += $done; } $total += $step['weight'] * $document_total / 100; $document_total = 0; } return $total; } public function get_document_completion($steps = array(), $document_id = '') { $total = 0; foreach ($steps[$document_id]['items'] as $item) { $done = $item->step_weight * $item->completion / 100; $total += $done; } return $total; } public function get_last_document($document_id, $step_id) { $query = new WP_Query(array( 'meta_query' => array( array( 'key' => '_aam_document_document_id', 'compare' => '=', 'value' => $document_id ), array( 'key' => '_aam_document_step_id', 'compare' => '=', 'value' => $step_id ) ), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'document' )); $posts = $query->get_posts(); return isset($posts[0]) ? $posts[0] : null; } public function get_documents($application_id, $document_id, $step_id) { $document_items = get_posts(array( 'post_type' => 'document', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => '_aam_document_application_id', 'value' => $application_id, 'compare' => '=' ), array( 'key' => '_aam_document_step_id', 'value' => $step_id, 'compare' => '=' ), array( 'key' => '_aam_document_document_id', 'value' => $document_id, 'compare' => '=' ) ) )); return $document_items; } /** * Shortcode for frontend client user profile edit */ public function aam_edit_profile() { global $current_user; $bo_days = get_the_author_meta('aam_bo_days', $current_user->ID); if (!$bo_days || !is_array($bo_days)) { $bo_days = array(array('from' => '', 'to' => '')); } $error = array(); /* If profile was saved, update profile. */ if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'update-user') { /* Update user information. */ if (!empty($_POST['email'])) { if (!is_email(esc_attr($_POST['email']))) $error[] = __('The Email you entered is not valid. please try again.', 'profile'); elseif (email_exists(esc_attr($_POST['email'])) != $current_user->ID) $error[] = __('This email is already used by another user. try a different one.', 'profile'); else { wp_update_user(array('ID' => $current_user->ID, 'user_email' => esc_attr($_POST['email']))); } } else { $error[] = __('The Email you entered is not valid. please try again.', 'profile'); } if (!empty($_POST['first-name'])) update_user_meta($current_user->ID, 'first_name', esc_attr($_POST['first-name'])); if (!empty($_POST['last-name'])) update_user_meta($current_user->ID, 'last_name', esc_attr($_POST['last-name'])); if (!empty($_POST['aam_bo_days'])) { $bo_days_data = array(); //var_dump($_POST['aam_bo_days']); foreach ($_POST['aam_bo_days'] as $day) { if ($this->_validateDate($day['from']) && $this->_validateDate($day['to'])) { $bo_days_data[] = array( 'from' => $day['from'], 'to' => $day['to'] ); } } //var_dump($bo_days_data); if (update_user_meta($current_user->ID, 'aam_bo_days', $bo_days_data)) { $bo_days = $bo_days_data; } } if (count($error) == 0) { //action hook for plugins and extra fields saving do_action('edit_user_profile_update', $current_user->ID); } } ?>

0) echo '

' . implode("
", $error) . '

'; ?>

$day) : ?>
X  +

format($format) == $date; } }