<?php 

define("EEDU_PAPERHEAD", "eedu_portal_default_paperhead");
require_once("pages/structure.php");
require_once("pages/settings.php");
require_once("pages/academic-session.php");
require_once("pages/performance.php");
require_once("pages/analytics.php");
require_once("pages/dashboard.php");

function course_name_exists($course_name) {
	$course_name = strtolower($course_name);
	$post = new post;
	$existing_record = $post->get_post_by_meta_data(['type' => 'course', 'course_name' => $course_name]);
	return (_count($existing_record) > 0) ? true : false;
}

// function class_name_exists($class_name) {
// 	$class_name = strtolower($class_name);
// 	$post = new post;
// 	$existing_record = $post->get_post_by_meta_data(['type' => 'class', 'class_name' => $class_name]);
// 	return (_count($existing_record) > 0) ? true : false;
// }

// function category_name_exists($category_name) {
// 	$category_name = strtolower($category_name);
// 	$post = new post;
// 	$existing_record = $post->get_post_by_meta_data(['type' => 'category', 'category_name' => $category_name]);
// 	return (_count($existing_record) > 0) ? true : false;
// }

function this_term_is_open($term_id) {
	$post = new post;
	$term_meta = $post->get_post_meta($term_id);
	if($term_meta['status'] == 'in session') {
		return true;
	} else return false;
}

function mark_calendar($event, $start = '', $end = '', $tag = '', $callback = '') {
	$post = new post;
	$start = ($start == '') ? time() : $start;
	$tag = strtolower($tag);
	$end = ($end == '') ? strtotime(date('Y-m-d', $start).' 11:59PM') : $end;
	$end = ($start > $end) ? strtotime(date('Y-m-d', $start).' 11:59PM') : $end;
	if($start > time()) {
		$status = 'upcoming';
	}
	else if($start < time() && $end > time()) {
		$status = 'ongoing';
	}
	else {
		$status = 'past';
	}
	$meta = [
		'type' => 'calendar_event',
		'event' => $event,
		'start' => $start,
		'end' => $end,
		'callback' => $callback,
		'status' => $status,
		'tag' => $tag
	];
	if($tag != '') {
		$q = $post->get_post_by_meta_data(['type' => 'calendar_event', 'tag' => $tag]);
		if(_count($q) > 0) {
			$q = array_shift($q);
			if ($event_id = $post->update_post_meta($q['id'], $meta)) {
				$info = "Calendar event has been updated by the school admin. Event: ".$event." Start ".date(_DATE_FORMAT_, $start);
				// inform_admins($info);
				admin_log($info);
				return $event_id;
			}
		} else {
			if($event_id = $post->add_post($meta)) {
				$info = "New calendar event has been marked by the school admin. Event: ".$event." Start ".date(_DATE_FORMAT_, $start);
				// inform_admins($info);
				admin_log($info);
				return $event_id;
			}
		}
	} else {
		if($event_id = $post->add_post($meta)) {
			$info = "New calendar event has been marked by the school admin. Event: ".$event." Start ".date(_DATE_FORMAT_, $start);
			// inform_admins($info);
			admin_log($info);
			return $event_id;
		}
	}
	
}

function format_events_for_calendar($events) {
	if(_count($events) < 1)
		return array();
	$can_edit = current_user_can('edit_event');
	foreach ($events as $key => $value) {
		set_time_limit(80);
		if(($value['end'] - $value['start']) >= 604800) {
			//more than one week interval
			$result[$key.'start']['title'] = '[Start] '.$value['event'];
			$result[$key.'start']['start'] = date('Y-m-d', $value['start']).'T'.date('H:i:sP', $value['start']);
			// $result[$key.'start']['end'] = 
			if($can_edit) {
				$result[$key.'start']['url'] = 'edit-event?id='.$value['id'];
			}

			$result[$key.'end']['title'] = '[End] '.$value['event'];
			$result[$key.'end']['start'] = date('Y-m-d', $value['end']).'T'.date('H:i:sP', $value['end']);
			// $result[$key.'end']['end'] = 
			if($can_edit) {
				$result[$key.'end']['url'] = 'edit-event?id='.$value['id'];
			}
		} else {
			$result[$key]['title'] = $value['event'];
			$result[$key]['start'] = date('Y-m-d', $value['start']).'T'.date('H:i:sP', $value['start']);
			$result[$key]['end'] = date('Y-m-d', $value['end']).'T'.date('H:i:sP', $value['end']);
			if($can_edit) {
				$result[$key]['url'] = 'edit-event?id='.$value['id'];
			}
		}
	}
	return $result;
}

function get_teachers_period($teacher_id, $class_id, $category_id, $timetable = false, $teacher_mapping = false) {
	if(!$timetable) {
		$timetable = get_option('timetable');
	}
	if(!isset($timetable[$class_id])) {
		return false;
	}
	$fin_res = [];
	if(is_array($timetable[$class_id][$category_id]) && _count($timetable[$class_id][$category_id])) {
		foreach ($timetable[$class_id][$category_id] as $period => $value) {
			set_time_limit(80);
			$start = $value['start'];
			$stop = $value['stop'];
			unset($value['start']);
			unset($value['stop']);
			foreach ($value as $day => $course_name) {
				set_time_limit(80);
				$course_meta = get_course_meta_by_name($course_name);
				$teacher = get_course_teacher($course_meta['id'], $class_id, $category_id, $teacher_mapping);
				if($teacher == $teacher_id) {
					$res[$day] = $course_name;
				}
			}
			if(isset($res)) {
				$res['start'] = $start;
				$res['stop'] = $stop;
				$fin_res[$period] = $res;
			}
			unset($res);
		}
	}
	
	if(empty($fin_res)) {
		return false;
	} else return $fin_res;
}

function get_course_meta_by_name($course_name) {
	$post = new post;
	return array_shift($post->get_post_by_meta_data(['type' => 'course', 'course_name' => $course_name]));
}

function get_course_teacher($course_id, $class_id, $category_id, $teacher_mapping = false) {
	if(!$teacher_mapping) {
		$teacher_mapping = get_option('teacher_mapping');
	}
	return $teacher_mapping[$class_id][$category_id][$course_id];
}

function get_course_teachers($course_id, $class_id, $teacher_mapping = false) {
	if(!$teacher_mapping) {
		$teacher_mapping = get_option('teacher_mapping');
	}
	$teachers = array();
	if(isset($teacher_mapping[$class_id]) && is_array($teacher_mapping[$class_id])) {
		if(_count($teacher_mapping[$class_id])) {
			foreach ($teacher_mapping[$class_id] as $cat => $value) {
				$teachers[] = $value[$course_id];
			}
		}
	}
	$teachers = array_unique($teachers);
	return array_filter($teachers);
}

// array of class_id and category_id
function get_class_students($class) {
	$user = new user;
	if(is_array($class)) {
		if(!isset($class['category_id'])) {
			return $user->get_user_by_meta_data(['role' => 'student', 'class' => $class['class_id'], 'status' => 'active']);
		}
		if($class['category_id'] == 'all') {
			return $user->get_user_by_meta_data(['role' => 'student', 'class' => $class['class_id'], 'status' => 'active']);
		}
		return $user->get_user_by_meta_data(['role' => 'student', 'class' => $class['class_id'], 'category' => $class['category_id'], 'status' => 'active']);
	} else {
		return $user->get_user_by_meta_data(['role' => 'student', 'class' => $class, 'status' => 'active']);
	}
	
}

function get_class_students_id($class) {
	$res = array();
	$students = get_class_students($class);
	if(_count($students)) {
		foreach ($students as $student_meta) {
			set_time_limit(80);
			array_push($res, $student_meta['id']);
		}
	}
	return $res;
}

// deprecating
// function compile_result($student_id, $session, $term, $class, $category, $std_count, $results, $use_pin = true) {
// 	ignore_user_abort(true);
// 	$post = new post;
// 	$user = new user;
// 	$q = $results;
// 	if(_count($results) < 1) {
// 		return;
// 	}
// 	$attendance = analyse_individual_attendance($class, $category, $term, $student_id);
// 	$student_meta = $user->get_user_meta($student_id);
// 	$position = unserialize($student_meta['position']);
// 	$position = $position[$term];
// 	$compilation['attendance'] = serialize($attendance);
// 	$compilation['type'] = 'compiled_result';
// 	$compilation['term'] = $term;
// 	$compilation['term_name'] = $post->get_post_meta($term)['term_name'];
// 	$compilation['student_id'] = $student_id;
// 	$compilation['session'] = $session;
// 	$compilation['class'] = $class;
// 	$compilation['category'] = $category;
// 	$compilation['ft_comment'] = $position['ft_comment'];
// 	$compilation['psychometrics'] = $student_meta['psychometrics'];
// 	$compilation['position'] = $position['position'];
// 	$compilation['picture'] = get_user_image($student_meta['id']);
// 	$compilation['std_count'] = $std_count;
// 	$compilation['principal'] = get_option('school_principal');
// 	$compilation['form_teacher'] = get_form_teacher($class, $category);
// 	$compilation['last_compiled'] = time();
// 	$total_marks = 0;
// 	foreach ($results as $key => $value) {
// 		set_time_limit(80);
// 		//compiles course identification
// 		$compilation['courses'][$value['course']]['course'] = $value['course'];
// 		$course_meta = $post->get_post_meta($value['course']);
// 		$compilation['courses'][$value['course']]['course_name'] = $course_meta['course_name'];

// 		// compiles scores
// 		$scores = unserialize($value['result']);
// 		if(_count($scores)) {
// 			foreach ($scores as $key1 => $value1) {
// 				set_time_limit(80);
// 				if($key1 == $student_id) {
// 					$calc = 0; //reset calc
// 					$compilation['courses'][$value['course']] = array_merge($value1, $compilation['courses'][$value['course']]);
// 					foreach ($value1 as $m => $s) {
// 						set_time_limit(80);
// 						$total_marks += $s;
// 						$calc += $s;
// 					}
// 					if($calc < 1) {
// 						unset($compilation['courses'][$value['course']]);
// 					}
// 				}
// 			}
// 		}
// 	}
// 	$compilation['course_count'] = _count($compilation['courses']);
// 	$compilation['tm_obtainable'] = 100*$compilation['course_count'];
// 	do_action('before_compilation', ['student_id' => $student_id, 'session' => $session, 'term' => $term, 'class' => $class, 'category' => $category, 'std_count' => $std_count]);
// 	$compilation['marks_obtained'] = $total_marks;
// 	$compilation['mode_of_scoring'] = serialize(get_option('mode_of_scoring'));
// 	$compilation['courses'] = serialize($compilation['courses']);
// 	$existing = $post->get_post_by_meta_data(['type' => 'compiled_result', 'session' => $session, 'term' => $term, 'class' => $class, 'category' => $category, 'student_id' => $student_id]);
// 	if(_count($existing) > 0) {
// 		$existing = array_shift($existing);
// 		if(isset($existing['ft_custom_comment'])) {
// 			$compilation['ft_comment'] = $existing['ft_custom_comment'];
// 		}
// 		$post->update_post_meta($existing['id'], $compilation);
// 		do_action('after_compilation', ['student_id' => $student_id, 'session' => $session, 'term' => $term, 'class' => $class, 'category' => $category, 'std_count' => $std_count, 'compilation_id' => $existing['id']]);
// 		return $existing['id'];
// 	} else {
// 		if($use_pin) {
// 			$compilation['status'] = 'locked';
// 		} else $compilation['status'] = 'unlocked';
// 		$id = $post->add_post($compilation);
// 		do_action('after_compilation', ['student_id' => $student_id, 'session' => $session, 'term' => $term, 'class' => $class, 'category' => $category, 'std_count' => $std_count, 'compilation_id' => $id]);
// 		$info = "Your ".get_class_name($class, $category)." ".get_term_name($term)." ".get_session_name($session)." result has been compiled. You can access it with your scratch card pin";
// 		inform_user($student_id, $info, "RESULT COMPILED", $home_url, EMAIL, NOTIFICATION);
// 		return $id;
// 	}
// }

