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

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

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

            <div class="row border-bottom pb-2">
                <div class="col-xl-9 col-lg-9">
                    <h4 class="page-title fw-bold col-md-6 mb-0"><?= $translate["customers_list"]; ?></h4>
                </div>
                <div class="col-xl-3 col-lg-3 col-md-6 btn-group">
                    <button class="btn btn-indigo text-uppercase btnAddCustomer" type="button"> <i class="ph-plus me-1"></i> <?= $translate["new_customer"]; ?></button>
                </div>
            </div>

            <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-4 col-md-6 col-sm-12 mb-2" style="display: none;">
                    <label class="form-label fw-medium text-uppercase"><?= $translate["branch"]; ?></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-3 col-md-6 col-sm-12 mb-2">
                    <label class="form-label fw-medium text-uppercase"><?= $translate["status"]; ?></label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="ph ph-list-checks"></i></span>
                        <select class="form-control form-control-lg select2 searchStatus" data-width="1%" onchange="listDataToDatatable();">
                            <option value="with_debt" selected><?= $translate["with_debt"]; ?></option>
                            <option value="without_debt"><?= $translate["without_debt"]; ?></option>
                            <!-- <option value="All"><?= $translate["all"]; ?></option> -->
                        </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 -->


        <!-- Content area -->
        <!-- <div class="content"> -->

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

            <table class="table table-sm table-hover customers-table">
                <thead>
                    <tr class="table-dark text-uppercase">
                        <th>#</th>
                        <th><?= $translate["customer"]; ?></th>
                        <th><?= $translate["phone"]; ?></th>
                        <th><?= $translate["debt"]; ?></th>
                        <th><?= $translate["pending_payments"]; ?></th>
                        <th><?= $translate["cashback"]; ?></th>
                        <th><?= $translate["edit"]; ?></th>
                        <th><?= $translate["reset"]; ?></th>
                    </tr>
                </thead>
            </table>

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


        <!-- </div> -->
        <!-- /content area -->

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

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


<!-- CUSTOMER DEBT MODAL -->
<div id="modalCustomerDebtOrdes" class="modal" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title"><?= $translate["pending_payments"]; ?></h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <table class="table table-sm table-hover tbCustomersDebtsOrdersList">
                    <thead>
                        <tr class="table-dark text-uppercase">
                            <th>#</th>
                            <th><?= $translate["branch"]; ?></th>
                            <th><?= $translate["date"]; ?></th>
                            <th><?= $translate["added_by"]; ?></th>
                            <th><?= $translate["total"]; ?></th>
                            <th><?= $translate["debt"]; ?></th>
                            <th><?= $translate["options"]; ?></th>
                        </tr>
                    </thead>
                </table>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="mi-close me-1"></i> <?= $translate["close"]; ?></button>
            </div>
        </div>
    </div>
</div>
<!-- CUSTOMER DEBT MODAL -->


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