<!-- 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["providers_list"]; ?></h4>
                </div>
                <div class="col-xl-3 col-lg-3 col-md-6 btn-group">
                    <button class="btn btn-indigo text-uppercase btnAddProvider" type="button"> <i class="ph-plus me-1"></i> <?= $translate["new_provider"]; ?></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["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="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 -->


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

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

            <table class="table table-sm table-hover providers-table">
                <thead>
                    <tr class="table-dark text-uppercase">
                        <th>#</th>
                        <th><?= $translate["branch"]; ?></th>
                        <th><?= $translate["provider"]; ?></th>
                        <th><?= $translate["address"]; ?></th>
                        <th><?= $translate["phone"]; ?></th>
                        <th><?= $translate["fiscal_number"]; ?></th>
                        <th><?= $translate["status"]; ?></th>
                        <th><?= $translate["edit"]; ?></th>
                    </tr>
                </thead>
            </table>

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


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

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

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


<!-- PROVIDER MODAL -->
<div id="provider-modal" class="modal" tabindex="-1">
    <div class="modal-dialog">
        <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="frmAddEditProvider" 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="prov_id" id="prov_id">
                        <input type="hidden" name="prov_ent_id" id="prov_ent_id">
                        <input type="hidden" name="prov_pos_id" id="prov_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-6 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["provider_name"]; ?> <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="prov_name" id="prov_name" required autocomplete="off" placeholder="<?= $translate["provider_name"]; ?>">
                            </div>
                        </div>

                        <div class="col-lg-6 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["fiscal_number"]; ?> (EIN-RNC-NIF)</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="ph-hash-straight"></i></span>
                                <input type="text" class="form-control form-control-lg" name="prov_fiscal_number" id="prov_fiscal_number" required autocomplete="off" placeholder="<?= $translate["fiscal_number"]; ?>">
                            </div>
                        </div>

                        <div class="col-lg-12 mt-2 mb-4 border-bottom text-center">
                            <label class="fs-base fw-bold pb-2 text-uppercase"><?= $translate["address_and_contact"]; ?></label>
                        </div>

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

                        <div class="col-lg-6 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-simple"></i></span>
                                <input type="email" class="form-control form-control-lg" name="prov_email" id="prov_email" required autocomplete="off" placeholder="email@domain.com">
                            </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="prov_address" id="prov_address" required autocomplete="off" placeholder="<?= $translate["address"]; ?>">
                            </div>
                        </div>

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

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

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

                        <div class="col-lg-6 col-md-12 mb-3">
                            <label class="form-label"><?= $translate["country"]; ?></label>
                            <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="prov_country" id="prov_country">
                                <?php

                                $sql = "SELECT country_code,country_name FROM tb_countries ORDER BY country_id ASC;";
                                $answer = executePDOFetchAll($sql, "");

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

                                ?>
                            </select>
                        </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>
<!-- PROVIDER MODAL -->


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