<?php session_start();
include("connect.php");
if(!isset($_SESSION['stureg_id'])){
	header("location:index.php");
}else{
	$ddd=mysqli_query($con,"select * from student where id='".$_SESSION['stureg_id']."'");
	$me=mysqli_fetch_assoc($ddd);
	
	$bam=mysqli_query($con,"select * from `programme` where id='".$me['programme_id']."'");
	$pro=mysqli_fetch_assoc($bam);
	
	$bxm=mysqli_query($con,"select * from `department` where id='".$me['dept_id']."'");
	$dep=mysqli_fetch_assoc($bxm);
	
	$bm=mysqli_query($con,"select * from `faculty` where id='".$dep['fac_id']."'");
	$fac=mysqli_fetch_assoc($bm);
	
	$bc=mysqli_query($con,"select * from `semester` where programme_id='".$me['programme_id']."' AND session !='' AND current_semester=1 order by id desc");
	$sem=mysqli_fetch_assoc($bc);
	
	if($me['dept_id']==0 || $me['dept_id']==''){
		header("location:dashboard.php");
	}
}


	unset($_SESSION['grab_course']);
	//unset($_SESSION['student_level']);
	

if(isset($_GET['cancel_search'])){
	unset($_SESSION['student_level']);		
	unset($_SESSION['extra_year_student']);		
	header("location:registration.php");
}


?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	 <title>Course Registration Dashboard :: Inspire Polytechnic, Course Registration Portal</title>
   <meta name="description" content="Inspire Polytechnic, Course Registration Portal" />
	<meta name="keyword" content="Inspire Polytechnic, Course Registration, Portal, Studies, Education" />
	<meta name="author" content="Dosumu Ololade"/>
    <link rel="icon" href="img/lasu_logo.png">
	<link href="vendors/bower_components/select2/dist/css/select2.min.css" rel="stylesheet" type="text/css"/>
		<link href="vendors/bower_components/bootstrap-select/dist/css/bootstrap-select.min.css" rel="stylesheet" type="text/css"/>
	<link href="vendors/bower_components/datatables/media/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
	<link href="dist/css/style.css" rel="stylesheet" type="text/css">
	
	
	
</head>

