<?php
//start school functions
	function get_all_schools($con){
				$select="SELECT * FROM schools WHERE school_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$school_id=$row['school_id'];
												$school_title=$row['title'];
												$school_status=$row['school_status'];

												 $output.='<option value="'.$school_id.'">'.$school_title.'</option>';

											}

										}

		return $output;
}

function get_all_schools_drop($con,$schol_id){
				$select="SELECT * FROM schools WHERE school_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$school_id1=$row['school_id'];
												$drop_title=$row['title'];
												$school_status=$row['school_status'];
												if($schol_id == $school_id1 )
												{
												 $output.='<option value="'.$school_id1.'" selected>'.$drop_title.'</option>';
												}else{
												 $output.='<option value="'.$school_id1.'">'.$drop_title.'</option>';
												}

											}

										}

		return $output;
}
function get_school_by_id($con,$school_id){
			$select="SELECT * FROM schools WHERE school_id ='$school_id'";
									$sql_select=mysqli_query($con,$select);
									$num_rows=mysqli_num_rows($sql_select);
									if($num_rows > 0){

										while($row=mysqli_fetch_array($sql_select)){

											$school_title=$row['title'];




										}

									}

		return @$school_title;
}
//end school functions

//start faculties functions
function get_all_faculty($con){
				$select="SELECT * FROM faculties WHERE faculty_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$faculty_id=$row['faculty_id'];
												$faculty_title=$row['title'];
												$faculty_status=$row['faculty_status'];

												 $faculty_output.='<option value="'.$faculty_id.'">'.$faculty_title.'</option>';

											}

										}

		return $faculty_output;
}
function get_all_faculty_drop($con,$facult_id){
				$select="SELECT * FROM faculties WHERE faculty_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$faculty_id1=$row['faculty_id'];
												$f_drop_title=$row['title'];
												$faculty_status=$row['faculty_status'];
												if($facult_id == $faculty_id1)
												{
												 $f_drop_output.='<option value="'.$faculty_id1.'" selected>'.$f_drop_title.'</option>';
												}else{
												 $f_drop_output.='<option value="'.$faculty_id1.'">'.$f_drop_title.'</option>';
												}

											}

										}

		return $f_drop_output;
}
function get_faculty_by_id($con, $faculty_id){
	$select="SELECT * FROM faculties WHERE faculty_id ='$faculty_id'";
							$sql_select=mysqli_query($con,$select);
							$num_rows=mysqli_num_rows($sql_select);
							if($num_rows > 0){

								while($rows=mysqli_fetch_array($sql_select)){

									$faculty_titles=$rows['title'];




								}

							}

return @$faculty_titles;
}
//end faculty functions

//start department functions
function get_all_department($con){
				$select="SELECT * FROM departments WHERE department_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$department_id=$row['department_id'];
												$department_title=$row['title'];
												$department_status=$row['department_status'];

												 $department_output.='<option value="'.$department_id.'">'.$department_title.'</option>';

											}

										}

		return $department_output;
}
function get_all_departmenta_drop($con,$departmnt_id){
				$select="SELECT * FROM departments WHERE department_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$department_id1=$row['department_id'];
												$d_drop_title=$row['title'];
												$department_status=$row['department_status'];
												if($departmnt_id == $department_id1)
												{
												 $$d_drop_output.='<option value="'.$department_id1.'" selected>'.$d_drop_title.'</option>';
												}else{
												 $$d_drop_output.='<option value="'.$department_id1.'">'.$d_drop_title.'</option>';
												}

											}

										}

		return $$d_drop_output;
}
function get_department_by_id($con,$department_id){
				$select="SELECT * FROM departments WHERE department_id ='$department_id'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){

												$dept_title=$row['title'];




											}

										}

		return $dept_title;
}
//end department functions

//start programme functions
function get_all_programme_drop($con,$programm_id){
				$select="SELECT * FROM programmes WHERE programme_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$programme_id1=$row['programme_id'];
												$p_drop_title=$row['title'];
												$programme_status=$row['programme_status'];
												if($programm_id == $programme_id1)
												{
												 $$p_drop_output.='<option value="'.$programme_id1.'" selected>'.$p_drop_title.'</option>';
												}else{
												 $$p_drop_output.='<option value="'.$programme_id1.'">'.$p_drop_title.'</option>';
												}

											}

										}

		return $$p_drop_output;
}
function get_all_programmes($con){
				$select="SELECT * FROM programmes WHERE programme_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$programme_id=$row['programme_id'];
												$programme_title=$row['title'];
												$programme_status=$row['programme_status'];

												 $$programme_output.='<option value="'.$programme_id.'">'.$programme_title.'</option>';

											}

										}

		return $$programme_output;
}


function get_programmes_by_id($con,$programme_id){
				$select="SELECT * FROM programmes WHERE id ='$programme_id'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){

												$programme=$row['title'];




											}

										}

		return @$programme;
}

function get_programmes_by_id_duap($con,$programme_id){
				$select="SELECT * FROM programmes WHERE id ='$programme_id'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){

												$programme=$row['title'];




											}

										}

		return @$programme;
}
//end programme functions


//function select gender
function select_gender($gd)
{

		if ($gd == 'M' OR $gd=='male')
		{
			$output = '<option value="0" > -- Please Select --</option>';
			$output .= '<option value="M" selected > Male</option>';
			$output .= '<option value="F" > Female</option>';
			$output .= '<option value="F" > Others</option>';


		}
		else if ($gd == 'F' OR $gd=='female')
		{
			$output = '<option value="0" > -- Please Select --</option>';
			$output .= '<option value="M"> Male</option>';
			$output .= '<option value="F" selected > Female</option>';
			$output .= '<option value="F" > Others</option>';


		}
		else
		{

			$output = '<option value="0"  selected  > -- Please Select --</option>';
			$output .= '<option value="M"> Male</option>';
			$output .= '<option value="F"> Female</option>';
			$output .= '<option value="F" > Others</option>';
		}

	return $output;

}
//end of select gender


//start course functions
function get_all_course($con){
				$select="SELECT * FROM courses WHERE course_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$course_id=$row['course_id'];
												$course_title=$row['title'];
												$course_status=$row['course_status'];

												 $output.='<option value="'.$course_id.'">'.$course_title.'</option>';

											}

										}

		return $output;
}
function get_course_id($con,$course_id){
				$select="SELECT * FROM courses WHERE course_id ='$course_id'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){

												$course_title=$row['title'];




											}

										}

		return $course_title;
}
function get_all_course_drop($con,$courses_id){
				$select="SELECT * FROM courses WHERE course_status ='1'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){
												$course_id1=$row['course_id'];
												$title=$row['title'];
												$course_status=$row['course_status'];
												if($courses_id == $course_id1 )
												{
												 $output.='<option value="'.$course_id1.'" selected>'.$title.'</option>';
												}else{
												 $output.='<option value="'.$course_id1.'">'.$title.'</option>';
												}

											}

										}

		return $output;
}
//end course functions

function get_admin_role_by_id($con,$admin_role_id){
				$select="SELECT * FROM roles WHERE role_id ='$admin_role_id'";
										$sql_select=mysqli_query($con,$select);
										$num_rows=mysqli_num_rows($sql_select);
										if($num_rows > 0){

											while($row=mysqli_fetch_array($sql_select)){

												$admin_title=$row['role_title'];




											}

										}

		return $admin_title;
}

