<?php

use Bookingor\Backend\Controller\Customer\CustomerControl;

// Exit if accessed directly
if (! defined('ABSPATH')) exit; ?>
<div class="wrap bookingor">
  <header>
    <div class="bookingor-header">
      <div class="bookingor-flex bkinz-justify-b bkinz-width bkinz-align-items-c p-0-1">
        <div class="bookingor-flex bkinz-align-items-c">
          <div class="bkinz-m-0 p-r up-heading"><?php esc_html_e("Customer", "bookingor"); ?></div>
        </div>

      </div>
    </div>
  </header>
  <div class="bookingor">
    <div id="myTable" class="bookingor-admin-bg t-p-all bookingor-d-none">
      <table id="example" class="table table-hover mb-0 table table-bordered">
        <thead class="bookingor-t-head bookingor-t-h-r">
          <tr>
            <th class="bookingor-t-h-f">
              <?php esc_html_e('ID', 'bookingor'); ?>

            </th>
            <th class="bookingor-t-h-f"><?php esc_html_e("Customer", "bookingor"); ?></th>
            <th class="bookingor-t-h-f"><?php esc_html_e("total Bookings", "bookingor"); ?></th>
            <th class="bookingor-t-h-f"><?php esc_html_e("Last Appointment", "bookingor"); ?></th>
            <th class="bookingor-t-h-f"><?php esc_html_e("Paid Amount", "bookingor"); ?></th>
            <th class="bookingor-t-h-f"><?php esc_html_e("Bookingor Login", "bookingor"); ?></th>
            <th class="bookingor-t-h-f"><?php esc_html_e("Action", "bookingor"); ?></th>
          </tr>
        </thead>
        <tbody>
          <?php
          foreach (CustomerControl::bp_get_customer_view() as $key => $value) { ?>
            <tr class="bookingor-t-row">
              <td class="bookingor-t-f">
                <div><?php echo esc_html($value->customer_id); ?></div>
              </td>
              <td class="bookingor-t-f">
                <div class="bookingor-flex align-items-center">
                  <div class="bkinz-category-icon-view">
                  </div>
                  <div>
                    <div><?php echo esc_html($value->customer_first_name . " " . $value->customer_last_name); ?></div>
                    <div><?php echo esc_html($value->customer_email); ?></div>
                    <div><?php echo esc_html($value->customer_phone); ?></div>
                  </div>
                </div>
              </td>
              <td class="bookingor-t-f"><?php echo esc_html($value->total_booking); ?></td>
              <td class="bookingor-t-f"><?php echo esc_html($value->picked_date); ?></td>
              <td class="bookingor-t-f"><?php echo esc_html($value->paid_amount); ?></td>
              <td class="bookingor-t-f">
                <div><?php echo esc_html(get_user_by('email', $value->customer_email) ? 'Yes' : 'No'); ?></div>
              </td>
              <td class="bookingor-t-f">
                <div class="dropdown bookingor-flex c-drop">
                  <button
                    type="button"
                    class="bookingor-btn bookingor-btn-dim bookingor-btn-sm payment-view-update shw-bkdrp"
                    data-id="<?php echo esc_attr($value->customer_id); ?>"
                    data-bs-target="#myModal-<?php echo esc_html($value->customer_id); ?>"
                    data-bs-toggle="modal"><?php esc_html_e("Details", "bookingor"); ?>
                  </button>
                  <div class="modal fade" id="myModal-<?php echo esc_attr($value->customer_id); ?>" aria-hidden="true" tabindex="-1">
                    <div class="modal-dialog modal-dialog-centered mod-wd">
                      <div class="modal-content">
                        <div class="modal-header bookingor">
                          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body mod-pd">
                          <input type="hidden" name="get_pay_id" value="<?php echo esc_attr($value->customer_id); ?>" />
                          <div class="pay-n-h"><?php esc_html_e("Customer Info:", "bookingor"); ?></div>
                          <div class="row m-top">
                            <div class="mb-3">
                              <div class="mt bookingor-flex justify-content-between">
                                <div class="sm-ft mb-1">
                                  <div><?php esc_html_e("First Name:", "bookingor"); ?></div>
                                  <?php echo  esc_html($value->customer_first_name); ?>
                                </div>
                                <div class="sm-ft mb-1">
                                  <div><?php esc_html_e("Last Name:", "bookingor"); ?></div>
                                  <?php echo  esc_html($value->customer_last_name); ?>
                                </div>
                              </div>
                              <div class="sm-ft mb-1">
                                <div><?php esc_html_e("Email", "bookingor"); ?></div>
                                <div><?php echo esc_html($value->customer_email); ?></div>
                              </div>
                              <div class="sm-ft mb-1">
                                <div><?php esc_html_e("Phone", "bookingor"); ?></div>
                                <div><?php echo esc_html($value->customer_phone); ?></div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </td>
            <?php  }
            ?>
            </tr>
        </tbody>
      </table>
    </div>

  </div>
</div>