<?php
$errmsg='';
$sucmsg='';


    if(isset($_GET["i"])){
		$applicant_idgdef = $_GET["i"];
	}

if(isset($_POST['update'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record

    if(isset($_GET["i"])){
		$applicant_idgdef = $_GET["i"];
	}

	$qry2=mysqli_query($con, "UPDATE prob_logbook SET logbookMonth='$logbookMonth', logbookYear='$logbookYear' where applicant_id='$applicant_idgdef'");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
	}
	
    
}



//GET DETAILS FROM DB
	
	$q = "Select * from prob_logbook where applicant_id='".$_GET['i']."'";
    //echo $q;

    $qry=mysqli_query($con, $q);
	if($qry){
		
		if(mysqli_num_rows($qry) >0){
			$row=mysqli_fetch_assoc($qry);
			extract($row);
			
		}else{ $errmsg='details not found!'; }
				
	}else{
		$errmsg='details not found!';
	}
?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle"> PATICULARS OF LOGBOOK/DIARY STAGE 1 PASSED </h2>
	<div class="graph-form">
    		<div class="form-body">
    			
                <form method="post" name="logbookform" action="index.php?page=logbook&i=<?php echo $_GET['i']; ?>">  
                
                <?php 
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
                }
                
                ?>
                    <div class="form-group"> 
                        <label>Assessment Month</label> 
                        <!--input type="text" class="form-control" name="logbookMonth" value="<?php echo $logbookMonth; ?>" required="" /--> 
                         
                         <select class="form-control" name="logbookMonth" style="width:100%; height:auto" required="">
                         <?php echo "<option>$logbookMonth</option>"; ?> 
                         <option>JANUARY</option>
                         <option>FEBRUARY</option>
                         <option>MARCH</option>
                         <option>APRIL</option>
                         <option>MAY</option>
                         <option>JUNE</option>
                         <option>JULY</option>
                         <option>AUGUST</option>
                         <option>SEPTEMBER</option>
                         <option>OCTOBER</option>
                         <option>NOVEMBER</option>
                         <option>DECEMBER</option>
                         
                        </select> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Assessment Year</label> 
                        <!--input type="text" class="form-control" name="logbookYear" value="<?php echo $logbookYear; ?>" required="" /--> 
                        <select class="form-control" name="logbookYear" style="width:100%; height:auto" required="">
                         <?php echo "<option>$logbookYear</option>"; $y=date('Y'); for($iy=$y; $iy>1960; $iy--){ echo "<option>$iy</option>"; } ?>
                        </select>
                    </div> 
                    
                    <input name="update" type="submit" class="btn btn-default" value="Update Details"/> 
                </form> 
    		</div>
    
    </div>

</div>

<?php
	echo "<div><a href='?page=body&i=".$_GET['i']."'><button class='btn'>Back</button></a> ";
	
 if(!empty($logbookMonth) && !empty($logbookYear))
 {
	echo " <a href='?page=exemption&i=".$_GET['i']."'><button class='btn'>Next</button></a></div>";
 }
 ?>