<?php
    // Start the session
    session_start();
    
    //after the submit 
    if(isset($_POST['employname']) && isset($_POST['employpos']) && isset($_POST['supname']) && 
        isset($_POST['divname']) && isset($_POST['depname']) && isset($_POST['meetdate']) ){
            
            //Array contains all the informations submitted by the user
           $storage = array();
           $general_informations = array();
           
           $general_informations['Employee name'] = $_POST['employname'];
           $general_informations['Supervisor name'] = $_POST['supname'];
           $general_informations['Division name'] = $_POST['divname'];
           $general_informations['Department Name'] = $_POST['depname'];
           $general_informations['Meeting Date'] = $_POST['meetdate'];
           
           $storage['General Informations'] = $general_informations;
           
           //store elements in a json file
           $fp = fopen($_SESSION['idSession'].".json", 'w');
           fwrite($fp, json_encode($storage));
           fclose($fp);
           header('location: form_objective.php');
    }
    //the first access of this page will generate the session token
    else{
        //the session id will also be the json temporary file name
        $_SESSION['idSession'] = uniqid();
    }
?>

<!doctype html>
<html class="fixed">
	<head>
		<head>
		<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
	</head>
	</head>
	<body>
    	<section class="body-sign">
    			<div class="center-sign">
    				<form action="form_general_informations.php" method="post">
        				<p class="h4 text-center mb-4">Renseignement généraux </p>
        				<!-- input employee name -->
        				<label class="grey-text" >Nom de l'employé : </label>
        				<input type="text" class="form-control" name="employname">
        				<br>
        				
        				<!--  input employee position -->
        				<label class="grey-text">Poste de l'employé : </label>
        				<input type="text" class="form-control" name="employpos">
        				<br>
        				
        				<!-- input employee administrator -->
        				<label class="grey-text">Nom du gestionnaire immeditat : </label>
        				<input type="text" class="form-control" name="supname">
        				<br>
        				
        				<!-- input employee division -->
        				<label class="grey-text">Nom du secteur : </label>
        				<br>
        				<select class="select_ttl form-control" name="divname">
      						<option>Secteur corpo CH</option>
     						<option>Fondation</option>
      						<option>Sports</option>
      						<option>evenko</option>
     						<option>Spectra</option>
    					</select>
        				<br>
        				
        				<!-- input employee department -->
        				<label class="grey-text"> Nom du département : </label>
        				<input type="text" class="form-control" name="depname">
        				<br>
        				
        				<!-- input date of meeting -->
        				<label class="grey-text"> Date de la rencontre : </label>
        				<input type="date" class="form-control" name="meetdate">
        				<br>
    					
        				<div class="text-center mt-4">
            				<button class="btn btn-indigo" type="submit">Suivant</button>
        				</div>
    				</form>
    			</div>
    		</section>
	</body>
</html>