function is_course_teacher($teacher_id, $class_id, $category_id, $course_id) {
	$teacher_mapping = get_option('teacher_mapping');
	return ($teacher_id == $teacher_mapping[$class_id][$category_id][$course_id]) ? true : false;
}

function get_course_name($course_id) {
	if($record = get_record("eedu_course_name_".$course_id)) {
		return $record;
	}
	$post = new post;
	$course_name = $post->get_post_meta($course_id)['course_name'];
	update_record("eedu_course_name_".$course_id, $course_name);
	return $course_name;
}

function get_class_name($class_id, $category_id = '') {
	if($class_id == "All" or $class_id == "all") return "All";
	if(is_array($class_id)) {
		$class_name = $class_id['class_name'];
	} else {
		$class_name = _get_class_name($class_id);
	}
	if($category_id == "" || $category_id == false) {
		return $class_name;
	}
	if(is_array($category_id)) {
		$category_name = $category_id['category_name'];
	} else {
		$category_name = get_category_name($category_id);
	}
	return $class_name." ".$category_name;
}

function get_category_name($category_id) {
	if($record = get_record("eedu_category_name_".$category_id)) {
		return $record;
	}
	$post = new post;
	$category_name = $post->get_post_meta($category_id)['category_name'];
	update_record("eedu_category_name_".$category_id, $category_name);
	return $category_name;
}

function _get_class_name($class_id) {
	if($record = get_record("eedu_class_name_".$class_id)) {
		return $record;
	}
	$post = new post;
	$class_name = $post->get_post_meta($class_id)['class_name'];
	update_record("eedu_class_name_".$class_id, $class_name);
	return $class_name;
}

function get_term_name($term_id) {
	if($record = get_record("eedu_term_name_".$term_id)) {
		return $record;
	}
	$post = new post;
	$term_name = $post->get_post_meta($term_id)['term_name'];
	update_record("eedu_term_name_".$term_id, $term_name);
	return $term_name;
}

function get_term_session($term_id) {
	if($record = get_record("eedu_term_session_".$term_id)) {
		return $record;
	}
	$post = new post;
	$acsession = $post->get_post_meta($term_id)['acsession'];
	update_record("eedu_term_session_".$term_id, $acsession);
	return $acsession;
}

function get_full_term_name($term_id) {
	if($record = get_record("eedu_full_term_name_".$term_id)) {
		return $record;
	}
	$session_id = get_term_session($term_id);
	$session_name = get_session_name($session_id);
	$term_name = strtoupper(get_term_name($term_id)." ".$session_name);
	update_record("eedu_full_term_name_".$term_id, $term_name);
	return $term_name;
}

function get_session_name($session_id) {
	if($record = get_record("eedu_session_name_".$session_id)) {
		return $record;
	}
	$post = new post;
	$session_name = $post->get_post_meta($session_id)['session_name'];
	update_record("eedu_session_name_".$session_id, $session_name);
	return $session_name;
}

function get_form_teacher($class, $category) {
	$ftm  = get_option('form_teacher_mapping');
	return $ftm[$class][$category];
}

function get_form_teacher_classes($ft_id) {
	$ftm  = get_option('form_teacher_mapping');
	$my_classes = [];
	if ($ftm) {
		foreach ($ftm as $class_id => $value) {
			set_time_limit(80);
			if(_count($value) > 0) {
				foreach($value as $category_id => $fmt) {
					if($ft_id == $fmt) {
						$my_classes[] = ['class_name' => get_class_name($class_id, $category_id), 'class_id' =>  $class_id, 'category_id' =>  $category_id];
					}
				}
			}
		}
	}
	return $my_classes;
}

function get_teacher_courses($teacher_id) {
	$post = new post;
	$teacher_courses = [];
	$teacher_mapping = get_option('teacher_mapping');
	if($teacher_mapping) :
		foreach ($teacher_mapping as $class => $cat) {
			set_time_limit(80);
			$class_meta = $post->get_post_meta($class);
			if(_count($cat)): foreach ($cat as $category => $value) {
				set_time_limit(80);
				$category_meta = $post->get_post_meta($category);
				if(_count($value) && is_array($value)): foreach ($value as $course => $teacher) {
					set_time_limit(80);
					if($teacher == $teacher_id) {
						$course_meta = $post->get_post_meta($course);
						$course_meta['class'] = $class_meta;
						$course_meta['category'] = $category_meta;
						$teacher_courses[] = $course_meta;
					}
				} endif;
			} endif;
		}
	endif;
	return $teacher_courses;
}

function get_teacher_timetable_periods_all_class($teacher_id) {
	$post = new post;
	$timetable = get_option('timetable');
	$teacher_mapping = get_option('teacher_mapping');
	$my_timetable = [];
	$class = $post->get_post_by_meta_data(['type' => 'class']);
	$category = $post->get_post_by_meta_data(['type' => 'category']);
	if(_count($class) > 0) {
		foreach ($class as $class_meta) {
			set_time_limit(80);
			if(_count($category)) {
				foreach($category as $category_meta) {
					set_time_limit(80);
					$class_timetable = get_teachers_period($teacher_id, $class_meta['id'], $category_meta['id'], $timetable, $teacher_mapping);
					if($class_timetable) {
						$my_timetable = array_merge($my_timetable, $class_timetable);
					}
				}
			}
		}
	}
	return $my_timetable;
}

function get_form_teacher_students($ft_id) {
	$user = new user;
	$my_students = [];
	$ft_classes = get_form_teacher_classes($ft_id);
	
	if(_count($ft_classes) > 0) {
		foreach ($ft_classes as $ft_class) {
			set_time_limit(80);
			$students = $user->get_user_by_meta_data(['role' => 'student', 'status' => 'active', 'class' => $ft_class['class_id'], 'category' => $ft_class['category_id']]);
			$my_students = array_merge($my_students, $students);
		}
	}
	return $my_students;
}

function get_past_dates($term) {
	$post = new post;
	$term_meta = $post->get_post_meta($term);
	$term_begins = isset($term_meta['term_begins']) ? $term_meta['term_begins'] : $term_meta['posted_on'];
	$term_begins = strtotime("12 AM ".date("d M, Y", $term_begins));
	$term_ends = (isset($term_meta['term_ends']) && time() > $term_meta['term_ends']) ? $term_meta['term_ends'] : time();
	$_24hours = 60*60*24;
	$past_dates = [];
	$check = $term_begins;
	$init = false;
	$week = 1;
	do {
		$day = date('N', $check);
		if($init) {
			if($day == 1) {
				$week++;
			}
		}
		$init = true;
		if($day != 6 && $day != 7) {
			$past_dates[$week][] = $check;
		}
		$check += $_24hours;
	} while ($check <= $term_ends);
	return $past_dates;
}

function past_dates_remove_weeks($past_dates){
	$res = [];
	if(_count($past_dates)) {
		foreach ($past_dates as $key => $value) {
			set_time_limit(80);
			$res = array_merge($res, $value);
		}
	}
	return $res;
}

function format_to_date($n) {
	return date(_DATE_FORMAT_, $n);
}

function analyse_class_attendance($class, $category, $term) {
	$option = "attendance_".$term."_".$class."_".$category;
	$attendance = get_option($option);
	$students = get_class_students(['class_id' =>$class, 'category_id' =>$category]);
	$past_dates = get_past_dates($term);
	$analysis = [];
	$total_attendance = 0;
	$analysis['past_dates'] = past_dates_remove_weeks($past_dates);
	$analysis['dates_not_reported'] = $analysis['past_dates'];
	$analysis['students'] = $students;
	$analysis['_students'] = _count($students);
	$analysis['expected_attendance'] = _count($students) * _count($analysis['past_dates']);
	$analysis['_class_average'] = 0;
	$analysis['_past_dates'] = _count($analysis['past_dates']);
	$analysis['_dates_reported'] = _count($attendance);
	if(_count($students) > 0 && $attendance) {
		foreach ($attendance as $day => $stud_in_att) {
			set_time_limit(80);
			$key = array_keys($analysis['dates_not_reported'], $day)[0];
			unset($analysis['dates_not_reported'][$key]);
			$analysis[date(_DATE_FORMAT_, $day)]['stud_in_att'] = $stud_in_att;
			$analysis[date(_DATE_FORMAT_, $day)]['average'] = (_count($stud_in_att)*100)/count($students);
			$analysis[date(_DATE_FORMAT_, $day)]['students_absent'] = _count($students) - _count($stud_in_att);
			$analysis[date(_DATE_FORMAT_, $day)]['students_present'] = _count($stud_in_att);
			$total_attendance += _count($stud_in_att);
		}
	$analysis['dates_reported'] = array_map('format_to_date', array_keys($attendance));
	$analysis['past_dates'] = array_map('format_to_date', $analysis['past_dates']);
	$analysis['dates_not_reported'] = array_map('format_to_date', $analysis['dates_not_reported']);
	$analysis['_dates_not_reported'] = _count($analysis['dates_not_reported']);
	$analysis['total_attendance'] = $total_attendance;
	$analysis['total_absentism'] = $analysis['expected_attendance'] - $total_attendance;
	$analysis['class_average'] = ($total_attendance*100)/$analysis['expected_attendance'];
	$analysis['_class_average'] = ($total_attendance*100)/($analysis['_dates_reported'] * $analysis['_students']);
	}
	return $analysis;
}

function analyse_individual_attendance($class, $category, $term, $student_id = '') {
	if($student_id == '') {
		$session = Session::getInstance();
		$student_id = $session->id;
	}
	$option = "attendance_".$term."_".$class."_".$category;
	$attendance = get_option($option);
	$past_dates = get_past_dates($term);
	$past_dates = past_dates_remove_weeks($past_dates);
	$days_present = $days_absent = $analysis = [];
	$analysis['dates_not_reported'] = $past_dates;
	$analysis['dates_reported'] = array();
	if(_count($past_dates) > 0) {
		foreach ($past_dates as $date) {
			set_time_limit(80);
			if(isset($attendance[$date])) {
				$key = array_keys($analysis['dates_not_reported'], $date)[0];
				unset($analysis['dates_not_reported'][$key]);
				$analysis['dates_reported'][] = format_to_date($date);
			}
			if(isset($attendance[$date][$student_id])) {
				array_push($days_present, format_to_date($date));
			} else {
				array_push($days_absent, format_to_date($date));
			}
		}
	}
	$analysis['student_id'] = $student_id;
	$analysis['days_present'] = $days_present;
	$analysis['days_absent'] = $days_absent;
	$analysis['_days_present'] = _count($days_present);
	$analysis['_days_absent'] = _count($days_absent);
	$analysis['past_dates'] = array_map('format_to_date', $past_dates);
	$analysis['dates_not_reported'] = array_map('format_to_date', $analysis['dates_not_reported']);
	$analysis['_dates_not_reported'] = _count($analysis['dates_not_reported']);
	$analysis['_dates_reported'] = _count($analysis['dates_reported']);
	$analysis['_past_dates'] = _count($past_dates);
	if($analysis['_dates_reported'] > 0 && $analysis['_days_present'] > 0) {
		$analysis['average'] = ($analysis['_days_present']*100)/$analysis['_dates_reported'];
	}
	return $analysis;
}

function is_form_teacher($teacher_id, $class_id, $category_id) {
	$ft_mapping = get_option("form_teacher_mapping");
	if($ft_mapping[$class_id][$category_id] == $teacher_id) {
		return true;
	} else return false;
}

