SAE15_2022/contact/index.php

185 lines
9.2 KiB
PHP
Raw Normal View History

2023-01-17 22:21:28 +01:00
<?php
function contact_query($query_params) : string {
$url = parse_url($_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["HTTP_HOST"] . ($_SERVER["SERVER_PORT"] != "80" || "443" ? ":" . $_SERVER["SERVER_PORT"] : "") . $_SERVER["REQUEST_URI"]);
isset($url['query']) ? parse_str($url['query'], $params) : $params = array();
$params = array_merge($params, $query_params);
if (isset($params['profile']) && $params['profile'] == 'business') {
if (isset($params['subject']) && $params['subject'] == 'warranty') {
unset($params['subject']);
}
}
if (isset($params['profile']) && $params['profile'] == 'consumer') {
if (isset($params['subject']) && $params['subject'] == 'integration') {
unset($params['subject']);
}
}
$url['query'] = http_build_query($params);
return $url['scheme'] . '://' . $url['host'] . $url['path'] . '?' . $url['query'];
}
function contact_form($profile, $subject) : string {
$text = '</div>
<div class="contact">
<div class="right" id="contact-info">
<h3>Elite Solar</h3>
<p><a href="https://www.google.com/maps/place/8FW49MXP%2B3P" target="_blank">Route forestière Hurtault, 77300 Fontainebleau</a></p>
<p><a href="tel:+33160746800">+33 1 60 74 68 00</a></p>
<p><a href="mailto:elitesolar.contact77@gmail.com">elitesolar.contact77@gmail.com</a></p>
</div>';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$text .= "<p>Votre demande a bien été prise en compte, nous y répondrons dans les meilleurs délais.</p>";
} else {
$text .= '<form class="left" method="post">
2023-01-17 22:21:28 +01:00
<h3>Formulaire de contact</h3>
<div class="field">
<label for="name">Nom</label><br>
<input type="text" id="name" name="name" placeholder="Votre nom.." required><br>
</div>
<div class="field">
<label for="email">Adresse électronique</label><br>
<input type="email" id="email" name="email" placeholder="Votre adresse électronique.." required><br>
</div>';
if ($profile == 'business') {
$text .= '<input type="radio" name="type" value="business" hidden checked>
2023-01-17 22:21:28 +01:00
<div class="field"">
<label for="entreprise">Entreprise</label><br>
<input type="text" id="entreprise" name="entreprise" placeholder="Nom de votre entreprise.." required><br>
</div>';
} else echo '<input type="radio" name="type" value="consumer" hidden checked>';
2023-01-17 22:21:28 +01:00
if ($subject == 'integration') {
$text .= '<input type="text" name="subject" value="integration" hidden>';
} else $text .= '<label for="subject">Sujet</label><br>
2023-01-17 22:21:28 +01:00
<input type="text" id="subject" name="subject" placeholder="Le sujet de votre demande.." required><br>';
$text .= '<div class="field">
2023-01-17 22:21:28 +01:00
<label for="message">Message</label><br>
<textarea id="message" name="message" placeholder="Votre message.."></textarea><br>
</div>
<input class="button" type="submit" value="Envoyer">
</form>
';
}
$text .= '</div>';
2023-01-17 22:21:28 +01:00
return $text;
}
function select_subject($profile) : string {
$text = ' et votre demande concerne';
if (isset($_GET["subject"]) && $_GET["subject"] == 'warranty') {
$text .= " <a href='" . contact_query(array("subject" => "")) . "'>la garantie Solar Glass</a></h2>";
2023-01-17 22:21:28 +01:00
$text .= "<p>La <a href='https://www.service-public.fr/particuliers/vosdroits/F11094' target='_blank'>garantie légale de conformité</a>
est assuré par le fabricant intégrant la technologie Solar Glass dans ses appareils, en cas de problème concernant Solar Glass sur votre appareil,
merci donc de <b>contacter directement le fabricant de votre appareil</b>.</p>";
} elseif (isset($_GET["subject"]) && $_GET["subject"] == 'integration') {
$text .= " <a href='" . contact_query(array("subject" => "")) . "'>l'intégration de Solar Glass dans vos produits</a></h2>";
2023-01-17 22:21:28 +01:00
$text .= contact_form($profile, $_GET["subject"]);
} elseif (isset($_GET["subject"]) && $_GET["subject"] == 'other') {
$text .= " <a href='" . contact_query(array("subject" => "")) . "'>autre chose</a></h2>";
2023-01-17 22:21:28 +01:00
$text .= contact_form($profile, $_GET["subject"]);
} else {
$text .= "...</h2>";
if ($profile == 'business') $text .= "<a class='button' href='" . contact_query(array("subject" => "integration")) ."'>L'intégration de Solar Glass dans vos produits</a>";
if ($profile == 'consumer') $text .= "<a class='button' href='" . contact_query(array("subject" => "warranty")) . "'>La garantie Solar Glass</a>";
$text .= "<a class='button' href='" . contact_query(array("subject" => "other")) . "'>Autre chose</a></div>";
}
return $text;
}
function select_profile() : string {
$text = '';
$text .= "<h2>Vous êtes";
if (isset($_GET["profile"]) && $_GET["profile"] == 'business') {
$text .= " <a href='" . contact_query(array("profile" => "")) . "'>une entreprise</a>";
$text .= select_subject('business');
} else if (isset($_GET["profile"]) && $_GET["profile"] == 'consumer') {
$text .= " <a href='" . contact_query(array("profile" => "")) . "'>un particulier</a>";
$text .= select_subject('consumer');
} else $text .= "...</h2>
<a class='button' href=" . contact_query(array("profile" => "business")) . ">Une entreprise</a>
<a class='button' href=" . contact_query(array("profile" => "consumer")) . ">Un particulier</a></div>";
return $text;
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="../assets/img/favicon_dark.ico" media="(prefers-color-scheme: light)">
<link rel="icon" href="../assets/img/favicon_light.ico" media="(prefers-color-scheme: dark)">
2023-01-17 23:22:09 +01:00
<title>Contact - Elite Solar</title>
<meta property="og:title" content="Contact - Elite Solar">
<meta name="description" content="Besoin d'un renseignement ? Contactez-nous via notre formulaire en ligne">
<meta property="og:description" content="Besoin d'un renseignement ? Contactez-nous via notre formulaire en ligne">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Elite Solar">
<meta property="og:locale" content="fr_FR">
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="stylesheet" href="../assets/css/header.css">
2023-01-17 22:21:28 +01:00
<link rel="stylesheet" href="../assets/css/contact.css">
<link rel="stylesheet" href="../assets/css/footer.css">
<script src="../assets/js/header.js"></script>
</head>
<body>
<header>
<div>
<a href="../"><img id="logo" src="../assets/img/logo_noir.png" height="60"></a>
<img id="burger-menu" alt="Menu" onclick="burgerMenu()" src="../assets/img/open-menu.svg">
<nav>
<ul id="menu" class="invisible">
<li><a href="../">Accueil</a></li>
<li><a href="../about">Qui sommes-nous ?</a></li>
<li><a href="../product">Produit</a></li>
<li class="active"><a href="../contact">Contact</a></li>
<li><a href="../faq">FAQ</a></li>
</ul>
</nav>
</div>
</header>
2023-01-17 22:21:28 +01:00
<main>
<nav class="crumbs">
<ol>
<li class="crumb"><a href="../">Accueil</a></li> &gt;
<li class="crumb">Contact</li>
</ol>
</nav>
2023-01-17 22:21:28 +01:00
<div>
<h1>Nous contacter</h1>
<?= select_profile() ?>
</main>
<button onclick="topFunction()" id="backToTop" title="Revenir au début de la page">⬆️</button>
2023-01-09 10:44:39 +01:00
<footer>
<div class="content">
<div class="text">
© <?= date("Y") ?> Elite Solar
<a href="../legal">Mentions légales</a>
<a href="../sitemap">Plan du site</a>
</div>
<div class="social">
<a target="_blank" href="https://linkedin.com"><img src="../assets/img/linkedin.svg" width="25" height="25" alt="LinkedIn"></a>
<a target="_blank" href="https://instagram.com/elitesolar77"><img src="../assets/img/instagram.svg" width="25" height="25" alt="Instagram"></a>
<a target="_blank" href="https://www.facebook.com/profile.php?id=100089332237449"><img src="../assets/img/facebook.svg" width="25" height="25" alt="Facebook"></a>
<a target="_blank" href="https://twitter.com/EliteSolar77"><img src="../assets/img/twitter.svg" width="25" height="25" alt="Twitter"></a>
</div>
2023-01-09 10:44:39 +01:00
</div>
</footer>
2023-01-17 22:21:28 +01:00
<script src="../assets/js/contact.js"></script>
<script src="../assets/js/script.js"></script>
</body>
</html>