SAE15_2022/contact/index.php

180 lines
8.8 KiB
PHP

<?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">
<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>
<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>';
if ($subject == 'integration') {
$text .= '<input type="text" name="subject" value="integration" hidden>';
} else $text .= '<label for="subject">Sujet</label><br>
<input type="text" id="subject" name="subject" placeholder="Le sujet de votre demande.." required><br>';
$text .= '<div class="field">
<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>';
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>";
$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>";
$text .= contact_form($profile, $_GET["subject"]);
} elseif (isset($_GET["subject"]) && $_GET["subject"] == 'other') {
$text .= " <a href='" . contact_query(array("subject" => "")) . "'>autre chose</a></h2>";
$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">
<title>Contact - Elite Solar</title>
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="stylesheet" href="../assets/css/header.css">
<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>
<h1>Elite Solar</h1>
<img id="burger-menu" alt="Menu" onclick="burgerMenu()" src="../assets/img/open-menu.svg">
<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>
</header>
<main>
<div>
<h1>Nous contacter</h1>
<?= select_profile() ?>
</main>
<footer>
<div id="social">
<p>Suivez-Nous</p>
<ul>
<li><a href="https://linkedin.com"><img src="../assets/img/linkedin.svg" width="50" height="50" alt="LinkedIn"></a></li>
<li><a href="https://instagram.com/elitesolar77"><img src="../assets/img/instagram.svg" width="50" height="50" alt="Instagram"></a></li>
<li><a href="https://www.facebook.com/profile.php?id=100089332237449"><img src="../assets/img/facebook.svg" width="50" height="50" alt="Facebook"></a></li>
<li><a href="https://twitter.com/EliteSolar77"><img src="../assets/img/twitter.svg" width="50" height="50" alt="Twitter"></a></li>
</ul>
</div>
<div id="sitemap">
<p>Plan du site</p>
<ul>
<li><a href="../">Page d'accueil</a></li>
<li><a href="../about">Qui sommes-nous ?</a></li>
<li><a href="../product">Notre produit</a></li>
<li><a href="../faq">Foire aux questions</a></li>
<li><a href="../contact">Contact</a></li>
<li><a href="../privacy">Politique de confidentialité</a></li>
<li><a href="../legal">Mentions légales</a></li>
</ul>
</div>
<div id="contact">
<p>Contact</p>
<ul>
<li><a href="tel:+33160746800">+33 1 60 74 68 00</a></li>
<li><a href="mailto:elitesolar.contact77@gmail.com">elitesolar.contact77@gmail.com</a></li>
</ul>
</div>
<p id="copyright">© <?= date("Y") ?> Elite Solar. Créé par Lyanis Souidi, Tom Moguljak et Romain Journeau.</p>
</footer>
<script src="../assets/js/contact.js"></script>
</body>
</html>