<?php
$element = $block->getElement();
?>
<div class="admin__control-table-wrapper">
    <table class="admin__control-table" id="<?= $escaper->escapeHtmlAttr($element->getHtmlId()) ?>"
           data-mage-init='{"Autogedal_Manufacturers/js/sortable-table": {}}'>
        <thead>
            <tr>
                <th aria-sort="ascending"><?= $escaper->escapeHtml(__('Brand Name')) ?></th>
                <th><?= $escaper->escapeHtml(__('Products')) ?></th>
                <th><?= $escaper->escapeHtml(__('Active Products')) ?></th>
                <th><?= $escaper->escapeHtml(__('Active')) ?></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($block->getManufacturers() as $manufacturer): ?>
                <tr>
                    <td><?= $escaper->escapeHtml($manufacturer['name']) ?></td>
                    <td><?= (int)$manufacturer['products'] ?></td>
                    <td><?= (int)$manufacturer['active_products'] ?></td>
                    <td>
                        <?php $selectName = $element->getName() . '[' . $manufacturer['option_id'] . ']'; ?>
                        <select name="<?= $escaper->escapeHtmlAttr($selectName) ?>" class="admin__control-select">
                            <option value="1"<?= $manufacturer['is_active'] ? ' selected="selected"' : '' ?>>
                                <?= $escaper->escapeHtml(__('Yes')) ?>
                            </option>
                            <option value="0"<?= $manufacturer['is_active'] ? '' : ' selected="selected"' ?>>
                                <?= $escaper->escapeHtml(__('No')) ?>
                            </option>
                        </select>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>
