<?php
/**
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
 * versions in the future.
 *
 * @category  Smile
 * @package   Smile\ElasticsuiteAnalytics
 * @author    Vadym Honcharuk <vahonc@smile.fr>
 * @copyright 2024 Smile
 * @license   Open Software License ("OSL") v. 3.0
 */
?>

<?php
/**
 * @var Smile\ElasticsuiteAnalytics\Block\Adminhtml\Report\CustomerGroupSelector $block
 */
$customerGroups = $block->getCustomerGroups();
$customerGroupId = $block->getCurrentCustomerGroupId();
$baseUrl = $block->getUrl('*/*/*', ['_current' => true, 'customer_group' => '__customer_group__']);
?>
<?php if ($block->isCustomerGroupFilterEnabled()): ?>
    <div class="customer-group-selector">
        <label for="customer_group"><?= __('Customer Group:');?></label>
        <select id="customer_group" name="customer_group" class="admin__control-select">
            <option value="all"><?= __('All Customer Groups');?></option>
            <?php foreach ($customerGroups as $group): ?>
                <option value="<?= $block->escapeHtmlAttr($group['value']); ?>" <?php if ($customerGroupId == $group['value']): ?> selected="selected"<?php endif; ?>><?= $block->escapeHtml($group['label']); ?></option>
            <?php endforeach; ?>
        </select>
    </div>

    <script type="text/x-magento-init">
        {
            "*": {
                 "customerGroupSelector": {
                    "baseUrl": "<?= $block->escapeJs($block->escapeUrl($baseUrl)) ?>"
                 }
            }
        }
    </script>
<?php endif; ?>
