prepare( $query ); $queryRequest->bindParam( ':id_cap', $_SESSION['cap_num'], PDO::PARAM_INT ); $queryRequest->execute(); $dataCfa=$queryRequest->fetchAll(); $capitaine=decrypter($maCleDeCryptage,$dataCfa[0]['prenom_cap'])." ".decrypter($maCleDeCryptage,$dataCfa[0]['nom_cap']); $eta = decrypter($maCleDeCryptage,$dataCfa[0]['nom_eta']); $ncap = $_SESSION['cap_num']; $ncfa = $dataCfa[0]['id_eta']; /************************************************ //SOLLICITATION : AFFECTATION PAR LE CAPITAINE ************************************************/ if(isset($_POST['myAction']) && $_POST['myAction']=='affecterSol'){ $myDay = $_POST['myDay']; $myCreneau = $_POST['myCreneau']; $chxSol = $_POST['chxSol']; //Vérifie si le créneau est libre pour un des jours suivants $query=" SELECT * FROM capitaines INNER JOIN eta ON id_eta=num_eta INNER JOIN agenda ON id_cap = numCap WHERE id_eta=:id_eta AND id_cap=:id_cap AND jour=:jour AND creneau=:creneau AND numCoLy=0 AND statut='libre' "; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':id_eta', $ncfa, PDO::PARAM_INT ); $queryRequest->bindParam( ':id_cap', $ncap, PDO::PARAM_INT ); $queryRequest->bindParam( ':jour', $myDay, PDO::PARAM_STR ); $queryRequest->bindParam( ':creneau', $myCreneau, PDO::PARAM_STR ); $queryRequest->execute(); $count = $queryRequest->rowCount(); if($count==1){ //Récupère les données de la sollicitation $query=" SELECT * FROM sollicitations WHERE chxNumEta=:id_eta AND idCoLy=:chxSol AND traitement=0 "; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':id_eta', $ncfa, PDO::PARAM_INT ); $queryRequest->bindParam( ':chxSol', $chxSol, PDO::PARAM_INT ); $queryRequest->execute(); $countSol = $queryRequest->rowCount(); if($countSol==1){ $dataSol=$queryRequest->fetchAll(); $etaCoLy = $dataSol[0]['etaCoLy']; $nomCoLy = $dataSol[0]['nomCoLy']; $prenomCoLy = $dataSol[0]['prenomCoLy']; $fonctionCoLy = $dataSol[0]['fonctionCoLy']; $telCoLy = $dataSol[0]['telCoLy']; $emlCoLy = $dataSol[0]['emlCoLy']; $adresse1CoLy = $dataSol[0]['adresse1CoLy']; $adresse2CoLy = $dataSol[0]['adresse2CoLy']; $cpCoLy = $dataSol[0]['cpCoLy']; $villeCoLy = $dataSol[0]['villeCoLy']; $nbClasses = $dataSol[0]['nbClasses']; $nbEleves = $dataSol[0]['nbEleves']; $commentCoLy = $dataSol[0]['commentCoLy']; $dateCreate = $dataSol[0]['dateCreate']; $chxNumEta = $dataSol[0]['chxNumEta']; /****************************************/ //Insertion de l'établissement $query=" INSERT INTO collegelycee (etaCoLy, nomCoLy, prenomCoLy, fonctionCoLy, telCoLy, emlCoLy, adresse1CoLy, adresse2CoLy, cpCoLy, villeCoLy, nbClasses, nbEleves, commentCoLy, dateCreate, chxNumEta, provenance) VALUES (:etaCoLy, :nomCoLy, :prenomCoLy, :fonctionCoLy, :telCoLy, :emlCoLy, :adresse1CoLy, :adresse2CoLy, :cpCoLy, :villeCoLy, :nbClasses, :nbEleves, :commentCoLy, :dateCreate, :chxNumEta, :provenance)"; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':etaCoLy', $etaCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':nomCoLy', $nomCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':prenomCoLy', $prenomCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':fonctionCoLy', $fonctionCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':telCoLy', $telCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':emlCoLy', $emlCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':adresse1CoLy', $adresse1CoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':adresse2CoLy', $adresse2CoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':cpCoLy', $cpCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':villeCoLy', $villeCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':nbClasses', $nbClasses, PDO::PARAM_INT ); $queryRequest->bindParam( ':nbEleves', $nbEleves, PDO::PARAM_INT ); $queryRequest->bindParam( ':commentCoLy', $commentCoLy, PDO::PARAM_STR ); $queryRequest->bindParam( ':dateCreate', $dateCreate, PDO::PARAM_STR ); $queryRequest->bindParam( ':chxNumEta', $chxNumEta, PDO::PARAM_INT ); $queryRequest->bindParam( ':provenance', $chxSol, PDO::PARAM_INT ); $queryRequest->execute(); $idCoLy=$db->lastInsertId(); //Affectation au créneau $numCoLy = $idCoLy; $statut = 'reserve'; $userLastUpdate = 'cap'; //Affectation à la sollicitation $lastIdCapitaine = $ncap; $traitement = 1; $lastAction = 'cap'; //Statut traitée pour la sollicitation + logs $query=" UPDATE sollicitations SET lastIdCapitaine=:lastIdCapitaine, lastAction=:lastAction, traitement=:traitement WHERE idCoLy=:numCoLy"; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':numCoLy', $chxSol, PDO::PARAM_INT ); $queryRequest->bindParam( ':traitement', $traitement, PDO::PARAM_INT ); $queryRequest->bindParam( ':lastIdCapitaine', $lastIdCapitaine, PDO::PARAM_INT ); $queryRequest->bindParam( ':lastAction', $lastAction, PDO::PARAM_STR ); $queryRequest->execute(); $query=" UPDATE agenda SET numCoLy=:numCoLy, statut=:statut, dateLastUpdate='".date('Y-m-d')."',userLastUpdate=:userLastUpdate WHERE numCap=:numCap AND jour=:jour AND creneau=:creneau"; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':numCap', $ncap, PDO::PARAM_INT ); $queryRequest->bindParam( ':numCoLy', $numCoLy, PDO::PARAM_INT ); $queryRequest->bindParam( ':jour', $myDay, PDO::PARAM_STR ); $queryRequest->bindParam( ':creneau', $myCreneau, PDO::PARAM_STR ); $queryRequest->bindParam( ':statut', $statut, PDO::PARAM_STR ); $queryRequest->bindParam( ':userLastUpdate', $userLastUpdate, PDO::PARAM_STR ); $queryRequest->execute(); //echo 'okk'; //exit(); //Envoi d'un email au collège ou lycée require 'config/class.phpmailer.php'; require 'config/phpmailer.settings.php'; //Decryptage pour l'email $etaCoLy = decrypter($maCleDeCryptage,$dataSol[0]['etaCoLy']); $nomCoLy = decrypter($maCleDeCryptage,$dataSol[0]['nomCoLy']); $prenomCoLy = decrypter($maCleDeCryptage,$dataSol[0]['prenomCoLy']); $fonctionCoLy = decrypter($maCleDeCryptage,$dataSol[0]['fonctionCoLy']); $telCoLy = decrypter($maCleDeCryptage,$dataSol[0]['telCoLy']); $emlCoLy = decrypter($maCleDeCryptage,$dataSol[0]['emlCoLy']); $adresse1CoLy = decrypter($maCleDeCryptage,$dataSol[0]['adresse1CoLy']); $adresse2CoLy = decrypter($maCleDeCryptage,$dataSol[0]['adresse2CoLy']); $cpCoLy = decrypter($maCleDeCryptage,$dataSol[0]['cpCoLy']); $villeCoLy = decrypter($maCleDeCryptage,$dataSol[0]['villeCoLy']); $nbClasses = $dataSol[0]['nbClasses']; $nbEleves = $dataSol[0]['nbEleves']; $commentCoLy = decrypter($maCleDeCryptage,$dataSol[0]['commentCoLy']); $to=$emlCoLy; $objet="Votre évènement DECIDAY !"; $adresseCL = $adresse1CoLy; if(!empty($adresse2CoLy)) $adresseCL .= '
'.$adresse2CoLy; $adresseCL .= '
'.$cpCoLy.' '.$villeCoLy; $creneauCL = ""; $creneauCL = getCreneau($myCreneau); $affich=''; $affich.=''; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.=''; $affich.=''; $affich.=''."\n"; $affich.='
 
Bonjour,
 
Dans le cadre de l\'évènement Déciday !, un créneau a été réservé pour la venue d\'un trinôme au sein de votre établissement. Vos élèves pourront donc découvrir la filière, préparer leur projet d\'orientation professionnelle et rencontrer un professionnel.
 
Récapitulatif de cette rencontre :
 
Jour : '.MysqlToDateFr($myDay).'
Créneau : '.$creneauCL.'
 
Votre établissement : '.$etaCoLy.'
Nombre de classes : '.$nbClasses.'
Nombre d\'élèves : '.$nbEleves.'
 
Votre interlocuteur : '.$capitaine.'
Etablissement : '.$eta.'
 
Votre interlocuteur vous contactera pour définir les modalités de votre intervention.
 
Votre site
Déciday !
 
Cordialement.
 
L\'équipe DECIDAY.
'; $mail->IsHTML(true); $mail->AddEmbeddedImage('images/bandeau-contact.jpg', 'bando', 'bandeau-contact.jpg'); $mail->Subject = utf8_decode($objet); $mail->Body = utf8_decode($affich); $mail->AddAddress($to); $mail->AltBody = "/-------//--------/"; $mail->send(); $_SESSION['msg']='Le créneau a bien été réservé. Un email a été envoyé sur l\'email de l\'établissement pour l\'en informer.\nVous pouvez modifier la fiche de l\'établissement si vous le souhaitez.'; /****************************************/ } /*$data=$queryRequest->fetchAll(); $emlCapitaine = decrypter($maCleDeCryptage,$data[0]['email_cap']); $idCapitaine = $data[0]['id_cap']; $lastAction = 'cap'; $lastIdCap = $_SESSION['cap_num'];*/ } //header('location:agenda-cap-form.php?idCoLy='.$idCoLy); header('location:agenda-cap.php'); exit(); } /************************************************ //SOLLICITATION : REFUS DU CAPITAINE ************************************************/ if(isset($_POST['myAction']) && $_POST['myAction']=='refusSol'){ //Si aucun capitaine ne peut reprendre la sollicitation pour le créneau souhaité, c'est le référrent par défaut qui reprend (idCapitaine = 0) $emlReferrent = decrypter($maCleDeCryptage,$dataCfa[0]['email_ref']); $idCapitaine = 0; $lastAction = 'cap'; $lastIdCap = $_SESSION['cap_num']; if(empty($_POST['idCoLy']) || empty($_POST['myDay']) || empty($_POST['myCreneau'])){ $_SESSION['msg']='Une erreur a été rencontrée au refus de la sollicitation.'; header('location:agenda-cap.php'); exit(); } foreach($_POST as $cle=>$val){ $$cle=$val; //echo $cle.' => '.$val.'
'; } if($myCreneau == 'am'){ $creneau1 = 'am1'; $creneau2 = 'am2'; $nomCreneau = "Matin"; } if($myCreneau == 'pm'){ $creneau1 = 'pm1'; $creneau2 = 'pm2'; $nomCreneau = "Après-midi"; } //Vérifie si le créneau est libre pour un des jours suivants $query=" SELECT * FROM capitaines INNER JOIN eta ON id_eta=num_eta INNER JOIN agenda ON id_cap = numCap WHERE id_eta=:id_eta AND id_cap!=:id_cap AND jour=:jour AND (creneau=:creneau1 || creneau=:creneau2) AND numCoLy=0 AND statut='libre' ORDER BY id_cap"; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':id_eta', $ncfa, PDO::PARAM_INT ); $queryRequest->bindParam( ':id_cap', $ncap, PDO::PARAM_INT ); $queryRequest->bindParam( ':jour', $myDay, PDO::PARAM_STR ); $queryRequest->bindParam( ':creneau1', $creneau1, PDO::PARAM_STR ); $queryRequest->bindParam( ':creneau2', $creneau2, PDO::PARAM_STR ); $queryRequest->execute(); $count = $queryRequest->rowCount(); if($count>0){ $data=$queryRequest->fetchAll(); $emlCapitaine = decrypter($maCleDeCryptage,$data[0]['email_cap']); $idCapitaine = $data[0]['id_cap']; $lastAction = 'cap'; $lastIdCap = $_SESSION['cap_num']; } //echo $idCoLy.' '.$ncfa.' '.$idCapitaine.' '.$lastAction.' '.$lastIdCap; //Transfert de la sollicitation $query=" UPDATE sollicitations SET idCapitaine=:idCapitaine, lastAction=:lastAction, lastIdCapitaine=:lastIdCapitaine WHERE idCoLy=:idCoLy AND chxNumEta=:chxNumEta"; $queryRequest = $db->prepare( $query ); $queryRequest->bindParam( ':idCoLy', $idCoLy, PDO::PARAM_INT ); $queryRequest->bindParam( ':chxNumEta', $ncfa, PDO::PARAM_INT ); $queryRequest->bindParam( ':idCapitaine', $idCapitaine, PDO::PARAM_INT ); $queryRequest->bindParam( ':lastAction', $lastAction, PDO::PARAM_STR ); $queryRequest->bindParam( ':lastIdCapitaine', $lastIdCap, PDO::PARAM_INT ); $queryRequest->execute(); //Envoi d'un email au capitaine ou référrent //include('config/class.phpmailer.php'); //if(!empty($emlCapitaine)) $to=$emlCapitaine; else $to=$emlReferrent; $_SESSION['msg']='La sollicitation a bien été transférée à un capitaine ou au référent.'; header('location:agenda-cap.php'); exit(); } header('location:index.php?err=1'); exit(); ?>