186 lines
8.0 KiB
PHP
Executable File
186 lines
8.0 KiB
PHP
Executable File
<?php
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
require("../../include/variables.php");
|
|
require("../../include/init.php");
|
|
require './vendor/autoload.php';
|
|
|
|
if (!isset($_SESSION['userRole']) || $_SESSION['userRole'] < 50) {
|
|
http_response_code(403);
|
|
die("Vous n'êtes pas autorisé à accéder à cette ressource");
|
|
}
|
|
|
|
require("../../include/main-functions.php");
|
|
require("../../include/objects.php");
|
|
require("../../include/inputs.php");
|
|
require("../../include/panels.php");
|
|
|
|
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
|
|
|
if (isset($_POST['adherent-id'])) {
|
|
$adherentID = (int)$_POST['adherent-id'];
|
|
try {
|
|
// Requête SQL pour déplacer la ligne
|
|
$sql = "UPDATE adherents SET etape_adhesion = 2 WHERE ID = :adherentID";
|
|
|
|
$updateAdherentStmt = $pdo->prepare($sql);
|
|
$updateAdherentStmt->bindParam(":adherentID", $adherentID);
|
|
|
|
// Préparation de la requête
|
|
if ($updateAdherentStmt->execute()) {
|
|
// Exécution de la requête de suppression
|
|
$status = "Adhésion validée";
|
|
|
|
$sql = "SELECT email FROM adherents WHERE ID = :adherentID";
|
|
$emailStmt = $pdo->prepare($sql);
|
|
$emailStmt->bindParam(":adherentID", $adherentID);
|
|
$emailStmt->execute();
|
|
$emailResult = $emailStmt->fetchAll(PDO::FETCH_ASSOC);
|
|
$email = $emailResult[0]['email'];
|
|
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
|
try {
|
|
// Paramètres du serveur SMTP
|
|
$mail->isSMTP(); // Utiliser SMTP
|
|
$mail->Host = 'outlook.office365.com'; // Serveur SMTP Exchange
|
|
$mail->SMTPAuth = true; // Activer l'authentification SMTP
|
|
$mail->Username = 'smtp@e59.fr'; // Nom d'utilisateur SMTP
|
|
$mail->Password = 'WTFdoto5678TFWT'; // Mot de passe SMTP
|
|
$mail->SMTPSecure = 'tls'; // Activer le cryptage TLS
|
|
$mail->Port = 587;
|
|
$mail->CharSet = "UTF-8"; // Port TCP pour TLS
|
|
|
|
// Destinataires
|
|
$mail->setFrom('service-adhesions@e59.fr', 'Adhesions E59');
|
|
$mail->addAddress($email);
|
|
|
|
$mail->isHTML(true); // Activer le format HTML pour l'email
|
|
$mail->Subject = "Demande d'adhesion validee";
|
|
$mail->Body = "<!DOCTYPE html><html lang='fr'><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>Demande d'adhésion acceptée</title><style>.content {font-family: Bahnschrift;margin: 0 auto;width: 80%;text-align: center;}</style></head><body><div class='content'><h3>Votre demande d'adhesion a ete validee</h3><p>Votre demande d'adhésion a l'association E59-UVSQ a été validée.</p><p>Votre statut de membre sera valable après paiement de la cotisation fixée à 1€/an</p><a href='https://e59.fr/adhesion'>e59.fr/adhesion</a></div></body></html>";
|
|
$mail->AltBody = 'Votre demande d\' adhésion est acceptée, vous pouvez payer votre cotisation sur https://e59.fr/adhesion';
|
|
|
|
// Envoyer l'email
|
|
$mail->send();
|
|
} catch (Exception $e) {
|
|
error_log("Erreur de Mailer: {$mail->ErrorInfo}");
|
|
}
|
|
} else {
|
|
// En cas d'erreur lors de l'insertion, annuler la transaction
|
|
$status = "Erreur lors de l'insertion de la ligne";
|
|
error_log("Erreur lors de l'exécution de la requête d'insertion : " . $insertStmt->errorInfo()[2]);
|
|
}
|
|
} catch (Exception $e) {
|
|
// En cas d'exception, annuler la transaction
|
|
$status = "Erreur SQL";
|
|
error_log("Erreur : " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
|
|
<head>
|
|
<?php fillHead($rootPageURL, "Admin - " . $pageName, $darkTheme, $lightTheme);?>
|
|
<style>
|
|
.users-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.user-row {
|
|
margin: 0.5em;
|
|
border: 1px solid var(--text);
|
|
border-radius: 100px;
|
|
padding: 0 0.5em 0 1em;
|
|
}
|
|
.user-row form {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.user-row button {
|
|
display: inline;
|
|
}
|
|
.users {
|
|
min-height: 25em;
|
|
}
|
|
.admin-links {
|
|
margin-bottom: 4em;
|
|
}
|
|
.admin-links a {
|
|
margin: 0.5em;
|
|
display: inline-block;
|
|
}
|
|
main .content {
|
|
padding-top: 7em;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="body">
|
|
|
|
<header>
|
|
<div class="panel-content">
|
|
<?php fillHeader($rootPageURL, $headerTitle, $headerSubtitle, $social);?>
|
|
</div>
|
|
</header>
|
|
|
|
<nav>
|
|
<div class="panel-content">
|
|
<?php fillNav($rootPageURL);?>
|
|
</div>
|
|
</nav>
|
|
|
|
<main>
|
|
<div class="content">
|
|
<?=$status?>
|
|
<div class="users">
|
|
<?php
|
|
echo ('<div class="admin-links">');
|
|
echo ('<a href="index.php" class="button">Utilisateurs</a>');
|
|
echo ('<a href="adhesions.php" class="button">Demandes d\'adhésion</a>');
|
|
echo ('<a href="adhesions-non-payees.php" class="button">Adhésions non payées</a>');
|
|
echo ('<a href="adherents.php" class="button">Adhérents</a>');
|
|
echo ('<a href="/phpmyadmin" class="button">PHPMyAdmin</a></div>');
|
|
echo ('<form action="" method="get">');
|
|
$shapePath = '<path d="M10.25 3.75c-3.59 0-6.5 2.91-6.5 6.5s2.91 6.5 6.5 6.5c1.795 0 3.419-.726 4.596-1.904 1.178-1.177 1.904-2.801 1.904-4.596 0-3.59-2.91-6.5-6.5-6.5zm-8.5 6.5c0-4.694 3.806-8.5 8.5-8.5s8.5 3.806 8.5 8.5c0 1.986-.682 3.815-1.824 5.262l4.781 4.781-1.414 1.414-4.781-4.781c-1.447 1.142-3.276 1.824-5.262 1.824-4.694 0-8.5-3.806-8.5-8.5z"></path>';
|
|
textInput("text", $shapePath, "search", "Chercher", "");
|
|
echo ('</form>');
|
|
|
|
$search = isset($_GET['search']) ? '%' . $_GET['search'] . '%' : '%%';
|
|
|
|
$sqlRequest = "SELECT adherents.ID, adherents.firstname, adherents.lastname, adherents.email, adherents.join_date FROM adherents WHERE (adherents.lastname LIKE :search OR adherents.firstname LIKE :search) AND adherents.etape_adhesion = 0";
|
|
$request = $pdo->prepare($sqlRequest);
|
|
$request->bindParam(":search", $search);
|
|
$request->execute();
|
|
$result = $request->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($result) {
|
|
echo ('<div class="users-list">');
|
|
foreach($result as $row) {
|
|
echo ('<div class="user-row">');
|
|
echo ('<form action="#" method="post">');
|
|
echo ('<div>' . $row['firstname'] . ' ' . $row['lastname'] . '</div><div>' . $row['join_date'] . '</div><div><input type="hidden" name="adherent-id" value="' . $row['ID'] . '"><button type="submit" style="margin-left: 1em;">Accepter</button></div>');
|
|
echo ('</form></div>');
|
|
}
|
|
echo ('</div>');
|
|
} else {
|
|
echo ('Aucun utilisateur trouvé.');
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div class="panel-content">
|
|
<?php fillFooter($footerText);?>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|