<?php

use iwbvel\classes\helpers\Sanitizer;

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

global $wp_roles;
$iwbvel_user_roles = $wp_roles->roles;
$iwbvel_roles_option_html = '';

if (!empty($iwbvel_user_roles)) {
    foreach ($iwbvel_user_roles as $iwbvel_key => $iwbvel_role) {
        $iwbvel_roles_option_html .= '<option value="' . esc_attr($iwbvel_key) . '">' . esc_html($iwbvel_role['name']) . '</option>';
    }
}
?>

<strong>By iThemeland</strong>
<hr>

<div class="iwbvel-form-group">
    <div class="iwbvel-alert iwbvel-alert-warning iwbvel-mb0"><span><?php esc_html_e('These fields don\'t apply to \'Variations\'', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span></div>
</div>

<div class="iwbvel-form-group" data-name="it_product_hide_price_unregistered" data-sub-name="" data-type="meta_field">
    <label for="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-price-unregistered"><?php esc_html_e('Hide Price (unregistered)', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></label>
    <select class="iwbvel-input-md" data-field="value" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-price-unregistered">
        <option value=""><?php esc_html_e('Select', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
        <option value="yes"><?php esc_html_e('Yes', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
        <option value="no"><?php esc_html_e('No', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
    </select>
</div>
<div class="iwbvel-form-group" data-name="it_pricing_product_price_user_role" data-sub-name="" data-type="meta_field">
    <label for="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-price"><?php esc_html_e('Hide Price', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></label>
    <select data-field="operator" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-price-operator">
        <?php include IWBVEL_VIEWS_DIR . "bulk_edit/bulk_edit_form/operators/taxonomy.php"; ?>
    </select>
    <select multiple="" class="iwbvel-select2" data-field="value" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-price" data-placeholder="Select roles ...">
        <?php echo wp_kses($iwbvel_roles_option_html, Sanitizer::allowed_html()); ?>
    </select>
</div>
<div class="iwbvel-form-group" data-name="it_pricing_product_add_to_cart_user_role" data-sub-name="" data-type="meta_field">
    <label for="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-add-to-cart"><?php esc_html_e('Hide Add to cart', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></label>
    <select data-field="operator" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-add-to-cart-operator">
        <?php include IWBVEL_VIEWS_DIR . "bulk_edit/bulk_edit_form/operators/taxonomy.php"; ?>
    </select>
    <select multiple="" class="iwbvel-select2" data-field="value" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-add-to-cart" data-placeholder="Select roles ...">
        <?php echo wp_kses($iwbvel_roles_option_html, Sanitizer::allowed_html()); ?>
    </select>
</div>
<div class="iwbvel-form-group" data-name="it_pricing_product_hide_user_role" data-sub-name="" data-type="meta_field">
    <label for="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-product"><?php esc_html_e('Hide Product', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></label>
    <select data-field="operator" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-product-operator">
        <?php include IWBVEL_VIEWS_DIR . "bulk_edit/bulk_edit_form/operators/taxonomy.php"; ?>
    </select>
    <select multiple="" class="iwbvel-select2" data-field="value" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-hide-product" data-placeholder="Select roles ...">
        <?php echo wp_kses($iwbvel_roles_option_html, Sanitizer::allowed_html()); ?>
    </select>
</div>
<div class="iwbvel-form-group">
    <div class="iwbvel-alert iwbvel-alert-warning iwbvel-mt20 iwbvel-mb0">
        <span><?php esc_html_e('If you want to apply these fields to \'Variations\', you should select theme in table.', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span>
    </div>
</div>
<div class="iwbvel-form-group" data-name="it_product_disable_discount" data-sub-name="" data-type="meta_field">
    <label for="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-disable-discount"><?php esc_html_e('Disable Discount', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></label>
    <select class="iwbvel-input-md" data-field="value" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-disable-discount">
        <option value=""><?php esc_html_e('Select', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
        <option value="yes"><?php esc_html_e('Yes', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
        <option value="no"><?php esc_html_e('No', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
    </select>
</div>
<?php
if (!empty($wp_roles->roles)) :
    foreach ($wp_roles->roles as $iwbvel_key => $iwbvel_role) :
?>
        <div class="iwbvel-form-group" data-name="pricing_rules_product" data-sub-name="<?php echo esc_attr($iwbvel_key); ?>" data-type="meta_field">
            <label for="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-role-<?php echo esc_attr($iwbvel_key); ?>"><?php echo esc_html($iwbvel_role['name']); ?></label>
            <input type="number" class="iwbvel-input-md" data-field="value" data-name="<?php echo esc_attr($iwbvel_key); ?>" id="iwbvel-bulk-edit-form-it-wc-dynamic-pricing-role-<?php echo esc_attr($iwbvel_key); ?>" placeholder="<?php esc_attr_e('Amount ...', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>">
        </div>
<?php
    endforeach;
endif;
?>