<?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->__('Ship to Multiple Addresses') ?><div class="call-to-action" style="margin-top: -6px"><button type="button" title="<?php echo $this->__('Enter a New Address') ?>" class="button" onclick="$('add_new_address_flag').value=1; $('checkout_multishipping_form').submit();"><span><span><?php echo $this->__('Enter a New Address') ?></span></span></button></div></h1>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<form id="checkout_multishipping_form" action="<?php echo $this->getPostActionUrl() ?>" method="post">
    <div class="multiple-checkout">
        <input type="hidden" name="continue" value="0" id="can_continue_flag" />
        <input type="hidden" name="new_address" value="0" id="add_new_address_flag" />
        <h3><?php echo $this->__('Please select shipping address for applicable items') ?></h3>
        <table class="data-table" id="multiship-addresses-table">
            <col />
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <thead>
                <tr>
                    <th><?php echo $this->__('Product') ?></th>
                    <th class="a-center"><?php echo $this->__('Qty') ?></th>
                    <th><?php echo $this->__('Send To') ?></th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td colspan="100" class="a-right"><button type="submit" title="<?php echo $this->__('Update Qty &amp; Addresses') ?>" class="light-button" onclick="$('can_continue_flag').value=0"><span><span><?php echo $this->__('Update Qty &amp; Addresses') ?></span></span></button></td>
                </tr>
            </tfoot>
            <tbody>
            <?php foreach ($this->getItems() as $_index => $_item): ?>
                <?php if ($_item->getQuoteItem()) :?>
                <tr>
                    <td><?php echo $this->getItemHtml($_item->getQuoteItem())?></td>
                    <td><input type="text" name="ship[<?php echo $_index ?>][<?php echo $_item->getQuoteItemId() ?>][qty]" value="<?php echo $this->escapeHtml($_item->getQty()) ?>" size="2" class="input-text qty" /></td>
                    <td><?php if ($_item->getProduct()->getIsVirtual()): echo $this->__('Shipping selection is not applicable.'); else: echo $this->getAddressesHtmlSelect($_item, $_index); endif; ?></td>
                    <td class="a-center"><a href="<?php echo $this->getItemDeleteUrl($_item) ?>" title="<?php echo $this->__('Remove Item') ?>" class="remove-link"><?php echo $this->__('Remove') ?></a></td>
                </tr>
                <?php endif; ?>
            <?php endforeach; ?>
            </tbody>
        </table>
        <script type="text/javascript">decorateTable('multiship-addresses-table')</script>
        <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 Shopping Cart') ?></a></p>
            <button type="submit" title="<?php echo $this->__('Continue to Shipping Information') ?>" class="action-button <?php if ($this->isContinueDisabled()):?> disabled<?php endif; ?>" onclick="$('can_continue_flag').value=1"<?php if ($this->isContinueDisabled()):?> disabled="disabled"<?php endif; ?>><span><?php echo $this->__('Continue to Shipping Information') ?></span></button>
        </div>
    </div>
</form>
</div>