<?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)
 */

/** @var Mage_Adminhtml_Block_Sales_Items_Renderer_Configurable $this */
?>
<?php $_item = $this->getItem() ?>
<?php $this->setPriceDataObject($_item); ?>
<tr class="border">
<td><?= $this->getColumnHtml($_item, 'configurable_name') ?></td>
<td class="a-right">
    <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
        <span class="price-excl-tax">
                <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
                    <span class="label"><?= $this->__('Excl. Tax') ?>:</span>
                <?php endif ?>

            <?php if (Mage::helper('weee')->typeOfDisplay($_item, [0, 1, 4], 'sales')): ?>
                <?php
                echo $this->displayPrices(
                    $_item->getBasePrice() + $_item->getBaseWeeeTaxAppliedAmount() + $_item->getBaseWeeeTaxDisposition(),
                    $_item->getPrice() + $_item->getWeeeTaxAppliedAmount() + $_item->getWeeeTaxDisposition()
                );
                ?>
            <?php else: ?>
                <?= $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
            <?php endif ?>


            <?php if (Mage::helper('weee')->getApplied($_item)): ?>
                <br/>
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_amount'], $tax['amount']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                        <span class="nobr"><small><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_amount'], $tax['amount']) ?></small></span>
                    <?php endforeach ?>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_amount'], $tax['amount']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php endif ?>

                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <br/>
                    <span class="nobr"><?= Mage::helper('weee')->__('Total') ?>:<br/>
                        <?php
                        echo $this->displayPrices(
                            $_item->getBasePrice() + $_item->getBaseWeeeTaxAppliedAmount() + $_item->getBaseWeeeTaxDisposition(),
                            $_item->getPrice() + $_item->getWeeeTaxAppliedAmount() + $_item->getWeeeTaxDisposition()
                        );
                        ?>
                        </span>
                <?php endif ?>
            <?php endif ?>
            </span>
        <br/>
    <?php endif ?>
    <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
        <span class="price-incl-tax">
                <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
                    <span class="label"><?= $this->__('Incl. Tax') ?>:</span>
                <?php endif ?>
            <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
            <?php $_baseIncl = $this->helper('checkout')->getBasePriceInclTax($_item); ?>

            <?php if (Mage::helper('weee')->typeOfDisplay($_item, [0, 1, 4], 'sales')): ?>
                <?= $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)) ?>
            <?php else: ?>
                <?= $this->displayPrices($_baseIncl - $_item->getBaseWeeeTaxDisposition(), $_incl - $_item->getWeeeTaxDisposition()) ?>
            <?php endif ?>

            <?php if (Mage::helper('weee')->getApplied($_item)): ?>
                <br/>
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                        <span class="nobr"><small><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']) ?></small></span>
                    <?php endforeach ?>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php endif ?>

                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <br/>
                    <span class="nobr"><?= Mage::helper('weee')->__('Total') ?>
                        :<br/> <?= $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)) ?></span>
                <?php endif ?>
            <?php endif ?>
            </span>
    <?php endif ?>
</td>
<td class="a-center"><?= $this->getColumnHtml($_item, 'qty') ?></td>
<?php if ($this->canParentReturnToStock($_item)) : ?>
    <td class="a-center">
        <?php if ($this->canReturnItemToStock($_item)) : ?>
            <input type="checkbox" name="creditmemo[items][<?= $_item->getOrderItemId() ?>][back_to_stock]"
                   value="1"<?php if ($_item->getBackToStock()): ?> checked<?php endif ?>/>
        <?php endif ?>
    </td>
<?php endif ?>
<td class="a-center">
    <?php if ($this->canEditQty()) : ?>
        <input type="text" class="input-text qty-input"
               name="creditmemo[items][<?= $_item->getOrderItemId() ?>][qty]"
               value="<?= $_item->getQty() * 1 ?>"/>
    <?php else: ?>
        <?= $_item->getQty() * 1 ?>
    <?php endif ?>
</td>
<td class="a-right">
    <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
        <span class="price-excl-tax">
                <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
                    <span class="label"><?= $this->__('Excl. Tax') ?>:</span>
                <?php endif ?>

            <?php if (Mage::helper('weee')->typeOfDisplay($_item, [0, 1, 4], 'sales')): ?>
                <?php
                echo $this->displayPrices(
                    $_item->getBaseRowTotal() + $_item->getBaseWeeeTaxAppliedRowAmount() + $_item->getBaseWeeeTaxRowDisposition(),
                    $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition()
                );
                ?>
            <?php else: ?>
                <?= $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
            <?php endif ?>


            <?php if (Mage::helper('weee')->getApplied($_item)): ?>
                <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_row_amount'], $tax['row_amount']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                        <span class="nobr"><small><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_row_amount'], $tax['row_amount']) ?></small></span>
                    <?php endforeach ?>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_row_amount'], $tax['row_amount']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php endif ?>

                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <br/>
                    <span class="nobr"><?= Mage::helper('weee')->__('Total') ?>:<br/>
                        <?php
                        echo $this->displayPrices(
                            $_item->getBaseRowTotal() + $_item->getBaseWeeeTaxAppliedRowAmount() + $_item->getBaseWeeeTaxRowDisposition(),
                            $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition()
                        );
                        ?>
                        </span>
                <?php endif ?>
            <?php endif ?>
            </span>
        <br/>
    <?php endif ?>
    <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
        <span class="price-incl-tax">
                <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
                    <span class="label"><?= $this->__('Incl. Tax') ?>:</span>
                <?php endif ?>
            <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
            <?php $_baseIncl = $this->helper('checkout')->getBaseSubtotalInclTax($_item); ?>
            <?php if (Mage::helper('weee')->typeOfDisplay($_item, [0, 1, 4], 'sales')): ?>
                <?= $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseRowWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)) ?>
            <?php else: ?>
                <?= $this->displayPrices($_baseIncl - $_item->getBaseWeeeTaxRowDisposition(), $_incl - $_item->getWeeeTaxRowDisposition()) ?>
            <?php endif ?>


            <?php if (Mage::helper('weee')->getApplied($_item)): ?>

                <br/>
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                        <span class="nobr"><small><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']) ?></small></span>
                    <?php endforeach ?>
                <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
                    <small>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="nobr"><?= $tax['title'] ?>
                                : <?= $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']) ?></span>
                        <?php endforeach ?>
                    </small>
                <?php endif ?>

                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                    <br/><span class="nobr"><?= Mage::helper('weee')->__('Total') ?>
                        :<br/> <?= $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseRowWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)) ?></span>
                <?php endif ?>
            <?php endif ?>
            </span>
    <?php endif ?>
</td>
<td class="a-right"><?= $this->displayPriceAttribute('tax_amount') ?></td>
<td class="a-right"><?= $this->displayPriceAttribute('discount_amount') ?></td>
<td class="a-right last">
    <?php echo $this->displayPrices(
        $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() - $_item->getBaseDiscountAmount() + $_item->getBaseWeeeTaxAppliedRowAmount(),
        $_item->getRowTotal() + $_item->getTaxAmount() - $_item->getDiscountAmount() + $_item->getWeeeTaxAppliedRowAmount()
    ) ?>
</td>
</tr>
