Skip to content
Snippets Groups Projects
Commit 6bb72e4d authored by Nicolas Dubois's avatar Nicolas Dubois
Browse files

Add job name in email to managers

parent f03cf229
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,14 @@
if (isset($_GET['edit'])) {
// update data
updatePostulation($pdo, $candidateData, $_FILES);
// get job name
$job = $DBController->getPositionName($candidateData->formation);
if ($SENDEMAILS) {
mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $job);
mailToApprenti($candidateData->mailApprenti);
}
include("templates/confirmationText.php");
} else {
// write infos in DB
......@@ -34,8 +42,10 @@
// insert files in DB
insertFiles($pdo, $candidateData->fichiers, $candidateId, $candidateData->rootpath);
// get job name
$job = $DBController->getPositionName($candidateData->formation);
if ($SENDEMAILS) {
mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $candidateData->formation);
mailToResp($candidateData->prenomApprenti, $candidateData->nomApprenti, $job);
mailToApprenti($candidateData->mailApprenti);
}
// kill session
......
<?php
#region [Mail Sendings]
function mailToResp($surname, $name, $job){
require_once("templates/mails/mailToResp.php");
mail($to, $subject, $message, $headers);
global $EMAIL_FORMATION, $EMAIL_FROM, $EMAIL_REPLY_TO;
$subject = 'Nouvelle Candidature';
$message = "Candidat: $surname $name\r\n".
"Profession: $job\r\n".
"Consulter la candidature sur: https://canap-gest.epfl.ch/";
$headers = "From: $EMAIL_FROM\r\n" .
"Reply-To: $EMAIL_REPLY_TO\r\n" .
"X-Mailer: PHP/" . phpversion();
mail($EMAIL_FORMATION, $subject, $message, $headers);
}
function mailToApprenti($to){
require_once("templates/mails/mailToApp.php");
mail($to, $subject, $message, $headers);
global $EMAIL_FROM, $EMAIL_REPLY_TO;
$subject = 'Votre candidature pour une place d\'apprentissage';
$message = file_get_contents('./templates/mails/apprenticeMailTemplate.html');
$headers = "From: $EMAIL_FROM\r\n" .
"Content-type: text/html; charset=utf8\r\n" .
"Reply-To: $EMAIL_REPLY_TO\r\n" .
"X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);
}
#endregion
......
......@@ -15,4 +15,15 @@ class DBController {
$query->execute();
return $query->fetchAll();
}
public function getPositionName(int $positionId)
{
$sqlreq = "SELECT * FROM position JOIN job ON job_id = fk_job JOIN location ON fk_location = location_id WHERE position_id = :position";
$query = $this->pdo->prepare($sqlreq);
$query->bindParam(':position', $positionId, PDO::PARAM_INT);
$query->execute();
$job = $query->fetch();
return "{$job["job_full_value"]} ({$job["location_site"]})";
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment