<?php
/**
 * Shopping cart template
 *
 * @see Mage_Checkout_Block_Cart
 */
?>
<div class="cart">
    <div class="page-title title-buttons">
        <h1><?php echo $this->__('Shopping Cart') ?></h1>
        <?php if(!$this->hasError()): ?>
            <ul class="checkout-types">
                <?php foreach ($this->getMethods('top_methods') as $method): ?>
                    <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
                        <li><?php echo $methodHtml; ?></li>
                    <?php endif; ?>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
    </div>
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <div class="row">
        <div class="col-md-12 col-lg-8 col-xl-9">
            <div class="cart-table-wrap">
                <?php echo $this->getChildHtml('form_before') ?>
                <form action="<?php echo $this->getFormActionUrl() ?>" method="post">
                    <?php echo $this->getBlockHtml('formkey'); ?>
                    <fieldset>
                        <table id="shopping-cart-table" class="data-table cart-table">
                            <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
                            <thead>
                            <tr>
                                <th rowspan="<?php echo $mergedCells; ?>">&nbsp;</th>
                                <th rowspan="<?php echo $mergedCells; ?>">&nbsp;</th>
                                <th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th>
                                <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
                                    <th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th>
                                <?php endif ?>
                                <th colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th>
                                <th rowspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Qty') ?></th>
                                <th class="last" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th>
                            </tr>
                            <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
                                <tr>
                                    <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
                                    <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
                                    <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
                                    <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
                                </tr>
                            <?php endif; ?>
                            </thead>
                            <tfoot>
                            <tr>
                                <td colspan="50" class="a-right">
                                    <?php if($this->getContinueShoppingUrl()): ?>
                                        <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getUrl('') ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
                                    <?php endif; ?>
                                    <button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button>
                                    <button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button>
                                    <!--[if lt IE 8]>
                                    <input type="hidden" id="update_cart_action_container" />
                                    <script type="text/javascript">
                                        //<![CDATA[
                                        Event.observe(window, 'load', function()
                                        {
                                            // Internet Explorer (lt 8) does not support value attribute in button elements
                                            $emptyCartButton = $('empty_cart_button');
                                            $cartActionContainer = $('update_cart_action_container');
                                            if ($emptyCartButton && $cartActionContainer) {
                                                Event.observe($emptyCartButton, 'click', function()
                                                {
                                                    $emptyCartButton.setAttribute('name', 'update_cart_action_temp');
                                                    $cartActionContainer.setAttribute('name', 'update_cart_action');
                                                    $cartActionContainer.setValue('empty_cart');
                                                });
                                            }

                                        });
                                    //]]>
                                    </script>
                                    <![endif]-->
                                </td>
                            </tr>
                            </tfoot>
                            <tbody>
                            <?php foreach($this->getItems() as $_item): ?>
                                <?php echo $this->getItemHtml($_item) ?>
                            <?php endforeach ?>
                            </tbody>
                        </table>
                        <script type="text/javascript">decorateTable('shopping-cart-table')</script>
                        <script type="text/javascript">
                            //<![CDATA[
                            jQuery(function($){
                                $(".cart .discount h2,.cart .shipping h2").click(function(){
                                    if ($(this).hasClass('opened')) {
                                        $(this).removeClass('opened');
                                        $(this).next().slideUp();
                                    } else {
                                        $(this).addClass('opened');
                                        $(this).next().slideDown();
                                    }
                                });
                            })
                            //]]>
                        </script>
                    </fieldset>
                </form>
            </div>
        </div>
        <div class="col-md-12 col-lg-4 col-xl-3">
            <div class="cart-collaterals">
                <?php /* Extensions placeholder */ ?>
                <?php echo $this->getChildHtml('checkout.cart.extra') ?>
                <?php echo $this->getChildHtml('coupon') ?>
                <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
                <div class="totals">
                    <h2><?php echo $this->__('Cart Totals') ?></h2>
                    <div>
                        <?php echo $this->getChildHtml('totals'); ?>
                        <?php if(!$this->hasError()): ?>
                            <ul class="checkout-types">
                                <?php foreach ($this->getMethods('methods') as $method): ?>
                                    <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
                                        <li><?php echo $methodHtml; ?></li>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </ul>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php echo $this->getChildHtml('crosssell') ?>
</div>