<?php
    // Start the session
    session_start();

    if(isset($_POST['radioitem1']) && isset($_POST['radioitem2']) && isset($_POST['radioitem3']) && 
        isset($_POST['radioitem4']) && isset($_POST['radioitem5']) && isset($_POST['radioitem6']) && 
            isset($_POST['radioitem7']) && isset($_POST['radioitem8']) && isset($_POST['radioitem9'])
                && isset($_SESSION['idSession'])){
                    
            //Array contains all the informations submitted by the user
           $storage = array();
           $contribution = array();
           
           //taking the current values
           $str = file_get_contents($_SESSION['idSession'].".json");
           $storage = json_decode($str, true);
           
           $contribution['Qualite du Travail'] = $_POST['radioitem1']; 
           
           $contribution['Organisation'] = $_POST['radioitem2']; 
           
           $contribution['Creativite'] = $_POST['radioitem3']; 
           
           $contribution['Collaboration'] = $_POST['radioitem4'];
           
           $contribution['Sens client'] = $_POST['radioitem5']; 
           
           $contribution['Habilite de Communication'] = $_POST['radioitem6'];
           
           $contribution['Agilite'] = $_POST['radioitem7'];
           
           $contribution['Centre sur les resultats'] = $_POST['radioitem8'];
           
           $contribution['Gestion du stress'] = $_POST['radioitem9']; 
           
           if(isset($_POST['radioitem10']) && isset($_POST['radioitem11']) 
                && isset($_POST['radioitem12']) && $_SESSION['isGestionnaire']){
                    
               $contribution['Courage Managerial'] = $_POST['radioitem10'];
               
               $contribution['Capacite a mobiliser'] = $_POST['radioitem11']; 
               
               $contribution['Elaboration des strategies'] = $_POST['radioitem12'];
           }
           
           $storage['Personal Contribution'] = $contribution;
           
           //store elements in a json file
           $fp = fopen($_SESSION['idSession'].".json", 'w');
           fwrite($fp, json_encode($storage));
           fclose($fp);
           
           header('location: form_global_evaluation.php');
           die();
    }
?>