function is_prefect($student_id, $class_id) {
	$prefect_mapping = get_option("prefect_mapping");
	if($prefect_mapping[$class_id] == $teacher_id) {
		return true;
	} else return false;
}

function get_next_class($class_id = '', $reverse = false) {
	$promotion_order = get_option('promotion_order');
	$last_item = end($promotion_order);
	if($last_item == $class_id && $reverse == false) {
		return 'Graduate';
	}
	if($class_id == "") {
		return $promotion_order[0];
	}
	else {
		$class_key = array_search($class_id, $promotion_order);
		if($class_key === false) {
			return $promotion_order[0];
		} else {
			if($reverse) {
				$next_class_key = --$class_key;
				return $promotion_order[$next_class_key];
			} else {
				$next_class_key = ++$class_key;
				return $promotion_order[$next_class_key];
			}
		}
	}
}

//deprecating
function promote_student($student_id, $graduation_year = '') {
	// accepts student meta or id
	$user = new user;
	if(!is_array($student_id)) {
		$student_meta = $user->get_user_meta($student_id);
	} else $student_meta = $student_id;
	set_time_limit(200);
	$promote = is_to_be_promoted($student_meta);
	if(!$promote) return false;

	$next_class = get_next_class($student_meta['class'], false);
	if($next_class == 'Graduate') {
		if($graduation_year == '') {
			$graduation_year = get_session_name(get_option('current_academic_session'));
		}
		return $user->update_user_meta($student_meta['id'], ['class' => $next_class, 'role' => 'alumini', 'graduation_year' => $graduation_year, 'last_promoted' => time(), 'promotion' => 1]);
	}
	return $user->update_user_meta($student_meta['id'], ['class' => $next_class, 'last_promoted' => time(), 'promotion' => 1]);
}

//deprecating
function is_to_be_promoted($student_id) {
	// accepts student meta or id
	$user = new user;
	if(!is_array($student_id)) {
		$student_meta = $user->get_user_meta($student_id);
	} else $student_meta = $student_id;
	$promoted = true;
	if(!isset($student_meta['promotion'])) {
		$promoted = true;
	} else {
		if($student_meta['promotion']) {
			if(!isset($student_meta['last_promoted'])) {
				$promoted = true;
			} else {
				//default promotion interval is 2 months
				$promotion_interval_sec = ($option = get_option('promotion_interval')) ? $option*2592000 : 5184000;
				if($student_meta['last_promoted'] + $promotion_interval_sec > time()) {
					$promoted = false;
				} else {
					$promoted = true;
				}
			}
		} else {
			$user->update_user_meta($student_meta['id'], ['last_promoted' => time(), 'promotion' => 1]);
			return false;
		}
		
	}

	return $promoted;

}

function promotion_done_in_session($session_id) {
	if(!is_array($session_id)) {
		$post = new post;
		$session_id = $post->get_post_meta($session_id);
	}
	return (isset($session_id['promotion']) && $session_id['promotion']) ? true : false;
}

function get_select_options_from_post_q($args, $key, $val = 'id', $raw = true) {
    $result = [];
    $sorting = new sorting;
    if($raw) {
        $post = new post;
        $options = $post->get_post_by_meta_data($args);
    } else {
        $options = $args;
    }
    $options = $sorting->sort_by_meta_value($options, 'acsession', 'desc');
    if(_count($options) > 0){
        foreach ($options as $value) {
        	set_time_limit(80);
        	$session_name = get_session_name($value['acsession']);
            $result[$session_name.' Session :: '.$value[$key]] = $value[$val];
        }
    }
    return $result;
}

function get_all_form_teachers($by_meta = true) {
	$user = new user;
	$ft_mapping = get_option('form_teacher_mapping');
	$res = [];
	foreach ($ft_mapping as $class => $value) {
		foreach ($value as $category => $ft_id) {
			if($ft_id == '')
				continue;
			if($by_meta) {
				$res[$ft_id] = get_user_meta($ft_id);
			} else {
				$res[$ft_id][] = ['class' => $class, 'category' => $category];
			}
		}
	}
	return $res;
}

function get_class_categories_meta($class_id) {
	$post = new post;
	$categories = $post->get_post_by_meta_data(['type' => 'category']);
	$category_mapping = get_option('category_mapping');
	$res = array();
	if(!isset($category_mapping[$class_id])) {
		return $res;
	} else {
		if(_count($categories)) {
			foreach ($categories as $key => $category_meta) {
				set_time_limit(80);
				if(in_array($category_meta['id'], $category_mapping[$class_id])) {
					$res[$key] = $category_meta;
				}
			}
		} else return $res;
	}
	return $res;
}

function get_class_courses($class_id, $category_id, $teacher_mapping = false, $merge_branch = true, $all_teachers = false) {
	$session = Session::getInstance();
	$post = new post;
	$role = $all_teachers ? false : current_user_can('teacher_only');
	$se = current_user_can('update_software');
	$option = $merge_branch ? "merged" : "expanded";
	$res = [];
	if($se || !$role) {
		if($record = get_record("class_courses_".$class_id."_".$category_id."_".$option)) {
			return $record;
		}
	} else {
		if(isset($session->class_course_{$class_id."_".$category_id."_".$option})) {
			return $session->{"class_course_".$class_id."_".$category_id."_".$option};
		}
	}
	if($category_id === false) {
		$category_mapping = get_option("category_mapping");
		if(isset($category_mapping[$class_id]) && (_count($category_mapping[$class_id]) > 0)) {
			foreach ($category_mapping[$class_id] as $cat) {
				$temp = get_class_courses($class_id, $cat, $teacher_mapping, $merge_branch);
				$res = $res + $temp;
			}
		}
		if($se || !$role) {
			update_record("class_courses_".$class_id."_".$category_id."_".$option, $res);
		} else {
			$session->{"class_course_".$class_id."_".$category_id."_".$option} = $res;
		}
		return $res;
	}
	$course_mapping = get_option("course_mapping");
	if(!$teacher_mapping) {
		$teacher_mapping = get_option('teacher_mapping');
	}
	if(isset($course_mapping[$class_id])) {
		if(_count($course_mapping[$class_id][$category_id])) {
			foreach ($course_mapping[$class_id][$category_id] as $course_id) {
				set_time_limit(80);
				if($role && !$se) {
					$branches = $post->get_post_by_meta_data(['type' => 'subject_branch', 'course_id' => $course_id]);
					if(is_array($branches)) {
						if(_count($branches)) {
							foreach ($branches as $branch) {
								if($teacher_mapping[$class_id][$category_id][$branch['id']] == $session->id) {
									if($merge_branch) {
										$res[$course_id] = get_course_name($course_id);
									} else {
										$res[$branch['id']] = get_course_name($course_id)." - ".$branch['course_name'];
									}
								}
							}
						} else {
							if($teacher_mapping[$class_id][$category_id][$course_id] == $session->id) {
								$res[$course_id] = get_course_name($course_id);
							}
						}
					} else {
						if($teacher_mapping[$class_id][$category_id][$course_id] == $session->id) {
							$res[$course_id] = get_course_name($course_id);
						}
					}
				} else {
					$branches = $post->get_post_by_meta_data(['type' => 'subject_branch', 'course_id' => $course_id]);
					if(is_array($branches)) {
						if(_count($branches)) {
							foreach ($branches as $branch) {
								if($merge_branch) {
									$res[$course_id] = get_course_name($course_id);
								} else {
									$res[$branch['id']] = $branch['course_name'];
								}
							}
						} else {
							$res[$course_id] = get_course_name($course_id);
						}
					} else {
						$res[$course_id] = get_course_name($course_id);
					}
				}	
			}
		}
	}
	if($se || !$role) {
		update_record("class_courses_".$class_id."_".$category_id."_".$option, $res);
	} else {
		$session->{"class_course_".$class_id."_".$category_id."_".$option} = $res;
	}
	return $res;
}

function get_teacher_classes($teacher_id) {
	$teacher_mapping = get_option('teacher_mapping');
	$classes = array();
	if(is_array($teacher_mapping)) {
		if (_count($teacher_mapping) && is_array($teacher_mapping)) {
			foreach ($teacher_mapping as $class_id => $value) {
				if(_count($value) && is_array($value)) {
					foreach ($value as $category => $value1) {
						if(_count($value1) && is_array($value1)) {
							foreach ($value1 as $course => $teacher) {
								if($teacher == $teacher_id) {
									$classes[] = $class_id;
								}
							}
						}
					}
				}
			}
		}
	}
	return array_unique($classes);
}

function students_id_in_class($class, $term_meta, $all_terms) {
	$students = get_class_students($class);
	$result = array();
	if(_count($students)) {
		foreach($students as $student_meta) {
			set_time_limit(80);
			if(isset($student_meta['term_of_admission'])) {
				if(isset($all_terms[$student_meta['term_of_admission']])) {
					if($all_terms[$student_meta['term_of_admission']]['term_begins'] > $term_meta['term_begins']) {
						continue;
					}
				}
			}
			$result[$student_meta['category']][] = $student_meta['id'];
		}
	}
	return $result;
}

function update_students_id_in_class($class = "all", $category = false, $term = false, $session = false) {
	if(!$term) $term = get_option("current_academic_term");
	if(!$session) $session = get_option("current_academic_session");
	if(promotion_done_in_session($session)) {
		return;
	}
	if(!$term) {
		return;
	}
	$post = new post;
	$term_meta = $post->get_post_meta($term);
	$all_terms = $post->get_post_by_meta_data(['type' => 'academic_term'], "LIKE", true);
	if(!$session) {
		$session = $term_meta['acsession'];
	}
	if($class == 'all') {
		$post = new post;
		$classes = $post->get_post_by_meta_data(['type' => 'class']);
		if(_count($classes)) {
			foreach ($classes as $class_meta) {
				set_time_limit(80);
				update_students_id_in_class($class_meta['id']);
			}
			return;
		}
	}
	if($category) {
		$_class = ['class_id' => $class, 'category_id' => $category];
	} else $_class = $class;
	$students = students_id_in_class($_class, $term_meta, $all_terms);
	$option = get_option('students-'.$session.'-'.$term);
	if(!$option) $option = array();
	$option[$class] = $students;
	update_option('students-'.$session.'-'.$term, $option);
}

function force_update_students_id_in_class($class, $category, $people, $term, $session = false, $reload = true) {
	$post = new post;
	$user = new user;
	$term_meta = $post->get_post_meta($term);
	$all_terms = $post->get_post_by_meta_data(['type' => 'academic_term'], "LIKE", true);
	if(!$session) {
		$session = $term_meta['acsession'];
	}
	$students = array();
	if(_count($people)) {
		foreach($people as $student) {
			set_time_limit(80);
			$student = !is_array($student) ? $user->get_user_meta($student) : $student;
			if($student['role'] != 'student') continue; //checks and skips non students in the grouping
			$students[] = $student['id']; 
		}
	}
	$option = get_option('students-'.$session.'-'.$term);
	if(!$option) $option = array();
	if(!$reload) {
		if(is_array($students)) {
			if(!isset($option[$class])) {
				$option[$class] = [];
			}
			if(!isset($option[$class][$category])) {
				$option[$class][$category] = [];
			}
			if(!is_array($option[$class][$category])) {
				$option[$class][$category] = [];
			}
			$students = array_merge($students, $option[$class][$category]);
			$option[$class][$category] = array_unique($students);
		}
	} else {
		$option[$class][$category] = $students;
	}
	update_option('students-'.$session.'-'.$term, $option);
}

