diff($date);
return $interval->y;
}
try {
$error = false;
$dbh = new PDO('mysql:host=saeweb2022.souidi.fr;dbname=saeweb2022', "saeweb2022");
$url = parse_url($_SERVER["REQUEST_URI"])["path"];
if (str_ends_with($url, "/")) {
$url = substr($url, 0, -1);
}
$url = explode("/", $url);
if (end($url) == "team") {
$mode = "list";
$employees = array();
foreach($dbh->query('SELECT name, jobTitle, slug FROM employee;') as $row) {
$employees[] = $row;
}
} else {
$mode = "view";
$sth = $dbh->prepare("SELECT name, jobTitle, birthdate, email FROM employee WHERE employee.slug = ?;");
$sth->execute([end($url)]);
$employee = $sth->fetch(PDO::FETCH_ASSOC);
if (empty($employee)) {
http_response_code(404);
$error = "notfound";
}
if (isset($_GET["articles"])) {
$mode = "articles";
$sth = $dbh->prepare("SELECT article.title, article.slug, article.created_at, article.excerpt FROM article JOIN employee ON article.author=employee.id WHERE employee.slug = ? ORDER BY article.created_at DESC;");
$sth->execute([end($url)]);
$employee["articles"] = $sth->fetchAll(PDO::FETCH_ASSOC);
} else {
$employee['age'] = age($employee['birthdate']);
$sth = $dbh->prepare("SELECT social.name, social.url FROM employee_social social JOIN employee ON social.employeeId=employee.id WHERE employee.slug = ?;");
$sth->execute([end($url)]);
$employee["socials"] = $sth->fetchAll(PDO::FETCH_ASSOC);
$employee['cv'] = array('formation' => array(), 'work' => array(), 'language' => array(), 'skill' => array(), 'project' => array());
if (isset($_GET["cv"])) {
$mode = "cv";
$sth = $dbh->prepare("SELECT cv.type, cv.title, cv.description, cv.link FROM cv JOIN employee ON cv.employeeId=employee.id WHERE employee.slug = ? ORDER BY cv.priority;");
$sth->execute([end($url)]);
foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $e) {
if ($e['type'] == "skill") {
$employee['cv'][$e['type']][$e['title']][] = $e['description'];
} else {
$employee['cv'][$e['type']][] = array(
'title' => $e['title'],
'description' => $e['description'],
'link' => $e['link']
);
}
}
} else {
$sth = $dbh->prepare("SELECT article.title, article.slug, article.created_at, article.excerpt FROM article JOIN employee ON article.author=employee.id WHERE employee.slug = ? ORDER BY article.created_at DESC LIMIT 2;");
$sth->execute([end($url)]);
$employee["articles"] = $sth->fetchAll(PDO::FETCH_ASSOC);
$sth = $dbh->prepare("SELECT cv.title, cv.description, cv.link FROM cv JOIN employee ON cv.employeeId=employee.id WHERE employee.slug = ? AND cv.type = 'formation' ORDER BY cv.priority LIMIT 1;");
$sth->execute([end($url)]);
foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $e) {
$employee['cv']['formation'][] = array(
'title' => $e['title'],
'description' => $e['description'],
'link' => $e['link']
);
}
}
}
$sth = null;
}
$dbh = null;
} catch (PDOException) {
http_response_code(503);
$error = "db";
}
?>
Équipe - Elite Solar';
echo ' ';
echo ' ';
echo ' ';
} elseif ($mode == 'view') {
echo ''. $employee['name'] .' - Elite Solar ';
echo ' ';
echo ' ';
echo ' ';
} elseif ($mode == 'articles') {
echo 'Articles de '. $employee['name'] .' - Elite Solar ';
echo ' ';
echo ' ';
echo ' ';
} elseif ($mode == 'cv') {
echo 'CV de ' . $employee['name'];
echo 'CV de '. $employee['name'] .' - Elite Solar ';
echo ' ';
echo ' ';
echo ' ';
}
?>
Accueil >
Équipe
Une erreur est survenue lors du chargement de la page.
';
} elseif ($error == "notfound") {
echo '
Accueil >
Équipe
Employé
' .
"Page introuvable
La page que vous cherchez à atteindre ne peut pas être trouvée.
Il est possible qu'elle ait été supprimée ou déplacée. Si vous avez saisi manuellement son adresse,
veuillez vérifier une éventuelle erreur de saisie.
Retour à la page d'accueil
";
} else {
if ($mode == 'list') {
echo '
Accueil >
Équipe
' .
"Notre équipe ";
foreach ($employees as $employee) {
echo '
';
}
echo "
";
echo"Vous souhaitez rejoindre notre équipe ? Contactez-nous par mail à l'adresse suivante : elitesolar.contact77@gmail.com
";
} elseif ($mode == 'view') {
echo '
Accueil >
Équipe >
' . $employee["name"] . '
' .
"" . $employee["name"] . " ";
echo "" . $employee["age"] . " ans | " . $employee["jobTitle"] . " ";
echo '';
foreach ($employee["socials"] as $social) {
echo ' ';
}
echo ' ';
echo "Articles récents (Voir tout ) ";
if (empty($employee["articles"])) echo 'Aucun article.
';
echo '';
foreach ($employee["articles"] as $article) {
$date = new DateTime($article['created_at']);
echo '' . $article["title"] . '
Date : ' . $date->format('d/m/Y') . '
Extrait : ' . $article["excerpt"] . ' ';
}
echo ' ';
echo '';
} elseif ($mode == "cv") {
echo '
Accueil >
Équipe >
' . $employee["name"] . ' >
CV
' .
"";
echo "";
echo "
Informations " .
"
Âge : " . $employee["age"] . "
Adresse électronique : " . $employee["email"] . " ";
foreach ($employee["socials"] as $social) {
if ($social["name"] == "linkedin" || $social["name"] == "github") {
echo "" . $social["url"] . " ";
}
}
echo " ";
echo '
';
echo '
Expérience ';
if (empty($employee["cv"]["work"])) echo '
Aucune expérience enregistrée.
';
foreach ($employee["cv"]["work"] as $work) {
echo '
' . $work["title"] . ' ' . $work["description"] . ' ';
}
echo '
';
echo '
Langues ';
if (empty($employee["cv"]["language"])) echo '
Aucune langue enregistrée.
';
echo '
';
foreach ($employee["cv"]["language"] as $language) {
echo '' . $language["title"] . ' : ' . $language["description"] . ' ';
}
echo ' ';
echo '
Compétences ';
if (empty($employee["cv"]["skill"])) echo '
Aucune compétence enregistrée.
';
while ($skill = current($employee["cv"]["skill"])) {
echo '
' . key($employee["cv"]["skill"]) . ' ';
echo implode(' ', $skill);
echo ' ';
next($employee["cv"]["skill"]);
}
echo '
';
echo '
Projets ';
if (empty($employee["cv"]["project"])) echo '
Aucun projet enregistré.
';
foreach ($employee["cv"]["project"] as $project) {
if (empty($project["link"])) {
echo '
' . $project["title"] . ' ' . $project["description"] . ' ';
} else {
echo '
' . $project["title"] . ' ' . $project["description"] . ' ';
}
}
echo '
';
} elseif ($mode == 'articles') {
echo '
Accueil >
Équipe >
' . $employee["name"] . ' >
Articles
' .
"";
if (empty($employee["articles"])) echo 'Aucun article.
';
echo '';
foreach ($employee["articles"] as $article) {
$date = new DateTime($article['created_at']);
echo '' . $article["title"] . '
Date : ' . $date->format('d/m/Y') . '
Extrait : ' . $article["excerpt"] . ' ';
}
echo ' ';
}
}
?>
⬆️