<!doctype html>
<html class="fixed">
	<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>
	<body>
	<section class="body-sign">
			<div class="center-sign">
				<form action="form_personal_contribution.php" method="post" id="sign-up_area" role="form">
					<!-- Default input password -->
    				<p class="h4 text-left mb-4">Gestion du travail </p>
    				<!-- input employee name -->
    				<label class="grey-text" >Qualité du travail : </label>
		            <div class="input-group form-group">
    		          	<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem1" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem1" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem1" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem1" id="radioitem-4" value="4">4
    				    </label>
		            </div>
    				<br>
    				
    				<!--  input employee position -->
    				<label class="grey-text">Organisation / gestion du temps : </label>
					<div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem2" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem2" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem2" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem2" id="radioitem-4" value="4">4
    				    </label>
	                </div>
    				<br>
    				
    				<!-- input employee administrator -->
    				<label class="grey-text">Sens de l'innovation créativité </label>
					<div class="input-group form-group">
	          		    <label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem3" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem3" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem3" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem3" id="radioitem-4" value="4">4
    				    </label>
	                </div>
    				<br>

					<p class="h4 text-left mb-4">Gestion des relations </p>
    				<!-- input employee name -->
    				<label class="grey-text" >Collaboration : </label>
		            <div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem4" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem4" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem4" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem4" id="radioitem-4" value="4">4
    				    </label>
		            </div>
    				<br>
    				
    				<!--  input employee position -->
    				<label class="grey-text">Sens client : </label>
					<div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
    		              	<input class="input_radio" type="radio" name="radioitem5" id="radioitem-0" value="1">
    		              	1
			            </label>
			            <label class="radio-inline" for="radioitem-1">
				            <input class="input_radio" type="radio" name="radioitem5" id="radioitem-1" value="2">
				            2
			           </label>
					   <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem5" id="radioitem-0" value="3">
    						3
					    </label>
					    <label class="radio-inline" for="radioitem-1">
						    <input class="input_radio" type="radio" name="radioitem5" id="radioitem-1" value="4">
						    4
					    </label>
		            </div>
    				<br>


						<!-- input employee administrator -->
    				<label class="grey-text">Habilité de communications </label>
					<div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem6" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem6" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem6" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem6" id="radioitem-4" value="4">4
    				    </label>
		            </div>
    				<br>

                    <p class="h4 text-left mb-4">Gestion de soi </p>
    				<!-- input employee name -->
    				<label class="grey-text" >Agilité : </label>
		            <div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem7" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem7" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem7" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem7" id="radioitem-4" value="4">4
    				    </label>	 
		            </div>
    				<br>


						<!--  input employee position -->
    				<label class="grey-text">Centré sur les résultats : </label>
					<div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem8" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem8" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem8" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem8" id="radioitem-4" value="4">4
    				    </label>
		            </div>
    				<br>
    				
    				<!-- input employee administrator -->
    				<label class="grey-text">Gestion du stress </label>
					<div class="input-group form-group">
		          		<label class="radio-inline" for="radioitem-0">
        		            <input class="input_radio" type="radio" name="radioitem9" id="radioitem-1" value="1">1
    			        </label>
    			        <label class="radio-inline" for="radioitem-1">
    				        <input class="input_radio" type="radio" name="radioitem9" id="radioitem-2" value="2">2
    			        </label>
    			         <label class="radio-inline" for="radioitem-0">
    						<input class="input_radio" type="radio" name="radioitem9" id="radioitem-3" value="3">3
    				    </label>
    				    <label class="radio-inline" for="radioitem-1">
    					    <input class="input_radio" type="radio" name="radioitem9" id="radioitem-4" value="4">4
    				    </label>
		            </div>
    				<br>
    				
    				<?php
    				    //If the employe is a supervisor he can fill these 3 sections
    				    if (isset($_SESSION['isGestionnaire'])){
    				?>
    				    <p class="h4 text-left mb-4">Gestion d’équipe </p>
    				    <!-- input employee name -->
        				<label class="grey-text" >Courage Managerial : </label>
    		            <div class="input-group form-group">
    		          		<label class="radio-inline" for="radioitem-0">
            		            <input class="input_radio" type="radio" name="radioitem10" id="radioitem-1" value="1">1
        			        </label>
        			        <label class="radio-inline" for="radioitem-1">
        				        <input class="input_radio" type="radio" name="radioitem10" id="radioitem-2" value="2">2
        			        </label>
        			         <label class="radio-inline" for="radioitem-0">
        						<input class="input_radio" type="radio" name="radioitem10" id="radioitem-3" value="3">3
        				    </label>
        				    <label class="radio-inline" for="radioitem-1">
        					    <input class="input_radio" type="radio" name="radioitem10" id="radioitem-4" value="4">4
        				    </label>	 
    		            </div>
        				<br>
    
    
    						<!--  input employee position -->
        				<label class="grey-text">Capacité à mobiliser : </label>
    					<div class="input-group form-group">
    		          		<label class="radio-inline" for="radioitem-0">
            		            <input class="input_radio" type="radio" name="radioitem11" id="radioitem-1" value="1">1
        			        </label>
        			        <label class="radio-inline" for="radioitem-1">
        				        <input class="input_radio" type="radio" name="radioitem11" id="radioitem-2" value="2">2
        			        </label>
        			         <label class="radio-inline" for="radioitem-0">
        						<input class="input_radio" type="radio" name="radioitem11" id="radioitem-3" value="3">3
        				    </label>
        				    <label class="radio-inline" for="radioitem-1">
        					    <input class="input_radio" type="radio" name="radioitem11" id="radioitem-4" value="4">4
        				    </label>
    		            </div>
        				<br>
        				
        				<!-- input employee administrator -->
        				<label class="grey-text">Elaboration des strategies : </label>
    					<div class="input-group form-group">
    		          		<label class="radio-inline" for="radioitem-0">
            		            <input class="input_radio" type="radio" name="radioitem12" id="radioitem-1" value="1">1
        			        </label>
        			        <label class="radio-inline" for="radioitem-1">
        				        <input class="input_radio" type="radio" name="radioitem12" id="radioitem-2" value="2">2
        			        </label>
        			         <label class="radio-inline" for="radioitem-0">
        						<input class="input_radio" type="radio" name="radioitem12" id="radioitem-3" value="3">3
        				    </label>
        				    <label class="radio-inline" for="radioitem-1">
        					    <input class="input_radio" type="radio" name="radioitem12" id="radioitem-4" value="4">4
        				    </label>
    		            </div>
        				<br>
    				<?php
    				    }
    				?>
    				
    				<div class="text-left mt-4">
        				<button class="btn btn-indigo" type="submit">Suivant</button>
    				</div>
				</form>
			</div>
		</section>
    </body>
</html>
