<?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
 */
?>
<div class="grid_12 white-box">
<h1 style="margin: 0"><?php echo $this->__('Select Shipping Method') ?></h1>
<div class="multiple-checkout">
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
        <?php foreach ($this->getAddresses() as $_index => $_address): ?>
        <div class="clearfix">
            <h3><?php echo $this->__('Shipping Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h3>
            <div class="white-box-inner">
                <div class="grid_3 alpha omega">
                    <div class="box">
                        <div class="box-title">
                            <h4><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h4>
                        </div>
                        <div class="box-content">
                            <address><?php echo $_address->format('html') ?></address>
                        </div>
                    </div>
                    <div class="box box-sp-methods">
                        <div class="pointer"></div>
                        <div class="box-title">
                            <h4><?php echo $this->__('Shipping Method') ?></h4>
                        </div>
                        <div class="box-content">
                            <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
                                <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
                            <?php else: ?>
                            <dl class="sp-methods">
                                <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
                                    <dt><?php echo $this->getCarrierName($code) ?></dt>
                                    <dd>
                                        <ul>
                                        <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
                                            <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"' ?>>
                                               <?php if ($_rate->getErrorMessage()): ?>
                                                    <?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?>
                                               <?php else: ?>
                                                    <?php if ($_sole) : ?>
                                                    <span class="no-display"><input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
                                                    <?php else: ?>
                                                    <input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" />
                                                    <?php endif; ?>
                                                    <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
                                                    <?php $_excl = $this->getShippingPrice($_address, $_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
                                                    <?php $_incl = $this->getShippingPrice($_address, $_rate->getPrice(), true); ?>
                                                    <?php echo $_excl; ?>
                                                    <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
                                                        (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
                                                    <?php endif; ?>
                                                    </label>
                                               <?php endif ?>
                                            </li>
                                        <?php endforeach; ?>
                                        </ul>
                                    </dd>
                                <?php endforeach; ?>
                            </dl>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
                <div class="grid_8 omega">
                    <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
                    <h4><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h4>
                    <table class="data-table" id="shipping-table-<?php echo $_address->getId() ?>">
                        <col />
                        <col width="1" />
                        <thead>
                            <tr>
                                <th><?php echo $this->__('Product Name') ?></th>
                                <th class="a-center"><?php echo $this->__('Qty') ?></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($this->getAddressItems($_address) as $_item): ?>
                            <tr>
                                <td>
                                    <?php echo $this->getItemHtml($_item->getQuoteItem()) ?>
                                </td>
                                <td class="a-center"><?php echo $_item->getQty() ?></td>
                            </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                    <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
                    <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
                </div>
            </div>
        </div>
        <?php endforeach; ?>
        <?php echo $this->getChildHtml('checkout_billing_items') ?>
        <div class="box-action box-multishipping clearfix">
            <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a></p>
            <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="action-button"><span><?php echo $this->__('Continue to Billing Information') ?></span></button>
        </div>
    </form>
</div>
</div>