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

$iwbvel_items = $edit_form_items['stock'];

foreach ($iwbvel_items as $iwbvel_name => $iwbvel_item):
    $iwbvel_field_id = 'iwbvel-bulk-edit-form-' . $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-type="<?php echo esc_attr($iwbvel_item['update_type']); ?>">
        <div>
            <label for="<?php echo esc_attr($iwbvel_field_id); ?>"><?php echo esc_html($iwbvel_item['label']); ?></label>

            <?php if (!empty($iwbvel_item['operators'])): ?>
                <select 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 === 'select'): ?>
                <select <?php echo (isset($iwbvel_item['disabled']) && $iwbvel_item['disabled']) ? 'disabled="disabled"' : ''; ?> class="iwbvel-input-md" id="<?php echo esc_attr($iwbvel_field_id); ?>" data-field="value">
                    <?php if (isset($iwbvel_item['options']) && is_array($iwbvel_item['options'])): ?>
                        <?php if (!isset($iwbvel_item['no_default_option'])): ?>
                            <option value=""><?php esc_html_e('Select', 'ithemeland-bulk-variation-editing-for-woocommerce'); ?></option>
                        <?php endif; ?>
                        <?php foreach ($iwbvel_item['options'] as $iwbvel_key => $iwbvel_value): ?>
                            <option value="<?php echo esc_attr($iwbvel_key); ?>"><?php echo esc_html($iwbvel_value); ?></option>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </select>
            <?php else: ?>
                <?php
                $iwbvel_field_type_path = IWBVEL_VIEWS_DIR . 'bulk_edit/bulk_edit_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/bulk_edit_form/fields_type/text.php';
                }
                ?>
            <?php endif; ?>
        </div>

        <?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; ?>