<body>
	<!--Preloader-->
	<div class="preloader-it">
		<div class="la-anim-1"></div>
	</div>
	<!--/Preloader-->
    <div class="wrapper theme-6-active pimary-color-green">
		<!-- Top Menu Items -->
		<nav class="navbar navbar-inverse navbar-fixed-top">
			<div class="mobile-only-brand pull-left">
				<div class="nav-header pull-left">
					<div class="logo-wrap">
						<a href="dashboard.php">
							<img class="brand-img" style="width:30px;" src="img/lasu_logo.png" alt="brand"/>
							
						</a>
					</div>
				</div>	
				<a id="toggle_nav_btn" class="toggle-left-nav-btn inline-block ml-20 pull-left" href="javascript:void(0);"><i class="zmdi zmdi-menu"></i></a>
				
			</div>
			<div id="mobile_only_nav" class="mobile-only-nav pull-right">
				<ul class="nav navbar-right top-nav pull-right">
					<li class="dropdown auth-drp">
						<a href="#" class="dropdown-toggle pr-0" data-toggle="dropdown"> <?php echo ucwords($me['sname']); ?> <img src="img/avatar.png" alt="user_auth" class="user-auth-img img-circle"/><span class="user-online-status"></span></a>
						<ul class="dropdown-menu user-auth-dropdown" data-dropdown-in="flipInX" data-dropdown-out="flipOutX">
							<li>
								<a href="logout.php"><i class="zmdi zmdi-power"></i><span>Log Out</span></a>
							</li>
						</ul>
					</li>
				</ul>
			</div>	
		</nav>
		<!-- /Top Menu Items -->
		
		<!-- Left Sidebar Menu -->
		<div class="fixed-sidebar-left">
			<ul class="nav navbar-nav side-nav nicescroll-bar">
				<li class="navigation-header">
					<span><?php echo $me['matric_no']?></span> 
					<i class="zmdi zmdi-more"></i>
				</li>
				
				<li>
					<a href="index.php"><div class="pull-left"><i class="fa fa-home mr-20"></i><span class="right-nav-text">Home</span></div>
					<div class="clearfix"></div></a>
				</li>
				
				<li>
					<a href="dashboard.php"><div class="pull-left"><i class="fa fa-dashboard mr-20"></i><span class="right-nav-text">Dashboard</span></div>
					<div class="clearfix"></div></a>
				</li>
				
				<li>
					<a href="registration.php" class="active"><div class="pull-left"><i class="fa fa-language mr-20"></i><span class="right-nav-text">Course Registration</span></div>
					<div class="clearfix"></div></a>
				</li>
				<li>
					<a href="add_delete.php"><div class="pull-left"><i class="fa fa-edit mr-20"></i><span class="right-nav-text">Add & Delete Course</span></div>
					<div class="clearfix"></div></a>
				</li>
				<li>
			<a href="course_form.php"><div class="pull-left"><i class="fa fa-print mr-20"></i><span class="right-nav-text">Print Course Form</span></div>
					<div class="clearfix"></div></a>
				</li>
				<li>
			<a href="exam_slip.php"><div class="pull-left"><i class="icon icon-notebook mr-20"></i><span class="right-nav-text"> Exam Slip</span></div>
					<div class="clearfix"></div></a>
				</li>
				<li>
			<a href="logout.php"><div class="pull-left"><i class="fa fa-power-off mr-20"></i><span class="right-nav-text">Logout</span></div>
					<div class="clearfix"></div></a>
				</li>
			</ul>
		</div>
		<!-- /Left Sidebar Menu -->
		
		
		
		
		<!-- Right Sidebar Backdrop -->
		<div class="right-sidebar-backdrop"></div>
		<!-- /Right Sidebar Backdrop -->

        <!-- Main Content -->
		<div class="page-wrapper">
            <div class="container-fluid pt-25">
					
					<div class="row">
					
					<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
						<div class="panel panel-success card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0">
						<div align="center"><img src="img/logo.png" style="width:250px; padding:20px 5px;" class="img-responsive"></div>
									
								</div>
							</div>
						</div>
					</div>
					
					<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
						<div class="panel panel-default card-view ">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0">
									<div class="sm-data-box">
										<div class="container-fluid">
											<div class="row">
												<div style="margin-top:-12px;margin-bottom:-12px;" class="col-md-12 text-center pl-0 pr-0 data-wrap-left">
													<span class="txt-dark block counter" style="font-weight:600;">
													<i class="fa fa-language"></i> COURSE REGISTRATION</span>
												</div>
											</div>	
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					
				</div>
					
				<!-- Row -->
					
				
				<div class="row">
				
					<div class="col-md-4">
					<div class="panel panel-default card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0" style="padding-left:;">
									<div class="sm-data-box">
										<div class="container-fluid">
											<div class="row">
												<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left">
													<span class="txt-dark block counter" style="font-size:20px; padding-left:14px;">
													<?php echo $pro['name']; ?></span>
													<span class="weight-500 uppercase-font block font-13 pt-10">Programme</span>
												</div>
												<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right">
													<i class="fa fa-certificate data-right-rep-icon txt-light-grey"></i>
												</div>
											</div>	
										</div>
									</div>
								</div>
							</div>
						</div>
						
						<div class="panel panel-default card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0" style="padding-left:;">
									<div class="sm-data-box">
										<div class="container-fluid">
											<div class="row">
												<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left">
													<span class="txt-dark block counter" style="font-size:20px; padding-left:14px;">
													<?php echo $dep['department'];	?></span>
													<span class="weight-500 uppercase-font block font-13 pt-10">Department</span>
												</div>
												<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right">
													<i class="fa fa-graduation-cap data-right-rep-icon txt-light-grey"></i>
												</div>
											</div>	
										</div>
									</div>
								</div>
							</div>
						</div>
						
						<div class="panel panel-default card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0" style="padding-left:;">
									<div class="sm-data-box">
										<div class="container-fluid">
											<div class="row">
												<div class="col-xs-6 text-center pl-0 pr-0 data-wrap-left">
													<span class="txt-dark block counter" style="font-size:20px; padding-left:14px;">
													<?php 
													if(mysqli_num_rows($bc)==0){
														echo 'Not Defined!';
													}else if($sem['session']!=''){
														echo $sem['session'];	
													}else{
														echo 'Not Defined!';	
													}
													?></span>
													<span class="weight-500 uppercase-font block font-13 pt-10">Current Academic Session</span>
												</div>
												<div class="col-xs-6 text-center  pl-0 pr-0 data-wrap-right">
													<i class="fa fa-calendar data-right-rep-icon txt-light-grey"></i>
												</div>
											</div>	
										</div>
									</div>
								</div>
							</div>
						</div>
						
					
					</div>
					
					<div class="col-md-8">
					<?php
					
			if(isset($_SESSION['student_level'])){ //////////////////// TO START REG
			$svm=mysqli_query($con,"select * from semester where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !=''");
			if(mysqli_num_rows($svm)>0){
				
				
				
				
				///////////////////////////////// payment
				
				
				/////////// to verify student tution fee
			$ssm=mysqli_query($con,"select * from semester where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !=''");
			if(mysqli_num_rows($ssm)>0){
				
			$ckk=mysqli_fetch_assoc($ssm);
			
			$cax=mysqli_query($con,"select * from semester where programme_id='".$me['programme_id']."'");
			$fal=mysqli_fetch_assoc($cax);
			$cav=mysqli_query($con,"select SUM(fraction) as fraction from payment where matric_no='".trim($me['matric_no'])."' AND session='".trim($ckk['session'])."'");			$pdp=mysqli_fetch_assoc($cav);			$pay_sum=$pdp['fraction'];
			
			if($pay_sum==0 || $pay_sum==''){
				echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to pay your tution fee for '.$ckk['session'].' academic session</span>
										</div>';
			}else{				
				$pay_sum =$pay_sum;
				if(mysqli_num_rows($cax)==1 && $pay_sum<1.0){ //if programme is only one semester and yet to complete payment
				echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to complete your tution fee for '.$ckk['session'].' academic session</span>
										</div>';	
				}else if($ckk['semester']==1 && $pay_sum<0.7){ // if in the 1st semester and student is yet to pay up to 70%
					echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to complete your tution fee for '.$ckk['session'].' academic session</span>
										</div>';
				}else if($ckk['semester']>1 && $pay_sum<1.0){ // if in the 2nd or 3rd semester and student is yet to pay up
					echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to complete your tution fee for '.$ckk['session'].' academic session</span>
										</div>';
				}else{ ///////////////// IF STUDENT TUTION HAS BEEN PAID UP TO THE CURRENT SEMESTER
				
				///////////////////////////////// payment
				
			$cnn=mysqli_fetch_assoc($svm);
		//sid	matric_no	level	dep_id	course_id	course_code	description	unit	status	programme_id	programme	programme_description	semester_num	semester_description	session	date	
			
			/*$bas=mysqli_query($con,"select * from reg_course where sid='".$me['id']."' AND matric_no='".$me['matric_no']."' AND level='".$_SESSION['student_level']."' AND dep_id='".$me['dept_id']."' AND programme_id='".$me['programme_id']."' AND programme='".$pro['name']."' AND session='".$cnn['session']."' AND semester_num='".$cnn['semester']."' AND semester_description='".$cnn['description']."'");	*/
			
			$bas=mysqli_query($con,"select * from reg_course where sid='".$me['id']."' AND matric_no='".$me['matric_no']."' AND dep_id='".$me['dept_id']."' AND programme_id='".$me['programme_id']."' AND programme='".$pro['name']."' AND session='".$cnn['session']."' AND semester_num='".$cnn['semester']."' AND semester_description='".$cnn['description']."'");
			
			if(mysqli_num_rows($bas)==0){
			
			echo '<form method="post" id="form_submit1">
			<input type="hidden" name="submit_registration" value="'.$_SESSION['student_level'].'">
			<div class="panel  panel-primary card-view">
					<div class="panel-heading">
									<div class="pull-left">
										<h6 class="panel-title" style="color:white; font-weight:bold; font-size:15px; margin-top:-10px; margin-bottom:-10px;">COURSE LISTING</h6>
									</div>
									</div>
									<div class="panel-body">
							
					<div class="row">
					<div class="form-group col-md-5" style="font-size:18px;">
                             <label class="control-label mb-1" style="font-weight:bold; text-decoration:underline;">Semester: </label>
                            '.ucwords(strtolower($cnn['description'])).'
                     </div>
					<div class="form-group col-md-3" style="font-size:18px;">
                             <label class="control-label mb-1" style="font-weight:bold; text-decoration:underline;">Level: </label>
                            '.$_SESSION['student_level'].'
                     </div>
					
					<div class="form-group col-md-4" style="font-size:17px;">
                             <label class="control-label mb-1" style="font-weight:bold; text-decoration:underline;">Extra Year Student: </label>';
                          if(isset($_SESSION['extra_year_student']) && $_SESSION['extra_year_student']=='extra_year_student'){
							  echo ' Yes';
						  }else{
							  echo ' No';
						  }
                     echo '</div>
					
					</div>';

	$be=mysqli_query($con,"select * from `semester` where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !='' order by id desc");
	$seme=mysqli_fetch_assoc($be);			
	$mac=mysqli_query($con,"select * from course where programme_id='".$me['programme_id']."' AND semester_id='".$seme['id']."' AND level='".$_SESSION['student_level']."' AND dep_id='".$me['dept_id']."' AND (status='c' OR status='r') order by course_code asc");
	
	
	echo '<div class="table-wrap mt-40">
										<div class="table-responsive">
										  <table class="table table-hover table-bordered mb-0">
											<thead>
											  <tr>
												<th style="padding:6px;"></th>
												<th style="font-weight:bold;padding:6px;">COURSE CODE</th>
												<th style="font-weight:bold;padding:6px;">COURSE TITLE</th>
												<th style="font-weight:bold;padding:6px;">STATUS</th>
												<th style="font-weight:bold;padding:6px;">UNITS</th>
											  </tr>
											</thead>
											<tbody>';
	
	if(mysqli_num_rows($mac)>0){
		$ms=0;
	while($cos=mysqli_fetch_assoc($mac)){
		$ms=$ms+1;
		echo '<tr>
		<td align="center" style="padding:5px;">
		<input type="checkbox" class="checker" name="select_course['.$ms.']" value="'.$cos['id'].'">
		</td>
		<td align="center" style="padding:5px;">'.strtoupper($cos['course_code']).'</td>
		<td style="padding:5px;">'.strtoupper($cos['description']).'</td>
		<td align="center" style="padding:5px;">'.strtoupper($cos['status']).'</td>
		<td align="center" style="padding:5px;">'.$cos['unit'].'</td>
		</tr>';
	}
	}else{
		$ms=1;
		echo '<tr class="no_course_found"><td colspan="5" align="center">No course found, you can use the add course module below!</td></tr>';
	}
	echo '</tbody></table></div></div><br>';
	
	/* <div class="pull-right" style="color:black; margin-top:12px; font-size:17px;">Total Number of Units Selected: <input type="text" value="0" class="show_tnu" name="total_unit_selected" readonly style="font-weight:600; cursor:default; border:0; background:transparent; box-shadow:0;"></div> <div class="clearfix"></div><hr> */
	
	echo '<input type="hidden" value="" class="show_selected" name="show_selected">
	
	<input type="hidden" value="'.$ms.'" class="cap_no">
	
					<div class="error"></div>
									<div class="form-group mt-20">
												<label class="control-label mb-10" style="font-weight:600;">Select Additional Course</label>
													<select class="form-control select2 additional_course" name="additional_course">
														<option value="">Select</option>';
											

	$ba=mysqli_query($con,"select * from `semester` where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !='' order by id desc");
	$sam=mysqli_fetch_assoc($ba);	
	
	$mec=mysqli_query($con,"select * from course where programme_id='".$me['programme_id']."' AND semester_id='".$sam['id']."' AND level<='".$_SESSION['student_level']."' AND `id` NOT IN (select id from course where programme_id='".$me['programme_id']."' AND semester_id='".$sam['id']."' AND level='".$_SESSION['student_level']."' AND dep_id='".$me['dept_id']."' AND (status='c' OR status='r') order by course_code asc)  order by course_code asc, status asc");
	
	if(mysqli_num_rows($mec)>0){
	while($ele=mysqli_fetch_assoc($mec)){
		
		$das=mysqli_query($con,"select * from department where id='".$ele['dep_id']."'");
		$dept=mysqli_fetch_assoc($das);
		
		echo '<option value="'.$ele['id'].'">'.strtoupper($ele['course_code']).' ('.ucwords(strtolower($ele['description'])).') || Status: '.strtoupper($ele['status']).' || Dept: '.ucwords(strtolower($dept['department'])).'</option>';
	}
	}else{
		echo '<option value="">No additional course found!</option>';
	}
											
													
													echo '</select>
													
													</div>	
													
									<div class="form-group" align="center">
			<button type="button" style="margin-top:10px;" class="btn btn-primary add_now"><span class="btn-text">Add Selected Course </span><i class="fa fa-plus-circle"></i></button>
											</div>
													
				<div style="margin-top:37px;">
		<a href="?cancel_search=true&request=true&'.uniqid().'" class="btn btn-warning pull-left">Cancel <i class="fa fa-times"></i></a> 	
		
			<button type="submit" class="btn btn-success pull-right">Submit <i class="fa fa-check-circle"></i></button>	
			<div class="clearfix"></div>
			</div>
					
									
						</div></div>
						</form>';
			
			}else{
				echo '<div class="alert alert-success" style="font-size:19px;">
											<i class=" ti-check-box " style="font-size:30px;"></i>&nbsp;
											<span style="color:;">You\'ve already registered for the current semester academic session</span>
										</div>
										<div class="panel panel-default card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0" style="padding-left:;">
									<img src="img/banner3.png" class="img-responsive">
								</div>
							</div>
						</div>';
			}
			
			
			
	////////////////// payment	
} 
				
			}
			}

/////////////////  payment
			
			
						
			}else{
				echo '<div class="alert alert-warning alert-dismissable alert-style-1" style="font-size:22px;">
											<i class="zmdi zmdi-alert-circle-o" style="font-size:37px;"></i>
											<span style="color:#ff8000;">SORRY! Registration period has expired.</span>
										</div>
										<div class="panel panel-default card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0" style="padding-left:;">
									<img src="img/banner3.png" class="img-responsive">
								</div>
							</div>
						</div>';
			}	



					
					}else{ //////////// TO END REG
					
					$svm=mysqli_query($con,"select * from semester where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !=''");
					if(mysqli_num_rows($svm)>0){
						
				 ///////////////////////////////// payment
				/////////// to verify student tution fee
			$ssm=mysqli_query($con,"select * from semester where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !=''");
			if(mysqli_num_rows($ssm)>0){
				
			$ckk=mysqli_fetch_assoc($ssm);
			
			$cax=mysqli_query($con,"select * from semester where programme_id='".$me['programme_id']."'");
			$fal=mysqli_fetch_assoc($cax);
			
			$cav=mysqli_query($con,"select SUM(fraction) as fraction from payment where matric_no='".trim($me['matric_no'])."' AND session='".trim($ckk['session'])."'");			$pdp=mysqli_fetch_assoc($cav);			$pay_sum=$pdp['fraction'];
					if($pay_sum==0 || $pay_sum==''){
				echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to pay your tution fee for '.$ckk['session'].' academic session</span>
										</div>';
			}else{
				$pay_sum =$pay_sum;				
				if(mysqli_num_rows($cax)==1 && $pay_sum<1.0){ //if programme is only one semester and yet to complete payment
				echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to complete your tution fee for '.$ckk['session'].' academic session</span>
										</div>';	
				}else if($ckk['semester']==1 && $pay_sum<0.7){ // if in the 1st semester and student is yet to pay up to 70%
					echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to complete your tution fee for '.$ckk['session'].' academic session</span>
										</div>';
				}else if($ckk['semester']>1 && $pay_sum<1.0){ // if in the 2nd or 3rd semester and student is yet to pay up
					echo '<div class="alert alert-danger" style="font-size:19px;">
											<i class=" fa fa-exclamation-circle " style="font-size:30px;"></i>&nbsp;
											<span>You are yet to complete your tution fee for '.$ckk['session'].' academic session</span>
										</div>';
				}else{ ///////////////// IF STUDENT TUTION HAS BEEN PAID UP TO THE CURRENT SEMESTER
				
				
				
				///////////////////////////////// payment
						
						
						
						$row=mysqli_fetch_assoc($svm);
					
						echo '<div class="panel  panel-primary card-view">
					<div class="panel-heading">
									<div class="pull-left">
										<h6 class="panel-title" style="color:white; font-weight:bold; font-size:15px; margin-top:-10px; margin-bottom:-10px;">INITIATE COURSE REGISTRATION</h6>
									</div>
									</div>
									<div class="panel-body">
									
									<form method="post" id="form_submit">
						
<div style="margin-bottom:30px;" align="center">
<div class="form-group" align="center" style="margin-top:5px; margin-bottom:5px; border:1px solid #809fff; padding:12px;">
<label for="extra_year_student" style="color:#0033cc;"> 
<input type="checkbox" id="extra_year_student" value="extra_year_student" name="extra_year_student" /> Click to indicate that you are an extra year student!</label>
</div>
									</div>
						
									
									<input type="hidden" name="c_course" value="dosumu">
									<div class="row">
									
									<div class="form-group col-md-6">
                             <label class="control-label mb-5" for="email_de">Semester</label>
												<select class="form-control" name="c_semester" required >
								<option value="'.$row['id'].'"> Semester '.$row['semester'].' : : '.ucwords(strtolower($row['description'])).'</option>
												</select>
                                                </div>
												
												<div class="form-group col-md-6">
									<label class="control-label mb-5" for="email_de">Level</label>
												<select class="form-control" name="c_level">
												<option value="">Select</option>';
												
												for($y=1; $y<=9; $y++){
													echo '<option>'.$y.'00</option>';
												}
												
												echo '</select>
                                                </div>
									
									</div>
									<div class="msg"></div>
									<button type="submit" class="pull-right btn btn-primary btn-rounded">Submit <i class="fa fa-search"></i></button>
									<div class="clearfix"></div>
									
									</form>
									
						</div></div>';
						
						
			////////////////// payment	
		} 
				
			}
			}

/////////////////  payment

				
					}else{
						echo '<div class="alert alert-warning alert-dismissable alert-style-1" style="font-size:22px;">
											<i class="zmdi zmdi-alert-circle-o" style="font-size:37px;"></i>
											<span style="color:#ff8000;">SORRY! Registration period has expired.</span>
										</div>
										<div class="panel panel-default card-view pa-0">
							<div class="panel-wrapper collapse in">
								<div class="panel-body pa-0" style="padding-left:;">
									<img src="img/banner3.png" class="img-responsive">
								</div>
							</div>
						</div>';
					}
					}
					?>
					
					
					
					
					
					</div>
					
					
				
					
				</div>
				<!-- /Row -->
			
			</div>
			<!-- Footer -->
			<footer class="footer container-fluid pl-30 pr-30">
				<div class="row">
					<div class="col-sm-12">
						<p style="text-align:center;"> &copy; Copyright <?php echo date("Y");?> Inspire Polytechnic. All rights reserved</p>
					</div>
				</div>
			</footer>
			<!-- /Footer -->
			
		</div>
        <!-- /Main Content -->

    </div>
    <!-- /#wrapper -->
	
	<!-- JavaScript -->
	
    <!-- jQuery -->
    <script src="vendors/bower_components/jquery/dist/jquery.min.js"></script>
	
	<script>
	jQuery().ready(function(){
		
		$("input.checker").click(function(){
			if($(this).is(":checked")){
				var signal = 'add';
				var course_id = $(this).val();
			}else{
				var course_id =$(this).val();
				var signal='delete';
			}
			var added_tnu= parseInt($("input.show_tnu").val());
			$.ajax({
						type: "POST",
                        url: "operation1.php",
                        data: ({signal:signal,course_id:course_id,tnu:added_tnu}),
                        cache: false,
                        success: function(data){
						$("input.show_tnu").val(parseInt(data));
						 } 
 });	
		});
		
		$("input.checker").click(function(){
			if($(this).is(":checked")){
				var course_id = $(this).val();
				var ss=$("input.show_selected").val();
				$("input.show_selected").val(ss +','+course_id);
			}else{
				var course_id = $(this).val();
				var ss=$("input.show_selected").val();
				$("input.show_selected").val(ss.replace(','+course_id,'').replace(/,\s*$/, ""));
				
				
			}
			
		});
		
		
		$("button.add_now").click(function(){
			var additional_course = $("select.additional_course").val();
			if(additional_course!=''){
				var plus_one = parseInt($("input.cap_no").val())+1;
				$("input.cap_no").val(plus_one);
					$.ajax({
						type: "POST",
                        url: "operation.php",
                        data: ({append_course:additional_course,plus_one:plus_one}),
                        cache: false,
                        success: function(data){
						if(data!=''){
						$("table").append(data);
						$("tr.no_course_found").hide();
						}  
						$("div.error").html("");
							
						 } 
 });
				
			}else{
				$("div.error").html("<p class='text-danger' style='padding:5px; text-align:center;'><i class='fa fa-exclamation-circle'></i> No Course Selected!</p>");
			}
		});
		
		$("select#programme").change(function(){
			var control_programme = $(this).val();
			if(control_programme!=''){
			$.ajax({
						type: "POST",
                        url: "operation.php",
                        data: ({control_programme:control_programme}),
                        cache: false,
                        success: function(data){ 
							$("div.control_result").html(data);
						 } 
 });
		}else{
			$("div.control_result").html('<div class="form-group control_result">\
                             <label class="control-label mb-5" for="email_de">Programme Control</label>\
												<select class="form-control" name="status" required >\
												<option value="">Select</option>\
												</select>\
                                                </div>');
		}
		});
		
		
$('#example').DataTable( {
		dom: 'Blfrtip',
		buttons: [
			'copy', 'csv', 'excel', 'pdf', 'print'
		],
		
		"fnDrawCallback": function(oSettings){
			
			$("a.delete_programme").click(function(){
			
		if(confirm("Are you sure you want to delete programme"))
		  {
		$("div.error").html("<p class='text-primary' style='padding:5px; text-align:center;'><i class='fa fa-spin fa-spinner'></i> Processing Request...</p>");
		var delete_programme=$(this).attr("id");
		$.ajax({
						type: "POST",
                        url: "operation.php",
                        data: ({delete_programme:delete_programme}),
                        cache: false,
                        success: function(data){ 
						$("tr#"+delete_programme).animate({ backgroundColor: "#fbc7c7" }, "fast").animate({ opacity: "hide" }, "slow");
						 } 
 });
	
		}
return false;
		});
			
		
		$("a.edit_programme").click(function(){
		var edit_programme = $(this).attr("id");
		
		$("div.result").html('<div align="center"><i class="fa fa-spin fa-spinner fa-2x" style="color:gray;"></i></div>');
	
			$.ajax({
						type: "POST",
                        url: "operation.php",
                        data: ({edit_programme:edit_programme}),
                        cache: false,
                        success: function(data){ 
							$("div.result").html(data);
						 } 
 });
		
	});
		
		}
	} );
		
		
		$("form#form_submit1").on('submit',(function(e){
			e.preventDefault();
	if(confirm("Are you sure you want to submit registration?"))
		  {	
	$("div.error").html("<p class='text-primary' style='padding:5px; text-align:center;'><i class='fa fa-spin fa-spinner'></i> Processing Request...</p>");
	
				$.ajax({
						type: "POST",
                        url: "operation2.php",
                        data: new FormData(this),
						contentType:false,
						processData:false,
                        cache: false,
                        success: function(data){ 
						$("div.error").html(data);
						}
    });			
		}
		return false;
	
		}));
		
		
		$("form#form_submit").on('submit',(function(e){
			e.preventDefault();
			
	$("div.msg").html("<p class='text-primary' style='padding:5px; text-align:center;'><i class='fa fa-spin fa-spinner'></i> Processing Request...</p>");
	
				$.ajax({
						type: "POST",
                        url: "operation.php",
                        data: new FormData(this),
						contentType:false,
						processData:false,
                        cache: false,
                        success: function(data){ 
						$("div.msg").html(data);
						}
    });			
	
	
		}));
		
		
	});
	</script>
	

    <!-- Bootstrap Core JavaScript -->
    <script src="vendors/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
	<script src="vendors/bower_components/switchery/dist/switchery.min.js"></script>
	<script src="vendors/bower_components/select2/dist/js/select2.full.min.js"></script>
	<script src="vendors/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
	<script src="dist/js/jquery.slimscroll.js"></script>
	<script src="dist/js/dropdown-bootstrap-extended.js"></script>
	<script src="vendors/bower_components/switchery/dist/switchery.min.js"></script>
	<script src="dist/js/init.js"></script>
	<script src="dist/js/form-advance-data.js"></script>
	<script src="dist/js/dashboard-data.js"></script>

</body>

</html>
