<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

?>
<?php /** @var Mage_Bundle_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Options_Type_Checkbox $this */ ?>
<?php $_option = $this->getOption(); ?>
<?php $_selections = $_option->getSelections(); ?>
<?php $_skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck(); ?>
<dt><label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php if ($_option->getRequired()) echo '<em>*</em>' ?><?= $this->escapeHtml($_option->getTitle()) ?></label></dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
    <div class="input-box">
    <?php if (count($_selections) == 1 && $_option->getRequired()): ?>
        <?= $this->getSelectionQtyTitlePrice($_selections[0]) ?>
        <input type="hidden" name="bundle_option[<?= $_option->getId() ?>]" value="<?= $_selections[0]->getSelectionId() ?>" price="<?= $this->getSelectionPrice($_selections[0]) ?>"'/>
    <?php else: ?>
        <ul class="options-list">
        <?php foreach($_selections as $_selection): ?>
            <li><input class="change-container-classname checkbox bundle-option-<?= $_option->getId() ?> <?php if ($_option->getRequired()) echo 'validate-one-required-by-name' ?>" id="bundle-option-<?= $_option->getId() ?>-<?= $_selection->getSelectionId() ?>" type="checkbox" name="bundle_option[<?= $_option->getId() ?>][]"<?php if ($this->_isSelected($_selection)) echo ' checked="checked"' ?><?php if (!$_selection->isSaleable() && !$_skipSaleableCheck) echo ' disabled="disabled"' ?> value="<?= $_selection->getSelectionId() ?>" onclick="ProductConfigure.bundleControl.changeSelection(this)" price="<?= $this->getSelectionPrice($_selection) ?>"/>
                <span class="label"><label for="bundle-option-<?= $_option->getId() ?>-<?= $_selection->getSelectionId() ?>"><?= $this->getSelectionQtyTitlePrice($_selection) ?></label></span>
                <?php if($_option->getRequired()): ?>
                    <?= $this->setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?>
                <?php endif ?>
            </li>
        <?php endforeach ?>
        </ul>
        <div id="bundle-option-<?= $_option->getId() ?>-container"></div>
    <?php endif ?>
    </div>
</dd>
