<?php
    // Start the session
    session_start();
    
    //after the submit 
    if(isset($_POST['supnote']) && isset($_POST['empnote']) 
        && isset($_POST['internote']) && isset($_SESSION['idSession'])){
            
            //Array contains all the informations submitted by the user
           $storage = array();
           $global_evaluation = array();
           
           //taking the current values
           $str = file_get_contents($_SESSION['idSession'].".json");
           $storage = json_decode($str, true);
           
           $global_evaluation['Supervisor Note'] = $_POST['supnote'];
           $global_evaluation['Employee Note'] = $_POST['empnote'];
           $global_evaluation['Interest Note'] = $_POST['internote'];
           
           $storage['Global evaluation'] = $global_evaluation;
           
           //store elements in a json file
           $fp = fopen($_SESSION['idSession'].".json", 'w');
           fwrite($fp, json_encode($storage));
           fclose($fp);
           header('location: form_developement_plan.php');
    }
?>

<!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">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript" src="js/clone-form-td.js"></script>
	</head>
	</head>
	<body>
	    <section class="body-sign">
			<div class="center-sign">
				<form action="form_global_evaluation.php" method="post" id="sign-up_area" role="form">
					<!-- Default input password -->
    				<p class="h4 text-center mb-4">Évaluation Globale </p>
    				<!-- input employee name -->
    				<label class="grey-text-inline" >Sous Total Section 1 : </label>
    				<input type="text" class="form-control-inline" name="total1" readonly="readonly">

    				<br><br>
    				
    				<label class="grey-text-inline" >Sous Total Section 2 : </label>
    				<input type="text" class="form-control-inline" name="total2" readonly="readonly">
    				<br><br>
    				
    				<label class="grey-text-inline" >Note Globale : </label>
    				<input type="text" class="form-control-inline" name="globnote" readonly="readonly">
    				<br><br>
    				
    				<label class="grey-text-inline" >Commentaires du gestionnaire </label>
    				<textarea id="notes" name="supnote" class="form-control" placeHolder = "Entrez le commentaire ici"></textarea>
    				<br><br>
    				<label class="grey-text-inline" >Commentaires de l’employé </label>
    				<textarea id="notes" name="empnote" class="form-control" placeHolder = "Entrez le commentaire ici"></textarea>
    				<br><br>
    				
    				<label class="grey-text-inline" > Commentaires sur les champs d’intérêt de l’employé </label>
    				<textarea id="notes" name="internote" class="form-control" placeHolder = "Entrez le commentaire ici"></textarea>
    				<br><br>
					
    				<div class="text-center mt-4">
        				<button class="btn btn-indigo" type="submit">Suivant</button>
    				</div>
				</form>
			</div>
		</section>
	</body>
</html>