<!-- Main content -->
<div class="content-wrapper">

    <!-- Inner content -->
    <div class="content-inner">

        <!-- card card-header -->
        <div class="card card-header mb-2">

            <?php
            if ($_SESSION["user_profile"] == "ROOT") { ?>

                <div class="row border-bottom pb-2">
                    <div class="col-xl-9 col-lg-9 col-md-6">
                        <h4 class="page-title fw-bold mb-0"><?= $translate["sale_types"]; ?></h4>
                    </div>

                    <div class="col-xl-3 col-lg-3 col-md-6 btn-group">
                        <button class="btn btn-indigo text-uppercase btnAddNew" type="button"> <i class="ph-plus me-1"></i> <?= $translate["new_sale_type"]; ?></button>
                    </div>
                </div>
            <?php } else { ?>

                <div class="text-center border-bottom">
                    <h4 class="page-title fw-bold"><?= $translate["sale_types"]; ?></h4>
                </div>

            <?php } ?>

            <div class="row mt-3">

                <?php
                if ($_SESSION["user_profile"] == "ROOT") { ?>

                    <div class="col-lg-3 col-md-6 col-sm-12 mb-2">
                        <label class="form-label fw-medium text-uppercase"><?= $translate["enterprise"]; ?></label>
                        <div class="input-group">
                            <span class="input-group-text"><i class="ph ph-building-office"></i></span>
                            <select class="form-control form-control-lg select2" id="ent_id_value" onchange="selectBranchByUserPermission(this.value);" data-width="1%">
                                <?php

                                $sql = "SELECT ent_id,ent_name FROM tb_enterprises WHERE ent_contract_status = 'Enabled' ORDER BY ent_name ASC;";
                                $answer = executePDOFetchAll($sql, "");

                                foreach ($answer as $key => $value) {
                                    echo "<option value='{$value['ent_id']}' > {$value['ent_name']}</option>";
                                }

                                ?>
                            </select>
                        </div>
                    </div>

                <?php } else { ?>
                    <input type="hidden" id="ent_id_value" value="<?= $_SESSION["user_ent_id"]; ?>">
                <?php }
                ?>

                <div class="col-lg-3 col-md-6 col-sm-12 mb-2">
                    <label class="form-label fw-medium text-uppercase"><?= $translate["branches"]; ?></label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="ph ph-storefront"></i></span>
                        <select class="form-control form-control-lg select2" id="pos_id_value" onchange="listDataToDatatable();" data-width="1%">
                        </select>
                    </div>
                </div>

                <div class="col-lg-2 col-md-6 col-sm-12 mb-2">
                    <label class="form-label fw-medium text-uppercase">&nbsp;</label>
                    <div class="btn-group d-flex">
                        <button type="button" class="btn btn-warning text-uppercase btnSearch"><i class="ph-magnifying-glass me-1"></i> <?= $translate["search"]; ?></button>
                    </div>
                </div>

            </div>

        </div>
        <!-- /card card-header -->

        <!-- Card layout -->
        <div class="card card-header mt-1">

            <table class="table table-sm sales-types-table">
                <thead>
                    <tr class="table-dark text-uppercase">
                        <th>#</th>
                        <th><?= $translate["description"]; ?></th>
                        <th><?= $translate["tax"]; ?></th>
                        <th><?= $translate["tax_law"]; ?></th>
                        <th><?= $translate["additional_tax"]; ?></th>
                        <th><?= $translate["status"]; ?></th>
                        <th><?= $translate["edit"]; ?></th>
                    </tr>
                </thead>
            </table>

        </div>
        <!-- /Card layout -->

    </div>
    <!-- /inner content -->

</div>
<!-- /main content -->



<!-- Add / Edit modal -->
<!-- <div id="enterprise-modal" class="modal" data-bs-keyboard="false" data-bs-backdrop="static" tabindex="-1"> -->
<div id="sale-type-modal" class="modal" tabindex="-1">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title span-modal-title"></h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>

            <form action="" id="frmSaleType" autocomplete="off" method="POST">

                <input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">

                <div class="modal-body">

                    <div class="row">

                        <input type="hidden" name="sale_type_id" id="sale_type_id">
                        <input type="hidden" name="sale_type_ent_id" id="sale_type_ent_id">
                        <input type="hidden" name="sale_type_pos_id" id="sale_type_pos_id">

                        <div class="mb-4 text-uppercase fw-medium notAllowed">
                            <div class="col-lg-12">
                                <div class="input-group">
                                    <span class="input-group-text form-control form-control-lg content-left"><?= $translate["branch"]; ?></span>
                                    <span class="input-group-text form-control form-control-lg pos_description content-right"></span>
                                </div>
                            </div>
                        </div>

                        <div class="col-lg-12 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["description"]; ?> <span class="text-danger fs-15px">*</span></label>
                            <input type="text" class="form-control form-control-lg" name="sale_type_name" id="sale_type_name" required autocomplete="off" placeholder="<?= $translate["description"]; ?>">
                        </div>

                        <div class="col-lg-12 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["tax"]; ?></label>
                            <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="sale_type_tax" id="sale_type_tax">
                                <option value="Yes" selected><?= $translate['yes'] ?></option>
                                <option value="No"><?= $translate['no'] ?></option>
                            </select>
                        </div>

                        <div class="col-lg-12 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["tax_law"]; ?></label>
                            <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="sale_type_tax_law" id="sale_type_tax_law">
                                <option value="Yes"><?= $translate['yes'] ?></option>
                                <option value="No" selected><?= $translate['no'] ?></option>
                            </select>
                        </div>

                        <div class="col-lg-12 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["additional_tax"]; ?></label>
                            <input type="number" step="0.01" class="form-control form-control-lg" name="sale_type_add_tax" id="sale_type_add_tax" required autocomplete="off" min="0" placeholder="0.00" value="0.00">
                        </div>

                    </div>

                </div>
            </form>

            <div class="modal-footer">
                <button type="button" class="btn btn-indigo text-uppercase btnSave"><i class="ph-floppy-disk-back me-1"></i> <?= $translate["save"]; ?></button>
                <button type="button" class="btn btn-indigo text-uppercase btnEdit"><i class="ph-floppy-disk-back me-1"></i> <?= $translate["save"]; ?></button>
                <button type="button" class="btn btn-light text-uppercase" data-bs-dismiss="modal"><i class="mi-close me-1"></i> <?= $translate["close"]; ?></button>
            </div>
        </div>
    </div>
</div>
<!-- /Add / Edit modal -->

<script src="scripts/sale-types.js?v=<?= md5(time()) ?>"></script>