
<?php
/**
 * Multishipping checkout shipping template
 *
 * @see Mage_Checkout_Block_Multishipping_Shipping
 * @var $this Mage_Checkout_Block_Multishipping_Shipping
 */
?>

<div class="multiple_addresses">
    <div class="page-title">
        <h2><?php echo $this->__('Select Shipping Method') ?></h2>
    </div>
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
<fieldset class="multiple-checkout">
        <?php foreach ($this->getAddresses() as $_index => $_address): ?>
        <div class="col2-set">
            <h3 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h3>
            <div class="col-1 col-narrow">
                <div class="box">
                    <div class="box-title">
                        <h3><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h3>
                    </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">
                        <h3><?php echo $this->__('Shipping Method') ?></h3>
                    </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->escapeHtml($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 $this->escapeHtml($_rate->getCarrierTitle()) ?>: <?php echo $this->escapeHtml($_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->htmlEscape($_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 $_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 $this->escapeHtml($_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="col-2 col-wide">
                <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
                <h3><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h3>
                <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>
        <?php endforeach; ?>
        <?php echo $this->getChildHtml('checkout_billing_items') ?>
        <div class="buttons-set">
            <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="button btn-continue"><span><?php echo $this->__('Continue to Billing Information') ?></span></button>
            <a class="back-link" href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a>
        </div>
</fieldset>  <!--multiple-checkout-->
    </form>
</div> <!--multiple_addresses-->