<!-- 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 col-md-6">
                    <h4 class="page-title fw-bold mb-0"><?= $translate["users_list"]; ?></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["add_user"]; ?></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-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-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" onchange="listDataToDatatable();" data-width="1%">
                            <option value="Enabled" selected><?= $translate["enabled"]; ?></option>
                            <option value="Disabled"><?= $translate["disabled"]; ?></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 -->

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

            <table class="table table-sm users-table">
                <thead>
                    <tr class="table-dark text-uppercase">
                        <th>#</th>
                        <th><?= $translate["branch"]; ?></th>
                        <th><?= $translate["picture"]; ?></th>
                        <th><?= $translate["full_name"]; ?></th>
                        <th><?= $translate["user"]; ?></th>
                        <th><?= $translate["profile"]; ?></th>
                        <th><?= $translate["last_login"]; ?></th>
                        <th><?= $translate["last_activity"]; ?></th>
                        <th><?= $translate["email_report"]; ?></th>
                        <th><?= $translate["status"]; ?></th>
                        <th><?= $translate["options"]; ?></th>
                    </tr>
                </thead>
            </table>

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

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

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



<!-- Add / Edit Users modal -->
<!-- <div id="enterprise-modal" class="modal" data-bs-keyboard="false" data-bs-backdrop="static" tabindex="-1"> -->
<div id="user-modal" class="modal" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <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="frmUsers" autocomplete="off" method="POST" enctype="multipart/form-data">

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

                <div class="modal-body">

                    <div class="row">

                        <input type="hidden" name="user_id" id="user_id">
                        <input type="hidden" name="user_ent_id" id="user_ent_id">
                        <input type="hidden" name="user_pos_id" id="user_pos_id">
                        <input type="hidden" name="current_password" id="current_password">

                        <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-6 col-md-12">

                            <div class="card border-top">

                                <!-- <div class="mt-3 mb-1 text-center border-bottom-0">
                                    <label class="form-label text-uppercase fw-medium"><?= $translate["personal_information"]; ?></label>
                                </div> -->

                                <!-- <hr class="mt-1"> -->

                                <div class="card-body">
                                    <div class="row">

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

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

                                        <div class="col-lg-6 col-md-12 mb-3">
                                            <label class="form-label"><?= $translate["document_type"]; ?> <span class="text-danger">*</span></label>
                                            <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="user_document" id="user_document">
                                                <option value="Passport" selected><?= $translate['passport'] ?></option>
                                                <option value="License"><?= $translate['license'] ?></option>
                                                <option value="ID"><?= $translate['identification_card'] ?></option>
                                            </select>
                                        </div>

                                        <div class="col-lg-6 col-md-12 mb-3">
                                            <label class="form-label"><?= $translate["document_number"]; ?> <span class="text-danger">*</span></label>
                                            <input type="text" class="form-control form-control-lg" name="user_document_number" id="user_document_number" required autocomplete="off">
                                        </div>

                                        <div class="col-lg-6 col-md-12 mb-3">
                                            <label class="form-label"><?= $translate["date_of_birth"]; ?></label>
                                            <div class="input-group">
                                                <span class="input-group-text"><i class="ph-calendar"></i></span>
                                                <input type="text" class="form-control form-control-lg daterange-single" name="user_birthday" id="user_birthday" value="<?= date("Y-m-d"); ?>" autocomplete="off">
                                            </div>
                                        </div>

                                        <div class="col-lg-6 col-md-12 mb-3">
                                            <label class="form-label"><?= $translate["phone"]; ?></label>
                                            <div class="input-group">
                                                <input type="tel" class="form-control form-control-lg intelli-phone" id="user_phone" name="user_phone" required autocomplete="off">
                                            </div>
                                        </div>

                                        <div class="col-lg-12 col-md-12 mb-3">
                                            <label class="form-label"><?= $translate["email"]; ?></label>
                                            <div class="input-group">
                                                <span class="input-group-text"><i class="ph-envelope"></i></span>
                                                <input type="email" class="form-control form-control-lg" id="user_email" name="user_email" required autocomplete="off">
                                            </div>
                                        </div>

                                        <div class="col-lg-12 col-md-12 mb-3">
                                            <label class="form-label"><?= $translate["address"]; ?></label>
                                            <div class="input-group">
                                                <span class="input-group-text"><i class="ph-map-pin"></i></span>
                                                <input type="text" class="form-control form-control-lg" name="user_address" id="user_address" required autocomplete="off" placeholder="<?= $translate["address"]; ?>">
                                            </div>
                                        </div>

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

                        <div class="col-lg-6 col-md-12">

                            <div class="card card-body border-top">
                                <div class="row">

                                    <div class="col-lg-12 col-md-12 mb-3 d-flex justify-content-center">
                                        <img src="assets/images/anonymous.png" class="w-90px h-90px rounded-pill picturePreview">
                                    </div>

                                    <hr class="mt-1 mb-4">

                                    <div class="col-lg-6 col-md-12 mb-3">
                                        <label class="form-label"><?= $translate["profile"]; ?> <span class="text-danger">*</span></label>
                                        <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="user_profile" id="user_profile">
                                        </select>
                                    </div>

                                    <div class="col-lg-6 col-md-12 mb-3">
                                        <label class="form-label"><?= $translate["username"]; ?> <span class="text-danger">*</span></label>
                                        <div class="input-group">
                                            <span class="input-group-text"><i class="ph-user"></i></span>
                                            <input type="text" class="form-control form-control-lg" name="user_name" id="user_name" autocomplete="off">
                                        </div>
                                    </div>

                                    <div class="col-lg-6 col-md-12 mb-3">
                                        <label class="form-label"><?= $translate["password"]; ?> <span class="text-danger">*</span></label>
                                        <div class="input-group">
                                            <span class="input-group-text"><i class="ph-lock"></i></span>
                                            <input type="password" class="form-control form-control-lg" name="user_password" id="user_password" autocomplete="off">
                                        </div>
                                    </div>

                                    <div class="col-lg-6 col-md-12 mb-3">
                                        <label class="form-label"><?= $translate["confirm_password"]; ?> <span class="text-danger">*</span></label>
                                        <div class="input-group">
                                            <span class="input-group-text"><i class="ph-lock"></i></span>
                                            <input type="password" class="form-control form-control-lg" name="user_password_confirm" id="user_password_confirm" autocomplete="off">
                                        </div>
                                    </div>

                                    <div class="col-lg-12 col-md-12 mb-3">
                                        <label class="form-label"><?= $translate["profil_picture"]; ?></label>
                                        <input type="file" class="form-control form-control-lg new_picture" name="user_image" id="user_image">
                                        <div class="form-text"><?= $translate["accepted_formats_png_jpg_2_mb"]; ?></div>
                                    </div>

                                </div>
                            </div>
                        </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 Users modal -->


