<?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     default_iphone
 * @copyright   Copyright (c) 2010 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="in-page">
    <div class="page-head">
        <h3><?php echo $this->__('Select Shipping Method') ?></h3>
    </div>
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
    <div class="multi-address-checkout-box">
    <?php foreach ($this->getAddresses() as $_index => $_address): ?>
    <div class="box">
        <div class="count-head">
            <h4><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h4>
        </div>
        <table class="shopping-cart">
            <thead>
                <tr>
                    <th class="a-left">
                        <div class="col2-set">
                            <div class="col-1"><?php echo $this->__('Shipping To') ?></div>
                            <div class="col-2 a-right"><a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change Shipping Address') ?></a></div>
                        </div><div class="clear"></div>
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <address>
                            <?php echo $_address->format('html') ?>
                        </address>
                    </td>
                </tr>
            </tbody>
        </table><br />
        <div class="shipping-method-pointer">
            <div class="inner-head">
                <h5><?php echo $this->__('Shipping Method') ?></h5><div class="clear"></div>
            </div>
            <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
                <strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
            <?php else: ?>
            <dl class="shipment-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()): ?>
                                    <strong><?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?></strong>
                            <?php else: ?>
                                    <?php if ($_sole) : ?>
                                    <span class="no-display"><input name="shipping_method[<?php echo $_address->getId() ?>]" type="radio" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
                                    <?php else: ?>
                                    <input name="shipping_method[<?php echo $_address->getId() ?>]" type="radio" 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"' ?> />
                                    <?php endif; ?>
                                    <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> - <strong><?php echo $_rate->getPrice() ?></strong></label>
                            <?php endif ?>
                            </li>
                        <?php endforeach; ?>
                        </ul>
                    </dd>
                <?php endforeach; ?>
            </dl>
            <?php endif; ?>
        </div>
        <div>
            <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
            <table class="shopping-cart">
            <thead>
                <tr>
                    <th class="a-left" colspan="2">
                        <div class="col2-set">
                            <div class="col-1"><?php echo $this->__('Items') ?></div>
                            <div class="col-2 a-right"><a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></div>
                        </div><div class="clear"></div>
                    </th>
                </tr>
                <tr>
                    <th class="a-left"><?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><br />
        <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
        </div>
        <div class="clear"></div>
        <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
    </div>
    <?php endforeach; ?>
    </div>
    <div class="a-right">
        <button  class="form-button" type="submit"><span><?php echo $this->__('Continue to Billing Information') ?></span></button>
    </div><br />
    <div><a href="<?php echo $this->getBackUrl() ?>" class="left"><?php echo $this->__('&laquo; Back to Select Addresses') ?></a></div>
    </form>
</div><br /><br />
