<?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_Radio $this */ ?>
<?php $_option = $this->getOption(); ?>
<?php $_selections  = $_option->getSelections(); ?>
<?php $_default = $_option->getDefaultSelection(); ?>
<?php $_skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck(); ?>
<?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>

<dt>
    <span class="qty-holder">
        <label for="bundle-option-<?= $_option->getId() ?>-qty-input"><?= $this->__('Qty:') ?>&nbsp;</label><input <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?= $_option->getId() ?>-qty-input" class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" type="text" name="bundle_option_qty[<?= $_option->getId() ?>]" value="<?= $_defaultQty ?>"/>
    </span>
    <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 ($this->_showSingle()): ?>
        <?= $this->getSelectionTitlePrice($_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 if (!$_option->getRequired()): ?>
            <li><input type="radio" class="radio" id="bundle-option-<?= $_option->getId() ?>" name="bundle_option[<?= $_option->getId() ?>]"<?= ($_default && $_default->isSalable())?'':' checked="checked" ' ?> value="" onclick="ProductConfigure.bundleControl.changeSelection(this)"/>
            <span class="label"><label for="bundle-option-<?= $_option->getId() ?>"><?= $this->__('None') ?></label></span>
            </li>
        <?php endif ?>
        <?php foreach ($_selections as $_selection): ?>
            <li><input type="radio" class="radio<?= $_option->getRequired()?' validate-one-required-by-name':'' ?> change-container-classname" id="bundle-option-<?= $_option->getId() ?>-<?= $_selection->getSelectionId() ?>" 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) ?>" qtyId="bundle-option-<?= $_option->getId() ?>-qty-input"/>
            <span class="label"><label for="bundle-option-<?= $_option->getId() ?>-<?= $_selection->getSelectionId() ?>"><?= $this->getSelectionTitlePrice($_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>