function remove_student_id_from_class($class, $category, $student_id, $term, $session){
	$option = get_option('notstudents-'.$session.'-'.$term);
	if(!$option) $option = array();
	$option[$class][$category][] = $student_id;
	$option[$class][$category] = array_unique($option[$class][$category]);
	update_option('notstudents-'.$session.'-'.$term, $option);
}

function return_student_id_to_class($class, $category, $student_id, $term, $session){
	$option = get_option('notstudents-'.$session.'-'.$term);
	if(!$option) $option = array();
	if(isset($option[$class][$category])) {
		$index = array_search($student_id, $option[$class][$category]);
		if($index != false or $index == 0) {
			unset($option[$class][$category][$index]);
			$option[$class][$category] = array_values($option[$class][$category]);
			$option[$class][$category] = array_unique($option[$class][$category]);
			update_option('notstudents-'.$session.'-'.$term, $option);
		}
	}
}

function get_students_in_class($session, $term, $class = false, $category = false, $rooted = false) {

	// standardize to avoid error
	
	$session = is_array($session) ? $session['id'] : $session;
	$term = is_array($term) ? $term['id'] : $term;
	$class = is_array($class) ? $class['id'] : $class;
	$category = is_array($category) ? $category['id'] : $category;

	// standardize to avoid error

	$students = get_option('students-'.$session.'-'.$term);
	if(!$students) return array();
	if($class) {
		if($category) {
			$notstudents = get_students_not_in_class($session, $term, $class, $category);
			if(isset($students[$class][$category])) return array_diff($students[$class][$category], $notstudents);
			return array();
		} else {
			if(isset($students[$class])) {
				if($rooted) {
					$result = array();
					foreach ($students[$class] as $category => $people) {
						$result = array_merge($result, $people);
					}
					return $result;
				} else return $students[$class];
			}
			return array();
		}
	} else return $students;
}

function get_students_not_in_class($session, $term, $class, $category) {

	// standardize to avoid error
	
	$session = is_array($session) ? $session['id'] : $session;
	$term = is_array($term) ? $term['id'] : $term;
	$class = is_array($class) ? $class['id'] : $class;
	$category = is_array($category) ? $category['id'] : $category;

	// standardize to avoid error

	$students = get_option('notstudents-'.$session.'-'.$term);
	if(!$students) return array();
	if(isset($students[$class][$category])) return $students[$class][$category];
	return array();
}

function root_std_arr($_students) {
    $res = array();
    if(_count($_students)) {
        foreach ($_students as $class_id => $category_id) {
        	set_time_limit(80);
            if(_count($category_id)) {
                foreach ($category_id as $key => $value) {
                	set_time_limit(80);
                	$res = array_merge($res, $value);
                }
            }
        }
    }
    return $res;
}

function root_std_arr_catlevel($_students) {
    $res = array();
    if(_count($_students)) {
        foreach ($_students as $key => $value) {
        	set_time_limit(80);
        	$res = array_merge($res, $value);
        }
    }
    return $res;
}

function get_student_class_in_term($student_id, $term, $session = false, $option = false) {
	if(!$session) {
		$post = new post;
		$term_meta = $post->get_post_meta($term);
		$session = $term_meta['acsession'];
	}
	if(!$option) {
		$option = get_option('students-'.$session.'-'.$term);
		if(!$option) return array("class_id" => false, "category_id" => false, "class_name" => "N/A"); //Not Available
	}
	if(_count($option)) {
		foreach ($option as $class_id => $value) {
			set_time_limit(80);
			if(_count($value)) {
				foreach ($value as $category_id => $std_arr) {
					set_time_limit(80);
					if(_count($std_arr)) {
						foreach ($std_arr as $std) {
							set_time_limit(80);
							if($student_id == $std)
								return array("class_id" => $class_id, "category_id" => $category_id, "class_name" => get_class_name($class_id, $category_id));
						}
					}
				}
			}
		}
	}
	return array("class_id" => false, "category_id" => false, "class_name" => "N/A");
}

function get_extended_course_mapping($class_id){
	$category_mapping = get_option("category_mapping");
	$course_mapping = get_option("course_mapping");
	$class_cat = isset($category_mapping[$class_id]) ? $category_mapping[$class_id] : false;
	$res = array();
	if($class_cat) {
		foreach ($class_cat as $cat_id) {
			set_time_limit(80);
			if(isset($course_mapping[$class_id][$cat_id])) {
				$res = array_merge($res, $course_mapping[$class_id][$cat_id]);
			}
		}
	}
	return array_unique($res);
}

function get_next_username($is_student = true) {
	$user = new user;
	$prefix = get_option("sch_abbr");
	$prefix = ($prefix) ? $prefix."/" : "";
	$prefix = ($is_student) ? $prefix."STUDENT/" : $prefix."STAFF/";
	return $user->get_next_username($prefix);
}

function analyze_terms($current_term = false, $terms_query = false, $select_option = true) {
	$post = new post;
	$sorting = new sorting;
	if(!$current_term) {
		$current_term = get_option("current_academic_term");
	}
	if(!$current_term) return array();
	$current_term_meta = $post->get_post_meta($current_term);
	if(!$terms_query) {
		$terms = $post->get_post_by_meta_data(['type' => 'academic_term']);
	}
	$terms = $sorting->sort_by_meta_value($terms, "id", "desc");
	$past = $upcoming = $current = array();
	if(_count($terms)) {
		foreach ($terms as $term_meta) {
			set_time_limit(80);
			if($current_term == $term_meta['id']) {
				//current term
				if($select_option) {
					$current[$term_meta['id'].': '.$term_meta['term_name'].' - ['.get_session_name($term_meta['acsession']).']'] = $term_meta['id'];
				} else $current[$term_meta['id']] = $term_meta;
				continue;
			}	
			if($term_meta['term_begins'] >= $current_term_meta['term_ends']) {
				//future term
				if($select_option) {
					$upcoming[$term_meta['id'].': '.$term_meta['term_name'].' - ['.get_session_name($term_meta['acsession']).']'] = $term_meta['id'];
				} else $upcoming[$term_meta['id']] = $term_meta;
				continue;
			}
			if($term_meta['term_ends'] <= $current_term_meta['term_begins']) {
				//past term
				if($select_option) {
					$past[$term_meta['id'].': '.$term_meta['term_name'].' - ['.get_session_name($term_meta['acsession']).']'] = $term_meta['id'];
				} else $past[$term_meta['id']] = $term_meta;
				continue;
			}
		}
	}
	return ['current' => $current, 'past' => $past, 'upcoming' => $upcoming];
}

function get_class_category_gender_distribution($gender, $class, $role) {
	$user = new user;
	$category_mapping = get_option("category_mapping");
	$categories = $category_mapping[$class];
	$gender = display_gender($gender);
	$distribution = array();
	switch($gender) {
		case "Male":
			$gender = ['male','m'];
			break;

		default:
			$gender = ['female', 'f'];
			break;
	}
	if(_count($categories)) {
		foreach ($categories as $key => $value) {
			set_time_limit(80);
			$students = $user->get_user_by_meta_data(["role" => $role, "status" => "active", "class" => $class, "category" => $value, "gender" => $gender]);
			$distribution[$value]['count'] = _count($students);
			$distribution[$value]['category'] = $value;
		}
	}
	return $distribution;
}

function sanitize_mock_result_session($class, $session) {
	$post = new post;
	$output = $post->get_post_by_meta_data(['type' => 'compiled_mock_result', 'session' => $session, 'class' => $class]);
	$res = array();
	if(_count($output)) {
		foreach($output as $key => $value) {
			set_time_limit(80);
			$res[$value['exam']][] = $value;
		}
	}
	return $res;
}

function check_student_promotion_capability($args) {
	$post = new post;

	if(!current_user_can("promote_students")) {
		$cap = [false, "Sorry, You cannot run student's promotion script"];
		return $cap;
	}
		
	if(!$args) {
		$cap = [false, "Sorry, Promotion script unavailable."];
		return $cap;
	}
		
	if(promotion_done_in_session($args['acsession'])) {
		$cap = [false, "Promotion already done in session."];
		return $cap;
	}

	$current_term_meta = $post->get_post_meta($args['current_term']);
	if($current_term_meta['order'] !== "3") {
		$cap = [false, "Sorry, It seems like you are not in third term. Promotion script unavailable for other terms."];
		return $cap;
	}

	$next_session = eedu_portal_get_next_session($args['session_meta']);
	if(!$next_session) {
		$cap = [false, "Sorry, It seems like you have not opened the next academic session. Promotion script unavailable until you do so."];
		return $cap;
	}

	$first_term = eedu_portal_get_first_term($next_session);
	if(!$first_term) {
		$cap = [false, "Sorry, It seems like you have not opened the next academic term. Promotion script unavailable until you do so."];
		return $cap;
	}
	$args["next_term"] = $first_term;
	$args["next_session"] = $next_session;
	return [$args, "Students will be promoted for the Session: ".$next_session['session_name']." ".$first_term['term_name']];
}

function eedu_portal_get_next_session($session_meta) {
	$current_year = explode("/", $session_meta['session_name']);
	$current_year = end($current_year);
	$current_year = (int) $current_year;
	$next_year = $current_year + 1;
	$session_name = (string) $current_year."/".$next_year;
	$existing = db_post_unique(['type' => 'academic_session', 'session_name' => $session_name]);
	return $existing;
}

function eedu_portal_get_first_term($session_meta) {
	$post = new post;
	$sorting = new sorting;
	$res = $post->get_post_by_meta_data(['type' => 'academic_term', 'acsession' => $session_meta['id']]);
	if(!_count($res)) return false;
	$res = $sorting->sort_by_meta_value($res, 'order', 'asc');
	return $res[0];

}

function eedu_portal_get_class_selection($class_category){
	$resp = [];
	$arr = explode(",", $class_category);
	$resp['class'] = isset($arr[0]) ? $arr[0] : false;;
	$resp['category'] = isset($arr[1]) ? $arr[1] : false;
	return $resp;
}

function eedu_portal_default_paperhead($args = array()) {
	$session = Session::getInstance();
	$option = get_option("print_with_paperhead");
	if(isset($session->paperhead) && !$option) {
		return $session->paperhead;
	}
	$default = [
		'title-h' => 'h2'
	];
	$args = array_merge($default, $args);
	$html = add_page_stylesheet("contents/plugins/eedu_portal/css/paperhead.css", "eedu_paperheadCss", true);
	if ($option):
		$html .= "<style type=\"text/css\">@media print{ .paperhead{display: none;} .addtopmargin { width: 100%; height: 230px; }} </style><div class=\"addtopmargin\"></div>";
	endif;
    $html .= "<table class=\"table paperhead\"><tr><td colspan=3 class=\"text-center ministry col-xs-12 col-md-12\"><h5 class=\"ministry-main\">";
    $html .= get_option('sch_ministry');
    $html .= "</h5>";
    if ($ministry_branch = get_option('sch_ministry_branch')):
    	$html .= "<h6 class=\"text-sm-center ministry-branch\">".$ministry_branch."</h6>";
    endif;
    $html .= "</td></tr><tr><td style=\"min-height: 100px;\"><img class=\"mx-auto d-block logo\" src=\"";
    $html .= get_option("company-logo");
    $html .= "\" alt=\"Card image cap\" style=\"max-height: 120px;\"></td><td class=\"text-center\"><";
    $html .= ($args['title-h'] ?? 'h2'). "class=\"mt-2 mb-1 school-name\">". strtoupper(get_option('company_name')). "</" . $args['title-h'] ?? 'h2' . ">";
    $html .= "<h5 class=\"location\"><i class=\"fas fa-map-marker\">&nbsp;</i>&nbsp;";
    $html .= ucwords(get_option('company_address'));
    $html .= "</h5><div class=\"\"><small>";
	$email = get_option('company_email');
	$html .= ($company_phone = get_option('company_phone')) ? implode(", ", $company_phone) : '';
	$html .= ($email && $email != '') ? '&nbsp|&nbsp<i class="fas fa-envelope"></i>&nbsp;'.$email : '';
	$html .= "</small></div>";
    if ($motto = get_option('company_motto')):
	    $html .= "<div class=\"motto\">Motto: ".$motto."</div>";
	endif;
	$html .= "</td><td style=\"min-height: 100px;\">";
    if ($other_logo = get_option("other-logo")):
        $html .= "<img class=\"mx-auto d-block other-logo\" src=\"".$other_logo."\" alt=\"Card image cap\" style=\"max-height: 120px;\">";
    endif;
    $html .= "</td></tr></table>";
    if(!$option)
    	$session->paperhead = $html;
	return $html;
}

