<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * 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 through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://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" xmlns="http://www.w3.org/1999/html">
    <?php if ($this->hasProductUrl()): ?>
        <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></a>
    <?php else: ?>
        <span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(50, 50)->setWatermarkSize('30x10'); ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /></span>
    <?php endif; ?>
    <div class="product-details">
        <p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?php echo $this->getProductUrl() ?>"><?php endif; ?><?php echo $this->escapeHtml($this->getProductName()) ?><?php if ($this->hasProductUrl()): ?></a><?php endif; ?></p>

        <table class="info-wrapper">
            <tbody>
                <tr>
                    <th><?php echo $this->__('Price'); ?></th>
                    <td>
                        <?php if ($canApplyMsrp): ?>

                            <span class="map-cart-sidebar-item"><?php echo $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()): ?>
                                    <?php echo $this->__('Excl. Tax'); ?>:
                                <?php endif; ?>
                                <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
                                    <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
                                <?php else: ?>
                                    <?php echo $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"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></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><?php echo $tax['title']; ?>: <?php echo 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"><?php echo $tax['title']; ?>: <?php echo 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"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $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 /><?php echo $this->__('Incl. Tax'); ?>:
                                <?php endif; ?>
                                <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
                                    <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
                                <?php else: ?>
                                    <?php echo $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"><?php echo $tax['title']; ?>: <?php echo 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><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></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"><?php echo $tax['title']; ?>: <?php echo 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"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endif; ?>

                        <?php endif; //Can apply MSRP ?>
                    </td>
                </tr>
                <tr class="qty-wrapper">
                    <th><?php echo $this->__('Qty'); ?></th>
                    <td>
                        <input
                            id="qinput-<?php echo $_item->getId(); ?>"
                            data-link="<?php echo $this->getAjaxUpdateUrl() ?>"
                            data-item-id="<?php echo $_item->getId(); ?>"
                            data-cart-item-id="<?php echo $_item->getSku(); ?>"
                            class="qty cart-item-quantity input-text" name=""
                            value="<?php echo $this->getQty()?>"
                            <?php if ($this->isOnCheckoutPage()) echo 'disabled'; ?>
                            />

                        <button id="qbutton-<?php echo $_item->getId(); ?>"
                                data-item-id="<?php echo $_item->getId(); ?>"
                                disabled="disabled"
                                data-update
                                data-cart-item-update
                                class="button quantity-button">
                            <?php echo $this->__('ok'); ?>
                        </button>
                    </td>
                </tr>
            </tbody>
        </table>

        <?php if ($isVisibleProduct): ?>
        <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Edit item')) ?>" class="btn-edit">
            <?php echo $this->__('Edit item')?>
        </a>
            |
            <?php if (!$this->isOnCheckoutPage()): ?>
                <a href="<?php echo $this->getAjaxDeleteUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Remove This Item')) ?>"
                   data-confirm="<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>"
                   class="remove">
                    <?php echo $this->__('Remove Item') ?>
                </a>
            <?php else: ?>
                <span><?php echo $this->__('Remove Item') ?></span>
            <?php endif; ?>
        <?php endif ?>



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

    </div>
</li>
