<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_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
    $_item = $this->getItem();
    $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
    $canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
?>
<li class="item">
    <?php if ($this->hasProductUrl()): ?>
        <a href="<?= $this->getProductUrl()?>" title="<?= $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?= $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10') ?>" width="50" height="50" alt="<?= $this->escapeHtml($this->getProductName()) ?>" /></a>
    <?php else: ?>
        <span class="product-image"><img src="<?= $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10') ?>" width="50" height="50" alt="<?= $this->escapeHtml($this->getProductName()) ?>" /></span>
    <?php endif ?>
    <div class="product-details">
        <a href="#"
           title="<?= Mage::helper('core')->quoteEscape($this->__('Remove This Item')) ?>"
           onclick="if (confirm('<?= Mage::helper('core')->jsQuoteEscape($this->__('Are you sure you would like to remove this item from the shopping cart?')) ?>')) {
                   customFormSubmit('<?= $this->getDeleteUrlCustom(false) ?>','<?= $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()])) ?>', 'post')
                   }"
           class="btn-remove">
            <?= $this->__('Remove This Item') ?>
        </a>
        <p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?= $this->getProductUrl() ?>"><?php endif ?><?= $this->escapeHtml($this->getProductName()) ?><?php if ($this->hasProductUrl()): ?></a><?php endif ?></p>
        <?php if ($isVisibleProduct): ?>
        <a href="<?= $this->getConfigureUrl() ?>" title="<?= Mage::helper('core')->quoteEscape($this->__('Edit item')) ?>" class="btn-edit"><?= $this->__('Edit item') ?></a>
        <?php endif ?>
        <strong><?= $this->getQty() ?></strong> x

    <?php if ($canApplyMsrp): ?>

        <span class="map-cart-sidebar-item"><?= $this->__('See price before order confirmation.') ?></span>

    <?php else: ?>

    <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
            <?= $this->__('Excl. Tax') ?>:
        <?php endif ?>
        <?php if (Mage::helper('weee')->typeOfDisplay($_item, [0, 1, 4], 'sales')): ?>
            <?= $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()) ?>
        <?php else: ?>
            <?= $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
        <?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'] ?>: <?= Mage::helper('checkout')->formatPrice($tax['amount'],true,true) ?></span><br />
                <?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'] ?>: <?= Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true) ?></small></span><br />
                <?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'] ?>: <?= Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true) ?></span><br />
                <?php endforeach ?>
                </small>
            <?php endif ?>
            <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                <span class="nobr"><?= Mage::helper('weee')->__('Total') ?>:<br /> <?= $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()) ?></span>
            <?php endif ?>
        <?php endif ?>
    <?php endif ?>



    <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
        <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
            <br /><?= $this->__('Incl. Tax') ?>:
        <?php endif ?>
        <?php if (Mage::helper('weee')->typeOfDisplay($_item, [0, 1, 4], 'sales')): ?>
            <?= $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)) ?>
        <?php else: ?>
            <?= $this->helper('checkout')->formatPrice($_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'] ?>: <?= Mage::helper('checkout')->formatPrice($tax['amount'],true,true) ?></span><br />
                <?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'] ?>: <?= Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true) ?></small></span><br />
                <?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'] ?>: <?= Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true) ?></span><br />
                <?php endforeach ?>
                </small>
            <?php endif ?>
            <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
                <span class="nobr"><?= Mage::helper('weee')->__('Total incl. tax') ?>:<br /> <?= $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)) ?></span>
            <?php endif ?>
        <?php endif ?>
    <?php endif ?>

    <?php endif //Can apply MSRP ?>

        <?php if ($_options = $this->getOptionList()):?>
        <div class="truncated">
          <div class="truncated_full_value">
            <dl class="item-options">
                <?php foreach ($_options as $_option) : ?>
                <dt><?= $this->escapeHtml($_option['label']) ?></dt>
                <dd>
                    <?php if (is_array($_option['value'])): ?>
                    <?= nl2br(implode("\n", $_option['value'])) ?>
                    <?php else: ?>
                    <?= $_option['value'] ?>
                    <?php endif ?>
                </dd>
                <?php endforeach ?>
            </dl>
          </div>
        <a href="#" onclick="return false;" class="details"><?= $this->__('Details') ?></a>
        </div>
        <?php endif ?>
    </div>
</li>
