<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['update'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record
	$qry2=mysqli_query($con, "UPDATE pci_logbook SET logbookMonth='$logbookMonth', logbookYear='$logbookYear' where applicant_id='$applicant_idpci'");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
	}
	
    
}



//GET DETAILS FROM DB
	
	$q = "Select * from pci_logbook where applicant_id='$applicant_idpci'";
    $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 3 PASSED </h2>
	<div class="graph-form">
    		<div class="form-body">
    			<form method="post" name="logbookform" action="index.php?page=logbook"> 
                <?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> 
                         <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> 
                        <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>

   
<div>
<a href='?page=tpc'><button class='btn'>Back</button></a>
<?php
if(strlen($logbookMonth)>0){
 echo "<a href='?page=experience'><button class='btn'>Next</button></a>";
}

?>
</div>
