<?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_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.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="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>
    <div class="content col2-alt-set">
        <div class="col-1">
            <div class="head">
                <h5><?php echo $this->__('Shipping to') ?><span class="pipe">|</span><a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change Shipping Address') ?></a></h5>
            </div>
            <address>
                <?php echo $_address->format('html') ?>
            </address>
            <br />
            <div class="shipping-method-pointer">
                <img src="<?php echo $this->getSkinUrl('images/shipping_method_pointer.gif') ?>" class="pointer" alt="" />
                <div class="head">
                    <h5><?php echo $this->__('Shipping Method') ?></h5>
                </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 foreach ($_shippingRateGroups as $code => $_rates): ?>
                        <dt><?php echo $this->getCarrierName($code) ?></dt>
                        <dd>
                            <ul>
                            <?php foreach ($_rates as $_rate): ?>
                                <li>
                                   <?php if ($_rate->getErrorMessage()): ?>
                                        <strong><?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?></strong>
                                   <?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"' ?> />
                                        <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
                                        <strong>
                                        <?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; ?>
                                        </strong>
                                        </label>
                                   <?php endif ?>
                                </li>
                            <?php endforeach; ?>
                            </ul>
                        </dd>
                    <?php endforeach; ?>
                </dl>
                <?php endif; ?>
            </div>
        </div>
        <div class="col-2">
            <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
            <div class="head">
                <h5><?php echo $this->__('Items') ?><span class="pipe">|</span><a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h5>
            </div>
            <table cellspacing="0" id="shipping-table-<?php echo $_address->getId() ?>" class="data-table nested-table">
                <col />
                <col width="30" />
                <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>
        </div>
        <div class="clear"></div>
        <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
    </div>
    </div>
<?php endforeach; ?>
<?php echo $this->getChildHtml('checkout_billing_items') ?>
</div>
<div class="button-set">
    <a href="<?php echo $this->getBackUrl() ?>" class="left"><?php echo $this->__('&laquo; Back to Select Addresses') ?></a>
    <button  class="form-button" type="submit"><span><?php echo $this->__('Continue to Billing Information') ?></span></button>
</div>
</form>