function eedu_portal_get_class_students($class, $category = false, $term = false) {
	$user = new user;
	$sorting = new sorting;
	$students = [];
	if($term) {
		$session = get_term_session($term);
		if($term != get_option("current_academic_term")) {
			$students = get_students_in_class($session, $term, $class, $category, true);
			foreach ($students as $key => &$student_id) {
				$student_id = $user->get_user_meta($student_id);
			}
			return $sorting->sort_by_meta_value($students, "surname");
		}
	}
	$args = ['role' => 'student', 'status' => 'active', 'class' => $class];
	if($category) {
		$args['category'] = $category;
	}
	$students = $user->get_user_by_meta_data($args);
	return $sorting->sort_by_meta_value($students, "surname");
}

function eedu_portal_positioning($broadsheet) {
	$sorting = new sorting;
	$broadsheet = $sorting->sort_by_meta_value($broadsheet, "average", "desc");
	if(!_count($broadsheet)) {
		return $broadsheet;
	}
	if(!is_array($broadsheet)) {
		return $broadsheet;
	}
	$last_average = 0;
	$last_position = 0;
	$i = 1;
	foreach ($broadsheet as $key => &$value) {
		if($value["average"] == $last_average) {
			$value['position'] = $last_position;
		} else $value['position'] = $i;
		$last_position = $value['position'];
		$last_average = $value['average'];
		$i++;
	}
	return $broadsheet;
}

function eedu_portal_make_broadsheet($class, $category, $term, $format = "Standard", $columns = array(), $table_id = "table") {
	$default = [
		"sn" => "SN",
		"fullname" => "FULL NAME",
		"breakdown" => "BREAKDOWN", 
		"scores" => "SCORES", 
		"total" => "TOTAL", 
		"subjects_offered" => "SUBJECTS OFFERED", 
		"average" => "AVERAGE", 
		"position" => "POSITION"
	];
	$columns = array_merge($default, $columns);
	if($format === "Standard") {
		unset($columns['breakdown']);
	}
	$class_courses = get_class_courses($class, $category, false, true, true);
	$columns_count = (_count($columns) - 1) + (_count($class_courses));

	// get broadsheet
	$broadsheet = eedu_portal_get_broadsheet($class, $category, $term, $class_courses, $format);
	$html = "";
	$html .= "<div class=\"table-responsive broadsheet\"><table class=\"table table-bordered text-center\" id=\"".$table_id."\"><thead><tr><th colspan=\"".$columns_count."\" class=\"broadsheet-header text-center\">";
	$html .= strtoupper(get_class_name($class, $category)." ".$format)." FORMAT BROADSHEET ".get_full_term_name($term);
	$html .= "</th></tr>";
	$html .= "<tr>";
	foreach ($columns as $column => $label) {
		$tag_class = ($column == "fullname" || $column == "student_id") ? "text-left pr-0 pl-0" : "rotate90 pr-0 pl-0";
		if($column === "scores") {
			foreach ($class_courses as $course_id => $course_name) {
				$html .= "<th class=\"".$tag_class."\"><span>".$course_name."</span></th>";
			}
		} else {
			$html .= "<th class=\"".$tag_class."\"><span>".$label."</span></th>";
		}
	}
	$html .= "</tr></thead><tbody>";
	if(_count($broadsheet) && is_array($broadsheet)) {
		foreach ($broadsheet as $key => $value) {
			$html .= "<tr>";
			foreach ($columns as $column => $label) {
				$tag_class = ($column == "fullname" || $column == "student_id") ? "text-left pr-0 pl-0" : "pr-0 pl-0";
				if($column === "scores") {
					foreach ($class_courses as $course_id => $course_name) {
						if($format !== "Standard") {
							$html .= "<td class=\"".$tag_class."\">";
							if(isset($value[$course_id]['total'])) {
								$html .= $value[$course_id]['incourse']."<br />".$value[$course_id]['exam']."<hr /><strong>".$value[$course_id]['total']."</strong>";
							} else {
								$html .= "-";
							}
							$html .= "</td>";
						} else {
							if(isset($value[$course_id])) {
								$html .= "<td class=\"".$tag_class." pl-0 pr-0\">".$value[$course_id]."</td>";
							} else {
								$html .= "<td class=\"".$tag_class." pl-0 pr-0\">-</td>";
							}
							
						}
					}
				} else if($column === "sn") {
					$i = $key + 1;
					$html .= "<td class=\"pl-0 pr-0\">".$i."</td>";
				}  else if($column === "breakdown") {
					$html .= "<td class=\"text-right pl-0 pr-0\">Tests<br />Exam<hr /><strong>Total<strong/></td>";
				} else {
					if($column == "average") {
						$value[$column] = round($value[$column]);
					}
					$html .= "<td class=\"".$tag_class." pl-0 pr-0\">".$value[$column]."</td>";
				}
			}
			$html .= "</tr>";
		} // end foreach broadsheet
	}
	$html .= "</tbody></table></div>";
	return $html;
}

function eedu_portal_get_broadsheet($class, $category, $term, $class_courses, $format = "Standard") {
	if($record = get_record("eedu_broadsheet_".$format."_".$class."_".$category."_".$term, false)) {
		if($record = _unserialize($record)) {
			return $record;
		}
	}
	$post = new post;
	$comment = new ft_comment;
	$term_meta = $post->get_post_meta($term);
	$students_results = eedu_portal_get_results($class, $category, $term, $class_courses, $term_meta, $format);
	$broadsheet = [];
	if(!isset($students_results['students'])) {
		return $broadsheet;
	}
	if(!_count($students_results['students'])) {
		return $broadsheet;
	}
	foreach ($students_results['students'] as $student_meta) {
		$broadsheet[$student_meta['id']]['fullname'] = get_fullname($student_meta);
		$broadsheet[$student_meta['id']]['student_id'] = strtoupper($student_meta['username']);
		$broadsheet[$student_meta['id']]['total'] = $broadsheet[$student_meta['id']]['subjects_offered'] = 0;
		$count = 0;
		foreach ($class_courses as $course_id => $course_name) {
			$score = 0;
			if(isset($students_results['results'][$course_id][$student_meta['id']])) {
				if($format === "Standard") {
					$score = is_numeric($students_results['results'][$course_id][$student_meta['id']]) ? $students_results['results'][$course_id][$student_meta['id']] : 0;
					$broadsheet[$student_meta['id']][$course_id] = $score;
				} else {
					$score = is_numeric($students_results['results'][$course_id][$student_meta['id']]['total']) ? $students_results['results'][$course_id][$student_meta['id']]['total'] : 0;
					if($format === "Compile") {
						$broadsheet[$student_meta['id']]['courses'][$course_id] = $students_results['results'][$course_id][$student_meta['id']];
						// $broadsheet[$student_meta['id']]['courses'][$course_id]['total'] = $students_results['results'][$course_id][$student_meta['id']]['total'];
						$broadsheet[$student_meta['id']]['courses'][$course_id]['course_name'] = $course_name;
					} else {
						$broadsheet[$student_meta['id']][$course_id] = $students_results['results'][$course_id][$student_meta['id']];
					}
				}
				$count++;
			}
			$broadsheet[$student_meta['id']]['total'] += $score;
		}
		$broadsheet[$student_meta['id']]['subjects_offered'] += $count;
		$broadsheet[$student_meta['id']]['average'] = ($count > 0 && $broadsheet[$student_meta['id']]['total'] > 0) ? $broadsheet[$student_meta['id']]['total']/$count : 0;
		$broadsheet[$student_meta['id']]['comment'] = $comment->get_comment($broadsheet[$student_meta['id']]['average']);
	}
	$broadsheet = eedu_portal_positioning($broadsheet);
	$processed = serialize($broadsheet);
	$processed = base64_encode($processed);
	update_record("eedu_broadsheet_".$format."_".$class."_".$category."_".$term, $processed);
	remove_record("eedu_prepared_results_".$format."_".$class."_".$category."_".$term);
	return $broadsheet;
}

//returns an array of results and students
function eedu_portal_get_results($class, $category, $term, $class_courses, $term_meta = false, $format = "Standard") {
	$post = new post;
	$user = new user;
	$results_args = ['type' => 'result', 'class' => $class, 'term' => $term, 'status' => 'verified'];
	if($category !== false) {
		$results_args['category'] = $category;
	}
	$students = eedu_portal_get_class_students($class, $category, $term);
	if($record = get_record("eedu_prepared_results_".$format."_".$class."_".$category."_".$term, false)) {
		return ["results" => $record, "students" => $students];
	}
	$results = $post->get_post_by_meta_data($results_args);
	$results = eedu_portal_prepare_result($results, $format);
	update_record("eedu_prepared_results_".$format."_".$class."_".$category."_".$term, $results);
	return ["results" => $results, "students" => $students];
}

// Standard: courseid->studentid->total
// Detailed: courseid->studentid->label->score
function eedu_portal_prepare_result($results, $format = "Standard") {
	$output = [];
	if(_count($results) < 1) {
		return $output;
	}
	if(!is_array($results)) {
		return $output;
	}
	foreach ($results as $key => $value) {
		set_time_limit(80);
		$scores = _unserialize($value['result']);
		foreach ($scores as $student_id => $s) {
			set_time_limit(80);
			$total = 0;
			$written = false;
			if($format === "Standard") {
				// standard format
				foreach ($s as $ss) {
					set_time_limit(80);
					$check = trim($ss);
					if($check !== "" && strtolower($check) !== "x") {
						$written = true;
						$total += (is_numeric($ss)) ? $ss : 0;
					}
				}
				if($written) {
					$output[$value['course']][$student_id] = $total;
				}
			} else {
				//detailed format
				$incourse = 0;
				foreach ($s as $key => $ss) {
					set_time_limit(80);
					$check = trim($ss);
					if($check !== "" && strtolower($check) !== "x") {
						$written = true;
						$total += (is_numeric($ss)) ? $ss : 0;
					}
					if($format === 'Compile') {
						if($written) {
							$output[$value['course']][$student_id][$key] = $ss;
						}
					} else {
						if(!in_array($key, ['exam', 'Exam', 'examination', 'Examination'])) {
							$incourse += (is_numeric($ss)) ? $ss : 0;
						}
					}
				}
				if($written) {
					$output[$value['course']][$student_id]['total'] = $total;
				}
				if($format !== "Compile" && $written) {
					$output[$value['course']][$student_id]['incourse'] = $incourse;
					$output[$value['course']][$student_id]['exam'] = $total - $incourse;
				}
			}
		}
	}
	return $output;
}

