<?php
	error_reporting(0);
	define('INCLUDE_CHECK',true);
	session_start();
	require ('classes/config.php');
	require_once('classes/session.php');
	
	if(isset($_POST['adm'])) {  
			$checkbox1=$_POST['sadmitted'];  
			$chk="";  
			foreach($checkbox1 as $chk1) {  
			  	$chk = $chk1;  
		   	  	$chk_form = substr($chk,0,9);
				$chk_type = substr($chk,9,12);
			$sql = mysql_query("INSERT INTO cap_admission_status(formno,status,entry,acpt,type,pass,session,date_admitted,access) values ('$chk_form','ADMITTED','{$_SESSION['entry']}','no','$chk_type','{$_SESSION['pass']}','{$_SESSION['sek']}',NOW(),'active')"); 
			$sqlupdate=mysql_query("UPDATE admitted_student_details_2019 SET status ='admitted' WHERE formno='$chk_form'")or die ('An error occured ' . mysql_error());} 
			if($sql==1){  
			  echo'<script>alert("Admitted Successfully")</script>';  
		   	}else{  
			  echo'<script>alert("Failed To Admitted")</script>';
		   	} 
		}   
?>
<title>OSCOTECH, ESA-OKE :: Admin-Dashboard > CAP Admission Operation Student List</title>


        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">CAP Admission List By Programme and Department</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                	<div class="well" style="background:#FFF">
                    	<form method="post" action="" role="form">                        	
                        	<div class="form-group input-group">
                        	<table class="table table-bordered table-hover">
                            	<tr>
                                	<td>
                                        <select name="courses" id="courses"  class="form-control">
                                          <option value="">-- Select Department -- </option>
                                            <?php 
                                                    $getdept = mysql_query("SELECT department FROM school_setup WHERE programme='BF'");
                                                    while($row = mysql_fetch_array($getdept)){
                                                ?>
                                                    <option value="<?php echo $row['department'] ?>"><?php echo $row['department']?></option>
                                                <?php
                                                    }
                                            ?>
                                        </select>
                                	</td>
                                    <td>
                                    	<select name="programme" class="form-control" id="programme">
                                            <option value="">--Select Programme--</option>
                                            <option value="Cert.">Certificates</option>
                                            <option value="Adv. Cert.">Advance Certificates</option>
                                            <option value="ND">National Diploma</option>
                                            <option value="HND">Higher National Diploma</option>
                                            <option value="PGD">Post Graduate Diploma</option>
                                            <option value="PreND">Basic and Foundational Studies</option>
                                        </select>
                                    </td>
                                    <td>
                                    	<select name="session" class="form-control" id="session">
                                            <option value="">--Select Session--</option>
                                            <option value="2015/2016">2015/2016</option>
                                            <option value="2016/2017">2016/2017</option>
                                            <option value="2017/2018">2017/2018</option>
                                            <option value="2018/2019">2018/2019</option>
                                            <option value="2019/2020">2019/2020</option>
                                        </select>
                                    </td>
                                    <td>
				                       <input type="text" class="form-control" placeholder="From: yyyy-mm-dd"name="fromdate" title="Uploading Date " autocomplete="on">
                                    </td>
                                    <td>
				                       <input type="text" class="form-control" placeholder="To: yyyy-mm-dd"name="todate" title="Uploading Date " autocomplete="on">
                                    </td>
                                	<td>
                                        <span class="input-group-btn">
                                            <input type="submit" class="btn btn-danger" name="btnsearch" value="Search" id="button-search" title="Search Student">
                                        </span>
                                    </td>
                             	</tr>
                            </table>
                            </div>
                        </form>
                    </div>
                    <form action="" method="post">
                    <div class="panel panel-primary chat-panel">
                        <div class="panel-heading ">
                            Student Details Table
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                        <tr height="20">
                                            <th>S/N</th>
                                            <th>FORM NO</th>
                                            <th>SURNAME</th>
                                            <th>OTHER NAMES</th>
                                            <th>PHONE</th>
                                            <th>PROGRAMME</th>
                                            <th>COURSES</th>
                                            <th>PROV</th>
                                            <th>CONC</th>
                                        </tr>
                                    </thead>
					<?php
							$_SESSION['sek']= $_POST['session'];
							$_SESSION['courses']= $_POST['courses'];
							$_SESSION['programme']= $_POST['programme'];
							$_SESSION['fromdate']= $_POST['fromdate'];
							$_SESSION['todate']= $_POST['todate'];
							$courses=$_POST['courses'];
							$key="CA";
							echo $courses,$_POST[programme],$_POST[session];
							
                        	if($_POST[fromdate]=="" || $_POST[todate]=="")
								$sql = mysql_query("SELECT * FROM dmitted_student_details_2019
										WHERE courses='$courses' AND programme='$_POST[programme]' 
										AND formno  like '%$key%' AND session='$_POST[session]' 
										AND status='not-admitted'");
										
						//	elseif($_POST[courses]=="" || $_POST[programme]=="" || $_POST[session]=="" || $_POST[fromdate]=="" || $_POST[todate]=="")								
							//	$sql = mysql_query("SElECT * FROM admission_students_details");
							else							
								$sql = mysql_query("SELECT * FROM dmitted_student_details_2019
										WHERE courses='$courses' AND programme='$_POST[programme]' 
										AND formno  like '%$key%'
										AND reg_date Between '$_POST[fromdate]' AND '$_POST[todate]'
										AND session='$_POST[session]' AND status='not-admitted'");
                           
                        $i=0;
                        while($row=mysql_fetch_array($sql)){
                        $i++;
                        $color=($i%2==0)?"lightblue":"white";
                    ?>
                                    <tbody>
                                        <tr >
                                        	<td><?php echo $i;?></td>
                                            <td><?php echo $row['formno'];?></td>
                                            <td><?php echo $row['surname'];?></td>
                                            <td><?php echo $row['othernames'];?></td>
                                            <td><?php echo $row['phone'];?></td>
                                            <td><?php echo $row['programme'];?></td>
                                            <td><?php echo $row['courses'];?></td>
                                            <td><input type="checkbox" name="sadmitted[]" value="<?php echo $row['formno']."PRO";?>" /></td>
                                            <td><input type="checkbox" name="sadmitted[]" value="<?php echo $row['formno']."CON";?>" /></td>
                                        </tr>
                                    </tbody>
                          <?php	
							}
							if ($_SESSION['programme']=='HND'){ ($_SESSION['pass'] ="HND") AND ($_SESSION['entry'] ="Higher National Diploma, Weekend Part Time-2years");}
							elseif ($_SESSION['programme']=='ND'){ ($_SESSION['pass'] ="ND") AND ($_SESSION['entry'] ="National Diploma, Weekend Part Time-3years");}
							elseif ($_SESSION['programme']=='Adv. Cert.'){ ($_SESSION['pass'] ="Adv. Cert.") AND ($_SESSION['entry'] ="Advance Certificates, Weekend Part Time-1years");}
							
							// Adv. Cert.">Advance Certificates
							?>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                          
                        </div>
                        <!-- /.panel-body --> 
                    </div> 
                    <!-- /.panel -->
                    	<center>
                       		<!-- <a href="#" target="_new" class="btn btn-success">ADMITTED</a> -->
                            <input type="submit" class="btn btn-success" value="ADMITTED" name="adm" />
                            <p>&nbsp;</p>
                        </center>
                    </form>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->

        </div>
        <!-- /#page-wrapper -->
       

    </div>
    <!-- /#wrapper -->
    
