<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage_Bundle
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

?>

<?php $_option = $this->getOption() ?>
<?php $_selections = $_option->getSelections() ?>
<?php $_default = $_option->getDefaultSelection() ?>
<?php $_showSingle = (count($_selections) == 1 && $_option->getRequired()) ?>
<dt><label class="left"><?php echo $this->htmlEscape($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<span class="required">&nbsp;*</span>' ?></label>
    <span class="qty-holder">
        <?php if ($_default): ?>
            <?php $_defaultQty = $_default->getSelectionQty()*1 ?>
            <?php $_canChangeQty = $_default->getSelectionCanChangeQty() ?>
        <?php else: ?>
            <?php if (!$_showSingle): ?>
                <?php $_defaultQty = '0' ?>
                <?php $_canChangeQty = false ?>
            <?php else: ?>
                <?php $_defaultQty = $_selections[0]->getSelectionQty()*1 ?>
                <?php $_canChangeQty = $_selections[0]->getSelectionCanChangeQty() ?>
            <?php endif; ?>
        <?php endif; ?>
        <label for="bundle-option-<?php echo $_option->getId() ?>-qty-input"><?php echo $this->__('Qty:') ?>&nbsp;</label><input onkeyup="bundle.changeOptionQty(this)" <?php echo $_canChangeQty?'':'disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" class="input-text qty<?php echo $_canChangeQty?'':' qty-disabled' ?>" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>" />
    </span>
</dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
    <?php if (count($_selections) == 1 && $_option->getRequired()): ?>
        <?php echo $this->getSelectionTitlePrice($_selections[0]) ?>
        <input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>" />
    <?php else:?>
        <ul class="options-list">
        <?php if(!$_option->getRequired()): ?>
            <li><input onclick="bundle.changeSelection(this)" class="radio" id="bundle-option-<?php echo $_option->getId() ?>" type="radio" name="bundle_option[<?php echo $_option->getId() ?>]"<?php echo ($_default && $_default->isSalable())?'':' checked="checked" ' ?> value="" />
            <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>"><?php echo $this->__('None') ?></label></span>
            </li>
        <?php endif; ?>
        <?php foreach($_selections as $_selection): ?>
            <li><input onclick="bundle.changeSelection(this)" class="radio<?php echo $_option->getRequired()?' validate-one-required-by-name':'' ?>" id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>" type="radio" name="bundle_option[<?php echo $_option->getId() ?>]"<?php echo ($_selection->getIsDefault() && $_selection->isSaleable())?' checked="checked" ':'' ?><?php echo !$_selection->isSaleable()?' disabled="disabled" ':'' ?> value="<?php echo $_selection->getSelectionId() ?>" />
            <span class="label"><label for="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"><?php echo $this->getSelectionTitlePrice($_selection) ?></label></span>
            <?php if($_option->getRequired()): ?>
                <?php echo $this->setValidationContainer('bundle-option-'.$_option->getId().'-'.$_selection->getSelectionId(), 'bundle-option-'.$_option->getId().'-container') ?>
            <?php endif; ?>
            </li>
        <?php endforeach;?>
        </ul>
        <span id="bundle-option-<?php echo $_option->getId() ?>-container"></span>
    <?php endif; ?>
</dd>
