2024-12-07 10:21:28 +00:00

110 lines
4.1 KiB
PHP
Executable File

<?php
require("../../include/variables.php");
require("../../include/init.php");
if (!isset($_SESSION['userRole']) || $_SESSION['userRole'] != 51) {
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);
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php fillHead($rootPageURL, "Admin - " . $pageName, $darkTheme, $lightTheme);?>
<style>
.checkouts-list {
display: flex;
flex-direction: column;
}
.checkout-row {
margin: 0.5em;
border-bottom: 1px solid var(--text);
padding: 0 1em 0.5em 1em;
display: flex;
}
.checkout-row button {
display: inline;
}
.checkouts {
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="checkouts">
<?php
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 checkouts.amount, checkouts.reference, checkouts.currency, checkouts.date, users.display_name, checkouts.type FROM checkouts JOIN users ON checkouts.userid = users.ID WHERE checkouts.reference LIKE :search OR checkouts.description LIKE :search ORDER BY date DESC";
$request = $pdo->prepare($sqlRequest);
$request->bindParam(":search", $search);
$request->execute();
$result = $request->fetchAll(PDO::FETCH_ASSOC);
if ($result) {
echo ('<div class="checkouts-list">');
$types = array(
1 => "Don",
2 => "Achat"
);
foreach($result as $row) {
echo ('<div class="checkout-row">');
echo ('<div style="width: 10em;">' . $row['reference'] . '</div><div style="width: 10em;">' . $row['amount'] . ' ' . $row['currency'] . '</div><div style="width: 15em;">' . $row['date'] . '</div><div style="width: 20em;">' . $row['display_name'] . '</div><div style="width: 8em;">' . $types[$row['type']] . '</div></div>');
}
echo ('</div>');
} else {
echo ('Aucun checkout trouvé.');
}
?>
</div>
</div>
</main>
<footer>
<div class="panel-content">
<?php fillFooter($footerText);?>
</div>
</footer>
</body>
</html>