<?php

	include('include/entete.php');
	$id_proJ=$id_proP="";
/*	echo '<pre>';
	var_dump($_GET);
	echo '</pre>'; die();*/
	if(isset($_GET['nProJ']) && !empty($_GET['nProJ'])){
        $id_proJ = intval($_GET['nProJ']);

		if($id_proJ == 0)
		{
			header('location:./');
			exit();
		}

	}
	if(isset($_GET['nProP']) && !empty($_GET['nProP'])){
		$id_proP= intval($_GET['nProP']);
        if($id_proP == 0)
        {
            header('location:./');
            exit();
        }
	}


	if($id_proJ=='' && $id_proP==''){
		header('location:./');
		exit();
	}

	if($id_proJ!='') $id_pro=$id_proJ;
	if($id_proP!='') $id_pro=$id_proP;

	include('config/config.inc.php');
	include('config/lib.inc.php');
	include('include/agenda.inc.php');

	$maCleDeCryptage = getCleDeCryptage();	
	
	//Affiche les infos du CFA
	$query="
		SELECT * from inscriptions_pro 
		WHERE id_pro=:num_pro
	";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->bindParam( ':num_pro', $id_pro, PDO::PARAM_INT );
	$queryRequest->execute();
	$dataCfa=$queryRequest->fetchAll();
	$countCfa = $queryRequest->rowCount();
	if($countCfa!=1){	//CFA introuvable
		header('location:./');
		exit();
	}
	$nomEta = $dataCfa[0]['etablissement_pro'];	


?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>FAFIH - DECIDAY</title>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/fonctions.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
<script>
	
	jQuery(document).ready(function(){

		<?php
		if(isset($_SESSION['msg']) && !empty($_SESSION['msg'])){
			?>
		alert('<?php print addslashes($_SESSION['msg']);?>');
		<?php
			$_SESSION['msg']="";
		}
		?>


		
		document.frmPro.nom_pro.focus();

	});
	
	function validContactPro(){
		if(document.frmPro.acceptePro.checked==false){
			alert('Merci de confirmer votre souhait d\'être contacté par un professionnel.');
			return false;
		}
		if(document.frmPro.nom_pro.value==""){
			alert('Merci de renseigner le nom.');
			document.frmPro.nom_pro.focus();
			return false;
		}
		if(document.frmPro.prenom_pro.value==""){
			alert('Merci de renseigner le prénom.');
			document.frmPro.prenom_pro.focus();
			return false;
		}
		if(document.frmPro.age_pro.value==""){
			alert('Merci de renseigner l\'âge.');
			document.frmPro.age_pro.focus();
			return false;
		}
		if(document.frmPro.age_pro.value!=parseInt(document.frmPro.age_pro.value)){
			alert('Merci de renseigner l\'âge.');
			document.frmPro.classe_pro.focus();
			return false;
		}
		if(document.frmPro.classe_pro.value==""){
			alert('Merci de renseigner la classe.');
			document.frmPro.classe_pro.focus();
			return false;
		}
		if(!verifmail('document.frmPro.email_pro',1)){
			return false;
		}

		return true;
	}

	function contactPro(){
		if(validContactPro()) document.frmPro.submit();
	}
	
</script>
    <script src='https://www.google.com/recaptcha/api.js'></script>
</head>

<body>
	<?php include('include/header.php');?>
	
	<div class="container contentPage">

		<div class="col-lg-2 col-md-2 col-sm-1 hidden-xs bgTitrePage"></div>
		<div class="col-lg-8 col-md-8 col-sm-10 col-xs-12 titreContenuPage">Contactez un professionnel  :</div>
		<div class="col-lg-2 col-md-2 col-sm-1 hidden-xs bgTitrePage"></div>
		<div class="clearfix"></div>
		
		<div class="headerCap" style="text-align: center; margin:18px 0 12px;">
			<b>Professionnel :</b> <br /><span class="ssTitreViolet"><b><?php echo decrypter($maCleDeCryptage,$dataCfa[0]['etablissement_pro']);?></b></span><br />
		</div>
		
		<form name="frmPro" method="post" action="actions-pro.php" id="frmPro">
			
			<input type="hidden" name="myAction" value="proContact">
			<?php
			if($id_proJ!='') echo '<input type="hidden" name="id_proJ" value="'.$id_proJ.'" />';
			if($id_proP!='') echo '<input type="hidden" name="id_proP" value="'.$id_proP.'" />';

			?>
			
			<div class="formPro">
				<div class="col-xs-1 col-sm-offset-4 col-sm-1 col-md-offset-3 col-md-1 text-right marginForm"><input type="checkbox" name="acceptePro" id="acceptePro"></div><div class="col-xs-11 col-sm-7 col-md-8 marginForm" style="text-align:left;"><label for="acceptePro" >Je souhaite être contacté par un professionnel<sup class="obligatory">*</sup></label></div>
				<div class="clearfix"></div>
			</div>
			
			<div class="labFrm">Nom<sup class="obligatory">*</sup> :</div><input type="text" name="nom_pro" id="nom_pro" /><br />
			<div class="labFrm">Prénom<sup class="obligatory">*</sup> :</div><input type="text" name="prenom_pro" id="prenom_pro" /><br />
			<div class="labFrm">Age<sup class="obligatory">*</sup> :</div><input type="text" name="age_pro" id="age_pro" /><br />
			<div class="labFrm">Classe<sup class="obligatory">*</sup> :</div><input type="text" name="classe_pro" id="classe_pro" /><br />
			<div class="labFrm">E-mail<sup class="obligatory">*</sup> :</div><input type="text" name="email_pro" id="email_pro" /><br />
			<div class="labFrm">Commentaires  :</div><textarea name="comment_pro" id="comment_pro" /></textarea><br /><br />
            <div class="g-recaptcha" style="max-width: 300px; margin: 5px auto 30px auto;" data-sitekey="6LfPdIIUAAAAAM-02tRGPn0Xz4owkDxXJHIWUGKM"></div>
			<div class="btnDeci"><a href="javascript:void(0);" onClick="contactPro()">Envoyer</a></div>
			<div style="height: 20px;"></div>
		</form>
		
	</div>
	
	<?php include('include/footer.php');?>
</body>
</html>