385 lines
15 KiB
PHP
385 lines
15 KiB
PHP
<?php
|
|
|
|
include('include/entete.php');
|
|
include('include/entete_cap.php');
|
|
include('config/config.inc.php');
|
|
include('config/lib.inc.php');
|
|
|
|
include('include/agenda.inc.php');
|
|
|
|
$maCleDeCryptage = getCleDeCryptage();
|
|
|
|
$db = connect_base();
|
|
|
|
//Récupère les infos capitaine et réferrent
|
|
$query="select * from eta,capitaines where id_eta=num_eta and id_cap=:id_cap";
|
|
$db = connect_base();
|
|
$queryRequest = $db->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 .= '<br />'.$adresse2CoLy;
|
|
$adresseCL .= '<br />'.$cpCoLy.' '.$villeCoLy;
|
|
|
|
$creneauCL = "";
|
|
$creneauCL = getCreneau($myCreneau);
|
|
|
|
|
|
$affich='';
|
|
$affich.='<table cellpadding="3" style="font-family:ARIAL; width:600px;">';
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"><img src="" /></td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"><img src="cid:bando" alt="" width="600" height="150" border="0" /></td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2">Bonjour,</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2">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 <b>découvrir la filière, préparer leur projet d\'orientation professionnelle</b> et <b>rencontrer un professionnel</b>.</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2">Récapitulatif de cette rencontre : </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Jour : </b></td><td>'.MysqlToDateFr($myDay).'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Créneau : </b></td><td>'.$creneauCL.'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Votre établissement : </b></td><td>'.$etaCoLy.'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Nombre de classes : </b></td><td>'.$nbClasses.'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Nombre d\'élèves : </b></td><td>'.$nbEleves.'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Votre interlocuteur : </b></td><td>'.$capitaine.'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td align="right"><b>Etablissement : </b></td><td>'.$eta.'</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"><b>Votre interlocuteur vous contactera pour définir les modalités de votre intervention.</b></td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2" align="center"><table style="width:200px;background-color: #674B64;border: 1px solid #371B34;padding: 4px 6px;"><tr><td align="center"><a href="http://www.deciday.fr" style="color: #FFF;text-decoration: none;text-transform: uppercase; font-family:ARIAL;"><strong>Votre site <br />Déciday !</strong></a></td></tr></table></td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2">Cordialement.</td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2"> </td>';
|
|
$affich.='</tr>'."\n";
|
|
$affich.='<tr>';
|
|
$affich.='<td colspan="2">L\'équipe DECIDAY.</td>';
|
|
$affich.='</tr>'."\n";
|
|
|
|
$affich.='</table>';
|
|
|
|
|
|
$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.'<br />';
|
|
}
|
|
|
|
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();
|
|
|
|
?>
|