<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2022 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 if (!$this->isReadonly()):?>
<div class="entry-edit">
    <div id="assign_product_warrning" style="display: none;">
        <ul class="messages">
            <li class="error-msg">
                <ul>
                    <li><?= $this->__('Links with associated products will retain only after saving current product.') ?></li>
                </ul>
            </li>
        </ul>
    </div>
    <div class="entry-edit-head">
        <h4><?= Mage::helper('catalog')->__('Create Simple Associated Product') ?></h4>
    </div>
    <fieldset class="a-right">
        <?= $this->getChildHtml('create_empty') ?> <?= $this->getChildHtml('create_from_configurable') ?>
    </fieldset>
</div>

<div id="<?= $this->getHtmlId() ?>_simple_form" class="ignore-validate configurable-simple-product">
<?= $this->getChildHtml('simple') ?>
</div>
<?php endif ?>
<div class="entry-edit">
    <div class="entry-edit-head">
        <h4><?= Mage::helper('catalog')->__('Super product attributes configuration') ?></h4>
    </div>
    <fieldset id="<?= $this->getHtmlId() ?>">
        <legend><?= Mage::helper('catalog')->__('Super product attributes configuration') ?></legend>
        <input type="hidden" id="<?= $this->getHtmlId() ?>_save_links" name="configurable_products_data" value=""/>
        <input type="hidden" id="<?= $this->getHtmlId() ?>_save_attributes" name="configurable_attributes_data" />

        <ul class="messages">
            <li class="notice-msg">
                <ul><li><?= Mage::helper('catalog')->__('Price values for options should be specified in system base currency.') ?></li></ul>
                <ul><li><?= Mage::helper('catalog')->__('Attrribute names can be specified per store.') ?></li></ul>
            </li>
        </ul>
        <ul id="<?= $this->getHtmlId() ?>_attributes" class="super-attributes">
        </ul>
    </fieldset>
</div>
<div class="no-display" id="<?= $this->getHtmlId() ?>_attribute_template">
    <div class="<?php if (!$this->isReadonly()):?>attribute-name-container <?php endif ?>left">
        '{{frontend_label}}'
    </div>
    <div class="values-container right">
        <label for="__id___label" class="bold"><?= Mage::helper('catalog')->__('Attribute Name:') ?></label>
        <input id="__id___label" type="text" <?php if ($this->isAttributesConfigurationReadonly()): ?> disabled="disabled" <?php endif ?> class="input-text attribute-label required-entry template no-display" value="'{{label}}'" readonly="label" />
        <input id="__id___label_use_default" type="checkbox" value="1" " checked="use_default" class="attribute-use-default-label">
        <label for="__id___label_use_default"><?= Mage::helper('catalog')->__('Use default') ?> ('{{store_label}}')</label>
        <ul class="attribute-values">
        </ul>
    </div>
</div>
<div class="no-display" id="<?= $this->getHtmlId() ?>_value_template">
    <div class="attribute-value-label-container left">
    <?= Mage::helper('catalog')->__('Option:') ?> <strong>'{{label}}'</strong>
</div>
<?php if ($this->getCanReadPrice() !== false) : ?>
<div class="attribute-values-container-main">
    <div class="attribute-values-container left">
    <?= Mage::helper('catalog')->__('Price:') ?>
    <input id="__id___pricing" type="text" <?php if ($this->isAttributesPricesReadonly() || $this->getCanEditPrice() === false): ?> disabled="disabled" <?php endif ?> class="input-text attribute-price validate-number template no-display" value="'{{pricing_value}}'"/>
</div>
<div class="attribute-values-container left">
    &nbsp;<select class="attribute-price-type" id="__id___price_type" <?php if ($this->isAttributesPricesReadonly() || $this->getCanEditPrice() === false): ?> disabled="disabled" <?php endif ?>>
        <option value="0"><?= Mage::helper('catalog')->__('Fixed') ?></option>
        <option value="1"><?= Mage::helper('catalog')->__('Percentage') ?></option>
    </select>
</div>
<?php if ($this->getShowUseDefaultPrice()):?>
<div class="attribute-values-container">
    &nbsp;<input id="__id___default" type="checkbox" <?php if ($this->isAttributesPricesReadonly() || $this->getCanEditPrice() === false): ?> disabled="disabled" <?php endif ?> class="attribute-use-default-value"> <label for="__id___default" class="normal"><?= Mage::helper('catalog')->__('Use Default Value') ?></label>
</div>
<?php endif ?>
<?php else: ?>
<div class="attribute-values-container-main">
    <div class="attribute-values-container left">
    <input id="__id___pricing" type="hidden"  class="attribute-price template no-display" value="0" />
</div>
<div class="attribute-values-container left">
    <input type="hidden" class="attribute-price-type" id="__id___price_type" value="0" />
</div>
<?php if ($this->getShowUseDefaultPrice()) : ?>
<div class="attribute-values-container no-display">
    <input id="__id___default" type="checkbox" <?php if ($this->isReadonly() || $this->getCanEditPrice() === false):?> disabled="disabled" <?php endif ?> class="attribute-use-default-value">
</div>
<?php endif ?>
<?php endif ?>
</div>
</div>
<div class="template no-display" id="<?= $this->getHtmlId() ?>_simple_pricing">
    <?php if ($this->getCanReadPrice() !== false) : ?>
        <div class="attribute-values-container left v-middle">
            &nbsp;<?= Mage::helper('catalog')->__('Price:') ?>
            <input type="text" class="input-text attribute-price validate-number"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled" <?php endif ?>/>
        </div>
        <div class="attribute-values-container left v-middle">
            &nbsp;<select class="attribute-price-type"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled" <?php endif ?>>
                <option value="0"><?= Mage::helper('catalog')->__('Fixed') ?></option>
                <option value="1"><?= Mage::helper('catalog')->__('Percentage') ?></option>
            </select>
        </div>
    <?php else: ?>
        <input type="hidden" class="attribute-price" />
        <input type="hidden" class="attribute-price-type" />
    <?php endif ?>
</div>
<div class="template no-display" id="<?= $this->getHtmlId() ?>_simple_pricing_view">
    &nbsp;<?= Mage::helper('catalog')->__('Price') ?> <strong>'{{value}}'</strong>
</div>
<?= $this->getGridHtml() ?>
<script type="text/javascript">
var superProduct = new Product.Configurable(<?= $this->getAttributesJson() ?>,<?= $this->getLinksJson() ?>,'<?= $this->getHtmlId() ?>_',<?= $this->getGridJsObject() ?>, <?= ( $this->isReadonly() ? 'true' : 'false') ?>);
superProduct.createEmptyUrl = '<?= $this->getNewEmptyProductUrl() ?>';
superProduct.createNormalUrl = '<?= $this->getNewProductUrl() ?>';
superProduct.createQuickUrl = '<?= $this->getQuickCreationUrl() ?>';

Validation.add(
    'validate-configurable',
    '<?= $this->escapeJs(Mage::helper('catalog')->__('Product with this combination of attributes already associated to configurable.')) ?>',
    superProduct.checkCreationUniqueAttributes.bind(superProduct)
)
</script>

<div><input type="hidden" name="affect_configurable_product_attributes" value="1" /></div>
