<?php
$_page_title = "Discount";
$_main_root = '../';
require_once $_main_root . 'db/model.php';

$db = new Model();
if (isset($_POST['type'])) {
    if ($_POST['type'] == "list") {
        $list = $db->DiscountList();
        header('Content-Type: application/json');
        echo json_encode($list);
        exit;
    }
}

include($_main_root . 'content/common/header.php');
if (!Permission(2)) {
    return;
}
?>

<style>
    #dataTable tbody td:nth-child(2){
        text-align: end;
    }

    #dataTable tbody td:nth-child(3),
    #dataTable tbody td:nth-child(4) {
        text-align: center;
    }
</style>

<!-- modal -->
<div id="modalDiv"></div>

<div class="container container-fluid">
    <div class="my-4 d-flex justify-content-between align-items-center">
        <h2 style="color:var(--s-text-color);">Discount LIST</h2>
        <div>
        <a href="package.php" class="btn btn-sm btn-outline-info ms-3">PACKAGE</a>
            <button class="btn btn-sm btn-outline-info" onclick="DetailDiscount(0)">
                <i class="bi bi-plus-circle me-2"></i> NEW DISCOUNT
            </button>
        </div>
    </div>

    <div class="row my-4">
        <div class="table-responsive-lg">
            <table id="dataTable" class="table table-sm table-dark table-hover table-bordered" style="width: 100%;">

                <thead style="color:var(--s-text-color);" class="mt-3">
                    <th class="">Package Name</th>
                    <th style="width: 80px;">Discount</th>
                    <th style="width: 80px;">Valid From</th>
                    <th style="width: 80px;">Valid Until</th>
                    <th style="width: 50px;">Action</th>
                </thead>
                <tbody>
                </tbody>
            </table>

        </div>
    </div>
</div>

<?php $s_scripts = ['discount']; ?>
<?php include($_main_root . 'content/common/footer.php'); ?>