<?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@magentocommerce.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.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Multishipping checkout shipping template
 *
 * @see Mage_Checkout_Block_Multishipping_Shipping
 */
?>
<div class="multiple-checkout">
    <div class="page-title">
        <h1><?php echo $this->__('Select Shipping Method') ?></h1>
    </div>
    <?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="col2-set">
            <h2 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h2>
            <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->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->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 $this->htmlEscape($_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="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">
            <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="button"><span><span><?php echo $this->__('Continue to Billing Information') ?></span></span></button>
        </div>
    </form>
</div>