function get_all_campus($con){
			$select="SELECT * FROM hostel_campuses WHERE status ='1'";
									$sql_select=mysqli_query($con,$select);
									$num_rows=mysqli_num_rows($sql_select);
									if($num_rows > 0){

										while($row=mysqli_fetch_array($sql_select)){
											$campus_id=$row['id'];
											$campus_title=$row['title'];
											$campus_status=$row['status'];

											 $output.='<option value="'.$campus_id.'">'.$campus_title.'</option>';

										}

									}

	return $output;
}

function get_all_block($con){
			$select="SELECT * FROM hostel_categories WHERE reserved ='1'";
									$sql_select=mysqli_query($con,$select);
									$num_rows=mysqli_num_rows($sql_select);
									if($num_rows > 0){

										while($row=mysqli_fetch_array($sql_select)){
											$block_id=$row['id'];
											$block_title=$row['title'];
											$block_status=$row['status'];

											 $output.='<option value="'.$block_id.'">'.$block_title.'</option>';

										}

									}

	return $output;
}

function get_all_rooms($con){
			$select="SELECT * FROM hostel_rooms WHERE reserved ='1'";
									$sql_select=mysqli_query($con,$select);
									$num_rows=mysqli_num_rows($sql_select);
									if($num_rows > 0){

										while($row=mysqli_fetch_array($sql_select)){
											$room_id=$row['id'];
											$room_title=$row['title'];
											$room_status=$row['status'];

											 $output.='<option value="'.$block_id.'">'.$room_title.'</option>';

										}

									}

	return $output;
}

