<?php
/**
 * OpenMage
 *
 * 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 at https://opensource.org/license/afl-3-0-php
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
 * @copyright   Copyright (c) 2021-2022 The OpenMage Contributors (https://www.openmage.org)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Shoping cart sidebar
 *
 * @var Mage_Checkout_Block_Cart_Minicart $this
 */
?>

<?php
$_cartQty = $this->getSummaryCount();
if(empty($_cartQty)) {
    $_cartQty = 0;
}
?>
<div id="minicart-error-message" class="minicart-message"></div>
<div id="minicart-success-message" class="minicart-message"></div>

<div class="minicart-wrapper">

    <p class="block-subtitle">
        <?php echo $this->__('Recently added item(s)') ?>
        <a class="close skip-link-close" href="#" title="<?php echo $this->quoteEscape($this->__('Close')); ?>">&times;</a>
    </p>

    <?php $_items = $this->getRecentItems() ?>
    <?php $countItems = count($_items); ?>
    <?php if($countItems): ?>
        <div>
            <ul id="cart-sidebar" class="mini-products-list">
                <?php foreach($_items as $_item): ?>
                    <?php echo $this->getItemHtml($_item) ?>
                <?php endforeach ?>
            </ul>
        </div>
        <script type="text/javascript">
            truncateOptions();
            decorateList('cart-sidebar', 'none-recursive');
            $j('document').ready(function() {
                var minicartOptions  = {
                    formKey:           "<?php echo $this->getFormKey();?>"
                }
                var Mini = new Minicart(minicartOptions);
                Mini.init();
            });
        </script>

        <div id="minicart-widgets">
            <?php echo $this->getChildHtml('cart_promotion') ?>
        </div>
        <div class="block-content">
            <p class="subtotal">
                <?php if ($this->canApplyMsrp()): ?>
                    <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
                <?php else: ?>
                    <span class="label"><?php echo $this->__('Cart Subtotal:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
                    <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
                        <br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)
                    <?php endif ?>
                <?php endif ?>
            </p>
        </div>


        <div class="minicart-actions">
            <?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>
                <ul class="checkout-types minicart">
                    <?php echo $this->getChildHtml('extra_actions') ?>
                    <li>
                        <a title="<?php echo $this->quoteEscape($this->__('Checkout')) ?>" class="button checkout-button" href="<?php echo $this->getCheckoutUrl() ?>">
                            <?php echo $this->__('Checkout') ?>
                        </a>
                    </li>
                </ul>
            <?php endif ?>
            <a class="cart-link" href="<?php echo $this->getUrl('checkout/cart'); ?>">
                <?php echo $this->__('View Shopping Cart'); ?>
            </a>
        </div>

    <?php else: ?>
        <p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>

    <?php endif ?>
</div>
