| 1 |
<?php |
| 2 |
if (!defined( 'ABSPATH' ) )exit('No Such File'); |
| 3 |
wpsp_header(); |
| 4 |
if( is_user_logged_in() ) { |
| 5 |
global $current_user, $wp_roles, $wpdb; |
| 6 |
$current_user_role=$current_user->roles[0]; |
| 7 |
if($current_user_role=='administrator' || $current_user_role=='teacher'){ |
| 8 |
wpsp_topbar(); |
| 9 |
wpsp_sidebar(); |
| 10 |
wpsp_body_start(); |
| 11 |
if(isset($_GET['tab']) && sanitize_text_field($_GET['tab'])=='addparent'){ |
| 12 |
if($current_user_role=='administrator'){ |
| 13 |
include_once( WPSP_PLUGIN_PATH.'/includes/wpsp-parentForm.php'); |
| 14 |
} |
| 15 |
} else { |
| 16 |
include_once( WPSP_PLUGIN_PATH .'/includes/wpsp-parentList.php'); |
| 17 |
?> |
| 18 |
<div class="wpsp-popupMain" id="ViewModal"> |
| 19 |
<div class="wpsp-overlayer"></div> |
| 20 |
<div class="wpsp-popBody"> |
| 21 |
<div class="wpsp-popInner"> |
| 22 |
<a href="javascript:;" class="wpsp-closePopup"></a> |
| 23 |
<div id="ViewModalContent"></div> |
| 24 |
</div> |
| 25 |
</div> |
| 26 |
</div> |
| 27 |
|
| 28 |
<?php if($current_user_role=='administrator'){?> |
| 29 |
<div class="modal modal-wide" id="AddModal" tabindex="-1" role="dialog" aria-labelledby="AddModal" aria-hidden="true"> |
| 30 |
<div class="modal-dialog"> |
| 31 |
<div class="modal-content"> |
| 32 |
<div class="col-lg-12 col-md-12"> |
| 33 |
</div> |
| 34 |
</div> |
| 35 |
</div> |
| 36 |
</div> |
| 37 |
<?php } |
| 38 |
if($current_user_role=='administrator'){ ?> |
| 39 |
<div class="modal modal-wide" id="ImportModal" tabindex="-1" role="dialog" aria-labelledby="ImportModal" aria-hidden="true"> |
| 40 |
<div class="modal-dialog"> |
| 41 |
<div class="modal-content"> |
| 42 |
<div class="col-md-12"> |
| 43 |
<div class="box box-info"> |
| 44 |
<div class="box-header"> |
| 45 |
</div> |
| 46 |
<form action="#" name="ImportDetails" id="ImportDetails"> |
| 47 |
<div class="form-group"> |
| 48 |
<?php wp_nonce_field( 'UserImport', 'import_nonce', '', true ) ?> |
| 49 |
<input type="hidden" name="userType" value="2"> |
| 50 |
</div> |
| 51 |
</form> |
| 52 |
<?php do_action('wpsp_parent_import_html'); ?> |
| 53 |
</div> |
| 54 |
</div> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
</div><!-- /.modal --> |
| 58 |
<?php |
| 59 |
} |
| 60 |
} |
| 61 |
wpsp_body_end(); |
| 62 |
wpsp_footer(); |
| 63 |
} |
| 64 |
if($current_user_role=='parent' || $current_user_role=='student' ) { |
| 65 |
wpsp_topbar(); |
| 66 |
wpsp_sidebar(); |
| 67 |
wpsp_body_start(); |
| 68 |
$parent_id = intval($current_user->ID); |
| 69 |
$label = esc_html('Your Profile','wpschoolpress'); |
| 70 |
if( $current_user_role=='student' ) { |
| 71 |
$student_id = intval($current_user->ID); |
| 72 |
$student_table = $wpdb->prefix."wpsp_student"; |
| 73 |
// $parent_info = $wpdb->get_row("select parent_wp_usr_id from $student_table where wp_usr_id='".esc_sql($student_id)."'"); |
| 74 |
$parent_info = $wpdb->get_row($wpdb->prepare("SELECT parent_wp_usr_id FROM $student_table WHERE wp_usr_id = %d",$student_id)); |
| 75 |
$parent_id = sanitize_text_field($parent_info->parent_wp_usr_id); |
| 76 |
$label = esc_html('Parent Profile','wpschoolpress'); |
| 77 |
} |
| 78 |
|
| 79 |
if($parent_id > 0){ |
| 80 |
global $wpdb; |
| 81 |
$student_table = $wpdb->prefix . "wpsp_student"; |
| 82 |
$users_table = $wpdb->prefix . "users"; |
| 83 |
if ($parent_id != ''){ |
| 84 |
$pid = intval($parent_id); |
| 85 |
}else{ |
| 86 |
$pid = ''; |
| 87 |
} |
| 88 |
if (!empty($pid)) $where = "where p.parent_wp_usr_id='".esc_sql($pid)."'"; |
| 89 |
|
| 90 |
$button = isset($_POST['button']) ? sanitize_text_field($_POST['button']) : ''; |
| 91 |
|
| 92 |
$pinfo = $wpdb->get_row("select p.*, CONCAT_WS(' ', p_fname, p_mname, p_lname ) AS full_name ,u.user_email from $student_table p LEFT JOIN $users_table u ON u.ID=p.parent_wp_usr_id $where"); |
| 93 |
$loc_avatar = get_user_meta($pid, 'simple_local_avatar', true); |
| 94 |
$img_url = $loc_avatar ? $loc_avatar['full'] : WPSP_PLUGIN_URL . 'img/avatar.png'; |
| 95 |
|
| 96 |
if (!empty($pinfo)){ |
| 97 |
$profile = "<div class='wpsp-panel-body'> |
| 98 |
<div class='wpsp-userpic'style='margin-top: 0;'> |
| 99 |
<img src=".esc_url($img_url)." height='150px' width='150px' class='img img-circle'/> |
| 100 |
</div> |
| 101 |
<div class='wpsp-userDetails'> |
| 102 |
<table class='wpsp-table'> |
| 103 |
<tbody> |
| 104 |
<tr> |
| 105 |
<td colspan='2'><strong>Full Name: </strong>".esc_html($pinfo->p_fname. $pinfo->p_mname. $pinfo->p_lname)." </td> |
| 106 |
</tr> |
| 107 |
<tr> |
| 108 |
<td><strong>Email: </strong>".esc_html($pinfo->user_email)."</td> |
| 109 |
<td><strong>Gender: </strong>".esc_html($pinfo->p_gender)."</td> |
| 110 |
</tr> |
| 111 |
<tr> |
| 112 |
<td><strong>Education: </strong>".esc_html($pinfo->p_edu)."</td> |
| 113 |
<td><strong>Profession: </strong>".esc_html($pinfo->p_profession)."</td> |
| 114 |
</tr> |
| 115 |
<tr> |
| 116 |
<td colspan='2'><strong>Blood Group: </strong> ".esc_html($pinfo->p_bloodgrp)."</td> |
| 117 |
</tr> |
| 118 |
</tbody> |
| 119 |
</table> |
| 120 |
</div> |
| 121 |
</div>"; |
| 122 |
} else { |
| 123 |
$profile = esc_html("No data retrived!..","wpschoolpress"); |
| 124 |
} |
| 125 |
// echo apply_filters('wpsp_parent_profile', wp_kses_post($profile), intval($pid)); |
| 126 |
echo wp_kses_post($profile); |
| 127 |
}else{ |
| 128 |
echo "<p>Parent profile not linked with this account, Kindly contact to School!</p>"; |
| 129 |
} |
| 130 |
wpsp_body_end(); |
| 131 |
wpsp_footer(); |
| 132 |
} |
| 133 |
} else { |
| 134 |
include_once( WPSP_PLUGIN_PATH.'/includes/wpsp-login.php'); |
| 135 |
} |
| 136 |
?> |
| 137 |
|