<?php

use Bookingor\Backend\Controller\Location\LocationControl;
use Bookingor\Helper\HelperControl;
use Bookingor\Routes\AdminRoute;

// Exit if accessed directly
if (! defined('ABSPATH')) exit; ?>
<div class="bookingor">
  <!-- Modal -->
  <div class="modal fade" id="locationModal" aria-labelledby="exampleModalLabelAdd" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-dialog-centered">
      <div class="modal-content bkings_pro-model">
        <div class="modal-header flex-column">
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          <div class="boookingor-popup-text">
            <h3 class="modal-title" id="categoryModalLabel"><?php echo esc_html('Add Location'); ?></h3>
            <div class="boookingor-popup-text">
              <span><?php esc_html_e("Add Location details", "bookingor"); ?></span>
            </div>
          </div>
        </div>
        <form id="bp-add-location">
          <div class="modal-body pl-3 pr-3">
            <ul class="nav nav-tabs" id="myTab" role="tablist">
              <li class="nav-item" role="presentation">
                <button class="nav-link active" id="basic-tab" data-bs-toggle="tab" data-bs-target="#basic-tab-pane" type="button" role="tab" aria-controls="basic-tab-pane" aria-selected="true">
                  Basic
                </button>
              </li>
              <!-- location tab  -->
              <?php
              if (class_exists('Bookingor\Backend\Controller\LocationTimeSheet\LocationTimeSheetControl')) {
                require_once wp_normalize_path(WP_PLUGIN_DIR . '/bookingor-location-timesheet/app/Backend/View/LocationTimeSheet/location-timesheet-tab.php');

              ?>
              <?php } ?>
            </ul>
            <div class="tab-content" id="myTabContent">
              <div class="tab-pane fade show active" id="basic-tab-pane" role="tabpanel" aria-labelledby="basic-tab" tabindex="0">
                <div class="row bookingor-g-0">
                  <div class="form-group align-items-center bookingor-col-xl-12">
                    <div class="row">
                      <div class="bookingor-col-12 bookingor-col-sm-12 bookingor-col-md-12 bookingor-col-lg-3 bookingor-col-xl-3">
                        <div class="bookingor-col-12 bookingor-col-sm-12 bookingor-col-md-12 bookingor-col-lg-12 bookingor-col-xl-12">
                          <div class="upload bookingor-c-set">
                            <div class="bookingor-circle">
                              <img id="bkinz-service-icon-add" class="bp-icons del-icon" src="<?php echo esc_attr(AdminRoute::$default_img ? AdminRoute::$default_img :  wp_get_attachment_url($value->service_icon)); ?>" alt="" />
                              <input type="hidden" name="location_icon_id" id="location-icon-id" class="check_validation" value="" />
                            </div>
                            <div class="p-image">
                              <button type="button" class="bookingor-btn bookingor-btn-primary" id="bp-location-icon"><?php esc_html_e("Upload", "bookingor"); ?></button>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="bookingor-col-12 bookingor-col-sm-12 bookingor-col-md-12 bookingor-col-lg-9 bookingor-col-xl-9">
                        <div class="bookingor-col-12 bookingor-col-sm-12 bookingor-col-md-12 bookingor-col-lg-12 bookingor-col-xl-12">
                          <div class="bookingor-flex up-dn">
                            <div class="bookingor-col-12 col-sm-12 pd-1">
                              <label class="h-l-n"><?php esc_html_e("Name", "bookingor"); ?></label>
                            </div>
                            <div class="bookingor-col-12 col-sm-12">
                              <input type="text" class="form-control align-self-start" name="bookingor_location_title" placeholder="Title" />
                            </div>
                          </div>
                        </div>
                        <div class="gap-input justify-content-between g-2 mb-3 bookingor-required-license">
                          <div class="bookingor-col-12 bookingor-g-0">
                            <div class="bookingor-flex up-dn">
                              <div class="bookingor-col-12 col-sm-12 pd-1">
                                <label class="h-l-n"><?php esc_html_e("Country", "bookingor"); ?></label>
                              </div>
                              <div class="bookingor-col-12 col-sm-12">
                                <select class="form-control bookingor-loc-select2" name="bp_location_country" id="country-lists">
                                  <option value="none"><?php esc_html_e("Select Country", "bookingor"); ?></option>
                                  <?php
                                  foreach (HelperControl::getCountriesList() as $key => $value) {
                                  ?>
                                    <option value="<?php echo esc_attr($value); ?>">
                                      <?php echo esc_html($value); ?>
                                    </option>
                                  <?php
                                  }
                                  ?>
                                </select>
                              </div>
                            </div>
                          </div>
                          <div class="bookingor-col-12 bookingor-g-0">
                            <div class="bookingor-flex up-dn">
                              <div class="bookingor-col-12 col-sm-12 pd-1">
                                <label class="h-l-n"><?php esc_html_e("City", "bookingor"); ?></label>
                              </div>
                              <div class="bookingor-col-12 col-sm-12"><input type="text" class="form-control align-self-start" name="bp_location_city_name" placeholder="Landon" /></div>
                            </div>
                          </div>
                        </div>
                        <div class="bookingor-col-5 mb-3 bookingor-required-license">
                          <div class="bookingor-flex up-dn">
                            <div class="bookingor-col-12 col-sm-12 bookingor-col pd-1">
                              <label class="h-l-n"><?php esc_html_e("Phone Number", "bookingor"); ?></label>
                            </div>
                            <div class="bookingor-col-12 col-sm-12">
                              <input type="text" class="form-control align-self-start bookingor-location-phone" name="bp_location_phone_number" placeholder="000-000-000" />
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="row">
                      <div class="bookingor-flex up-dn mb-2">
                        <div class="bookingor-col-12 col-sm-12 bookingor-col pd-1">
                          <label class="h-l-n"><?php esc_html_e("Address", "bookingor"); ?></label>
                        </div>
                        <div class="bookingor-col-12 col-sm-12">
                          <input type="text" required id="bookingor-geocode" autocomplete class="form-control align-self-start" name="bp_location_streetAddress" placeholder="Street Address" />
                        </div>
                      </div>
                    </div>

                    <?php
                    if (is_plugin_active('bookingor-google-maps/bookingor-google-maps.php')) {
                      $file_path = WP_PLUGIN_DIR . '/bookingor-google-maps/admin/partials/google-maps/loaction-google-map-create.php';
                      include_once  $file_path;
                    ?>
                    <?php } ?>
                    <div class="row justify-content-between">
                      <div class="bookingor-col-6">
                        <div class="bookingor-flex up-dn">
                          <div class="bookingor-col-12 col-sm-12 bookingor-col pd-1">
                            <label class="h-l-n"><?php esc_html_e("Latitude", "bookingor"); ?></label>
                          </div>
                          <div class="bookingor-col-12 col-sm-12"><input type="text" class="form-control align-self-start" id="lat" name="bp_location_lati" /></div>
                        </div>
                      </div>
                      <div class="bookingor-col-5">
                        <div class="bookingor-flex up-dn">
                          <div class="bookingor-col-12 col-sm-12 bookingor-col pd-1">
                            <label class="h-l-n"><?php esc_html_e("Longitude", "bookingor"); ?></label>
                          </div>
                          <div class="bookingor-col-12 col-sm-12"><input type="text" class="form-control align-self-start" id="longi" name="bp_location_langi" /></div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <!-- location tab content  -->
              <?php
              if (class_exists('Bookingor\Backend\Controller\LocationTimeSheet\LocationTimeSheetControl')) {
                require_once wp_normalize_path(WP_PLUGIN_DIR . '/bookingor-location-timesheet/app/Backend/View/LocationTimeSheet/location-timesheet-create.php');
              ?>
              <?php } ?>
            </div>
          </div>
          <div class="modal-footer">
            <button type="submit" name="tcn_category_draft" class="bookingor-btn bookingor-btn-secondary bkinz-status" data-dismiss="modal"><?php esc_html_e("Draft", "bookingor"); ?></button>
            <button type="submit" name="tcn_booking_category_save" class="bookingor-btn bookingor-btn-primary bkinz-status"><?php esc_html_e("Save Location", "bookingor");; ?></button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>