<div class="col-12">

    <div class="col-12">
        <button class="btn btn-dark mb-0" onclick="largeModal('eventsCategoriesAddForm')">{$lang["datatable"]["add_promo"]}</button>
    </div>

	{include file='main/datatable.tpl' tableTitle="{$lang.datatable.all_promos}"
	theads=["id", {$lang.datatable.code}, {$lang.datatable.discount_percent}, {$lang.datatable.valid_from}, {$lang.datatable.valid_to}, {$lang.datatable.usage_limit}, {$lang.datatable.count}, {$lang.datatable.actions}]
	data=$promocodes }

    <div id="eventsCategoriesAddForm" class="hidden">
        <h5 class="mt-0">{$lang["datatable"]["add_promo"]}:</h5>
        <form method="POST">
            <input type="hidden" name="form_key" value="{$form_key}">
            <div class="row">
                <div class="col-6">
                    <label class="col-form-label mt-1">{$lang["datatable"]["promo_name"]}</label>
                    <input type="text" class="form-control" name="code" id="code" required>
                </div>
                <div class="col-6">
                    <label class="col-form-label mt-1">{$lang.datatable.discount_percent}</label>
                    <input type="number" class="form-control" name="discount_percent" id="discount_percent" required>
                </div>
                <div class="col-6">
                    <label class="col-form-label mt-1">{$lang.datatable.valid_from}</label>
                    <input type="datetime-local" class="form-control" name="valid_from" id="valid_from" required>
                </div>
                <div class="col-6">
                    <label class="col-form-label mt-1">{$lang.datatable.valid_to}</label>
                    <input type="datetime-local" class="form-control" name="valid_to" id="valid_to" required>
                </div>
                <div class="col-6">
                    <label class="col-form-label mt-1">{$lang.datatable.usage_limit}</label>
                    <input type="number" class="form-control" name="usage_limit" id="usage_limit" required>
                </div>
                <div class="col-12">
                    <button type="submit" name="create_promocode" class="btn btn-success mt-4" id="submitButton">{$lang["datatable"]["add"]}</button>
                </div>
            </div>
        </form>
    </div>


<script>
    var usersSection = document.getElementById('usersSection');
    usersSection.classList.add('active');
    var usersBlock = document.getElementById('usersBlock');
    usersBlock.classList.add('show');

    $("#allPromocodes").addClass("active");

</script>
</div>