<?php
/**
 * Copyright © 2018 Porto. All rights reserved.
 */

// @codingStandardsIgnoreFile

?>
<?php /* @var $block \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Radio */ ?>
<?php $_option = $block->getOption(); ?>
<?php $_selections  = $_option->getSelections(); ?>
<?php $_default     = $_option->getDefaultSelection(); ?>
<?php list($_defaultQty, $_canChangeQty) = $block->getDefaultValues(); ?>

<div class="field option <?php echo ($_option->getRequired()) ? ' required': ''; ?>">
    <label class="label">
        <span><?php echo $block->escapeHtml($_option->getTitle()) ?></span>
    </label>
    <div class="control">
        <div class="nested options-list">
            <?php if ($block->showSingle()): ?>
                <?php /* @escapeNotVerified */ echo $block->getSelectionTitlePrice($_selections[0]) ?>
                <input type="hidden"
                       class="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>  product bundle option"
                       name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                       value="<?php /* @escapeNotVerified */ echo $_selections[0]->getSelectionId() ?>" />
                <?php foreach ($_selections as $_selection): ?>
                    <div class="field choice hidden">
                        <input type="radio"
                               class="radio product bundle option change-container-classname"
                               id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"
                               <?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':true}"'?>
                               name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                               <?php if ($block->isSelected($_selection)) echo ' checked="checked"' ?>
                               <?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>
                               value="<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"/>
                        <label class="label"
                               for="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>">
                            <span><?php /* @escapeNotVerified */ echo $block->getSelectionTitlePrice($_selection) ?></span>
                        </label>
                    </div>
                <?php endforeach; ?>
            <?php else:?>
                <?php if (!$_option->getRequired()): ?>
                    <div class="field choice">
                        <input type="radio"
                               class="radio product bundle option"
                               id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>"
                               name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                               <?php echo ($_default && $_default->isSalable())?'':' checked="checked" ' ?>
                               value=""/>
                        <label class="label" for="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>">
                            <span><?php /* @escapeNotVerified */ echo __('None') ?></span>
                        </label>
                    </div>
                <?php endif; ?>
                <?php foreach ($_selections as $_selection): ?>
                    <div class="field choice">
                        <input type="radio"
                               class="radio product bundle option change-container-classname"
                               id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"
                               <?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':true}"'?>
                               name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                               <?php if ($block->isSelected($_selection)) echo ' checked="checked"' ?>
                               <?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>
                               value="<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"/>
                        <label class="label"
                               for="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>">
                            <span><?php /* @escapeNotVerified */ echo $block->getSelectionTitlePrice($_selection) ?></span>
                        </label>
                    </div>
                <?php endforeach; ?>
                <div id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-container"></div>
            <?php endif; ?>
            <div class="field qty qty-holder">
                <label class="label" for="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-qty-input">
                    <span><?php /* @escapeNotVerified */ echo __('Quantity') ?></span>
                </label>
                <div class="control">
                    <input <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?>
                           id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-qty-input"
                           class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>"
                           type="number"
                           name="bundle_option_qty[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                           value="<?php /* @escapeNotVerified */ echo $_defaultQty ?>"/>
                  <div class="qty-changer">
                      <a href="javascript:void(0)" class="qty-inc"><i class="porto-icon-up-dir"></i></a>
                      <a href="javascript:void(0)" class="qty-dec"><i class="porto-icon-down-dir"></i></a>
                  </div>
                </div>
            </div>
        </div>
    </div>
</div>
