Site-Proximo/admin/stock.php

113 lines
3.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="name-column">Nom</th>
<th class="description-column">Description</th>
<th class="quantity-column">Quantité</th>
<th class="price-column">Prix</th>
<th class="code-column">Code Barre</th>
<th class="type-column">Type</th>
<th class="image-column">Image</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 Stocks</h1>
<?php if ($result): ?>
<h2 class="text-center">Ajouter un article</h2>
<table>
<tbody>
<?= $tableHeader ?>
<tr>
<td>
<input type="text" class="form-control" id="nameInput" placeholder="Nom">
</td>
<td>
<input type="text" class="form-control" id="descriptionInput" placeholder="Description">
</td>
<td>
<input type="number" class="form-control" id="quantityInput" placeholder="Quantité">
</td>
<td>
<input type="text" class="form-control" id="priceInput" placeholder="Prix">
</td>
<td>
<input type="text" class="form-control" id="codeInput" placeholder="Code Barre">
</td>
<td id="typeCheckboxesCell">
</td>
<td>
<input type="text" class="form-control" id="imageInput" placeholder="Lien Image">
</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 d'articles</h2>
<table id="stockTable">
<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 le stock
</button>
</div>
<?php else: ?>
<h2 class="text-center">Fichier de stock V2 non trouvé</h2>
<div style="display: flex; margin-top: 50px; margin-bottom: 50px">
<button class="btn btn-success btn-lg" style="margin: auto"
onclick="SaveManager.convertToV2()">
Convertir le stock existant en V2
</button>
</div>
<?php endif; ?>
<script type="text/javascript">
let json_dump =
<?php
if ($result)
echo $result;
else
echo 'undefined'
?>;
</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/stock.css" media="screen,projection"/>
<?php
$pageContent = ob_get_clean();
$pageTitle = "Gestion du stock";
$pageScripts = "<script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/saveManager.js\"></script><script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/stock.js\"></script>";
include($relativePath . "includes/template.php");
?>