Site-Proximo/admin/categories.php

87 lines
2.6 KiB
PHP

<?php
$relativePath = "../";
$file = '../data/stock-v2.json';
$fp = fopen($file, 'r');
$result = fread($fp, filesize($file));
fclose($fp);
ob_start();
?>
<tr>
<th class="id-column">Id</th>
<th class="name-column">Nom</th>
<th class="icon-column">
<a href="https://materialdesignicons.com/" target="_blank">
Icone
<i class="fas fa-external-link-alt"></i>
</a>
</th>
<th class="actions-column">Actions</th>
</tr>
<?php
$tableHeader = ob_get_clean();
ob_start();
?>
<div class="admin-container">
<a href="index.php">
<button class="btn btn-primary btn-large">Retour</button>
</a>
<h1 class="text-center">Gestion des Catégories</h1>
<h2 class="text-center">Ajouter une catégorie</h2>
<table>
<tbody>
<?= $tableHeader ?>
<tr>
<td>
<input type="text" class="form-control" id="idInput" placeholder="Id">
</td>
<td>
<input type="text" class="form-control" id="nameInput" placeholder="Nom">
</td>
<td>
<input type="text" class="form-control" id="iconInput" placeholder="Icone">
</td>
<td>
<button type="submit" class="btn btn-success" onclick="addNewItem()"><i class="fas fa-check"></i>
</button>
</td>
</tr>
</tbody>
</table>
<h2 class="text-center">Liste des catégories</h2>
<table id="categoriesTable">
<tbody>
<?= $tableHeader ?>
</tbody>
</table>
<div style="display: flex; margin-top: 100px; margin-bottom: 100px">
<button class="btn btn-success btn-lg" style="margin: auto"
onclick="saveDataset()">
Sauvegarder les catégories
</button>
</div>
<script type="text/javascript">
let json_dump = <?php echo $result; ?>;
</script>
</>
<link type="text/css" rel="stylesheet" href="https://cdn.materialdesignicons.com/4.4.95/css/materialdesignicons.min.css"
media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="<?= $relativePath ?>assets/css/admin.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="<?= $relativePath ?>assets/css/categories.css" media="screen,projection"/>
<?php
$pageContent = ob_get_clean();
$pageTitle = "Gestion des catégories";
$pageScripts = "<script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/saveManager.js\"></script><script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/categories.js\"></script>";
include($relativePath . "includes/template.php");
?>