function eedu_portal_make_annual_broadsheet($class, $session, $format = "Standard", $columns = array(), $table_id = "table") {
	$default = [
		"sn" => "SN",
		"fullname" => "FULL NAME",
		"terms" => "TERMS",
		"scores" => "SCORES", 
		"total" => "TOTAL", 
		"subjects_offered" => "SUBJECTS OFFERED", 
		"average" => "AVERAGE",
		"comment" => "COMMENT",
		"position" => "POSITION"
	];
	$columns = array_merge($default, $columns);
	if($format !== "Standard") {
		$post = new post;
		$terms = $post->get_post_by_meta_data(['type' => 'academic_term', 'acsession' => $session]);
		if(!$terms) {
			return false;
		}
		$sorting = new sorting;
		$terms = $sorting->sort_by_meta_value($terms, "order");
	} else {
		unset($columns['terms']);
	}
	$class_courses = get_class_courses($class, false, false, true, true);
	$columns_count = (_count($columns) - 1) + (_count($class_courses));
	// get broadsheet
	$broadsheet = eedu_portal_get_annual_broadsheet($class, $session, $class_courses);
	$html = "";
	$html .= "<div class=\"table-responsive broadsheet\"><table class=\"table table-bordered text-center\" id=\"".$table_id."\"><thead><tr><th colspan=\"".$columns_count."\" class=\"broadsheet-header text-center\">";
	$html .= strtoupper(get_class_name($class)." ".$format)." FORMAT BROADSHEET FOR ".get_session_name($session);
	$html .= "</th></tr>";
	$html .= "<tr>";
	foreach ($columns as $column => $label) {
		$tag_class = ($column == "fullname" || $column == "student_id") ? "text-left pl-0 pr-0" : "rotate90 pl-0 pr-0";
		if($column === "scores") {
			foreach ($class_courses as $course_id => $course_name) {
				$html .= "<th class=\"".$tag_class."\"><span>".$course_name."</span></th>";
			}
		} else {
			$html .= "<th class=\"".$tag_class."\"><span>".$label."</span></th>";
		}
	}
	$html .= "</tr></thead><tbody>";
	if(_count($broadsheet) && is_array($broadsheet)) {
		foreach ($broadsheet as $key => $value) {
			$html .= "<tr>";
			foreach ($columns as $column => $label) {
				$tag_class = ($column == "fullname" || $column == "student_id") ? "text-left pl-0 pr-0" : "pl-0 pr-0";
				if($column === "scores") {
					foreach ($class_courses as $course_id => $course_name) {
						if($format !== "Standard") {
							$total = 0;
							$count = _count($value[$course_id]['terms'] ?? 0);
							$html .= "<td class=\"".$tag_class."\">";
							if(isset($value[$course_id]['terms']) && $count) {
								foreach($terms as $term_meta) {
									if(isset($value[$course_id]['terms'][$term_meta['id']])) {
										$score = $value[$course_id]['terms'][$term_meta['id']];
										$total += is_numeric($score) ? $score : 0;
										$html .= round($score)."<br />";
									} else {
										$html .= "-<br />";
									}
								}
								$average = ($total > 0 && $count > 0) ? round($total/$count) : 0;
								$html .= "<hr />";
								$html .= "<strong>".$average."</strong>";

							}
							$html .= "</td>";
						} else {
							$html .= "<td class=\"".$tag_class."\">".round($value[$course_id]['average'] ?? 0)."</td>";
						}
					}
				} else if($column == "terms") {
					$html .= "<td class=\"text-center pl-0 pr-0\">";
					foreach ($terms as $term_meta) {
						$html .= substr($term_meta['term_name'], 0, 1)."<br />";
					}
					$html .= "<hr /><strong>A</strong>";
					$html .= "</td>";
				} else if($column === "sn") {
					$i = $key + 1;
					$html .= "<td class=\"pl-0 pr-0\">".$i."</td>";
				}
				else {
					if($column == "average" || $column == "total") {
						$value[$column] = round($value[$column], 2);
					}
					if($column == "comment") {
						if($value[$column] == "Promoted") {
							$value[$column] = "<span class=\"badge badge-success\">".$value[$column]."</span>";
						}
						if($value[$column] == "Not Promoted") {
							$value[$column] = "<span class=\"badge badge-danger\">".$value[$column]."</span>";
						}
					}
					$html .= "<td class=\"".$tag_class."\">".$value[$column]."</td>";
				}
			}
			$html .= "</tr>";
		} // end foreach broadsheet
	}
	$html .= "</tbody></table></div>";
	return $html;
}

function eedu_portal_get_annual_broadsheet($class, $session, $class_courses) {
	if($record = get_record("eedu_annual_prepared_broadsheet_".$class."_".$session, false)) {
		if($record = _unserialize($record)) {
			return $record;
		}
	}
	$post = new post;
	$user = new user;
	$comment = new ft_comment;
	$comment->class = $class;
	$terms = $post->get_post_by_meta_data(['type' => 'academic_term', 'acsession' => $session]);
	$_3rd_term = db_post_unique(['type' => 'academic_term', 'acsession' => $session, 'order' => 3]);
	if(!$terms) {
		return false;
	}
	if(!_count($terms)) {
		return false;
	}
	$broadsheets = [];
	$annual_broadsheet = [];
	$mocks = [];
	foreach ($terms as $term_meta) {
		if($mock = db_post_unique(['type' => "mock_for_mastersheet", "term" => $term_meta['id'], "class" => $class])) {
			$mocks[$term_meta['id']] = $mock["ext_exam"];
			$broadsheets[$term_meta['id']] = extexam_get_broadsheet($class, false, $term_meta['id'], $mock['ext_exam'], $class_courses);
		} else {
			$broadsheets[$term_meta['id']] = eedu_portal_get_broadsheet($class, false, $term_meta['id'], $class_courses, "Standard");
		}
	}
	if(!_count($broadsheets)) {
		return false;
	}
	$_3rd_term_broadsheet = isset($broadsheets[$_3rd_term['id']]) ? array_column($broadsheets[$_3rd_term['id']], null, 'student_id') : array();
	foreach ($broadsheets as $term => $results) {
		foreach ($results as $user_id => $result_data) {
			foreach ($class_courses as $course_id => $course_name) {
				set_time_limit(80);

				$course_total = (isset($annual_broadsheet[$result_data['student_id']][$course_id]['total'])) ? $annual_broadsheet[$result_data['student_id']][$course_id]['total'] : 0;
				$_3rd_term_score = isset($mocks[$_3rd_term['id']]) ? $_3rd_term_broadsheet[$result_data['student_id']]['courses'][$course_id]['score'] ?? 'x' : $_3rd_term_broadsheet[$result_data['student_id']][$course_id] ?? 'x';
				if($_3rd_term_score !== NULL && trim($_3rd_term_score) !== "" && trim(strtolower($_3rd_term_score)) != "x") {
					$score = isset($mocks[$term]) ? $result_data['courses'][$course_id]['score'] ?? NULL : $result_data[$course_id] ?? NULL;
				} else $score = NULL;
				if($score !== NULL) {
					$annual_broadsheet[$result_data['student_id']][$course_id]['terms'][$term] = $score;
					if(is_numeric($score)) {
						$course_total +=  $score;
					}
					if($count = _count($annual_broadsheet[$result_data['student_id']][$course_id]['terms'])) {
						$course_average = ($course_total > 0) ? $course_total/$count : 0;
						$annual_broadsheet[$result_data['student_id']][$course_id]['average'] = $course_average;
					}
					$annual_broadsheet[$result_data['student_id']][$course_id]['total'] = $course_total;
				}
			}
		}
	}
	if(!_count($annual_broadsheet)) {
		return false;
	}
	foreach ($annual_broadsheet as $student_id => &$stud_results) {
		if(!_count($stud_results)) {
			continue;
		}
		set_time_limit(80);
		$total = 0;
		$subjects_offered = _count($stud_results);
		foreach ($stud_results as $course_id => $scores) {
			$total += $scores['average'];
		}
		$user_meta = $user->get_user_meta($student_id, "username");
		$stud_results['fullname'] = get_fullname($user_meta);
		$stud_results['student_id'] = $student_id;
		$stud_results['subjects_offered'] = $subjects_offered;
		$stud_results['average'] = ($total > 0) ? $total/$subjects_offered : 0;
		$stud_results['total'] = $total;
		$stud_results['comment'] = $comment->get_annual_comment($stud_results['average'], $stud_results);
	}
	$annual_broadsheet = eedu_portal_positioning($annual_broadsheet);
	$processed = serialize($annual_broadsheet);
	$processed = base64_encode($processed);
	update_record("eedu_annual_prepared_broadsheet_".$class."_".$session, $processed);
	return $annual_broadsheet;
}

function eedu_portal_reset_broadsheet($class, $category, $term) {
	remove_record("eedu_broadsheet_standard_".$class."_".$category."_".$term);
	remove_record("eedu_broadsheet_detailed_".$class."_".$category."_".$term);
	remove_record("eedu_broadsheet_compile_".$class."_".$category."_".$term);
	remove_record("class_courses_".$class."_".$category."_merged");
	remove_record("class_courses_".$class."_".$category."_expanded");
	remove_record("eedu_prepared_results_standard_".$class."_".$category."_".$term);
	remove_record("eedu_prepared_results_detailed_".$class."_".$category."_".$term);
	remove_record("eedu_prepared_results_compiled_".$class."_".$category."_".$term);
	$category = false;
	remove_record("eedu_broadsheet_standard_".$class."_".$category."_".$term);
	remove_record("eedu_broadsheet_detailed_".$class."_".$category."_".$term);
	remove_record("eedu_broadsheet_compile_".$class."_".$category."_".$term);
	eedu_portal_reset_annual_broadsheet($class, $term);
}

function eedu_portal_reset_annual_broadsheet($class, $term = false, $session = false) {
	if(!$session) {
		$session = get_term_session($term);
	}
	remove_record("eedu_annual_prepared_broadsheet_".$class."_".$session);
}

function eedu_portal_reset_class_courses($class = false, $category = false) {
	if(!$class) {
		$categories = get_option("category_mapping");
		foreach ($categories as $class_id => $value) {
			eedu_portal_reset_class_courses($class_id);
		}
	}
	if(!$category) {
		$categories = get_option("category_mapping");
		$class_categories = $categories[$class];
		foreach ($class_categories as $category) {
			remove_record("class_courses_".$class."_".$category."_merged");
			remove_record("class_courses_".$class."_".$category."_expanded");
		}
		return;
	}
	remove_record("class_courses_".$class."_".$category."_merged");
	remove_record("class_courses_".$class."_".$category."_expanded");
	return;
}

function eedu_portal_reset_class_name($class) {
	remove_record("eedu_class_name_".$class);
}

function eedu_portal_reset_category_name($category) {
	remove_record("eedu_category_name_".$category);
}

function eedu_portal_reset_term_name($term) {
	remove_record("eedu_term_name_".$term);
	remove_record("eedu_full_term_name_".$term);
}

function eedu_portal_reset_session_name($session) {
	remove_record("eedu_session_name_".$session);
	$post = new post;
	$terms = $post->get_post_by_meta_data(['type' => 'academic_term', 'acsession' => $session]);
	if($terms) {
		foreach ($terms as $term_meta) {
			remove_record("eedu_full_term_name_".$term_meta['id']);
		}
	}
}

function eedu_portal_reset_term_session($term) {
	remove_record("eedu_term_session_".$term);
}

function get_student_annual_result_from_broadsheet($student_meta, $broadsheet) {
	if(!$broadsheet) {
		return false;
	}
	$broadsheet_columns = array_column($broadsheet, null, 'student_id');
	if(isset($broadsheet_columns[strtoupper($student_meta['username'])])) {
	    return $broadsheet_columns[strtoupper($student_meta['username'])];
	}
	else if(isset($broadsheet_columns[$student_meta['username']])) {
	    return $broadsheet_columns[strtoupper($student_meta['username'])];
	} else {
	    return false;
	}
}

