| 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 |
$filename = WPSP_PLUGIN_PATH .'includes/wpsp-studentList.php'; |
| 12 |
if( isset( $_GET['tab'] ) && $_GET['tab'] == 'addstudent' ) { |
| 13 |
if($current_user_role=='administrator'){ |
| 14 |
$label = __( 'Add New Student', 'wpschoolpress'); |
| 15 |
$filename = WPSP_PLUGIN_PATH .'includes/wpsp-studentForm.php'; |
| 16 |
} |
| 17 |
} else if( isset($_GET['id']) && is_numeric($_GET['id']) ) { |
| 18 |
if($current_user_role=='administrator' || $current_user_role=='teacher') { |
| 19 |
$label = __( 'Update Student', 'wpschoolpress'); |
| 20 |
$filename = WPSP_PLUGIN_PATH .'includes/wpsp-studentProfile.php'; |
| 21 |
} |
| 22 |
} else if( isset( $_POST['ClassID'] ) && empty( $_POST['ClassID'] ) ) { |
| 23 |
$label = esc_html('List Of Unassigned Students','wpschoolpress'); |
| 24 |
} else if( isset( $_POST['ClassID'] ) && $_POST['ClassID']=='all' ) { |
| 25 |
$label = esc_html('List Of All Students','wpschoolpress'); |
| 26 |
} else if( isset( $_POST['ClassID'] ) && !empty( $_POST['ClassID'] ) ){ |
| 27 |
$class_table = $wpdb->prefix."wpsp_class"; |
| 28 |
$sel_class = $wpdb->prepare( |
| 29 |
"SELECT * FROM $class_table WHERE cid LIKE %d;",'%' . $wpdb->esc_like( $_POST['ClassID'] ) . '%' |
| 30 |
); |
| 31 |
$label = 'List of class ' .esc_html($sel_class). ' Students'; |
| 32 |
} else { |
| 33 |
$label = esc_html('List Of All Students','wpschoolpress'); |
| 34 |
} |
| 35 |
include_once ( $filename ); |
| 36 |
if(isset($_GET['tab'])){ |
| 37 |
if($_GET['tab'] != 'addstudent' ) { |
| 38 |
do_action('wpsp_student_import_html'); |
| 39 |
} |
| 40 |
} |
| 41 |
wpsp_body_end(); |
| 42 |
wpsp_footer(); |
| 43 |
}else if($current_user_role=='parent') { |
| 44 |
/* Parents can View their children's class students */ |
| 45 |
wpsp_topbar(); |
| 46 |
wpsp_sidebar(); |
| 47 |
wpsp_body_start(); |
| 48 |
global $wpdb; |
| 49 |
$parent_id = intval($current_user->ID); |
| 50 |
$student_table = $wpdb->prefix."wpsp_student"; |
| 51 |
$class_table = $wpdb->prefix."wpsp_class"; |
| 52 |
$users_table = $wpdb->prefix."users"; |
| 53 |
// $students = $wpdb->get_results("select st.wp_usr_id, st.class_id, st.s_fname AS full_name,cl.c_name from $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id where st.parent_wp_usr_id='".esc_sql($parent_id)."'"); |
| 54 |
$students = $wpdb->get_results($wpdb->prepare("SELECT st.wp_usr_id, st.class_id, st.s_fname AS full_name,cl.c_name FROM $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id WHERE st.parent_wp_usr_id = %d",$parent_id)); |
| 55 |
$child=array(); |
| 56 |
foreach($students as $childinfo){ |
| 57 |
$child[]=array('student_id'=>$childinfo->wp_usr_id,'name'=>$childinfo->full_name,'class_id'=>$childinfo->class_id,'class_name'=>$childinfo->c_name); |
| 58 |
} |
| 59 |
if( count( $child ) > 0 ) { ?> |
| 60 |
<div class="wpsp-card"> |
| 61 |
<div class="wpsp-card-body"> |
| 62 |
<div class="tabbable-line"> |
| 63 |
<div class="tabSec wpsp-nav-tabs-custom" id="verticalTab"> |
| 64 |
<div class="tabList"> |
| 65 |
<ul class="wpsp-resp-tabs-list"> |
| 66 |
<?php $i=0; foreach($child as $ch) { ?> |
| 67 |
<li class="wpsp-tabing <?php echo ($i==0)?'active':''?>"><!-- <a href="#<?php echo esc_attr(str_replace(' ', '', $ch['name'].$i ));?>" data-toggle="tab"> --><?php echo esc_html($ch['name']);?><!-- </a> --></li> |
| 68 |
<?php $i++; } ?> |
| 69 |
</ul> |
| 70 |
</div> |
| 71 |
<div class="wpsp-tabBody wpsp-resp-tabs-container"> |
| 72 |
<?php |
| 73 |
$i=0; |
| 74 |
foreach($child as $ch) { |
| 75 |
$ch_class=$ch['class_id']; |
| 76 |
?> |
| 77 |
<div class="tab-pane wpsp-tabMain <?php echo ($i==0)?' active':''?>" id="<?php echo esc_attr(str_replace(' ', '', $ch['name'].$i ));?>"> |
| 78 |
<div class="studentProfile"> |
| 79 |
<?php |
| 80 |
$sid=sanitize_text_field($ch['student_id']); |
| 81 |
// $stinfo=$wpdb->get_row("select a.*,b.c_name,CONCAT_WS(' ', a.s_fname, a.s_mname, a.s_lname ) AS full_name,d.user_email from $student_table a LEFT JOIN $class_table b ON a.class_id=b.cid LEFT JOIN $users_table d ON d.ID=a.wp_usr_id where a.wp_usr_id='".esc_sql($sid)."'"); |
| 82 |
$stinfo = $wpdb->get_results($wpdb->prepare("SELECT a.*,b.c_name,CONCAT_WS(' ', a.s_fname, a.s_mname, a.s_lname ) AS full_name,d.user_email FROM $student_table a LEFT JOIN $class_table b ON a.class_id=b.cid LEFT JOIN $users_table d ON d.ID=a.wp_usr_id WHERE a.wp_usr_id = %d",$sid)); |
| 83 |
if (is_numeric($stinfo->class_id)){ |
| 84 |
$classIDArray[] = $stinfo->class_id; |
| 85 |
}else{ |
| 86 |
$classIDArray = unserialize($stinfo->class_id); |
| 87 |
} |
| 88 |
$classname_array = []; |
| 89 |
$classIDArray_Sanitiz = array_map('intval',$classIDArray); |
| 90 |
foreach ($classIDArray_Sanitiz as $id ) { |
| 91 |
$id = esc_sql($id); |
| 92 |
// $clasname = $wpdb->get_var("SELECT c_name FROM $class_table where cid='$id'"); |
| 93 |
$clasname = $wpdb->get_results($wpdb->prepare("SELECT c_name FROM $class_table WHERE cid = %d",$id)); |
| 94 |
$classname_array[] = $clasname; |
| 95 |
} |
| 96 |
if(!empty($stinfo)) { |
| 97 |
?> |
| 98 |
<div class="wpsp-row"> |
| 99 |
<div class="wpsp-col-xs-12 wpsp-col-sm-12 wpsp-col-md-12 wpsp-col-lg-12"> |
| 100 |
<div class="wpsp-panel wpsp-panel-info"> |
| 101 |
<div class="wpsp-row"> |
| 102 |
<div class="wpsp-col-md-3 wpsp-col-lg-2"> |
| 103 |
<?php |
| 104 |
$loc_avatar=get_user_meta($sid,'simple_local_avatar',true); |
| 105 |
$img_url= $loc_avatar ? sanitize_text_field($loc_avatar['full']) : WPSP_PLUGIN_URL.'img/avatar.png'; |
| 106 |
?> |
| 107 |
<img src="<?php echo esc_url($img_url);?>" height="150px" width="150px" class="img wpsp-img-circle"/> |
| 108 |
</div> |
| 109 |
<div class="wpsp-col-md-9 wpsp-col-lg-10"> |
| 110 |
<br> |
| 111 |
<h3 class="wpsp-card-title"><?php echo esc_html($stinfo->full_name); ?></h3> |
| 112 |
<div class="wpsp-table-responsive"> |
| 113 |
<table id="studentchildInfo" class="wpsp-table table-user-information" cellspacing="0" width="100%" style="width:100%"> |
| 114 |
<tbody> |
| 115 |
<tr> |
| 116 |
<td class="bold" width="200px"><?php esc_html_e( 'Roll No.', 'wpschoolpress'); ?></td> |
| 117 |
<td><?php echo esc_html($stinfo->s_rollno); ?></td> |
| 118 |
</tr> |
| 119 |
<tr> |
| 120 |
<td class="bold"><?php esc_html_e( 'Class', 'wpschoolpress'); ?> </td> |
| 121 |
<td><?php echo esc_html(implode(", ",$classname_array)); ?></td> |
| 122 |
</tr> |
| 123 |
<tr> |
| 124 |
<td class="bold"><?php esc_html_e( 'Gender', 'wpschoolpress'); ?></td> |
| 125 |
<td><?php echo esc_html($stinfo->s_gender); ?></td> |
| 126 |
</tr> |
| 127 |
<tr> |
| 128 |
<td class="bold"><?php esc_html_e( 'Date of Birth', 'wpschoolpress' );?></td> |
| 129 |
<td><?php echo esc_html(wpsp_ViewDate($stinfo->s_dob)); ?></td> |
| 130 |
</tr> |
| 131 |
<tr> |
| 132 |
<td class="bold"><?php esc_html_e( 'Date of Join', 'wpschoolpress'); ?></td> |
| 133 |
<td><?php echo esc_html(wpsp_ViewDate($stinfo->s_doj)); ?></td> |
| 134 |
</tr> |
| 135 |
<tr> |
| 136 |
<td class="bold"><?php esc_html_e( 'Permanent Address', 'wpschoolpress'); ?></td> |
| 137 |
<td><?php echo esc_html($stinfo->s_paddress); ?></td> |
| 138 |
</tr> |
| 139 |
<tr> |
| 140 |
<td class="bold"><?php esc_html_e( 'Permanent Country', 'wpschoolpress'); ?></td> |
| 141 |
<td><?php echo esc_html($stinfo->s_pcountry); ?></td> |
| 142 |
</tr> |
| 143 |
<tr> |
| 144 |
<td class="bold"><?php esc_html_e( 'Permanent Zipcode', 'wpschoolpress'); ?></td> |
| 145 |
<td><?php echo esc_html($stinfo->s_pzipcode); ?></td> |
| 146 |
</tr> |
| 147 |
<tr> |
| 148 |
<td class="bold"><?php esc_html_e( 'Email', 'wpschoolpress'); ?></td> |
| 149 |
<td><?php echo esc_html($stinfo->user_email); ?></td> |
| 150 |
</tr> |
| 151 |
<tr> |
| 152 |
<td class="bold"><?php esc_html_e( 'Phone Number', 'wpschoolpress'); ?></td> |
| 153 |
<td><?php echo esc_html($stinfo->s_phone); ?></td> |
| 154 |
</tr> |
| 155 |
<tr> |
| 156 |
<td class="bold"><?php esc_html_e( 'Blood Group', 'wpschoolpress'); ?></td> |
| 157 |
<td><?php echo esc_html($stinfo->s_bloodgrp); ?></td> |
| 158 |
</tr> |
| 159 |
</tbody> |
| 160 |
</table> |
| 161 |
</div> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
</div> |
| 168 |
<?php } else { |
| 169 |
esc_html_e( 'Sorry! No data retrieved', 'wpschoolpress'); |
| 170 |
} |
| 171 |
?> |
| 172 |
</div> |
| 173 |
<?php $i++; } ?> |
| 174 |
</div> |
| 175 |
</div> |
| 176 |
</div> |
| 177 |
</div> |
| 178 |
</div> |
| 179 |
<?php |
| 180 |
} else { |
| 181 |
esc_html_e('No Child Added, Please contact teacher/admin to add your child','wpschoolpress'); |
| 182 |
} ?> |
| 183 |
<?php |
| 184 |
wpsp_body_end(); |
| 185 |
wpsp_footer(); |
| 186 |
} else if($current_user_role=='student') { |
| 187 |
wpsp_topbar(); |
| 188 |
wpsp_sidebar(); |
| 189 |
wpsp_body_start(); |
| 190 |
global $wpdb; |
| 191 |
$student_id=intval($current_user->ID); |
| 192 |
$student_table=$wpdb->prefix."wpsp_student"; |
| 193 |
$class_table=$wpdb->prefix."wpsp_class"; |
| 194 |
// $student=$wpdb->get_row("select st.class_id, CONCAT_WS(' ', st.s_fname, st.s_mname, st.s_lname ) AS full_name,cl.c_name from $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id where st.wp_usr_id='".esc_sql($student_id)."'"); |
| 195 |
$student = $wpdb->get_row($wpdb->prepare("SELECT st.class_id, CONCAT_WS(' ', st.s_fname, st.s_mname, st.s_lname ) AS full_name,cl.c_name FROM $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id WHERE st.wp_usr_id = %d",$student_id)); |
| 196 |
?> |
| 197 |
<div class="wpsp-card"> |
| 198 |
<div class="wpsp-card-head"> |
| 199 |
<h3 class="wpsp-card-title"> |
| 200 |
<?php |
| 201 |
$st_class=$student->class_id; |
| 202 |
if( isset( $student->c_name ) && !empty( $student->c_name ) ) |
| 203 |
echo "Your Current Class is".esc_html( $student->c_name,'wpschoolpress' ); |
| 204 |
?> |
| 205 |
</h3> |
| 206 |
</div> |
| 207 |
<div class="wpsp-card-body"> |
| 208 |
<table class="wpsp-table"> |
| 209 |
<thead> |
| 210 |
<tr> |
| 211 |
<th>#</th> |
| 212 |
<th><?php echo esc_html(apply_filters( 'wpsp_student_table_rollno_heading','Roll No.'),'wpschoolpress');?></th> |
| 213 |
<th><?php echo esc_html(apply_filters( 'wpsp_student_table_fullname_heading','Student Name'),'wpschoolpress');?></th> |
| 214 |
<th><?php echo esc_html(apply_filters( 'wpsp_student_table_parent_heading','Parent Name'),'wpschoolpress');?></th> |
| 215 |
<th><?php echo esc_html(apply_filters( 'wpsp_student_table_streetaddress_heading','Permanent Address'),'wpschoolpress');?></th> |
| 216 |
</tr> |
| 217 |
</thead> |
| 218 |
<tbody> |
| 219 |
<?php |
| 220 |
$class_id = base64_decode(sanitize_text_field(stripslashes($_GET['cid']))); |
| 221 |
$cl_students=$wpdb->get_results("select wp_usr_id, class_id, CONCAT_WS(' ', s_fname, s_mname, s_lname ) AS full_name,parent_wp_usr_id, CONCAT_WS(' ', p_fname, p_mname, p_lname ) AS p_full_name, CONCAT_WS(' ', s_paddress, s_pcity, s_pcountry ) AS peraddress, s_rollno from $student_table"); |
| 222 |
$sno=1; |
| 223 |
$jsonArray=[]; |
| 224 |
foreach($cl_students as $cl_st) { |
| 225 |
$jsonArray=[]; |
| 226 |
$jsonvalue1 = false; // initialize |
| 227 |
$jsondata = $cl_st->class_id; |
| 228 |
if (is_numeric($jsondata)){ |
| 229 |
$jsonArray[] = $jsondata; |
| 230 |
$jsonvalue1 = $jsondata; |
| 231 |
}else{ |
| 232 |
$jsonArray = unserialize($jsondata); |
| 233 |
if(!empty($jsonArray)){ |
| 234 |
$jsonvalue1 = in_array($class_id, $jsonArray); |
| 235 |
} |
| 236 |
} |
| 237 |
if(!empty($jsonvalue1)){ |
| 238 |
?> |
| 239 |
<tr> |
| 240 |
<td><?php echo esc_html($sno);?></td> |
| 241 |
<td><?php echo esc_html($cl_st->s_rollno);?></td> |
| 242 |
<td><?php echo esc_html($cl_st->full_name);?></td> |
| 243 |
<td><?php echo esc_html($cl_st->p_full_name);?></a> |
| 244 |
<td><?php echo esc_html($cl_st->peraddress);?> </td> |
| 245 |
</tr> |
| 246 |
<?php $sno++; |
| 247 |
} |
| 248 |
} |
| 249 |
?> |
| 250 |
</tbody> |
| 251 |
</table> |
| 252 |
</div> |
| 253 |
</div> |
| 254 |
<?php |
| 255 |
wpsp_body_end(); |
| 256 |
wpsp_footer(); |
| 257 |
} |
| 258 |
?> |
| 259 |
<div class="wpsp-popupMain" id="ViewModal"> |
| 260 |
<div class="wpsp-overlayer"></div> |
| 261 |
<div class="wpsp-popBody"> |
| 262 |
<div class="wpsp-popInner"> |
| 263 |
<a href="javascript:;" class="wpsp-closePopup"></a> |
| 264 |
<div id="ViewModalContent"></div> |
| 265 |
</div> |
| 266 |
</div> |
| 267 |
</div> |
| 268 |
<?php |
| 269 |
}else { |
| 270 |
include_once( WPSP_PLUGIN_PATH.'/includes/wpsp-login.php');//Include login |
| 271 |
} |
| 272 |
?> |