<?php
$relativePath = "../";

if (!isset($isStock))
    $isStock = false;

ob_start();
?>
<div class="admin-container">

    <a href="index.php">
        <button class="btn btn-primary btn-large">
            <span class="mdi mdi-chevron-left"></span>
            Retour
        </button>
    </a>

    <h1 class="text-center"><?= $pageTitle ?></h1>

    <?php if (!$isStock): ?>
        <div style="display: flex">
            <button class="btn btn-success" style="margin: auto" onclick="listManager.showEditPopup(-1)">
                <i class="mdi mdi-plus"></i>
            </button>
        </div>
        <div id="listContainer">
            <ul id="dataList">

            </ul>
        </div>
    <?php else: ?>
        <div>
            <h3 class="text-center">Mode</h3>
            <div class="button-container">
                <button id="buyButton" class="btn mr-0">Achat</button>
                <button id="sellButton" class="btn ml-0">Vente</button>
            </div>
        </div>
        <div id="dataList">

        </div>
        <div style="display: flex">
            <button id="saveButton" style="margin: auto" class="btn btn-lg my-2">Sauvegarder</button>
        </div>
    <?php endif; ?>

</div>


<link type="text/css" rel="stylesheet" href="<?= $relativePath ?>assets/css/libs/materialdesignicons.min.css"
      media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="<?= $relativePath ?>assets/css/admin.css" media="screen,projection"/>

<?php if (!$isStock): ?>
    <link type="text/css" rel="stylesheet" href="<?= $relativePath ?>assets/css/list.css" media="screen,projection"/>
<?php else: ?>
    <link type="text/css" rel="stylesheet" href="<?= $relativePath ?>assets/css/stock.css" media="screen,projection"/>
<?php endif; ?>

<?php
$pageContent = ob_get_clean();
$pageScripts =
    "
    <script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/jquery-confirm-defaults.js\"></script>
    <script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/ajaxManager.js\"></script>
    <script type=\"text/javascript\" src=\"" . $relativePath . "assets/js/listManager.js\"></script>
    ";
$pageScripts .= $script;
include($relativePath . "includes/template.php");
?>
