<!-- 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["enterprises_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["new_enterprise"]; ?></button>
                </div>
            </div>

            <div class="row mt-3">

                <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%">
                            <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 table-hover enterprise-table">
                <thead>
                    <tr class="table-dark text-uppercase">
                        <th>#</th>
                        <th><?= $translate["logo"]; ?></th>
                        <th><?= $translate["enterprise"]; ?></th>
                        <th><?= $translate["document"]; ?></th>
                        <th><?= $translate["email"]; ?></th>
                        <th><?= $translate["notification"]; ?></th>
                        <th><?= $translate["email_report"]; ?></th>
                        <th><?= $translate["status"]; ?></th>
                        <th><?= $translate["contract"]; ?></th>
                        <th><?= $translate["edit"]; ?></th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

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

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

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



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

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

                <div class="modal-body">

                    <div class="col-lg-10 offset-lg-1">

                        <input type="hidden" name="requested" value="admin">
                        <input type="hidden" name="ent_id" id="ent_id">

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

                        <div class="row mb-3">
                            <label class="col-lg-3 col-form-label"><?= $translate["document_type"]; ?></label>
                            <div class="col-lg-9">
                                <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="ent_document" id="ent_document">
                                    <option value="EIN" selected>EIN</option>
                                    <option value="NIF">NIF</option>
                                    <option value="RNC">RNC</option>
                                    <option value="DNI">DNI</option>
                                </select>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label class="col-lg-3 col-form-label"><?= $translate["document_number"]; ?></label>
                            <div class="col-lg-9">
                                <input type="text" class="form-control form-control-lg" name="ent_document_number" id="ent_document_number" required autocomplete="off" placeholder="<?= $translate["document_number"]; ?>">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label class="col-lg-3 col-form-label"><?= $translate["email"]; ?></label>
                            <div class="col-lg-9">
                                <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="ent_email" id="ent_email" required autocomplete="off" placeholder="email@domain.com">
                                </div>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label class="col-lg-3 col-form-label"><?= $translate["website"]; ?></label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                    <span class="input-group-text"><i class="ph-globe"></i></span>
                                    <input type="text" class="form-control form-control-lg" name="ent_website_url" id="ent_website_url" required autocomplete="off" placeholder="domain.com">
                                </div>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label class="col-lg-3 col-form-label"><?= $translate["logo"]; ?></label>
                            <div class="col-lg-7 col-md-9">
                                <input type="file" class="form-control form-control-lg new_picture" name="ent_logo" id="ent_logo">
                                <div class="form-text"><?= $translate["accepted_formats_png_jpg_2_mb"]; ?></div>
                            </div>
                            <div class="col-lg-2 col-md-3 text-end">
                                <img src="assets/images/no-image.png" class="w-100px h-100px rounded-pill picturePreview">
                            </div>
                        </div>


                        <div class="col-lg-12 d-flex justify-content-center border-bottom mb-4">
                            <h4 class="text-uppercase mb-0 fs-base"><?= $translate["online_billing"]; ?></h4>
                        </div>

                        <div class="row">


                            <div class="col-lg-4 col-md-12">
                                <label class="form-label"><?= $translate['online_billing'] ?> <span class="text-danger">*</span></label>
                                <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="ent_online_billing_status" id="ent_online_billing_status">
                                    <option value="Enabled"><?= $translate['enabled'] ?></option>
                                    <option value="Disabled" selected><?= $translate['disabled'] ?></option>
                                </select>
                            </div>

                            <div class="col-lg-8 col-md-12">
                                <label class="form-label"><?= $translate['subscription_plan'] ?> <span class="text-danger">*</span></label>
                                <select class="form-control form-control-lg select2" data-minimum-results-for-search="Infinity" name="ent_plan_id" id="ent_plan_id">
                                    <?php

                                    $sql = "SELECT plan_id, plan_name, plan_price, plan_recurring, plan_interval, plan_interval_count FROM tb_stripe_plans ORDER BY plan_id ASC;";
                                    $answer = executePDOFetchAll($sql, "");

                                    foreach ($answer as $key => $value) {
                                        $priceFormatted = '$' . number_format($value['plan_price'], 2);
                                        $plan_recurring = 'One-Time';
                                        if ($value['plan_recurring'] == 'Yes') {
                                            $plan_recurring = "Recurring -> (Each " . $value['plan_interval_count'] . " " . ucfirst($value['plan_interval']) . ")";
                                        }
                                        echo "<option value='{$value['plan_id']}' > {$value['plan_name']} -> {$priceFormatted} -> {$plan_recurring}</option>";
                                    }
                                    ?>
                                </select>
                            </div>

                        </div>


                        <div class="col-lg-12 d-flex justify-content-center border-bottom mt-4 mb-4">
                            <h4 class="text-uppercase mb-0 fs-base"><?= $translate["access_code"]; ?></h4>
                        </div>

                        <div class="row">

                            <div class="col-lg-4 col-md-12">
                                <div class="mb-3">
                                    <label class="form-label"><?= $translate["cancellation_code"]; ?></label>
                                    <div class="input-group">
                                        <span class="input-group-text"><i class="ph-lock"></i></span>
                                        <input type="number" class="form-control form-control-lg" name="ent_cancel_password" id="ent_cancel_password" required autocomplete="off" value="1234" placeholder="****">
                                    </div>
                                </div>
                            </div>

                            <div class="col-lg-4 col-md-12">
                                <div class="mb-3">
                                    <label class="form-label"><?= $translate["discount_code"]; ?></label>
                                    <div class="input-group">
                                        <span class="input-group-text"><i class="ph-lock"></i></span>
                                        <input type="number" class="form-control form-control-lg" name="ent_discount_password" id="ent_discount_password" required autocomplete="off" value="1234" placeholder="****">
                                    </div>
                                </div>
                            </div>

                            <div class="col-lg-4 col-md-12">
                                <div class="mb-3">
                                    <label class="form-label"><?= $translate["statistics_code"]; ?></label>
                                    <div class="input-group">
                                        <span class="input-group-text"><i class="ph-lock"></i></span>
                                        <input type="number" class="form-control form-control-lg" name="ent_statistic_password" id="ent_statistic_password" required autocomplete="off" value="1234" placeholder="****">
                                    </div>
                                </div>
                            </div>

                        </div>


                        <div class="row mb-3">
                            <label class="col-lg-3 col-form-label"><?= $translate["text_notification"]; ?></label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="ph-bell"></i></span>
                                <input type="text" class="form-control form-control-lg" name="ent_notification_text" id="ent_notification_text" required autocomplete="off" placeholder="<?= $translate["text_notification"]; ?>">
                            </div>
                        </div>

                    </div>

                </div>
            </form>
            <!-- style="display: none;" -->
            <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 Product modal -->

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