<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['addseminar'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record
	$qry2=mysqli_query($con, "INSERT INTO epci_seminar values ('', '$applicant_idpci', '$seminarTitle', '$seminarOrganizer', '$seminarCpd', '$seminarDate')");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
	}
	
    
}



?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle">DETAILS OF CONTINUING PROFESSIONAL DEVELOPMENT</h2>
Please list all relevant CPD activities attended.
	<div class="graph-form">
    		<div class="form-body">
				<?php
				//GET DETAILS FROM DB
	
				$q = "Select * from epci_seminar where applicant_id='$applicant_idpci'";
				$qry=mysqli_query($con, $q);
				if($qry){
					$totalcpd = 0;
					if(mysqli_num_rows($qry) >0){
						$yyy = 1;
						echo "<table border='1' width='100%'>";
						echo "<tr><td><b>SN</b></td> <td><b>Title </b></td>  <td><b>Date </b></td>  <td><b>Organizer </b></td>  <td><b>CPD Units</b></td> </tr> ";
						
						while($row=mysqli_fetch_assoc($qry))
						{
							extract($row);
							echo "<tr><td>$yyy</td> <td>$seminarTitle </td> <td>$seminarDate </td> <td>$seminarOrganizer </td> <td>$seminarCpd</td> </tr>";
							$totalcpd = $totalcpd + $seminarCpd;
							$yyy++;
						}
						
						echo "</tables>";
						
					}else{ $errmsg=''; }
							
				}else{
					$errmsg='';
				}
				
				?>
			
			
			
			
    			<form method="post" name="seminarform" action="index.php?page=seminar"> 
                <?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>Title</label> 
                        <input type="text" class="form-control" name="seminarTitle" placeholder="Seminar Theme/Title" required="" />  
                    </div> 
                    
					<div class="form-group"> 
                        <label>Organizer</label> 
                        <input type="text" class="form-control" name="seminarOrganizer" placeholder="organized by	" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>CPD Units</label> 
                        <input type="text" class="form-control" name="seminarCpd" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Date</label> 
                        <input type="date" class="form-control" name="seminarDate" required="" />  
                    </div> 
                    
					
                    <input name="addseminar" type="submit" class="btn btn-default" value="Add"/> 
                </form> 
    		</div>
    
    </div>

</div>

<div>
<a href='?page=employer'><button class='btn'>Back</button></a>

<?php
if($totalcpd>59){
	echo "<a href='?page=sponsor'><button class='btn'>Next</button></a>";
}elseif(($totalcpd>0)&&($totalcpd<60)){ echo " Add more CPD activities to proceed";

}else{ echo " Add your CPD activities to proceed";}
?>
</div>