69 lines
1.5 KiB
PHP
69 lines
1.5 KiB
PHP
<?php
|
|
|
|
require_once("./assets/php/utils.php");
|
|
|
|
if (!is_connected()) {
|
|
header("location: login.php");
|
|
}
|
|
|
|
$erreur = "";
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["delete"])) {
|
|
if (!delete_cupboard($_POST["delete"])) {
|
|
$erreur = "<p>An item is in this cupboard, you can't delete it now.</p>\n";
|
|
}
|
|
}
|
|
|
|
$cupboard_list = "";
|
|
foreach (get_users_cupboards_array() as $row) {
|
|
$cupboard_list = $cupboard_list . "<tr><td>"
|
|
. htmlspecialchars($row["name"])
|
|
. "</td><td>"
|
|
. htmlspecialchars($row["description"])
|
|
. "</td><td>"
|
|
. "<form method='post'><button type='publish' name='delete' value='" . $row["public_id"] . "'>Delete</button></form>"
|
|
. "</td></tr>\n";
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<style type="text/css">
|
|
table,
|
|
th,
|
|
td {
|
|
border: 1px solid #333;
|
|
}
|
|
</style>
|
|
<title>List cupboard</title>
|
|
</head>
|
|
|
|
<body>
|
|
<?php echo $erreur; ?>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
Nom
|
|
</th>
|
|
<th>
|
|
Description
|
|
</th>
|
|
<th>
|
|
Supprimer
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php echo $cupboard_list; ?>
|
|
</tbody>
|
|
</table>
|
|
</body>
|
|
|
|
</html>
|