<?php

use Bookingor\Frontend\Controller\Category\CategoryControlFront;
use Bookingor\Helper\HelperControl;
use Bookingor\Frontend\Controller\Staff\StaffControlFront;
use Bookingor\Frontend\Controller\Service\ServiceControlFront;
use Bookingor\Frontend\Controller\Location\LocationControlFront;

// Exit if accessed directly
if (! defined('ABSPATH')) exit; ?>

<div id="bookingor-service" class="b_kings_pro">
  <div class="mt-3">
    <label class="wid-lbl bookingor-f-14 bookingor-service-heading"><?php echo esc_html(get_option('bookingor_settings_service_name')); ?></label>
    <?php
    if (ServiceControlFront::check_wc_id_empty_db()) { ?>
      <div class="bookingor-alert-woocommerce">
        <div>
          <?php esc_html_e('Connect WooCommerce to Bookingor Services', 'bookingor') ?>
        </div>
        <a href="https://youtu.be/20S6_k1g_gA" class="bookingor-btn" target="_blank">
          <?php esc_html_e('checkout video', 'bookingor'); ?>
        </a>
      </div>
    <?php } else { ?>
      <select name="select_service" class="bd form-control form-select" id="front-get-category-for-services">
        <option value=""><?php esc_html_e("Select ", "bookingor"); ?><?php echo esc_html(get_option('bookingor_settings_service_name')); ?></option>
        <?php foreach (ServiceControlFront::bp_front_services_view() as $key =>  $data) { ?>
          <option data-staff-get-id="<?php echo esc_attr($data['staff_get_id']); ?>" data-location-get-id="<?php echo esc_attr($data['location_get_id']); ?>" data-service-id="<?php echo esc_attr($data['service_id']); ?>" data-category-get-id="<?php echo esc_attr($data['category_get_id']); ?>" data-repeat-status="<?php echo esc_attr($data['recurring_status']); ?>" value="<?php echo esc_attr($data['name']); ?>"><?php echo esc_html($data['name']); ?><?php if (get_option('bookingor_settings_service_price_show') === 'on') { ?>
            ( <?php echo esc_html(get_option('bookingor_settings_currency_symbol')); ?>
            <?php echo esc_html(HelperControl::priceDecimal($data['price'])); ?> )
          <?php } ?>
          <?php if (get_option('bookingor_settings_service_duration_show') === 'on') { ?>
            ( <?php echo esc_html(HelperControl::convert_duration($data['service_duration'])); ?> )
          <?php } ?>
          </option>
        <?php }  ?>
      </select>
    <?php } ?>
    <span class="cs-vali-service bookingor-d-none"><?php esc_html_e("Must Select ", "bookingor"); ?><?php echo esc_html(get_option('bookingor_settings_service_name')); ?></span>
  </div>
</div>