
<?php require_once("includes/initialize.php");

global $database;
$alldept = ONLINEPAY:: showdept();
$allsession = ONLINEPAY:: showsession();
session_start();

// $display_course = COURSECLASS::fetch_all_course($biodata->courses, $level, $semester);

$succ='';
// if (isset($_POST['update1']) AND isset($_POST['update2'])){
   
//      echo '<h3>'.'Delete duplicate record before the update'.'</h3>';
// }else 
if (isset($_POST['update1'])){
    

      $table= $_SESSION['tbl'];
    $sem =  $_SESSION['sem'];
   $mat = $_SESSION['matricno'];
    
    $result = ONLINEPAY::updatestucourse($table,$sem,$mat);
    if ($result){
         $succ=1;
       echo '<h3>'.'Update successful. Print the course form'.'</h3>';
    }else {
        echo '<h3>'.'No changes performed on the student record'.'</h3>';
    // }else{
    //     $succ=0;
    }
}else {
    //echo 'No data found';
}


if (isset($_POST['delete1']) OR isset($_POST['delete2'])){
    
    $succ='';
    $table= $_SESSION['tbl'];
    $sem =  $_SESSION['sem'];
    $mat = $_SESSION['matricno'];
    
    $result2 = ONLINEPAY::deletestucourse($table,$mat);
    if ($result2){
       echo '<h3>'.'Delete successful'.'</h3>';
    }else{
        echo '<h3>'.'No changes performed on the student record'.'</h3>';
    }
}else {
    //echo 'No data found';
}

if ($succ){
    
   
        $result = ONLINEPAY::findstucourse($table,$mat);
}
?>

<body>
  <div class="container box">
   <h2 align="center">Correct Course Form Printing</h2>
   <h3 align="center"></h3>
   <br />
    	<div class="form-group input-group" align="center">
    	<table class="table table-bordered table-hover">
    	    
    	    <div class="form-group input-group" align="center">
            <div class="col-lg-12 col-xs-12">
              <span class="input-group-btn">
                <input type="text" class="form-control" placeholder="Matric No/Form No "name="matricno" id="matricno" title="Matriculation Number " autocomplete="off">  
                </span>
              </div>
            </div><br/>  
    	    
        	<tr>
        	    
    <!--    	    <td>-->
				<!--<select name="department" id="department" class="form-control action" style="width:200px">-->
				<!--	<option value="">Select Department</option>-->
				<!--	<option value="">All Department</option>-->
				<!--		<?php //foreach($alldept as $dept){?>-->
				<!--		<option value="<?php //echo $dept->department;?>">
				<?php
				//echo ucwords($dept->department);
				?></option> 
				<?php //}?>
				<!--</select></td>-->
        	    
        	    <td>
                	<select name="session" id="session" class="form-control action" style="width:120px" required>
						<option value="">Select Session</option>
						<option value="2018">2018/2019</option>
						<option value="2019">2019/2020</option>
	                    <option value="2020">2020/2021</option>
	                    
					</select>
                </td>
                
                <td>
                	<select name="level" id="level" class="form-control action" style="width:120px" required>
						<option value="">Select Level</option>
						<option value="ND I">ND I</option>
						<option value="ND II">ND II</option>
	                    <option value="HND I">HND I</option>
	                    <option value="HND II">HND II</option>
					</select>
                </td>
    			<td>
                    <select name="semester" id="semester" class="form-control action" style="width:120px" required>
                        <option value="">Select Semester</option>
                        <option value="First">First Semester</option>
                        <option value="Second">Second Semester</option>
                    </select>
				</td>
            	<td>
                    <span class="input-group-btn">
                        <input type="submit" class="btn btn-danger" name="search" value="Search" id="search">
                    </span>
                </td>
         	</tr>
        </table>
        </div>
    </br>
    <div class="art-content-layout">
        <div id="mytable">
   
        <h3 style="color:#033;">Registered Semester Courses</h3>
              
        </div>

        <?php
        
        if ($result && (sizeof($result)>0)){
            
             echo '<table class="table table-striped table-bordered">
 
			                <tr>
			                    <th>Matric No</th>  
			                    <th>Semester</th>  
			                    <th>Department</th>
			                    <th>Courses</th>
								<th>Select</th>
							
			                </tr>
			        	';
    if (isset($result)&& (!empty($result)>0))
    {
    foreach ($results as $res) {
       
        $_SESSION['count']= $count++;
        $i++;
        echo '<tr>'
            . '<td>' . $res->matricno . '</td>'
            . '<td>' . $res->ses_sem_id . '</td>'
            . '<td>' . $res->department . '</td>'
            . '<td>' . $res->courses . '</td>'
            . '<td>'. '<input type="submit" name="'.'print'.'" class="btn btn-success" id="print" value="Print">'.'</td></tr>';
            // <td><button type="button" name="delete" class="btn btn-danger btn-xs delete" id="'.$row->id.'">Delete</button></td>


           
    }
    
    }
    echo '</table>';


    
        }
        ?>
</div>


       



</article></div>
<style>
    #accept:hover {
        text-decoration: none;
        font-style: italic;
    }
</style>
<script src="../javascripts/jquery.min.js"></script>
<script src="../javascripts/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function () {

    //e.preventDefault();
  
   
          $('#search').click(function () {
           
          
            if ($('#level').val() != '' && ($('#semester').val() != '' ) && ($('#matricno').val() != '' )) {
                
                var session = $('#session').val();
                var level = $('#level').val();
                var semester = $('#semester').val();
                 var matricno = $('#matricno').val();
                
                 
                // alert('Value found: '+ session+" "+ level +" "+semester+ " "+ matricno);
                 
                 
                 $.ajax({
                        method: "POST",
                        url: "course_error_finder.php",
                        data: {session:session, level: level, semester: semester, matricno:matricno},
                        success: function (data) {
                           alert('Loading reg history from reg data bank'),
                          // alert(data),
                            $('#mytable').html(data);
                        }
                       
                        
                       
                    })
                    
           } 


           
    })
       
       
    
         $('#print').click (function () {
             
             //alert('ggggggg');
        
        // $.ajax({
        //                 method: "POST",
                        
                        var win = window.open('http://eportal.oscotechesaoke.edu.ng/admin_report1/reprint_coursess.php/', '_blank');
                        
                        
                        if (win) {
                          win.focus();
                        } else {
                         alert('No data to print');
                         
                        }
                       
                        
                       
                    // })
            
             
            })
})
</script>        
                
                
    
   
          
