<?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 !='' order by id desc");
	$sem=mysqli_fetch_assoc($bc);	
	
	if($me['dept_id']==0 || $me['dept_id']==''){
		header("location:dashboard.php");
	}
	
}

if(isset($_GET['print_form'])){
	
	$mac=mysqli_query($con,"select * from reg_course where id='".$_GET['print_form']."' AND sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."'");
	if(mysqli_num_rows($mac)>0){
	
		$sol=mysqli_fetch_assoc($mac);
	
	//semester: id	programme_id	semester	description	min_tnu	max_tnu	registration_control	add_delete_control	session
	//reg_course: id	sid	matric_no	level	dep_id	course_id	course_code	description	unit	status	programme_id	programme	programme_description	semester_num	semester_description	session	date
	
	//to show the courses registered
	$mpc=mysqli_query($con,"select * from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND semester_num='".$sol['semester_num']."' AND dep_id='".$me['dept_id']."' AND session='".$sol['session']."' order by course_code desc");
	$total_unit=0;
	$table_row='';
	while($opc=mysqli_fetch_assoc($mpc)){
		$total_unit=$total_unit+$opc['unit'];
		$table_row .='<tr style="border-bottom:2px double #d7d7d7;">
                     <td style="text-align:center;border:1px solid black;padding:8px; width:25%; font-size:11px;">'.strtoupper($opc['course_code']).'</td>
                      <td style="text-align:left;border:1px solid black;padding:8px; width:50%; font-size:11px;">'.strtoupper($opc['description']).'</td>
                      <td style="text-align:center;border:1px solid black;padding:8px; width:10%; font-size:11px;">'.strtoupper($opc['unit']).'</td>
                     <td style="text-align:center;border:1px solid black;padding:8px; width:15%; font-size:11px;">'.strtoupper($opc['status']).'</td>
                         </tr>';
	}
	//background-color:#fff7e6; border:1px solid black;
	$table_row .='
	<tr><td colspan="4" style="border-bottom:1px solid white;"></td></tr>
	<tr><td colspan="2" style="border-top:1px solid white; text-align:right; width:75%; font-weight:bold;"><br>TOTAL NUMBER OF UNITS = &nbsp; </td>
	<td colspan="2" style="border-top:1px solid white;font-weight:bold;text-align:left;width:25%;"><br>'.$total_unit.'</td></tr>';
	
	
	
										if(strtolower(trim($me['gender']))=='m' || strtolower(trim($me['gender']))=='male'){
												$gen= 'Male';		
										}else if(strtolower(trim($me['gender']))=='f' || strtolower(trim($me['gender']))=='female'){
												$gen= 'Female';		
										}else{
												$gen= 'Unknown';	
										}
	
	/////////////////////////////////////////// START PRINTING ///////////////
	/////////////////////////////////////////// START PRINTING ///////////////
	/////////////////////////////////////////// START PRINTING ///////////////
	
	
require_once('topdf/examples/tcpdf_include.php');
	
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Inspire Polytechnic.');
$pdf->SetTitle('Students Course Registration Form');
$pdf->SetSubject('Students Course Registration Form Print-Out');
$pdf->SetKeywords('Inspire Polytechnic, Course Registration, Student');
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

if (@file_exists(dirname(__FILE__).'topdf/examples/lang/eng.php')) {
	require_once(dirname(__FILE__).'topdf/examples/lang/eng.php');
	$pdf->setLanguageArray($l);
}

$pdf->SetFont('dejavusans', '', 10);
$pdf->AddPage();

$style = array(
	'border' => 2,
	'vpadding' => 'auto',
	'hpadding' => 'auto',
	'fgcolor' => array(0,0,0),
	'bgcolor' => false,
	'position' =>'C',
	'module_width' => 1,
	'module_height' => 1
);
	
$html='					
<div style="border-bottom:2px solid black;">
<table>
<tr>
<td style="width:18%;"><img src="img/lasu_logo.png" style="width:100px; margin-top:200px;"></td>
<td style="width:64%;">
<h2 style="text-align:center; color:black; font-family:Calibri; font-size:17px; margin-top:3px;">INSPIRE POLYTECHNIC<br>
<span style="font-weight:normal;font-size:10px;">39/41, Karimu Laka Street, Egbeda, Lagos, Nigeria</span><br>
<span style="text-align:center; text-decoration:none; margin-top:-10px;font-size:13px;">
'.strtoupper($pro['description'].' ('.$me['campus'].' CAMPUS)').'</span><br>
<span style="text-align:center; text-decoration:underline; margin-top:-10px;font-size:12px;">COURSE REGISTRATION FORM</span><br>
<span style="text-align:center; font-weight:normal; text-decoration:none; margin-top:-10px;font-size:12px;">DEPARTMENT OF '.strtoupper($dep['department']).'</span><br>
<span style="text-align:center; font-weight:normal; text-decoration:none; margin-top:-10px;font-size:12px;">'.$sol['session'].' SESSION ::: '.strtoupper($sol['semester_description']).'</span><br>

</h2>
</td>
<td style="width:18%;"> </td>
</tr>
</table> 
</div>

<h2 style="text-align:center; font-weight:bold; font-size:14px; text-decoration:underline; text-underline-offset:10px; padding:6px;">STUDENT DATA</h2><br><br>

<table style="padding:5px;">
<tr>
<td style="width:30%;padding:5px;border-top:1px solid gray;">Surname:
<span style="font-weight:bold;">'.strtoupper($me['sname']).'</span></td>
<td style="width:10%;padding:5px;border-top:1px solid gray;"></td>
<td style="width:60%;padding:5px;border-top:1px solid gray;">Other Names:
<span style="font-weight:bold;">'.strtoupper($me['mname'].' '.$me['fname']).'</span></td>
</tr>

<tr>
<td style="width:50%;padding:5px;border-top:1px solid gray;">Matriculation Number:
<span style="font-weight:bold;">'.$me['matric_no'].'</span></td>
<td style="width:20%;padding:5px;border-top:1px solid gray;">Gender:
<span style="font-weight:bold;">'.strtoupper($gen).'</span></td>
<td style="width:30%;padding:5px;border-top:1px solid gray;">Year of Entry:
<span style="font-weight:bold;">'.$me['entry'].'</span></td>
</tr>

<tr>
<td style="width:45%;padding:5px;border-top:1px solid gray;">Student\'s Signature:
<span style="font-weight:bold;">.......................</span></td>
<td style="width:20%;padding:5px;border-top:1px solid gray;">Level:
<span style="font-weight:bold;">'.$sol['level'].'</span></td>
<td style="width:35%;padding:5px;border-top:1px solid gray;">Registered On:
<span style="font-weight:bold;">'.explode(",",$sol['date'])[0].'</span></td>
</tr>
</table>
<hr>
<br>
<div style="height:10px;"></div>
<h2 style="text-align:center; font-weight:bold; font-size:14px; text-decoration:underline;">COURSE DETAILS</h2><br><br>
<table style="color:black; border:1px solid black;">
							<thead>
                   <tr style="background-color:#80bfff;">  
               <th style="font-size:12px;text-align:center;font-weight:bold;border:1px solid black;padding:8px; width:25%;">COURSE CODE</th>
               <th style="font-size:12px;text-align:center;font-weight:bold;border:1px solid black;padding:8px; width:50%;">COURSE TITLE</th>
                <th style="font-size:12px;text-align:center;font-weight:bold;border:1px solid black;padding:8px; width:10%;">UNITS</th>
                 <th style="font-size:12px;text-align:center;font-weight:bold;border:1px solid black;padding:8px; width:15%;">STATUS</th>
                   </tr>
                   </thead>		
					<tbody> 
					'.$table_row.'
					</tbody>
					</table><br>
				<p style="font-weight:normal; font-size:11px;">I certify that the above named student has submitted his/her '.strtolower($sol['semester_description']).' course form and qualify to register the above listed course(s) for the '.strtolower($sol['semester_description']).'.</p>	<br>
				<div style="border-top:1px dashed gray; width:100%; margin-bottom:30px;"></div><br><br>
				
				<h2 style="font-size:12px;">For official use</h2><br>
				<table style="color:black; border:1px solid black;">		
					<tbody> 
					<tr><td syle="font-size:11px;text-align:center;font-weight:bold;border:1px solid black;padding:14px; width:45%; font-weight:bold;"> &nbsp;&nbsp;&nbsp; H.O.D\'s Signature & Date</td> 
					<td style="width:50%;border:1px solid black;padding:14px;"></td></tr>
					</tbody>
					</table>
					
					<p style="font-size:11px; text-align:center;">Please note that registration is not complete until registration form is endorsed by the H.O.D</p>	<br>';
							
$pdf->writeHTML($html, true, false, true, false, '');
$smatric=str_replace("/", "_", $me['matric_no']);

/////////////////////////////FOR WATERMARK
$pdf->setPage(1);
// Get the page width/height
$myPageWidth = $pdf->getPageWidth();
$myPageHeight = $pdf->getPageHeight();

// Find the middle of the page and adjust.
$myX = ( $myPageWidth / 2 )-40;
$myY = ( $myPageHeight / 2 ) + 40;

// Set the transparency of the text to really light
$pdf->SetAlpha(0.09);

// Rotate 45 degrees and write the watermarking text
$pdf->StartTransform();
$pdf->Rotate(45, $myX, $myY);
$pdf->SetFont('helvetica', '', 30);
$pdf->Text($myX, $myY, $sol['session']." ".$sol['semester_description']);
$pdf->StopTransform();
// Reset the transparency to default
$pdf->SetAlpha(1);
/////////////////////////////END WATERMARK

$pdf->Output($smatric.'_CourseForm.pdf', 'I');							
							
	
	
	/////////////////////////////////////////// END PRINTING ///////////////
	/////////////////////////////////////////// END PRINTING ///////////////
	/////////////////////////////////////////// END PRINTING ///////////////
	
	}
}


?>
<!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>Print Course  Form :: 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/datatables/media/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
	<link href="vendors/bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>
		<link href="vendors/bower_components/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css"/>
		
		<link href="vendors/bower_components/sweetalert/dist/sweetalert.css" rel="stylesheet" type="text/css">
	<link href="dist/css/style.css" rel="stylesheet" type="text/css">
	
	<style>
	div#form_box{
	-webkit-transition: width 2s, height 2s, -webkit-transform 2s; /* Safari */
    transition: width 2s, height 2s, transform 2s;
	box-shadow: 6px 6px 7px gray;
}
div#form_box:hover{
    -webkit-transform: rotate(20deg); /* Safari */
    transform: rotate(20deg);
}
	</style>
	