<!-- Add / Edit POS Permissions modal -->
<!-- <div id="enterprise-modal" class="modal" data-bs-keyboard="false" data-bs-backdrop="static" tabindex="-1"> -->
<div id="user-branch-permission-modal" class="modal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title"><?= $translate["branch_permissions"]; ?></h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>

            <div class="modal-body">

                <div class="row">

                    <input type="hidden" id="user_id_branch_permission" value="">

                    <div class="col-lg-12 mb-2">
                        <label class="col-form-label">&nbsp;</label>
                        <button type="button" class="btn btn-warning" id="btn-select-all"><i class="ph-check-circle me-1"></i> <?= $translate["select_all"]; ?></button>
                    </div>

                    <div class="col-lg-12 mb-3">
                        <select multiple class="form-control select-access-multiple-open user_branch_permission" data-width="100%">
                        </select>
                    </div>

                </div>

                <div class="border-top mt-3 mb-2"></div>

                <div class="btn-group d-flex">
                    <button type="button" class="btn btn-indigo text-uppercase btnSaveBranchPermission"><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>
</div>
<!-- /Add / Edit POS Permissions modal -->


<!-- Add / Edit Permissions modal -->
<!-- <div id="enterprise-modal" class="modal" data-bs-keyboard="false" data-bs-backdrop="static" tabindex="-1"> -->


<!-- <div id="user-permission-modal" class="modal" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title"><?= $translate["role_permissions"]; ?></h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>

            <form action="" id="frmUsersPermission" 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="perm_user_id" id="perm_user_id">

                        <div class="d-flex justify-content-center align-items-center text-center">
                            <div class="mb-3">
                                <div class="border p-3 rounded">
                                    <div class="d-flex justify-content-between align-items-center form-check form-check-inline form-switch">
                                        <input type="checkbox" class="form-check-input form-check-input-lg form-check-input-indigo me-1" id="sc_li_c" checked>
                                        <label class="form-check-label fs-5 fw-semibold" for="sc_li_c"><?= $translate["select_all"]; ?></label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="permissions-section">

                            <div class="mb-3">
                                <p class="fw-semibold text-uppercase"><?= $translate["sales"]; ?></p>
                                <div class="border p-3 rounded">
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">View list</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_c">Create</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Show</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Edit</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Status</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Print</label>
                                    </div>
                                </div>
                            </div>

                            <div class="mb-3">
                                <p class="fw-semibold text-uppercase"><?= $translate["branches"]; ?></p>
                                <div class="border p-3 rounded">
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">View list</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_c">Create</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Show</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Edit</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Status</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Festive</label>
                                    </div>
                                </div>
                            </div>

                            <div class="mb-3">
                                <p class="fw-semibold text-uppercase"><?= $translate["tax_receipts"]; ?></p>
                                <div class="border p-3 rounded">
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">View list</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_c">Create</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Edit</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Add Record</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Show record</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Reset</label>
                                    </div>
                                    <div class="form-check form-check-inline form-switch mb-2 me-4">
                                        <input type="checkbox" class="form-check-input form-check-input-secondary" id="sc_li_c" checked>
                                        <label class="form-check-label" for="sc_li_u">Status</label>
                                    </div>
                                </div>
                            </div>

                        </div>



                    </div>
            </form>

            <div class="modal-footer">
                <button type="button" class="btn btn-indigo text-uppercase btnSavePermission"><i class="ph-floppy-disk-back me-1"></i> <?= $translate["save"]; ?></button>
                <button type="button" class="btn btn-indigo text-uppercase btnEditPermission"><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 Permissions modal -->


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