function eedu_portal_all_class_category() {
	$session = Session::getInstance();
	if(isset($session->{"class_options"})) {
		$options = $session->{"class_options"};
	} else {
		$post = new post;
		$category_mapping = get_option("category_mapping");
		$options = [];
		if($category_mapping && _count($category_mapping)) {
			foreach ($category_mapping as $class => $cats) {
				if((_count($cats) > 0)) {
					foreach ($cats as $category) {
						$options[get_class_name($class, $category)] = $class.",".$category;
					}
				}
			}
		}
		$session->{"class_options"} = $options;
	}
	return $options;
}

function eedu_portal_email_msg_template($subject, $content, $redirect = false) {
	$home_url = get_option('home_url');
	$redirect = $redirect ? $redirect : $home_url;
	$company_phone = ($option = get_option('company_phone')) ? implode(", ", $option) : "";
	$html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional //EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">

		<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">
		<head>
		<!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->
		<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\"/>
		<meta content=\"width=device-width\" name=\"viewport\"/>
		<!--[if !mso]><!-->
		<meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\"/>
		<!--<![endif]-->
		<title></title>
		<!--[if !mso]><!-->
		<link href=\"https://fonts.googleapis.com/css?family=Abril+Fatface\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Bitter\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Cabin\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Lato\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Merriweather\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Montserrat\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Droid+Serif\" rel=\"stylesheet\" type=\"text/css\"/>
		<link href=\"https://fonts.googleapis.com/css?family=Roboto\" rel=\"stylesheet\" type=\"text/css\"/>
		<!--<![endif]-->
		<style type=\"text/css\">
				body {
					margin: 0;
					padding: 0;
				}

				table,
				td,
				tr {
					vertical-align: top;
					border-collapse: collapse;
				}

				* {
					line-height: inherit;
				}

				a[x-apple-data-detectors=true] {
					color: inherit !important;
					text-decoration: none !important;
				}
			</style>
		<style id=\"media-query\" type=\"text/css\">
				@media (max-width: 660px) {

					.block-grid,
					.col {
						min-width: 320px !important;
						max-width: 100% !important;
						display: block !important;
					}

					.block-grid {
						width: 100% !important;
					}

					.col {
						width: 100% !important;
					}

					.col_cont {
						margin: 0 auto;
					}

					img.fullwidth,
					img.fullwidthOnMobile {
						max-width: 100% !important;
					}

					.no-stack .col {
						min-width: 0 !important;
						display: table-cell !important;
					}

					.no-stack.two-up .col {
						width: 50% !important;
					}

					.no-stack .col.num2 {
						width: 16.6% !important;
					}

					.no-stack .col.num3 {
						width: 25% !important;
					}

					.no-stack .col.num4 {
						width: 33% !important;
					}

					.no-stack .col.num5 {
						width: 41.6% !important;
					}

					.no-stack .col.num6 {
						width: 50% !important;
					}

					.no-stack .col.num7 {
						width: 58.3% !important;
					}

					.no-stack .col.num8 {
						width: 66.6% !important;
					}

					.no-stack .col.num9 {
						width: 75% !important;
					}

					.no-stack .col.num10 {
						width: 83.3% !important;
					}

					.video-block {
						max-width: none !important;
					}

					.mobile_hide {
						min-height: 0px;
						max-height: 0px;
						max-width: 0px;
						display: none;
						overflow: hidden;
						font-size: 0px;
					}

					.desktop_hide {
						display: block !important;
						max-height: none !important;
					}
				}
			</style>
		<style id=\"menu-media-query\" type=\"text/css\">
				@media (max-width: 660px) {
					.menu-checkbox[type=\"checkbox\"]~.menu-links {
						display: none !important;
						padding: 5px 0;
					}

					.menu-checkbox[type=\"checkbox\"]~.menu-links span.sep {
						display: none;
					}

					.menu-checkbox[type=\"checkbox\"]:checked~.menu-links,
					.menu-checkbox[type=\"checkbox\"]~.menu-trigger {
						display: block !important;
						max-width: none !important;
						max-height: none !important;
						font-size: inherit !important;
					}

					.menu-checkbox[type=\"checkbox\"]~.menu-links>a,
					.menu-checkbox[type=\"checkbox\"]~.menu-links>span.label {
						display: block !important;
						text-align: center;
					}

					.menu-checkbox[type=\"checkbox\"]:checked~.menu-trigger .menu-close {
						display: block !important;
					}

					.menu-checkbox[type=\"checkbox\"]:checked~.menu-trigger .menu-open {
						display: none !important;
					}

					#menukmav75~div label {
						border-radius: 0% !important;
					}

					#menukmav75:checked~.menu-links {
						background-color: #000000 !important;
					}

					#menukmav75:checked~.menu-links a {
						color: #ffffff !important;
					}

					#menukmav75:checked~.menu-links span {
						color: #ffffff !important;
					}
				}
			</style>
		</head>
		<body class=\"clean-body\" style=\"margin: 0; padding: 0; -webkit-text-size-adjust: 100%; background-color: #fafafa;\">
		<!--[if IE]><div class=\"ie-browser\"><![endif]-->
		<table bgcolor=\"#fafafa\" cellpadding=\"0\" cellspacing=\"0\" class=\"nl-container\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; min-width: 320px; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td style=\"word-break: break-word; vertical-align: top;\" valign=\"top\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"center\" style=\"background-color:#fafafa\"><![endif]-->
		<div style=\"background-color:#a9d794;\">
		<div class=\"block-grid\" style=\"min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: transparent;\">
		<div style=\"border-collapse: collapse;display: table;width: 100%;background-color:transparent;\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:#a9d794;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:640px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]-->
		<!--[if (mso)|(IE)]><td align=\"center\" width=\"640\" style=\"background-color:transparent;width:640px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->
		<div class=\"col num12\" style=\"min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#333333;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;\">
		<div style=\"line-height: 1.2; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #333333; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: center; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 17px; margin: 0;\">This is a notification mail sent through the school portal. Please treat as confidential</p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
		</div>
		</div>
		</div>
		<div style=\"background-color:transparent;\">
		<div class=\"block-grid\" style=\"min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: transparent;\">
		<div style=\"border-collapse: collapse;display: table;width: 100%;background-color:transparent;\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:transparent;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:640px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]-->
		<!--[if (mso)|(IE)]><td align=\"center\" width=\"640\" style=\"background-color:transparent;width:640px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:0px; padding-bottom:0px;\"><![endif]-->
		<div class=\"col num12\" style=\"min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:0px; padding-bottom:0px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"40\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 40px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"40\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<div align=\"center\" class=\"img-container center fixedwidth\" style=\"padding-right: 0px;padding-left: 0px;\">
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr style=\"line-height:0px\"><td style=\"padding-right: 0px;padding-left: 0px;\" align=\"center\"><![endif]--><img align=\"center\" alt=\"School logo\" border=\"0\" class=\"center fixedwidth\" src=\"".$home_url.get_option('company-logo')."\" style=\"text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; width: 100%; max-width: 128px; display: block;\" title=\"School logo\" width=\"128\"/>
		<!--[if mso]></td></tr></table><![endif]-->
		</div>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#555555;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;\">
		<div style=\"line-height: 1.2; font-size: 12px; color: #555555; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 12px; line-height: 1.2; word-break: break-word; text-align: center; mso-line-height-alt: 14px; margin: 0;\"><span style=\"font-size: 12px;\"><em>...sent from ".get_option('company_name')."</em></span></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"40\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 40px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"40\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#1d1d1d;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;\">
		<div style=\"line-height: 1.2; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #1d1d1d; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: center; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 17px; margin: 0;\"><strong><span style=\"font-size: 28px;\">".$subject."</span></strong></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"35\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 35px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"35\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 20px; padding-left: 20px; padding-top: 0px; padding-bottom: 0px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#333333;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.8;padding-top:0px;padding-right:20px;padding-bottom:0px;padding-left:20px;\">
		<div style=\"line-height: 1.8; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #333333; mso-line-height-alt: 22px;\">
		<p style=\"font-size: 16px; line-height: 1.8; word-break: break-word; text-align: center; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 29px; margin: 0;\">
		<span style=\"font-size: 16px;\">".$content."</span>
		</p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 1px solid #BBBBBB; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#555555;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;\">
		<div style=\"line-height: 1.2; font-size: 12px; color: #555555; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: justify; mso-line-height-alt: 17px; margin: 0;\"><strong><span style=\"font-size: 12px;\"><em>This message was sent to you because your email address was registered in ".get_option('company_name')." School Portal and we believe that you have a ward in the school. </em></span></strong></p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: justify; mso-line-height-alt: 17px; margin: 0;\"><strong><span style=\"font-size: 12px;\"><em>If this message got to you by error, Please disregard.</em></span></strong></p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: justify; mso-line-height-alt: 17px; margin: 0;\"><strong><span style=\"font-size: 12px;\"><em>A quick link was attached to this mail to provide a shortcut for you if you need to take immediate action as related to the information contained inside this mail. To take action, click the button below:</em></span></strong></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"30\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 30px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"30\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<div align=\"center\" class=\"button-container\" style=\"padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;\">
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;\"><tr><td style=\"padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px\" align=\"center\"><v:roundrect xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" href=\"".$redirect."\" style=\"height:33pt; width:223.5pt; v-text-anchor:middle;\" arcsize=\"55%\" strokeweight=\"0.75pt\" strokecolor=\"#1D1D1D\" fill=\"false\"><w:anchorlock/><v:textbox inset=\"0,0,0,0\"><center style=\"color:#1d1d1d; font-family:Tahoma, sans-serif; font-size:16px\"><![endif]--><a href=\"".$redirect."\" style=\"-webkit-text-size-adjust: none; text-decoration: none; display: inline-block; color: #1d1d1d; background-color: transparent; border-radius: 24px; -webkit-border-radius: 24px; -moz-border-radius: 24px; width: auto; width: auto; border-top: 1px solid #1D1D1D; border-right: 1px solid #1D1D1D; border-bottom: 1px solid #1D1D1D; border-left: 1px solid #1D1D1D; padding-top: 5px; padding-bottom: 5px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; text-align: center; mso-border-alt: none; word-break: keep-all;\" target=\"_blank\"><span style=\"padding-left:50px;padding-right:50px;font-size:16px;display:inline-block;\"><span style=\"font-size: 16px; line-height: 2; word-break: break-word; mso-line-height-alt: 32px;\"><strong>Go to Page</strong></span></span></a>
		<!--[if mso]></center></v:textbox></v:roundrect></td></tr></table><![endif]-->
		</div>
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"60\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 60px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"60\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
		</div>
		</div>
		</div>
		<div style=\"background-color:#ffffff;\">
		<div class=\"block-grid two-up\" style=\"min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: #ffffff;\">
		<div style=\"border-collapse: collapse;display: table;width: 100%;background-color:#ffffff;\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:#ffffff;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:640px\"><tr class=\"layout-full-width\" style=\"background-color:#ffffff\"><![endif]-->
		<!--[if (mso)|(IE)]><td align=\"center\" width=\"320\" style=\"background-color:#ffffff;width:320px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->
		<div class=\"col num6\" style=\"display: table-cell; vertical-align: top; max-width: 320px; min-width: 318px; width: 320px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<div align=\"center\" class=\"img-container center autowidth\" style=\"padding-right: 45px;padding-left: 45px;\">
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr style=\"line-height:0px\"><td style=\"padding-right: 45px;padding-left: 45px;\" align=\"center\"><![endif]-->
		<div style=\"font-size:1px;line-height:50px\"> </div><img align=\"center\" alt=\"A microphone, Guitar Pedal, and Audio Recorder\" border=\"0\" class=\"center autowidth\" src=\"".$home_url."contents/plugins/eedu_portal/images/pngwing.com2.png\" style=\"text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; width: 100%; max-width: 230px; display: block;\" title=\"A microphone, Guitar Pedal, and Audio Recorder\" width=\"230\"/>
		<div style=\"font-size:1px;line-height:50px\"> </div>
		<!--[if mso]></td></tr></table><![endif]-->
		</div>
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td><td align=\"center\" width=\"320\" style=\"background-color:#ffffff;width:320px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->
		<div class=\"col num6\" style=\"display: table-cell; vertical-align: top; max-width: 320px; min-width: 318px; width: 320px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"35\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 35px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"35\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 35px; padding-left: 35px; padding-top: 5px; padding-bottom: 5px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#1d1d1d;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:5px;padding-right:35px;padding-bottom:5px;padding-left:35px;\">
		<div style=\"line-height: 1.2; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #1d1d1d; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 24px; line-height: 1.2; word-break: break-word; text-align: left; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 29px; margin: 0;\"><span style=\"font-size: 24px;\"><strong><span style=\"\">Need to check results?<br/></span></strong></span></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"20\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 20px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"20\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 35px; padding-left: 35px; padding-top: 0px; padding-bottom: 0px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#333333;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.8;padding-top:0px;padding-right:35px;padding-bottom:0px;padding-left:35px;\">
		<div style=\"line-height: 1.8; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #333333; mso-line-height-alt: 22px;\">
		<p style=\"font-size: 16px; line-height: 1.8; word-break: break-word; text-align: left; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 29px; margin: 0;\"><span style=\"font-size: 16px;\">With Schools Konnect Academic Portal, Checking of results have been simplified<br/></span></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"20\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 20px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"20\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<div align=\"left\" class=\"button-container\" style=\"padding-top:0px;padding-right:35px;padding-bottom:0px;padding-left:35px;\">
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;\"><tr><td style=\"padding-top: 0px; padding-right: 35px; padding-bottom: 0px; padding-left: 35px\" align=\"left\"><v:roundrect xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" href=\"".$home_url."result-checker\" style=\"height:33pt; width:184.5pt; v-text-anchor:middle;\" arcsize=\"55%\" strokeweight=\"0.75pt\" strokecolor=\"#1D1D1D\" fill=\"false\"><w:anchorlock/><v:textbox inset=\"0,0,0,0\"><center style=\"color:#1d1d1d; font-family:Tahoma, sans-serif; font-size:16px\"><![endif]--><a href=\"".$home_url."result-checker\" style=\"-webkit-text-size-adjust: none; text-decoration: none; display: inline-block; color: #1d1d1d; background-color: transparent; border-radius: 24px; -webkit-border-radius: 24px; -moz-border-radius: 24px; width: auto; width: auto; border-top: 1px solid #1D1D1D; border-right: 1px solid #1D1D1D; border-bottom: 1px solid #1D1D1D; border-left: 1px solid #1D1D1D; padding-top: 5px; padding-bottom: 5px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; text-align: center; mso-border-alt: none; word-break: keep-all;\" target=\"_blank\"><span style=\"padding-left:40px;padding-right:40px;font-size:16px;display:inline-block;\"><span style=\"font-size: 16px; line-height: 2; word-break: break-word; mso-line-height-alt: 32px;\"><strong>Click Here </strong></span></span></a>
		<!--[if mso]></center></v:textbox></v:roundrect></td></tr></table><![endif]-->
		</div>
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"35\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 35px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"35\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
		</div>
		</div>
		</div>
		<div style=\"background-color:transparent;\">
		<div class=\"block-grid\" style=\"min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: transparent;\">
		<div style=\"border-collapse: collapse;display: table;width: 100%;background-color:transparent;\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:transparent;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:640px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]-->
		<!--[if (mso)|(IE)]><td align=\"center\" width=\"640\" style=\"background-color:transparent;width:640px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->
		<div class=\"col num12\" style=\"min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"60\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 60px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"60\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
		</div>
		</div>
		</div>
		<div style=\"background-color:transparent;\">
		<div class=\"block-grid two-up\" style=\"min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: transparent;\">
		<div style=\"border-collapse: collapse;display: table;width: 100%;background-color:transparent;\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:transparent;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:640px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]-->
		<!--[if (mso)|(IE)]><td align=\"center\" width=\"320\" style=\"background-color:transparent;width:320px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->
		<div class=\"col num6\" style=\"display: table-cell; vertical-align: top; max-width: 320px; min-width: 318px; width: 320px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<div align=\"center\" class=\"img-container center autowidth\" style=\"padding-right: 0px;padding-left: 0px;\">
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr style=\"line-height:0px\"><td style=\"padding-right: 0px;padding-left: 0px;\" align=\"center\"><![endif]--><img align=\"center\" alt=\"Alternate text\" border=\"0\" class=\"center autowidth\" src=\"".$home_url."contents/plugins/eedu_portal/images/schools_konnect_flyer-removebg-preview.png\" style=\"text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; width: 100%; max-width: 320px; display: block;\" title=\"Alternate text\" width=\"320\"/>
		<!--[if mso]></td></tr></table><![endif]-->
		</div>
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td><td align=\"center\" width=\"320\" style=\"background-color:transparent;width:320px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->
		<div class=\"col num6\" style=\"display: table-cell; vertical-align: top; max-width: 320px; min-width: 318px; width: 320px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 10px; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; font-family: Georgia, 'Times New Roman', serif\"><![endif]-->
		<div style=\"color:#252525;font-family:'Droid Serif', Georgia, Times, 'Times New Roman', serif;line-height:1.2;padding-top:0px;padding-right:10px;padding-bottom:0px;padding-left:10px;\">
		<div style=\"line-height: 1.2; font-size: 12px; font-family: 'Droid Serif', Georgia, Times, 'Times New Roman', serif; color: #252525; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 46px; line-height: 1.2; text-align: center; font-family: 'Droid Serif', Georgia, Times, 'Times New Roman', serif; word-break: break-word; mso-line-height-alt: 55px; margin: 0;\"><span style=\"font-size: 46px;\"><strong>SCHOOLS</strong></span></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Georgia, 'Times New Roman', serif\"><![endif]-->
		<div style=\"color:#1e7323;font-family:'Droid Serif', Georgia, Times, 'Times New Roman', serif;line-height:1.2;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;\">
		<div style=\"line-height: 1.2; font-size: 12px; font-family: 'Droid Serif', Georgia, Times, 'Times New Roman', serif; color: #1e7323; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 46px; line-height: 1.2; text-align: center; word-break: break-word; font-family: 'Droid Serif', Georgia, Times, 'Times New Roman', serif; mso-line-height-alt: 55px; margin: 0;\"><span style=\"font-size: 46px;\"><strong><span style=\"font-size: 42px;\">KONNECT</span></strong></span></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 20px; padding-left: 20px; padding-top: 20px; padding-bottom: 20px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#555555;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:20px;padding-right:20px;padding-bottom:20px;padding-left:20px;\">
		<div style=\"line-height: 1.2; font-size: 12px; color: #555555; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: left; mso-line-height-alt: 17px; margin: 0;\">A modern academic portal that gives 99.9% Flexibility in managing the digital aspect of every academic institution.</p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; text-align: left; mso-line-height-alt: 17px; margin: 0;\">Visit <a href=\"https://koweb.com.ng/schools-konnect-academic-portal/\" rel=\"noopener\" style=\"text-decoration: underline; color: #0068A5;\" target=\"_blank\">https://koweb.com.ng/schools-konnect-academic-portal/</a> for more information.</p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; mso-line-height-alt: 17px; margin: 0;\"> </p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; mso-line-height-alt: 17px; margin: 0;\">Contact: <strong>+2348039458027</strong> for easy sign up.</p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; mso-line-height-alt: 17px; margin: 0;\"> </p>
		<p style=\"font-size: 14px; line-height: 1.2; word-break: break-word; mso-line-height-alt: 17px; margin: 0;\">Serviced &amp; Maintained by <a href=\"https://koweb.com.ng\" rel=\"noopener\" style=\"text-decoration: none; color: #0068A5;\" target=\"_blank\">Kowebtech Ict</a></p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
		</div>
		</div>
		</div>
		<div style=\"background-color:#ededed;\">
		<div class=\"block-grid\" style=\"min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: transparent;\">
		<div style=\"border-collapse: collapse;display: table;width: 100%;background-color:transparent;\">
		<!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:#ededed;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:640px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]-->
		<!--[if (mso)|(IE)]><td align=\"center\" width=\"640\" style=\"background-color:transparent;width:640px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:20px; padding-bottom:30px;\"><![endif]-->
		<div class=\"col num12\" style=\"min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;\">
		<div class=\"col_cont\" style=\"width:100% !important;\">
		<!--[if (!mso)&(!IE)]><!-->
		<div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:20px; padding-bottom:30px; padding-right: 0px; padding-left: 0px;\">
		<!--<![endif]-->
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;\" valign=\"top\" width=\"100%\">
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td align=\"center\" style=\"word-break: break-word; vertical-align: top; padding-top: 15px; padding-bottom: 15px; padding-left: 0px; padding-right: 0px; text-align: center; font-size: 0px;\" valign=\"top\">
		<div class=\"menu-links\">
		<!--[if mso]>
		<table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">
		<tr>
		<td style=\"padding-top:5px;padding-right:20px;padding-bottom:5px;padding-left:20px\">
		<![endif]--><a href=\"".get_option('company_website')."\" style=\"padding-top:5px;padding-bottom:5px;padding-left:20px;padding-right:20px;display:inline;color:#515151;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;font-size:14px;text-decoration:none;\">Visit Our Website</a>
		<!--[if mso]></td><td><![endif]--><span class=\"sep\" style=\"font-size:14px;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;color:#515151;\">|</span>
		<!--[if mso]></td><![endif]-->
		<!--[if mso]></td><td style=\"padding-top:5px;padding-right:20px;padding-bottom:5px;padding-left:20px\"><![endif]--><a href=\"tel:".$company_phone."\" style=\"padding-top:5px;padding-bottom:5px;padding-left:20px;padding-right:20px;display:inline;color:#515151;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;font-size:14px;text-decoration:none;\">Call Us</a>
		<!--[if mso]></td></tr></table><![endif]-->
		</div>
		</td>
		</tr>
		</table>
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 1px solid #BBBBBB; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td class=\"divider_inner\" style=\"word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;\" valign=\"top\">
		<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"divider_content\" height=\"15\" role=\"presentation\" style=\"table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid transparent; height: 15px; width: 100%;\" valign=\"top\" width=\"100%\">
		<tbody>
		<tr style=\"vertical-align: top;\" valign=\"top\">
		<td height=\"15\" style=\"word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;\" valign=\"top\"><span></span></td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if mso]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 10px; padding-left: 10px; padding-top: 5px; padding-bottom: 5px; font-family: Tahoma, sans-serif\"><![endif]-->
		<div style=\"color:#888888;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:5px;padding-right:10px;padding-bottom:5px;padding-left:10px;\">
		<div style=\"line-height: 1.2; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #888888; mso-line-height-alt: 14px;\">
		<p style=\"font-size: 12px; line-height: 1.2; word-break: break-word; text-align: center; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px; margin: 0;\">
		<span style=\"font-size: 12px;\">© ".date('Y', time())." ".get_option('company_name')." | ".get_option('company_address')."</span>
		</p>
		</div>
		</div>
		<!--[if mso]></td></tr></table><![endif]-->
		<!--[if (!mso)&(!IE)]><!-->
		</div>
		<!--<![endif]-->
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
		</div>
		</div>
		</div>
		<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
		</td>
		</tr>
		</tbody>
		</table>
		<!--[if (IE)]></div><![endif]-->
		</body>
		</html>";
	return $html;
}