//function get total applicants
function get_all_total_applicants_prence($con)
{
	$q = "SELECT COUNT(*) FROM students_prence";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_nce($con)
{
	$q = "SELECT COUNT(*) FROM students_nce";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_abu($con)
{
	$q = "SELECT COUNT(*) FROM students_nce";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_udus($con)
{
	$q = "SELECT COUNT(*) FROM students_udus";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_summer($con)
{
	$q = "SELECT COUNT(*) FROM summer_students";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_lvsp($con)
{
	$q = "SELECT COUNT(*) FROM students_lvsp";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_qualified($con)
{
	$q = "SELECT COUNT(*) FROM students_nce where (level='100' OR level='400')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_qualified_male($con)
{
	$q = "SELECT COUNT(*) FROM students_nce where (level='100' OR level='400') AND (gender='male' or gender='m')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_qualified_female($con)
{
	$q = "SELECT COUNT(*) FROM students_nce where (level='100' OR level='400') AND (gender='female' or gender='f')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_not_qualified($con)
{
	$q = "SELECT COUNT(*) FROM students_nce where (level='200' OR level='300')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_not_qualified_female($con)
{
	$q = "SELECT COUNT(*) FROM students_nce where (level='200' OR level='300') AND (gender='female' or gender='f')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_applicants_not_qualified_male($con)
{
	$q = "SELECT COUNT(*) FROM students_nce where (level='200' OR level='300') AND (gender='male' or gender='m')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}


//function get total applicants
function get_all_total_allocation($con, $type)
{
	$q = "SELECT COUNT(*) FROM hostel_allocation WHERE type_id ='$type' ";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_allocations($con)
{
	$q = "SELECT COUNT(*) FROM hostel_allocation ";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_paid($con)
{
	$q = "SELECT COUNT(*) FROM hostel_fee_payments ";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_allocation_male($con)
{
	$q = "SELECT COUNT(*) FROM hostel_allocation, students_nce WHERE students_nce.id = hostel_allocation.student_id AND (students_nce.gender= 'm' OR students_nce.gender='male')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_all_total_allocation_female($con)
{
	$q = "SELECT COUNT(*) FROM hostel_allocation, students_nce WHERE students_nce.id = hostel_allocation.student_id AND (students_nce.gender= 'f' OR students_nce.gender='female')";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_total_applicants($con, $type)
{
	$q = "SELECT COUNT(*) FROM hostel_fee_payments WHERE programme_type_id ='$type' ";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//get list of the programmes
function  get_programme_list($con, $pt, $type)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE real_=0 ORDER BY title ");


		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=listing_programme&a='.sha1('fucku').'&pt='.$type.'&p='.$row['id'].'&sid='.$row['school_id'].'" class="btn btn-success  btn-lg" target="_blank" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_applicants($con, $type,$row['id']).'</span>'.'</a>';
		}


}

//get list of the programmes
function  get_programme_list_duap($con, $conn_1, $pt,$type)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE real_=0 ORDER BY title ");


		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=listing_programme&a='.sha1('fucku').'&pt='.$type.'&p='.$row['id'].'&sid='.$row['school_id'].'" class="btn btn-success  btn-lg" target="_blank" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_applicants($conn_1, $type,$row['id']).'</span>'.'</a>';
		}


}

//get list of the programmes
function  get_programme_lists($con, $pt,$type)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE real_=0 ORDER BY title ");


		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=listing_programmes&a='.sha1('fucku').'&pt='.$type.'&p='.$row['id'].'&sid='.$row['type_id'].'" class="btn btn-success  btn-lg" target="_blank" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_applicantss($con, $type,$row['id']).'</span>'.'</a>';
		}


}

//get list of the programmes
function  get_programme_lists_duap($con, $conn_1, $pt,$type)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE real_=0 ORDER BY title ");


		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=listing_programmes&a='.sha1('fucku').'&pt='.$type.'&p='.$row['id'].'&sid='.$row['type_id'].'" class="btn btn-success  btn-lg" target="_blank" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_applicantss_duap($conn_1, $type,$row['id']).'</span>'.'</a>';
		}


}

//function get total applicants in a programme
function get_total_prog_type_programme_applicants($con, $type, $id)
{
	$q = "SELECT COUNT(id) FROM hostel_fee_payments  WHERE programme_type_id = '$type' AND programme_id = '$id'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants in a programme
function get_total_prog_type_programme_applicantss($con, $type, $pid)
{
	$q = "SELECT COUNT(id) FROM hostel_fee_payments  WHERE programme_type_id = '$type' AND programme_id = '$pid'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants in a programme
function get_total_prog_type_programme_applicantss_duap($con, $type, $pid)
{
	$q = "SELECT COUNT(id) FROM hostel_fee_payments  WHERE programme_type_id = '$type' AND programme_id = '$pid'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}


function view_applicants_list_per_programmes($con, $pt,$p) // pt programm type , p programme
{
	$select="SELECT students_nce.id, students_nce.programme_type_applied_for,
	students_nce.department_id, students_nce.programme_id,
	students_nce.application_number, students_nce.state_id,
	students_nce.lga_id, students_nce.first_name, students_nce.middle_name,
	students_nce.other_names, students_nce.phone_no, students_nce.gender,  students_nce.email,
	DATE_FORMAT(students_nce.date_added, '%M %d, %Y %l:%i:%p') as date_added,
	hostel_fee_payments.student_id FROM  students_nce, hostel_fee_payments
	WHERE   students_nce.programme_type_applied_for = '$pt' AND
	students_nce.programme_id = '$p' AND students_nce.id = hostel_fee_payments.student_id
	ORDER BY students_nce.number ASC";
	$sql_select = mysqli_query($con,$select);
	$num_rows=mysqli_num_rows($sql_select);
	if($num_rows > 0){
		$sn=1;

		echo '<table class="table table-bordered" id="table">
				<thead>
				<tr class="filters">
						<th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


				<th > NMAE </th>

				<th >MATRIC NUMBER </th>

				<th> PROGRAMME </th>

				<th > PHONE NUMBER </th>
				<th> GENDER </th>

				<th > EMAIL </th>

<th>Created At</th>
						<th>Status</th>
						<th>Actions</th>
				</tr>
				</thead>
				<tbody>';
		while($row=mysqli_fetch_array($sql_select)){
			$f_name= $row['first_name'];
			$m_name= $row['middle_name'];
			$l_name= $row['last_name'];
			$name = $l_name.' '.$m_name.' '.$f_name;
			$student_id=$row['student_id'];
			$matric_number=$row['matric_number'];
			$programme_id=$row['programme_applied_for'];
			$email=$row['email'];
			$gender=$row['gender'];
			$phone_contacts=$row['phone_no'];
			$date_added=$row['date_added'];
			$faculty_status=$row['department_applied_for'];
			$status='Paid';

			echo $tr = '<tr>
						<td><center>'.$sn.'</center></td>
						<td>'.$name.'</td>
						<td>'.$matric_number.'</td>
						<td>'.get_programmes_by_id($con,$programme_id).'</td>
						<td>'.$phone_contacts.'</td>
						<td>'.$gender.'</td>
						<td>'.$email.'</td>
						<td>'.$date_added.'</td>
						<td>'.$status.'</td>



						<td><a href="#" class="edit_faculty" id="'.$student_id.'"><i
								class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Faculty"></i></a>
								<a
								href="#"
								id="'.$student_id.'"
								data-toggle="modal"

								class="delete_faculty"
								><i
								class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
						</a></td>

					</tr>

					</tbody>
			</table>';
					$sn++;

		}
	}else{
		echo
				   '<div class="alert alert-danger alert-dismissable">
					<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
					<img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
				   </div>';
	}
}


function view_applicants_list_per_programmes_student($con, $pt,$p) // pt programm type , p programme
{
	$select="SELECT id, programme_type_applied_for, department_applied_for, programme_applied_for,
						application_number, state_id, lga_id, first_name, middle_name, last_name, phone_no, gender, email,
						DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added, matric_number FROM  students_nce WHERE
						programme_type_applied_for = '$pt' AND programme_applied_for = '$p'

					ORDER BY matric_number ASC";
	$sql_select = mysqli_query($con,$select);
	$num_rows=mysqli_num_rows($sql_select);
	if($num_rows > 0){
		$sn=1;

		echo '<table class="table table-bordered" id="table">
				<thead>
				<tr class="filters">
						<th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


				<th > NMAE </th>

				<th >MATRIC NUMBER </th>

				<th> PROGRAMME </th>

				<th > PHONE NUMBER </th>
				<th> GENDER </th>

				<th > EMAIL </th>

<th>Created At</th>
						<th>Status</th>
						<th>Actions</th>
				</tr>
				</thead>
				<tbody>';
		while($row=mysqli_fetch_array($sql_select)){
			$f_name= $row['first_name'];
			$m_name= $row['middle_name'];
			$l_name= $row['last_name'];
			$name = $l_name.' '.$m_name.' '.$f_name;
			$student_id=$row['id'];
			$matric_number=$row['matric_number'];
			$programme_id=$row['programme_applied_for'];
			$email=$row['email'];
			$gender=$row['gender'];
			$phone_contacts=$row['phone_no'];
			$date_added=$row['date_added'];
			$faculty_status=$row['department_applied_for'];
			$status='Paid';

			echo $tr = '<tr>
						<td><center>'.$sn.'</center></td>
						<td>'.$name.'</td>
						<td>'.$matric_number.'</td>
						<td>'.get_programmes_by_id($con,$programme_id).'</td>
						<td>'.$phone_contacts.'</td>
						<td>'.$gender.'</td>
						<td>'.$email.'</td>
						<td>'.$date_added.'</td>
						<td>'.$status.'</td>



						<td><a href="#" class="edit_faculty" id="'.$student_id.'"><i
								class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Faculty"></i></a>
								<a
								href="#"
								id="'.$student_id.'"
								data-toggle="modal"

								class="delete_faculty"
								><i
								class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
						</a></td>

					</tr>

					</tbody>
			</table>';
					$sn++;

		}
	}else{
		echo
				   '<div class="alert alert-danger alert-dismissable">
					<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
					<img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
				   </div>';
	}
}
//function get total applicants
function get_all_total_applicants_admission($con)
{
	$q = "SELECT COUNT(*) FROM applicants";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//function get total applicants
function get_total_applicants_admission($con)
{
	$q = "SELECT COUNT(*) FROM applicants_fee_payments";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//get list of the programmes
function  get_programme_list_admission($con, $pt)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE school_id = '$pt' AND programme_id != 8 AND programme_id != 9 ORDER BY title");


	while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=listing_programme_admission&a='.sha1('fucku').'&pt='.$row['school_id'].'&p='.$row['programme_id'].'" class="btn btn-success  btn-lg" target="_blank" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_applicants_admission($con, $pt, $row['programme_id']).'</span>'.'</a>';
		}


}



//function get total applicants in a programme
function get_total_prog_type_programme_applicants_admission($con, $pt, $id)
{
	$q = "SELECT COUNT(applicant_payment_id) FROM applicants_fee_payments  WHERE programme_type_id = '$pt' AND programme_id = '$id'";
	$r = mysqli_query($con, $q);
	$rowss = mysqli_fetch_array($r,MYSQLI_NUM);

	return $rowss[0];

}


function view_applicants_list_per_programmes_admission($con, $pt,$p) // pt programm type , p programme
{
	$select="SELECT applicants.applicant_id, applicants.school_applied_for, applicants.department_applied_for, applicants.programme_applied_for, applicants.application_number,
						applicants.state_id, applicants.lga_id, applicants.first_name, applicants.middle_name, applicants.last_name, applicants.phone_no, applicants.gender,  applicants.email,
						DATE_FORMAT(applicants.date_added, '%M %d, %Y %l:%i:%p') as date_added, applicants.admission_status,
					 applicants_fee_payments.applicant_id
					 FROM  applicants, applicants_fee_payments

					 WHERE   applicants.school_applied_for = '$pt' AND applicants.programme_applied_for = '$p' AND applicants.applicant_id = applicants_fee_payments.applicant_id

					ORDER BY applicants.application_number ASC";
	$sql_select = mysqli_query($con,$select);
	$num_rows=mysqli_num_rows($sql_select);
	if($num_rows > 0){
		$sn=1;

		echo '<table class="table table-bordered" id="table">
				<thead>
				<tr class="filters">
						<th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


				<th > NMAE </th>

				<th >APPLICATION NUMBER </th>

				<th> PROGRAMME </th>

				<th > PHONE NUMBER </th>
				<th> GENDER </th>

				<th > EMAIL </th>

<th>Created At</th>
						<th>Status</th>
						<th>Actions</th>
				</tr>
				</thead>
				<tbody>';
		while($row=mysqli_fetch_array($sql_select)){
			$f_name= $row['first_name'];
			$m_name= $row['middle_name'];
			$l_name= $row['last_name'];
			$name = $l_name.' '.$m_name.' '.$f_name;
			$student_id=$row['student_id'];
			$matric_number=$row['application_number'];
			$programme_id=$row['programme_applied_for'];
			$email=$row['email'];
			$gender=$row['gender'];
			$phone_contacts=$row['phone_no'];
			$date_added=$row['date_added'];
			$faculty_status=$row['department_applied_for'];
			$admission_status = $row['admission_status'];
			if($admission_status=='1'){
					$status='Admitted';
			}else{
					$status='Not Admitted';
			}


			echo $tr = '<tr>
						<td><center>'.$sn.'</center></td>
						<td>'.$name.'</td>
						<td>'.$matric_number.'</td>
						<td>'.get_programmes_by_id($con,$programme_id).'</td>
						<td>'.$phone_contacts.'</td>
						<td>'.$gender.'</td>
						<td>'.$email.'</td>
						<td>'.$date_added.'</td>
						<td>'.$status.'</td>



						<td><a href="#" class="edit_faculty" id="'.$student_id.'"><i
								class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Faculty"></i></a>
								<a
								href="#"
								id="'.$student_id.'"
								data-toggle="modal"

								class="delete_faculty"
								><i
								class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
						</a></td>

					</tr>

					</tbody>
			</table>';
					$sn++;

		}
	}else{
		echo
				   '<div class="alert alert-danger alert-dismissable">
					<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
					<img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
				   </div>';
	}
}


//function get total admitted applicants
function get_total_admitted_applicants_batch_1($con)
{
	$q = "SELECT COUNT(applicant_id) FROM applicants WHERE  admission_status = '1' AND admission_batch = '1'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}


//function get total admitted applicants
function get_total_admitted_applicants_batch_2($con)
{
	$q = "SELECT COUNT(applicant_id) FROM applicants WHERE  admission_status = '1' AND admission_batch = '2'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}


//function get total admitted applicants
function get_total_admitted_applicants_batch_3($con)
{
	$q = "SELECT COUNT(applicant_id) FROM applicants WHERE  admission_status = '1' AND admission_batch = '3'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//get list of the programmes admitted candidate
function  get_programme_list_admitted_applicants($con, $pt)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE school_id = '$pt' ORDER BY title");


		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=listing_programme_admission&a='.sha1('fucku').'&pt='.$row['school_id'].'&p='.$row['programme_id'].'"
			class="btn btn-success  btn-lg" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_admitted_applicants($con, $row['school_id'],$row['programme_id'], $admitted = '1').'</span> / <span class="badge">'.get_total_prog_type_programme_applicants($con, $row['school_id'],$row['programme_id'] ).'</span> '.'</a>';
		}



}

//function get total applicants admitted in a programme
function get_total_prog_type_programme_admitted_applicants($con, $pt, $id, $admitted)
{
	$q = "SELECT COUNT(applicant_id) FROM applicants  WHERE school_id = '$pt' AND programme_id = '$id' AND admission_status = '$admitted'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return $row[0];

}

//get course name passed by id of the course
function get_programme_title($con, $id)
{
	$result = mysqli_query($con, "SELECT title FROM programmes WHERE programme_id = '$id'");
		$row = mysqli_fetch_assoc($result);
		$title = $row['title'];

	return $title;
}

//function that gets state title
function  get_state_title($con, $id)
{
	$result = mysqli_query($con, "SELECT * FROM states WHERE state_id = '$id'");
		$row = mysqli_fetch_assoc($result);
		$title = $row['name'];

	return $title;

}

//function that gets lga title
function  get_lga_title($con, $id)
{
	$result = mysqli_query($con, "SELECT * FROM lga WHERE local_id = '$id'");
		$row = mysqli_fetch_assoc($result);
		$title = $row['local_name'];

	return $title;

}


//function get applicant image by passing id alone
function get_applicant_image($con, $id)
{
	$result = mysqli_query($con, "SELECT image FROM applicants WHERE applicant_id = '$id'");
	$row = mysqli_fetch_assoc($result);
	$image = $row['image'];




	if($image != '')
	{//show table



			$output = '<img class="img-responsive img-rounded img-thumbnail center-block" src="../../students_nce/uploads'.$row['image'].'" style="height:100px ;width:80px"    />';


	}
	else
	{
		$output = '<label class="label label-danger">NO IMAGE</label>';
	}


	return $output;




}//end of function that shows candidate image

//function to get total sum of money paid for nce of courses a student carried per semester
function get_total_amount_paid_per_session($conn_1, $pt,$session)
{
	$result = mysqli_query($conn_1, "SELECT SUM(amount - 488) AS summed_up FROM hostel_fee_payments WHERE  session_id = '$session' AND programme_type_id='$pt' ");
	$row = mysqli_fetch_assoc($result);
	$summed_up = $row['summed_up'];

	return $summed_up;
}


//Function to fetch current session
	function get_current_session($con, $id)
	{
		$result = mysqli_query($con, "SELECT * FROM sessions WHERE current_session = '$id'");
		$row = mysqli_fetch_assoc($result);
		$id = $row['id'];

	return $id;
	}
	
	//Function to fetch  session
	function get_session_title($con, $id)
	{
		$result = mysqli_query($con, "SELECT title FROM sessions WHERE id = '$id'");
		$row = mysqli_fetch_assoc($result);
		$title = $row['title'];

	    return $title;
	}

	//function dat get user application number
		function get_applicant_matric_number($con, $user_id)
		{
		$q = "SELECT number FROM students_nce WHERE id = '$user_id'";
		$r = mysqli_query($con, $q);
		$row = mysqli_fetch_assoc($r);

		return $row['number'];


		}

		//function dat get user application number
			function get_applicant_matric_number_prence($con, $user_id)
			{
			$q = "SELECT number FROM students_prence WHERE id = '$user_id'";
			$r = mysqli_query($con, $q);
			$row = mysqli_fetch_assoc($r);

			return $row['number'];


			}

			//function dat get user application number
				function get_applicant_matric_number_abu($con, $user_id)
				{
				$q = "SELECT number FROM students_nce WHERE id = '$user_id'";
				$r = mysqli_query($con, $q);
				$row = mysqli_fetch_assoc($r);

				return $row['number'];


				}

				//function dat get user application number
					function get_applicant_matric_number_udus($con, $user_id)
					{
					$q = "SELECT number FROM students_udus WHERE id = '$user_id'";
					$r = mysqli_query($con, $q);
					$row = mysqli_fetch_assoc($r);

					return $row['number'];


					}

					//function dat get user application number
						function get_applicant_matric_number_summer($con, $user_id)
						{
						$q = "SELECT number FROM summer_students WHERE id = '$user_id'";
						$r = mysqli_query($con, $q);
						$row = mysqli_fetch_assoc($r);

						return $row['number'];


						}
						//function dat get user application number
							function get_applicant_matric_number_lvsp($con, $user_id)
							{
							$q = "SELECT number FROM summer_students WHERE id = '$user_id'";
							$r = mysqli_query($con, $q);
							$row = mysqli_fetch_assoc($r);

							return $row['number'];


							}

		//Functions to fetch student Full name
	function get_student_fullname($con, $id)
	{
		$result = mysqli_query($con, "SELECT * FROM students_nce WHERE id = '$id'");
		$row = mysqli_fetch_assoc($result);
		$first_name = $row['first_name'];
		$middle_name = $row['middle_name'];
		$last_name = $row['other_names'];

		$user_fullname = $first_name . " " . $middle_name ." ".$last_name;

	  return $user_fullname;
	}

	//Functions to fetch student Full name
	function get_student_fullname_prence($con, $id)
	{
	$result = mysqli_query($con, "SELECT * FROM students_prence WHERE id = '$id'");
	$row = mysqli_fetch_assoc($result);
	$first_name = $row['first_name'];
	$middle_name = $row['middle_name'];
	$last_name = $row['other_names'];

	$user_fullname = $first_name . " " . $middle_name ." ".$last_name;

	return $user_fullname;
	}

	//Functions to fetch student Full name
function get_student_fullname_abu($con, $id)
{
	$result = mysqli_query($con, "SELECT * FROM students_nce WHERE id = '$id'");
	$row = mysqli_fetch_assoc($result);
	$first_name = $row['first_name'];
	$middle_name = $row['middle_name'];
	$last_name = $row['other_names'];

	$user_fullname = $first_name . " " . $middle_name ." ".$last_name;

	return $user_fullname;
}

//Functions to fetch student Full name
function get_student_fullname_udus($con, $id)
{
$result = mysqli_query($con, "SELECT * FROM students_udus WHERE id = '$id'");
$row = mysqli_fetch_assoc($result);
$first_name = $row['first_name'];
$middle_name = $row['middle_name'];
$last_name = $row['other_names'];

$user_fullname = $first_name . " " . $middle_name ." ".$last_name;

return $user_fullname;
}

//Functions to fetch student Full name
function get_student_fullname_summer($con, $id)
{
$result = mysqli_query($con, "SELECT * FROM summer_students WHERE id = '$id'");
$row = mysqli_fetch_assoc($result);
$first_name = $row['first_name'];
$middle_name = $row['middle_name'];
$last_name = $row['other_names'];

$user_fullname = $first_name . " " . $middle_name ." ".$last_name;

return $user_fullname;
}

//Functions to fetch student Full name
function get_student_fullname_lvsp($con, $id)
{
$result = mysqli_query($con, "SELECT * FROM summer_students WHERE id = '$id'");
$row = mysqli_fetch_assoc($result);
$first_name = $row['first_name'];
$middle_name = $row['middle_name'];
$last_name = $row['other_names'];

$user_fullname = $first_name . " " . $middle_name ." ".$last_name;

return $user_fullname;
}

	//function transaction status
		  function transaction_status($id)
		  {
			  if($id == '1')
			  {
				  return '<label class="label label-success"> SUCCESSFUL </label>';
			  }
			  else
			  {
				  return  '<label class="label label-success" style="background-color:red"> PENDING </label>';
			  }
		  }


//function view transaction log
	function view_remita_transaction_log($con, $trans_type , $trans_for, $type_id )
	{

		$sess = get_current_session($con, 1);

		//query the database
		$query = "SELECT `id`, `invoice_id`, `transaction_type`, `user_id`, `transaction_for`, `payment_method`,
		`payment_status`, `response_code`, `response_description`,`transaction_id`, `transaction_reference`,
		 `title`, `description`, `amount`, DATE_FORMAT(date_added, '%b %e, %Y /  %l:%i:%p') as date_added,
		 DATE_FORMAT(transaction_date, '%b %e, %Y /  %l:%i:%p') as transaction_date

		 FROM `hostel_remita_webpay_transaction_log`

		 WHERE transaction_type = '$trans_type' AND	 transaction_for = '$trans_for' AND type_id='$type_id'
		 ORDER BY id DESC"; //AND session = $sess
	   $result = mysqli_query($con, $query);



		if(mysqli_num_rows($result) > 0)
		{//show table


			$output =
			'<div class="table-responsive table-responisve-lg table-responsive-xl">
	        <table class="table table-bordered" id="table">
			  <thead>

						   <th>MATRIC No.</th>
						  <th>Invoice #</th>
						  <th>Fullname</th>
						  <th>RRR</th>
						  <th>Transaction Ref.</th>
						  <th>Title</th>
						  <th>Amount- (N)</th>
						  <th>Transaction Response</th>
						  <th>Transaction Date / Time</th>
						  <th>Status</th>
						  <th>Action</th>


			  </thead>

			 <!-- <tfoot>

			  </tfoot>-->

			  <tbody>';


			while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
			{
			   // $int_amount = $row['amount'] * 100;


				$output .= "<tr>";
					$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_applicant_matric_number($con, $row['user_id'])."</td>"; //group belong to admin or user
					$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['invoice_id']."</td>"; //group belong to admin or user
					$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_student_fullname($con, $row['user_id'])."</td>";

				$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_id']."</td>";
				$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_reference']."</td>";
				$output .= "<td>".$row['title']."</td>";
				$output .= "<td>".number_format($row['amount'],2)."</td>";

				$output .= "<td>".$row['response_description'] ."(".$row['response_code'].")"."</td>";

				$output .= "<td>".$row['date_added']."</td>";


				$output .= "<td>".transaction_status($row['payment_status'])."</td>";

				if($row['payment_status'] != '1')
				{
					//app fees
					if($trans_for == 5 ){
						$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';
					//accept. fees
				}elseif($trans_for == 5){
						$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';

					}


				}
				else
				{
				   $output .= "<td></td>";

				}

				$output .= "</tr>";

			}
		}
		else
		{//show the msg

			  $output =
					 '<div class="alert alert-danger alert-dismissable">
					  <button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
					  <img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
					 </div>';


		}



		$output .=
		'</tbody>
		</table>
		</div>';





		return $output;






	}//end of view transaction log


	//function view transaction log
		function view_remita_transaction_log_prence($con, $trans_type , $trans_for, $type_id )
		{

			$sess = get_current_session($con, 1);

			//query the database
			$query = "SELECT `id`, `invoice_id`, `transaction_type`, `user_id`, `transaction_for`, `payment_method`,
			`payment_status`, `response_code`, `response_description`,`transaction_id`, `transaction_reference`,
			 `title`, `description`, `amount`, DATE_FORMAT(date_added, '%b %e, %Y /  %l:%i:%p') as date_added,
			 DATE_FORMAT(transaction_date, '%b %e, %Y /  %l:%i:%p') as transaction_date

			 FROM `hostel_remita_webpay_transaction_log`

			 WHERE transaction_type = '$trans_type' AND	 transaction_for = '$trans_for' AND type_id='$type_id'
			 ORDER BY id DESC"; //AND session = $sess
		   $result = mysqli_query($con, $query);



			if(mysqli_num_rows($result) > 0)
			{//show table


				$output =
				'<div class="table-responsive table-responisve-lg table-responsive-xl">
		        <table class="table table-bordered" id="table">
				  <thead>

							   <th>MATRIC No.</th>
							  <th>Invoice #</th>
							  <th>Fullname</th>
							  <th>RRR</th>
							  <th>Transaction Ref.</th>
							  <th>Title</th>
							  <th>Amount- (N)</th>
							  <th>Transaction Response</th>
							  <th>Transaction Date / Time</th>
							  <th>Status</th>
							  <th>Action</th>


				  </thead>

				 <!-- <tfoot>

				  </tfoot>-->

				  <tbody>';


				while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
				{
				   // $int_amount = $row['amount'] * 100;


					$output .= "<tr>";
						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_applicant_matric_number_prence($con, $row['user_id'])."</td>"; //group belong to admin or user
						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['invoice_id']."</td>"; //group belong to admin or user
						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_student_fullname_prence($con, $row['user_id'])."</td>";

					$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_id']."</td>";
					$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_reference']."</td>";
					$output .= "<td>".$row['title']."</td>";
					$output .= "<td>".number_format($row['amount'],2)."</td>";

					$output .= "<td>".$row['response_description'] ."(".$row['response_code'].")"."</td>";

					$output .= "<td>".$row['date_added']."</td>";


					$output .= "<td>".transaction_status($row['payment_status'])."</td>";

					if($row['payment_status'] != '1')
					{
						//app fees
						if($trans_for == 5 ){
							$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';
						//accept. fees
					}elseif($trans_for == 5){
							$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';

						}


					}
					else
					{
					   $output .= "<td></td>";

					}

					$output .= "</tr>";

				}
			}
			else
			{//show the msg

				  $output =
						 '<div class="alert alert-danger alert-dismissable">
						  <button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
						  <img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
						 </div>';


			}



			$output .=
			'</tbody>
			</table>
			</div>';





			return $output;






		}//end of view transaction log


		//function view transaction log
			function view_remita_transaction_log_summer($con, $trans_type , $trans_for, $type_id )
			{

				$sess = get_current_session($con, 1);

				//query the database
				$query = "SELECT `id`, `invoice_id`, `transaction_type`, `user_id`, `transaction_for`, `payment_method`,
				`payment_status`, `response_code`, `response_description`,`transaction_id`, `transaction_reference`,
				 `title`, `description`, `amount`, DATE_FORMAT(date_added, '%b %e, %Y /  %l:%i:%p') as date_added,
				 DATE_FORMAT(transaction_date, '%b %e, %Y /  %l:%i:%p') as transaction_date

				 FROM `hostel_remita_webpay_transaction_log`

				 WHERE transaction_type = '$trans_type' AND	 transaction_for = '$trans_for' AND type_id='$type_id'
				 ORDER BY id DESC"; //AND session = $sess
			   $result = mysqli_query($con, $query);



				if(mysqli_num_rows($result) > 0)
				{//show table


					$output =
					'<div class="table-responsive table-responisve-lg table-responsive-xl">
			        <table class="table table-bordered" id="table">
					  <thead>

								   <th>MATRIC No.</th>
								  <th>Invoice #</th>
								  <th>Fullname</th>
								  <th>RRR</th>
								  <th>Transaction Ref.</th>
								  <th>Title</th>
								  <th>Amount- (N)</th>
								  <th>Transaction Response</th>
								  <th>Transaction Date / Time</th>
								  <th>Status</th>
								  <th>Action</th>


					  </thead>

					 <!-- <tfoot>

					  </tfoot>-->

					  <tbody>';


					while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
					{
					   // $int_amount = $row['amount'] * 100;


						$output .= "<tr>";
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_applicant_matric_number_summer($con, $row['user_id'])."</td>"; //group belong to admin or user
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['invoice_id']."</td>"; //group belong to admin or user
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_student_fullname_summer($con, $row['user_id'])."</td>";

						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_id']."</td>";
						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_reference']."</td>";
						$output .= "<td>".$row['title']."</td>";
						$output .= "<td>".number_format($row['amount'],2)."</td>";

						$output .= "<td>".$row['response_description'] ."(".$row['response_code'].")"."</td>";

						$output .= "<td>".$row['date_added']."</td>";


						$output .= "<td>".transaction_status($row['payment_status'])."</td>";

						if($row['payment_status'] != '1')
						{
							//app fees
							if($trans_for == 5 ){
								$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';
							//accept. fees
						}elseif($trans_for == 5){
								$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';

							}


						}
						else
						{
						   $output .= "<td></td>";

						}

						$output .= "</tr>";

					}
				}
				else
				{//show the msg

					  $output =
							 '<div class="alert alert-danger alert-dismissable">
							  <button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
							  <img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
							 </div>';


				}



				$output .=
				'</tbody>
				</table>
				</div>';





				return $output;






			}//end of view transaction log

			//function view transaction log
				function view_remita_transaction_log_lvsp($con, $trans_type , $trans_for, $type_id )
				{

					$sess = get_current_session($con, 1);

					//query the database
					$query = "SELECT `id`, `invoice_id`, `transaction_type`, `user_id`, `transaction_for`, `payment_method`,
					`payment_status`, `response_code`, `response_description`,`transaction_id`, `transaction_reference`,
					 `title`, `description`, `amount`, DATE_FORMAT(date_added, '%b %e, %Y /  %l:%i:%p') as date_added,
					 DATE_FORMAT(transaction_date, '%b %e, %Y /  %l:%i:%p') as transaction_date

					 FROM `hostel_remita_webpay_transaction_log`

					 WHERE transaction_type = '$trans_type' AND	 transaction_for = '$trans_for' AND type_id='$type_id'
					 ORDER BY id DESC"; //AND session = $sess
					 $result = mysqli_query($con, $query);



					if(mysqli_num_rows($result) > 0)
					{//show table


						$output =
						'<div class="table-responsive table-responisve-lg table-responsive-xl">
								<table class="table table-bordered" id="table">
							<thead>

										 <th>MATRIC No.</th>
										<th>Invoice #</th>
										<th>Fullname</th>
										<th>RRR</th>
										<th>Transaction Ref.</th>
										<th>Title</th>
										<th>Amount- (N)</th>
										<th>Transaction Response</th>
										<th>Transaction Date / Time</th>
										<th>Status</th>
										<th>Action</th>


							</thead>

						 <!-- <tfoot>

							</tfoot>-->

							<tbody>';


						while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
						{
							 // $int_amount = $row['amount'] * 100;


							$output .= "<tr>";
								$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_applicant_matric_number_lvsp($con, $row['user_id'])."</td>"; //group belong to admin or user
								$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['invoice_id']."</td>"; //group belong to admin or user
								$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_student_fullname_lvsp($con, $row['user_id'])."</td>";

							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_id']."</td>";
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_reference']."</td>";
							$output .= "<td>".$row['title']."</td>";
							$output .= "<td>".number_format($row['amount'],2)."</td>";

							$output .= "<td>".$row['response_description'] ."(".$row['response_code'].")"."</td>";

							$output .= "<td>".$row['date_added']."</td>";


							$output .= "<td>".transaction_status($row['payment_status'])."</td>";

							if($row['payment_status'] != '1')
							{
								//app fees
								if($trans_for == 5 ){
									$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';
								//accept. fees
							}elseif($trans_for == 5){
									$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';

								}


							}
							else
							{
								 $output .= "<td></td>";

							}

							$output .= "</tr>";

						}
					}
					else
					{//show the msg

							$output =
								 '<div class="alert alert-danger alert-dismissable">
									<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
									<img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
								 </div>';


					}



					$output .=
					'</tbody>
					</table>
					</div>';





					return $output;






				}//end of view transaction log


		//function view transaction log
			function view_remita_transaction_log_abu($con, $trans_type , $trans_for, $type_id,$conn_1 )
			{

				$sess = get_current_session($con, 1);

				//query the database
				$query = "SELECT `id`, `invoice_id`, `transaction_type`, `user_id`, `transaction_for`, `payment_method`,
				`payment_status`, `response_code`, `response_description`,`transaction_id`, `transaction_reference`,
				 `title`, `description`, `amount`, DATE_FORMAT(date_added, '%b %e, %Y /  %l:%i:%p') as date_added,
				 DATE_FORMAT(transaction_date, '%b %e, %Y /  %l:%i:%p') as transaction_date

				 FROM `hostel_remita_webpay_transaction_log`

				 WHERE transaction_type = '$trans_type' AND	 transaction_for = '$trans_for' AND type_id='$type_id'
				 ORDER BY id DESC"; //AND session = $sess
				 $result = mysqli_query($con, $query);



				if(mysqli_num_rows($result) > 0)
				{//show table


					$output =
					'<div class="table-responsive table-responisve-lg table-responsive-xl">
							<table class="table table-bordered" id="table">
						<thead>

									 <th>MATRIC No.</th>
									<th>Invoice #</th>
									<th>Fullname</th>
									<th>RRR</th>
									<th>Transaction Ref.</th>
									<th>Title</th>
									<th>Amount- (N)</th>
									<th>Transaction Response</th>
									<th>Transaction Date / Time</th>
									<th>Status</th>
									<th>Action</th>


						</thead>

					 <!-- <tfoot>

						</tfoot>-->

						<tbody>';


					while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
					{
						 // $int_amount = $row['amount'] * 100;


						$output .= "<tr>";
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_applicant_matric_number_abu($conn_1, $row['user_id'])."</td>"; //group belong to admin or user
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['invoice_id']."</td>"; //group belong to admin or user
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_student_fullname_abu($conn_1, $row['user_id'])."</td>";

						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_id']."</td>";
						$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_reference']."</td>";
						$output .= "<td>".$row['title']."</td>";
						$output .= "<td>".number_format($row['amount'],2)."</td>";

						$output .= "<td>".$row['response_description'] ."(".$row['response_code'].")"."</td>";

						$output .= "<td>".$row['date_added']."</td>";


						$output .= "<td>".transaction_status($row['payment_status'])."</td>";

						if($row['payment_status'] != '1')
						{
							//app fees
							if($trans_for == 5 ){
								$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';
							//accept. fees
						}elseif($trans_for == 5){
								$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';

							}


						}
						else
						{
							 $output .= "<td></td>";

						}

						$output .= "</tr>";

					}
				}
				else
				{//show the msg

						$output =
							 '<div class="alert alert-danger alert-dismissable">
								<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
								<img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
							 </div>';


				}



				$output .=
				'</tbody>
				</table>
				</div>';





				return $output;






			}//end of view transaction log

			//function view transaction log
				function view_remita_transaction_log_udus($con, $trans_type , $trans_for, $type_id,$conn_1 )
				{

					$sess = get_current_session($con, 1);

					//query the database
					$query = "SELECT `id`, `invoice_id`, `transaction_type`, `user_id`, `transaction_for`, `payment_method`,
					`payment_status`, `response_code`, `response_description`,`transaction_id`, `transaction_reference`,
					 `title`, `description`, `amount`, DATE_FORMAT(date_added, '%b %e, %Y /  %l:%i:%p') as date_added,
					 DATE_FORMAT(transaction_date, '%b %e, %Y /  %l:%i:%p') as transaction_date

					 FROM `hostel_remita_webpay_transaction_log`

					 WHERE transaction_type = '$trans_type' AND	 transaction_for = '$trans_for' AND type_id='$type_id'
					 ORDER BY id DESC"; //AND session = $sess
					 $result = mysqli_query($con, $query);



					if(mysqli_num_rows($result) > 0)
					{//show table


						$output =
						'<div class="table-responsive table-responisve-lg table-responsive-xl">
								<table class="table table-bordered" id="table">
							<thead>

										 <th>MATRIC No.</th>
										<th>Invoice #</th>
										<th>Fullname</th>
										<th>RRR</th>
										<th>Transaction Ref.</th>
										<th>Title</th>
										<th>Amount- (N)</th>
										<th>Transaction Response</th>
										<th>Transaction Date / Time</th>
										<th>Status</th>
										<th>Action</th>


							</thead>

						 <!-- <tfoot>

							</tfoot>-->

							<tbody>';


						while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
						{
							 // $int_amount = $row['amount'] * 100;


							$output .= "<tr>";
								$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_applicant_matric_number_udus($conn_1, $row['user_id'])."</td>"; //group belong to admin or user
								$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['invoice_id']."</td>"; //group belong to admin or user
								$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".get_student_fullname_udus($conn_1, $row['user_id'])."</td>";

							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_id']."</td>";
							$output .= "<td class='text-info' style='font-size:14px; font-weight:bold'>".$row['transaction_reference']."</td>";
							$output .= "<td>".$row['title']."</td>";
							$output .= "<td>".number_format($row['amount'],2)."</td>";

							$output .= "<td>".$row['response_description'] ."(".$row['response_code'].")"."</td>";

							$output .= "<td>".$row['date_added']."</td>";


							$output .= "<td>".transaction_status($row['payment_status'])."</td>";

							if($row['payment_status'] != '1')
							{
								//app fees
								if($trans_for == 5 ){
									$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';
								//accept. fees
							}elseif($trans_for == 5){
									$output .= '<td><a target="_blank" class="btn btn-sm btn-primary" href="dashboard.php?hub=view_rr_log_hostel_fees&txnref='.$row['transaction_reference'].'&type_id='.$type_id.'" > Re - Query </a></td>';

								}


							}
							else
							{
								 $output .= "<td></td>";

							}

							$output .= "</tr>";

						}
					}
					else
					{//show the msg

							$output =
								 '<div class="alert alert-danger alert-dismissable">
									<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
									<img src="images/info.png" />&nbsp;&nbsp; No record found in the system.
								 </div>';


					}



					$output .=
					'</tbody>
					</table>
					</div>';





					return $output;






				}//end of view transaction log

				//function to get invoice payment to using orderID
				function get_invoice_to_using_txnref($conn_1, $oid)
				{
				$result = mysqli_query($conn_1, "SELECT user_id FROM hostel_remita_webpay_transaction_log WHERE transaction_reference = '$oid'");
				$row = mysqli_fetch_assoc($result);
				$v = $row['user_id'];

				return $v;
				}
				//function to get invoice id   using orderID
				function get_invoice_id_using_txnref($conn_1, $oid)
				{
				$result = mysqli_query($conn_1, "SELECT invoice_id FROM hostel_remita_webpay_transaction_log WHERE transaction_reference = '$oid'");
				$row = mysqli_fetch_assoc($result);
				$v = $row['invoice_id'];

				return $v;
				}

				//Function to fetch  invoice type
				function get_invoice_type($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT invoice_type FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['invoice_type'];

				return $v;
				}

				//Function to fetch  invoice to
				function get_invoice_invoice_to($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT invoice_to FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['invoice_to'];

				return $v;
				}

				//Function to fetch  pay to
				function get_invoice_pay_to($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT pay_to FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['pay_to'];

				return $v;
				}

				//Function to fetch  invocie for
				function get_invoice_for($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT invoice_for FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['invoice_for'];

				return $v;
				}

				//Function to fetch  invoice title
				function get_invoice_title($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT title FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['title'];

				return $v;
				}

				//Function to fetch descripion
				function get_invoice_desc($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT description FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['description'];

				return $v;
				}

				//Function to fetch total amount
				function get_invoice_total_amount($conn_1, $iid)
				{
					$result = mysqli_query($conn_1, "SELECT total_amount FROM hostel_invoices WHERE invoice_id = '$iid'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['total_amount'];

				return $v;
				}

				//function fetch user department applied for
				function get_user_department_applied_for_nce($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT department_id FROM students_nce WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['department_id'];


					return $v;
				}

				//function fetch user department applied for
				function get_user_department_applied_for_prence($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT department_id FROM students_prence WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['department_id'];


					return $v;
				}

				//function fetch user department applied for
				function get_user_department_applied_for_abu($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT department_id FROM students_nce WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['department_id'];


					return $v;
				}

				//function fetch user department applied for
				function get_user_department_applied_for_udus($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT department_id FROM students_nce WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['department_id'];


					return $v;
				}

				//function fetch user department applied for
				function get_user_department_applied_for_summer($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT department_id FROM summer_students WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['department_id'];


					return $v;
				}

				//function fetch user department applied for
				function get_user_department_applied_for_lvsp($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT department_id FROM summer_students WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['department_id'];


					return $v;
				}

				//function fetch user programme_applied_for
				function get_user_programme_applied_for_prence($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT programme_id FROM students_prence WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['programme_id'];


					return $v;
				}

				//function fetch user programme_applied_for
				function get_user_programme_applied_for_nce($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT programme_id FROM students_nce WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['programme_id'];


					return $v;
				}

				//function fetch user programme_applied_for
				function get_user_programme_applied_for_abu($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT programme_id FROM students_nce WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['programme_id'];


					return $v;
				}

				//function fetch user programme_applied_for
				function get_user_programme_applied_for_udus($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT programme_id FROM students_nce WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['programme_id'];


					return $v;
				}

				//function fetch user programme_applied_for
				function get_user_programme_applied_for_summer($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT programme_id FROM summer_students WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['programme_id'];


					return $v;
				}

				//function fetch user programme_applied_for
				function get_user_programme_applied_for_lvsp($conn_1, $id)
				{
					$result = mysqli_query($conn_1, "SELECT programme_id FROM summer_students WHERE id = '$id'");
					$row = mysqli_fetch_assoc($result);
					$v = $row['programme_id'];


					return $v;
				}

				// function that check if a applicant application number exist in stduents table or not
				function applicant_id_exist_payments($conn_1, $user_id)
				{
					$result = mysqli_query($conn_1, "SELECT student_id FROM hostel_fee_payments WHERE student_id = '$user_id'");
					//$row = mysql_fetch_assoc($result);
					//$an = $row['applicant_id'];

					if(mysqli_num_rows($result)>0)
					{
						return true;
					}
					else
					{
						return false;
					}
				}
				//

				//end of application no exist
				function get_payment_status_by_resp_code($resp_code)
				{
					if($resp_code == '00' || $resp_code == '01')
					{
						return 1;
					}
					else
					{
						return  2;
					}

				}//end of payments status

				//function for remita response code
			  function remita_response_code($stat, $rrr, $desc, $iid )
			  {
				  $mes = '<ul class="list-group">';

				  if($stat == '01' || $stat == '00')
				  {
					  $mes .= '<li class="list-group-item list-group-item-success"><p><i class="glyphicon glyphicon-exclamation-sign"></i> Your transaction is Approved and being processed. <br/>';
					  $mes .= '<h2>Transaction Successful</h2>';
					  $mes .= "<h4> Transaction #ref: $iid</h4>";
					  $mes .= "<br/><h3> Remita Retrieval Reference: $rrr </h3></p></li>";


				  }
				  else if($stat == '021')
				  {
					  $mes .= '<li class="list-group-item list-group-item-success"><p><i class="glyphicon glyphicon-exclamation-sign"></i> RRR!. <br/> ';
					  $mes .= '<h2>RRR Generated Successfully</h2>';
					  $mes .= "<h4>Transaction #ref: $iid</h4>";
					  $mes .= "<br/><h3> Remita Retrieval Reference: $rrr </h3> You can take this RRR to Remita Enabled Banks to make payment!</p></li>";


				  }
				  else
				  {
					  $mes .= '<li class="list-group-item list-group-item-danger"><p><i class="glyphicon glyphicon-exclamation-sign"></i> <h2>Your Transaction was not Successful.</h2> <br/> ';


					  if($rrr !=null)
					  {
						  $mes .= "<br/><h3> Remita Retrieval Reference: $rrr </h3>";
					  }
					  $mes .= "<h4>Transaction #ref: $iid</h4>";
					  $mes .= "<br/> <strong>Reason:  $desc </strong> <br/><br/> ";
					  $mes .= "Click view invoice on the top to try again!</p></li>";

				  }

				  $mes .='</ul>';


				  return $mes;
			  }


	//function count number of bank epin generated
		function get_total_confirmed_payments_per_semester($con, $session)
		{
			$q = "SELECT COUNT(*) FROM hostel_fee_payments WHERE  session_id = '$session' AND student_id != ''";
			$r = mysqli_query($con, $q);
			$row = mysqli_fetch_array($r,MYSQLI_NUM);


			$v = number_format($row[0]);

			return $v;
			//return ;
		}


		//get list of the programmes
function  get_programme_list_paid($con, $pt)
{
	$result = mysqli_query($con, "SELECT * FROM programmes WHERE school_id = '$pt' AND id != 8 AND id != 9 ORDER BY title");


	//if(mysqli_num_rows($result>0))
//	{
		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
		{
			echo '<a href="dashboard.php?hub=view_applicants_per_course&a='.sha1('fucku').'&pt='.$row['school_id'].'&p='.$row['id'].'" class="btn btn-success  btn-lg" target="_blank" style="margin:4px;" >'.$row['title'].' - <span class="badge">'.get_total_prog_type_programme_applicants_paid($con, $pt,$row['id']).'</span>'.'</a>';
		}

	//}
//	else
//	{
//		echo "No data found..";
//	}

}



//function get total applicants in a programme
function get_total_prog_type_programme_applicants_paid($con, $pt, $id)
{
	$q = "SELECT SUM(amount - 900) FROM hostel_fee_payments  WHERE programme_type_id = '$pt' AND programme_id = '$id'";
	$r = mysqli_query($con, $q);
	$row = mysqli_fetch_array($r,MYSQLI_NUM);

	return number_format($row[0]);

}

?>