</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"><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" class="active"><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-file-text-o"></i> PRINT COURSE FORM</span>
												</div>
											</div>	
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					
				</div>
					
				<!-- Row -->
					
				<?php 
			$max=mysqli_query($con,"select * from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !=''");
			if(mysqli_num_rows($max)>0){
			
			//to get the number of session
			$m1=mysqli_query($con,"select DISTINCT(session) from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !=''");
			
			//to get the number of semesters used so far
			$m2=mysqli_query($con,"select id from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !='' GROUP BY semester_num, session");
			
			//to get the number of course registered so far
			$m3=mysqli_query($con,"select id from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !=''");
			
			//to get the total number of units registered so far
			$m4=mysqli_query($con,"select SUM(unit) as unit from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !=''");
			$snn=mysqli_fetch_assoc($m4);
			
			//to get the number of compulsory course registered so far
			$m5=mysqli_query($con,"select id from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !='' AND status='c'");
			
			//to get the number of elective course registered so far
			$m6=mysqli_query($con,"select id from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !='' AND status='e'");
			
			//to get the number of required course registered so far
			$m7=mysqli_query($con,"select id from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !='' AND status='r'");
			
			
			echo '<div class="row">
			
			<div class="col-md-4">
			
			<div class="panel panel-inverse card-view">
							<div class="panel-heading">
									<div class="pull-left">
										<h6 class="panel-title" style="color:black; font-weight:bold; font-size:15px; margin-top:-10px; margin-bottom:-10px;">CUMULATIVE ANALYSIS <i class="fa fa-sort-numeric-asc"></i></h6>
									</div>
									</div>
							<div class="panel-wrapper collapse in">
								<div class="panel-body">
					
					<div>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o txt-warning" style="font-size:13px;"></i> Registered Sessions
										</span>
										<span class="btn btn-square btn-warning pull-right" style="font-size:18px; padding:7px 14px;">'.mysqli_num_rows($m1).'</span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10"/>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o txt-danger" style="font-size:13px;"></i> Registered Semesters
										</span>
										<span class="btn btn-square btn-danger pull-right" style="font-size:18px; padding:7px 14px;">'.mysqli_num_rows($m2).'</span>
										<div class="clearfix"></div>
										<hr class="light-grey-hr row mt-10 mb-10"/>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o txt-success" style="font-size:13px;"></i> Total Registered Courses
										</span>
										<span class="btn btn-square btn-success pull-right" style="font-size:18px; padding:7px 14px;">'.mysqli_num_rows($m3).'</span>
										<div class="clearfix"></div>
										
										<hr class="light-grey-hr row mt-10 mb-10"/>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o txt-primary" style="font-size:13px;"></i> Total Number of Units
										</span>
										<span class="btn btn-square btn-primary pull-right" style="font-size:18px; padding:7px 14px;">'.$snn['unit'].'</span>
										<div class="clearfix"></div>
										
										<hr class="light-grey-hr row mt-10 mb-10"/>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o txt-info" style="font-size:13px;"></i> Compulsory Courses Registered
										</span>
										<span class="btn btn-square btn-info pull-right" style="font-size:18px; padding:7px 14px;">'.mysqli_num_rows($m5).'</span>
										<div class="clearfix"></div>
										
										<hr class="light-grey-hr row mt-10 mb-10"/>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o" style="font-size:13px;"></i> Elective Courses Registered
										</span>
										<span class="btn btn-square btn-default pull-right" style="font-size:18px; padding:7px 14px;">'.mysqli_num_rows($m6).'</span>
										<div class="clearfix"></div>
										
										<hr class="light-grey-hr row mt-10 mb-10"/>
										<span style="font-size:18px;" class="pull-left inline-block capitalize-font txt-dark">
											<i class="fa fa-circle-o txt-success" style="font-size:13px;"></i> Required Courses Registered
										</span>
										<span class="btn btn-square btn-success pull-right" style="font-size:18px; padding:7px 14px;">'.mysqli_num_rows($m7).'</span>
										<div class="clearfix"></div>
										
										
									</div>
									 
									 </div>
									 </div>
									 </div>
			
			
			</div>
			<div class="col-md-8">
			<div class="row">';
			
			//$mc=mysqli_query($con,"select * from `semester` where programme_id='".$me['programme_id']."' AND session !='' order by session desc, semester desc");
			$mc=mysqli_query($con,"select id,semester_num,session,semester_description from reg_course where sid='".$_SESSION['stureg_id']."' AND  matric_no='".$me['matric_no']."' AND programme_id='".$me['programme_id']."' AND dep_id='".$me['dept_id']."' AND session !='' GROUP BY semester_num, session order by session desc, semester_num desc");
			
			if(mysqli_num_rows($mc)>0){
			while($ala=mysqli_fetch_assoc($mc)){	
				
					$rand=rand(1,6);
						if($rand==1){
							$color='#ffb31a';
						}else if($rand==2){
							$color='#0066ff';
						}else if($rand==3){
							$color='#e60000';
						}else if($rand==4){
							$color='#00994d';
						}else if($rand==5){
							$color='#ffb31a';
						}else if($rand==6){
							$color='#cc0066';
						}else{
							$color='#00b2b3';
						}
			
			echo '<div class="col-md-6">
						<a href="?print_form='.$ala['id'].'&pid='.uniqid().'" data-toggle="tooltip" data-placement="top" title="Download Course Form">
						<div class="panel panel-default card-view pa-0" id="form_box" style="border-radius:20px 0 20px 0; background-color:white; border:5px solid '.$color.';">
							<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 class="col-xs-6 text-center pl-0 pr-0 data-wrap-left">
													<span class="txt-dark block counter">
													<span style="font-weight:600; font-size:20px; color:'.$color.';">'.$ala['session'].'</span></span>
												</div>
												<div class="col-xs-6 text-center data-wrap-right">
									<i style="font-size:53px; color:black;" class="pull-right icon-layers data-right-rep-icon"></i> 
									<div class="clearfix"></div>
												</div>
												
										<div class="weight-500" style="padding-left:25px; padding-bottom:20px; text-align:center; font-size:20px; color:black;">
										'.ucwords(strtolower($ala['semester_description'])).'
										</div>
											</div>	
										</div>
									</div>
								</div>
							</div>
						</div></a>
						</div>';
			
			}	
			}	
			echo '</div></div></div>';
			}else{
				
				echo '<div class="row">
					<div class="col-lg-12 col-xs-12">
					
					<div class="panel panel-default card-view">
					<div class="panel-wrapper collapse in">
					<div class="panel-body" align="center">
					<img src="img/error-man.png" style="width:300px;" class="img-responsive">
					<div style="margin-bottom:30px; margin-top:-40px; font-weight:400;"><h2 style="font-size:26px; color:#891200;"><span style="font-weight:900;font-size:34px;">Oh No!</span> You are yet to register for any course...</h2></div>
					</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(){
		
		$("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_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>
	
	
	<!-- Switchery JavaScript -->
		<script src="vendors/bower_components/switchery/dist/switchery.min.js"></script>
		<script src="vendors/bower_components/sweetalert/dist/sweetalert.min.js"></script>
		
		
		<!-- Data table JavaScript -->
	<script src="vendors/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
	<script src="vendors/bower_components/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
	<script src="vendors/bower_components/datatables.net-buttons/js/buttons.flash.min.js"></script>
	<script src="vendors/bower_components/jszip/dist/jszip.min.js"></script>
	<script src="vendors/bower_components/pdfmake/build/pdfmake.min.js"></script>
	<script src="vendors/bower_components/pdfmake/build/vfs_fonts.js"></script>
	
	<script src="vendors/bower_components/datatables.net-buttons/js/buttons.html5.min.js"></script>
	<script src="vendors/bower_components/datatables.net-buttons/js/buttons.print.min.js"></script>
	<!--<script src="dist/js/export-table-data.js"></script>-->
	
	
	<script type="text/javascript" src="vendors/bower_components/moment/min/moment-with-locales.min.js"></script>
		<script src="vendors/bower_components/mjolnic-bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
		<script type="text/javascript" src="vendors/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
		<!--<script src="dist/js/form-picker-data.js"></script>
		
		
		<script src="dist/js/form-advance-data.js"></script>-->
	
	<!-- Slimscroll JavaScript -->
	<script src="dist/js/jquery.slimscroll.js"></script>
	
	<!-- Fancy Dropdown JS -->
	<script src="dist/js/dropdown-bootstrap-extended.js"></script>
	
	<!-- Switchery JavaScript -->
	<script src="vendors/bower_components/switchery/dist/switchery.min.js"></script>
	
	<!-- Bootstrap Tagsinput JavaScript -->
		<script src="vendors/bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>
	<script src="dist/js/init.js"></script>
	<script src="dist/js/dashboard-data.js"></script>

</body>

</html>
