| 1 |
<?php |
| 2 |
if (!defined( 'ABSPATH' ) )exit('No Such File'); |
| 3 |
wpsp_header(); |
| 4 |
if( is_user_logged_in() ) { |
| 5 |
global $current_user, $wpdb; |
| 6 |
$current_user_role=$current_user->roles[0]; |
| 7 |
if( $current_user_role=='administrator' || $current_user_role=='teacher') |
| 8 |
{ |
| 9 |
wpsp_topbar(); |
| 10 |
wpsp_sidebar(); |
| 11 |
wpsp_body_start(); |
| 12 |
$class_table = $wpdb->prefix."wpsp_class"; |
| 13 |
$classQuery = "select cid,c_name from $class_table Order By cid ASC"; |
| 14 |
$msg = 'Please Add Class Before Adding Subjects'; |
| 15 |
|
| 16 |
$sel_class = $wpdb->get_results( $classQuery ); |
| 17 |
if(( isset($_GET['classid']) && is_numeric($_GET['classid']))) { |
| 18 |
if($current_user_role=='administrator'){ |
| 19 |
$label = __( 'Add New Class', 'wpschoolpress'); |
| 20 |
$filename = WPSP_PLUGIN_PATH .'includes/wpsp-subjectForm.php'; |
| 21 |
} |
| 22 |
include_once ( $filename ); |
| 23 |
}elseif(( isset($_GET['id']) && is_numeric($_GET['id']))) { |
| 24 |
if($current_user_role=='administrator'){ |
| 25 |
$label = __( 'Edit Class', 'wpschoolpress'); |
| 26 |
$filename = WPSP_PLUGIN_PATH .'includes/wpsp-editsubjectForm.php'; |
| 27 |
include_once ( $filename ); |
| 28 |
} |
| 29 |
}else{ |
| 30 |
if($sel_class[0]->c_name != ''){ |
| 31 |
$sel_classname = $sel_class[0]->c_name; |
| 32 |
//echo $sel_classid = $sel_class[0]->cid; |
| 33 |
if( isset( $_POST['ClassID'] ) && !empty (sanitize_text_field($_POST['ClassID']) ) ) { |
| 34 |
$sel_classid = intval($_POST['ClassID']); |
| 35 |
foreach( $sel_class as $key=>$value ) { |
| 36 |
if( $value->cid == $sel_classid ) { |
| 37 |
$sel_classname = $value->c_name; |
| 38 |
break; |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
}else{ |
| 43 |
$sel_classname = ''; |
| 44 |
} |
| 45 |
?> |
| 46 |
<div class="wpsp-card"> |
| 47 |
<?php if( empty( $sel_class ) ) { echo '<div class="alert alert-danger col-lg-2">'.esc_html($msg).'</div>'; } else { ?> |
| 48 |
<div class="wpsp-card-head"> |
| 49 |
<div class="subject-inner wpsp-left wpsp-class-filter"> |
| 50 |
<form action="" id="SubjectList-Form" name="SubjectList-Form" method="POST"> |
| 51 |
<label class="wpsp-labelMain"><?php esc_html_e( 'Select Class Name', 'wpschoolpress' ); ?> *</label> |
| 52 |
<select name="ClassID" id="ClassID" class="wpsp-form-control"> |
| 53 |
<?php if($sel_classid == ''){$sel_classid = 'all';} ?> |
| 54 |
<option value="all" <?php if($sel_classid == 'all') echo esc_html("selected","wpschoolpress"); ?>><?php esc_html_e( 'All', 'wpschoolpress' ); ?></option> |
| 55 |
<?php |
| 56 |
foreach($sel_class as $classes) { ?> |
| 57 |
<option value="<?php echo esc_attr(intval($classes->cid));?>" <?php if($sel_classid == $classes->cid) echo esc_html("selected","wpschoolpress"); ?>><?php echo esc_html($classes->c_name);?></option> |
| 58 |
<?php } ?> |
| 59 |
</select> |
| 60 |
</form> |
| 61 |
</div> |
| 62 |
</div> |
| 63 |
<div class="wpsp-card-body"> |
| 64 |
<table id="subject_table" class="wpsp-table subjectdataTable" cellspacing="0" width="100%" style="width:100%"> |
| 65 |
<thead> |
| 66 |
<tr> |
| 67 |
<th class="nosort">#</th> |
| 68 |
<th><?php esc_html_e( 'Subject Code', 'wpschoolpress' ); ?></th> |
| 69 |
<th><?php esc_html_e( 'Subject Name', 'wpschoolpress' ); ?></th> |
| 70 |
<th><?php esc_html_e( 'Faculty', 'wpschoolpress' ); ?></th> |
| 71 |
<th><?php esc_html_e( 'Book Name', 'wpschoolpress' ); ?></th> |
| 72 |
<?php if( $current_user_role=='administrator') { ?> |
| 73 |
<th class="nosort" ><?php esc_html_e( 'Action', 'wpschoolpress' ); ?></th> |
| 74 |
<?php } ?> |
| 75 |
</tr> |
| 76 |
</thead> |
| 77 |
<tbody> |
| 78 |
<?php |
| 79 |
$teacher_table= $wpdb->prefix."wpsp_teacher"; |
| 80 |
$teacher_data = $wpdb->get_results("select wp_usr_id,CONCAT_WS(' ', first_name, last_name ) AS full_name from $teacher_table order by tid"); |
| 81 |
$teacherlist = array(); |
| 82 |
if( !empty( $teacher_data ) ) { |
| 83 |
foreach( $teacher_data as $value ) |
| 84 |
$teacherlist[$value->wp_usr_id] = $value->full_name; |
| 85 |
} |
| 86 |
$subtable=$wpdb->prefix."wpsp_subject"; |
| 87 |
$class_id=''; |
| 88 |
if( isset($_POST['ClassID'] ) ) { |
| 89 |
$class_id=sanitize_text_field($_POST['ClassID']); |
| 90 |
}else if( !empty( $sel_class ) ) { |
| 91 |
$class_id = 'all'; |
| 92 |
} |
| 93 |
$classquery = "where class_id='".esc_sql($class_id)."'"; |
| 94 |
if($class_id=='NULL'){ |
| 95 |
$classquery = ""; |
| 96 |
}elseif($class_id=='all'){ |
| 97 |
$classquery=""; |
| 98 |
} |
| 99 |
$wpsp_subjects =$wpdb->get_results("select * from $subtable $classquery order by sub_code desc"); |
| 100 |
$sno=1; |
| 101 |
if(!empty($wpsp_subjects)){ |
| 102 |
foreach ($wpsp_subjects as $wpsp_subject) |
| 103 |
{ |
| 104 |
$teach_id= (int)$wpsp_subject->sub_teach_id; |
| 105 |
$teacher=get_userdata($teach_id); |
| 106 |
?> |
| 107 |
<tr id="<?php echo esc_html($wpsp_subject->id);?>" class="pointer"> |
| 108 |
<td><?php echo esc_html($sno);?></td> |
| 109 |
<td><?php echo !empty( $wpsp_subject->sub_code ) ? esc_html($wpsp_subject->sub_code) :'-'; ?></td> |
| 110 |
<td><?php echo esc_html($wpsp_subject->sub_name);?></td> |
| 111 |
<td><?php echo isset( $teacherlist[$teach_id] ) ? esc_html($teacherlist[$teach_id]) : '';?></td> |
| 112 |
<td><?php echo esc_html($wpsp_subject->book_name);?></td> |
| 113 |
<?php if( $current_user_role=='administrator') { ?> |
| 114 |
<td > |
| 115 |
<div class="wpsp-action-col"> |
| 116 |
<?php if($wpsp_subject->id!=1){?> |
| 117 |
<a href="<?php echo esc_url(wpsp_admin_url().'sch-subject&id='.esc_attr(intval ($wpsp_subject->id)).'&edit=true');?>" title="Edit"><i class="icon wpsp-edit wpsp-edit-icon"></i></a> |
| 118 |
<?php } ?> |
| 119 |
<!-- <a href="<//?php echo esc_url(wpsp_admin_url().'sch-subject&id='.esc_attr(intval ($wpsp_subject->id)).'&edit=true');?>"><i class="icon wpsp-edit wpsp-edit-icon"></i></a> --> |
| 120 |
<a href="javascript:;" id="d_teacher" class="wpsp-popclick" data-pop="DeleteModal" title="Delete" data-id="<?php echo esc_attr(intval($wpsp_subject->id));?>" > |
| 121 |
<i class="icon wpsp-trash wpsp-delete-icon" data-id="<?php echo esc_attr(intval($wpsp_subject->id));?>"></i> |
| 122 |
</a> |
| 123 |
</div> |
| 124 |
</td> |
| 125 |
<?php } ?> |
| 126 |
</tr> |
| 127 |
<?php |
| 128 |
$sno++; |
| 129 |
} |
| 130 |
} |
| 131 |
?> |
| 132 |
</tbody> |
| 133 |
<tfoot> |
| 134 |
<tr> |
| 135 |
<th class="nosort">#</th> |
| 136 |
<th><?php esc_html_e( 'Subject Code', 'wpschoolpress' ); ?></th> |
| 137 |
<th><?php esc_html_e( 'Subject Name', 'wpschoolpress' ); ?></th> |
| 138 |
<th><?php esc_html_e( 'Faculty', 'wpschoolpress' ); ?></th> |
| 139 |
<th><?php esc_html_e( 'Book Name', 'wpschoolpress' ); ?></th> |
| 140 |
<?php if( $current_user_role=='administrator') { ?> |
| 141 |
<th class="nosort" ><?php esc_html_e( 'Action', 'wpschoolpress' ); ?></th> |
| 142 |
<?php } ?> |
| 143 |
</tr> |
| 144 |
</tfoot> |
| 145 |
</table> |
| 146 |
</div> |
| 147 |
<?php } ?> |
| 148 |
</div> |
| 149 |
<?php }?> |
| 150 |
<?php if($current_user_role=='administrator'){?> |
| 151 |
<div class="modal fade" id="InfoModal" tabindex="-1" role="dialog" aria-labelledby="InfoModal" aria-hidden="true"> |
| 152 |
<div class="modal-dialog"> |
| 153 |
<div class="modal-content"> |
| 154 |
<div class="col-md-12"> |
| 155 |
<div class="box box-success"> |
| 156 |
<div class="box-header"> |
| 157 |
<h3 class="box-title" id="InfoModalTitle"></h3> |
| 158 |
</div><!-- /.box-header --> |
| 159 |
<div id="InfoModalBody" class="box-body"> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
</div><!-- /.modal --> |
| 166 |
<?php } |
| 167 |
wpsp_body_end(); |
| 168 |
wpsp_footer(); |
| 169 |
} |
| 170 |
else if($current_user_role=='parent') |
| 171 |
{ |
| 172 |
wpsp_topbar(); |
| 173 |
wpsp_sidebar(); |
| 174 |
wpsp_body_start(); |
| 175 |
$parent_id=intval($current_user->ID); |
| 176 |
$ciid = sanitize_text_field(stripslashes($_GET['cid'])); |
| 177 |
$class_id = sanitize_text_field(base64_decode($ciid)); |
| 178 |
$student_table=$wpdb->prefix."wpsp_student"; |
| 179 |
$class_table=$wpdb->prefix."wpsp_class"; |
| 180 |
$subject_table=$wpdb->prefix."wpsp_subject"; |
| 181 |
// $students=$wpdb->get_results("select st.wp_usr_id, st.class_id, st.s_fname, st.sid, 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='".esc_sql($class_id)."' where st.parent_wp_usr_id='".esc_sql($parent_id)."'"); |
| 182 |
$students = $wpdb->get_results($wpdb->prepare("SELECT st.wp_usr_id, st.class_id, st.s_fname, st.sid, 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 = %d WHERE st.parent_wp_usr_id = %d ",$class_id,$parent_id)); |
| 183 |
$child=array(); |
| 184 |
foreach($students as $childinfo){ |
| 185 |
$child[]=array('student_id'=>$childinfo->wp_usr_id,'fname'=>$childinfo->s_fname,'name'=>$childinfo->full_name,'class_id'=>$childinfo->class_id,'class_name'=>$childinfo->c_name, 'sid'=>$childinfo->sid); |
| 186 |
} |
| 187 |
?> |
| 188 |
<div class="wpsp-card"> |
| 189 |
<div class="wpsp-card-body"> |
| 190 |
<div class="tabbable-line"> |
| 191 |
<div class="tabSec wpsp-nav-tabs-custom" id="verticalTab"> |
| 192 |
<div class="tabList"> |
| 193 |
<ul class="wpsp-resp-tabs-list"> |
| 194 |
<?php $i=0; foreach($child as $ch) { |
| 195 |
if(base64_decode(sanitize_text_field($_GET['sid'])) == $ch['sid']){ ?> |
| 196 |
<li class="wpsp-tabing <?php echo ($i==0)?'active':''?>"> |
| 197 |
<?php echo esc_html($ch['name']);?> |
| 198 |
</li> |
| 199 |
<?php } $i++; } ?> |
| 200 |
</ul> |
| 201 |
</div> |
| 202 |
<div class="wpsp-tabBody wpsp-resp-tabs-container"> |
| 203 |
<?php |
| 204 |
$teacher_table= $wpdb->prefix."wpsp_teacher"; |
| 205 |
$teacher_data = $wpdb->get_results("select wp_usr_id,CONCAT_WS(' ', first_name, last_name ) AS full_name from $teacher_table order by tid"); |
| 206 |
$teacherlist = array(); |
| 207 |
if( !empty( $teacher_data ) ) { |
| 208 |
foreach( $teacher_data as $value ) |
| 209 |
$teacherlist[$value->wp_usr_id] = $value->full_name; |
| 210 |
} |
| 211 |
$i=0; |
| 212 |
foreach($child as $ch) { |
| 213 |
$ch_class=$ch['class_id']; |
| 214 |
?> |
| 215 |
<div class="tab-pane wpsp-tabMain <?php echo ($i==0)?'active':''?>" id="<?php echo esc_attr(str_replace(" ", "",$ch['fname'].$i));?>"> |
| 216 |
<caption><label class="wpsp-labelMain"> <?php esc_html_e( 'Class Name', 'wpschoolpress' ); ?> : </label> <?php echo esc_html($ch['class_name']);?></caption> <div class="wpsp-table-responsive"> |
| 217 |
<table id="subject_table<?php echo esc_attr($i++); ?>" class="wpsp-table subjectdataTable" cellspacing="0" width="100%" style="width:100%"> |
| 218 |
<thead> |
| 219 |
<tr> |
| 220 |
<th>#</th> |
| 221 |
<th><?php esc_html_e( 'Subject Code', 'wpschoolpress' ); ?></th> |
| 222 |
<th><?php esc_html_e( 'Subject Name', 'wpschoolpress' ); ?></th> |
| 223 |
<th><?php esc_html_e( 'Faculty', 'wpschoolpress' ); ?></th> |
| 224 |
<th><?php esc_html_e( 'Book Name', 'wpschoolpress' ); ?></th> |
| 225 |
</tr> |
| 226 |
</thead> |
| 227 |
<tbody> |
| 228 |
<?php |
| 229 |
$class_id = sanitize_text_field($class_id); |
| 230 |
//$cl_subjects=$wpdb->get_results("select * from $subject_table where class_id='".esc_sql($class_id)."'"); |
| 231 |
$cl_subjects = $wpdb->get_results($wpdb->prepare("SELECT * FROM $subject_table WHERE class_id = %d ",$class_id)); |
| 232 |
$sno=1; |
| 233 |
foreach($cl_subjects as $cl_sub){ |
| 234 |
$teach_id= (int)$cl_sub->sub_teach_id; |
| 235 |
$teacher=get_userdata($teach_id); |
| 236 |
?> |
| 237 |
<tr id="<?php echo esc_attr(intval($cl_sub->id));?>" class="pointer"> |
| 238 |
<td><?php echo esc_html($sno);?></td> |
| 239 |
<td><?php echo !empty( $cl_sub->sub_code ) ? esc_html($cl_sub->sub_code) : '-' ; ?></td> |
| 240 |
<td><?php echo esc_html($cl_sub->sub_name);?></td> |
| 241 |
<td><?php echo isset( $teacherlist[$teach_id] ) ? esc_html($teacherlist[$teach_id]) : '';?></td> |
| 242 |
<td><?php echo esc_html($cl_sub->book_name);?></td> |
| 243 |
</tr> |
| 244 |
<?php |
| 245 |
$sno++; |
| 246 |
} |
| 247 |
?> |
| 248 |
</tbody> |
| 249 |
</table> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
<?php $i++; } ?> |
| 253 |
</div> |
| 254 |
</div> |
| 255 |
</div> |
| 256 |
</div> |
| 257 |
</div> |
| 258 |
<?php |
| 259 |
wpsp_body_end(); |
| 260 |
wpsp_footer(); |
| 261 |
}else if($current_user_role=='student') |
| 262 |
{ |
| 263 |
wpsp_topbar(); |
| 264 |
wpsp_sidebar(); |
| 265 |
wpsp_body_start(); |
| 266 |
$ciid = sanitize_text_field(stripslashes($_GET['cid'])); |
| 267 |
$class_id = sanitize_text_field(base64_decode($ciid)); |
| 268 |
$student_id=sanitize_text_field($current_user->ID); |
| 269 |
$student_table=$wpdb->prefix."wpsp_student"; |
| 270 |
$class_table=$wpdb->prefix."wpsp_class"; |
| 271 |
$subject_table=$wpdb->prefix."wpsp_subject"; |
| 272 |
// $cl_subjects = $wpdb->get_results("select st.class_id,su.* from $student_table st LEFT JOIN $subject_table su ON su.class_id='".esc_sql($class_id)."' where st.wp_usr_id='".esc_sql($student_id)."'"); |
| 273 |
$cl_subjects = $wpdb->get_results($wpdb->prepare("SELECT st.class_id,su.* FROM $student_table st LEFT JOIN $subject_table su ON su.class_id = %d WHERE st.wp_usr_id = %d ",$class_id,$student_id)); |
| 274 |
?> |
| 275 |
<section class="wpsp-card"> |
| 276 |
<div class="wpsp-card-head"> |
| 277 |
<h3 class="wpsp-card-title"><?php esc_html_e( 'List of Subjects', 'wpschoolpress' )?> </h3> |
| 278 |
</div> |
| 279 |
<div class="wpsp-card-body"> |
| 280 |
<table class="wpsp-table" id="listofsubjects" cellspacing="0" width="100%" style="width:100%"> |
| 281 |
<thead> |
| 282 |
<tr> |
| 283 |
<th>#</th> |
| 284 |
<th><?php esc_html_e( 'Subject Code', 'wpschoolpress' ); ?></th> |
| 285 |
<th><?php esc_html_e( 'Subject Name', 'wpschoolpress' ); ?></th> |
| 286 |
<th><?php esc_html_e( 'Faculty', 'wpschoolpress' ); ?></th> |
| 287 |
<th><?php esc_html_e( 'Book Name', 'wpschoolpress' ); ?></th> |
| 288 |
</tr> |
| 289 |
</thead> |
| 290 |
<tbody> |
| 291 |
<?php |
| 292 |
$teacher_table= $wpdb->prefix."wpsp_teacher"; |
| 293 |
$teacher_data = $wpdb->get_results("select wp_usr_id,CONCAT_WS(' ', first_name, last_name ) AS full_name from $teacher_table order by tid"); |
| 294 |
$teacherlist = array(); |
| 295 |
if( !empty( $teacher_data ) ) { |
| 296 |
foreach( $teacher_data as $value ) |
| 297 |
$teacherlist[$value->wp_usr_id] = $value->full_name; |
| 298 |
} |
| 299 |
$sno=1; |
| 300 |
foreach($cl_subjects as $cl_sub){ |
| 301 |
$teach_id= (int)$cl_sub->sub_teach_id; |
| 302 |
//$teacher=get_userdata($teach_id); |
| 303 |
?> |
| 304 |
<tr id="<?php echo esc_attr(intval($cl_sub->id));?>" class="pointer"> |
| 305 |
<td><?php echo esc_html($sno);?></td> |
| 306 |
<td><?php echo !empty( $cl_sub->sub_code ) ? esc_html($cl_sub->sub_code) : '-' ; ?></td> |
| 307 |
<td><?php echo esc_html($cl_sub->sub_name);?> </td> |
| 308 |
<td><?php echo isset( $teacherlist[$teach_id] ) ? esc_html($teacherlist[$teach_id]) : '';?></td> |
| 309 |
<td><?php echo esc_html($cl_sub->book_name);?></td> |
| 310 |
</tr> |
| 311 |
<?php |
| 312 |
$sno++; |
| 313 |
} |
| 314 |
?> |
| 315 |
</tbody> |
| 316 |
</table> |
| 317 |
</div> |
| 318 |
</section> |
| 319 |
<?php |
| 320 |
wpsp_body_end(); |
| 321 |
wpsp_footer(); |
| 322 |
} |
| 323 |
} |
| 324 |
else{ |
| 325 |
//Include Login Section |
| 326 |
include_once( WPSP_PLUGIN_PATH.'/includes/wpsp-login.php'); |
| 327 |
} |
| 328 |
?> |
| 329 |
|