<?php
/**
 * Avalanche for Magento 1.8+
 * Designed by Fast Division (http://fastdivision.com)
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file license.txt.
 * It is also available through the world-wide-web at this URL:
 * http://fastdivision.com/legal/license.txt
 *
 * @author     Fast Division
 * @version    1.5.0
 * @copyright  Copyright 2013 Fast Division
 * @license    http://fastdivision.com/legal/license.txt
 */
?>
<?php
    $_item = $this->getItem();
    $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
?>
<tr>
	<td class="product-image a-center">
	    <?php if ($this->hasProductUrl()): ?>
	        <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>"><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><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; ?>
	</td>
    <td class="product-details" style="width: 57%">
        <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>
        <?php if ($_options = $this->getOptionList()):?>
		<div class="product-options">
	        <?php foreach ($_options as $_option) : ?>
			<?php echo $this->escapeHtml($_option['label']) ?>: 
			<?php if (is_array($_option['value'])): ?>
	          	<?php echo nl2br(implode("\n", $_option['value'])) ?>
            <?php else: ?>
              	<?php echo $_option['value'] ?>
            <?php endif; ?><br>
	        <?php endforeach; ?>
		</div>
        <?php endif; ?>
    </td>
	<td class="product-quantity a-center" style="width: 6%">
		<strong><?php echo $this->getQty() ?></strong><br>
		<?php
			// Set remove link -- If AJAX request we'll have the current URL passed, otherwise default remove link
			if($_item->getData('currentUrl')) {
				$removeLink = $this->getUrl('checkout/cart/delete', array('id' => $this->getItem()->getId(), Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl($_item->getData('currentUrl'))));
			} else {
				$removeLink = $this->getDeleteUrl();
			}
		?>
		<a href="<?php echo $removeLink ?>" title="<?php echo $this->__('Remove') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you want to remove this item from the cart?') ?>');" class="remove-link"><?php echo $this->__('Remove') ?></a>
	</td>
	<td class="product-subtotal a-right" style="width: 24%">
		<?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><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><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+$_item->getWeeeTaxAppliedAmount()); ?>
	        <?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><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 incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
	            <?php endif; ?>
	        <?php endif; ?>
	    <?php endif; ?>
	</td>
</tr>
