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

$iwbvel_items = $filter_form_items['general'];

foreach ($iwbvel_items as $iwbvel_name => $iwbvel_item):
    $iwbvel_field_id = 'iwbvel-filter-form-product-' . $iwbvel_item['id'];
    $iwbvel_field_type = isset($iwbvel_item['field_type']) ? $iwbvel_item['field_type'] : 'text';
?>
    <div class="iwbvel-form-group" data-name="<?php echo esc_attr($iwbvel_name); ?>" data-filter-type="<?php echo esc_attr($iwbvel_item['filter_type']); ?>" data-field-type="<?php echo esc_attr($iwbvel_field_type); ?>">
        <label for="<?php echo esc_attr($iwbvel_field_id); ?>"><?php echo esc_html($iwbvel_item['label']); ?></label>

        <?php if (!empty($iwbvel_item['operators'])): ?>
            <select <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled']) ? 'disabled="disabled"' : ''; ?> id="<?php echo esc_attr($iwbvel_field_id); ?>-operator" data-field="operator" title="<?php esc_attr_e('Select Operator', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?>">
                <?php foreach ($iwbvel_item['operators'] as $iwbvel_operator_name => $iwbvel_operator_label): ?>
                    <option value="<?php echo esc_attr($iwbvel_operator_name); ?>"><?php echo esc_html($iwbvel_operator_label); ?></option>
                <?php endforeach; ?>
            </select>
        <?php endif; ?>

        <?php if ($iwbvel_field_type === 'from_to_date'): ?>
            <input <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled']) ? 'disabled="disabled"' : ''; ?> class="iwbvel-input-ft iwbvel-datepicker iwbvel-date-from" type="text" id="<?php echo esc_attr($iwbvel_field_id); ?>-from" data-field="from" data-to-id="<?php echo esc_attr($iwbvel_field_id); ?>-to" placeholder="<?php echo esc_attr($iwbvel_item['placeholder_from']); ?>">
            <input <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled']) ? 'disabled="disabled"' : ''; ?> class="iwbvel-input-ft iwbvel-datepicker" type="text" id="<?php echo esc_attr($iwbvel_field_id); ?>-to" data-field="to" placeholder="<?php echo esc_attr($iwbvel_item['placeholder_to']); ?>">
        <?php else: ?>
            <?php
            $iwbvel_field_type_path = IWBVEL_VIEWS_DIR . 'bulk_edit/filter_form/fields_type/' . $iwbvel_field_type . '.php';
            if (file_exists($iwbvel_field_type_path)) {
                include $iwbvel_field_type_path;
            } else {
                include IWBVEL_VIEWS_DIR . 'bulk_edit/filter_form/fields_type/text.php';
            }
            ?>
        <?php endif; ?>

        <?php if (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled']): ?>
            <span class="iwbvel-alert-pro-description"><?php esc_html_e('Upgrade to pro version!', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></span>
        <?php endif; ?>
    </div>
<?php endforeach; ?>