<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * Multishipping checkout shipping template
 *
 * @var $block \Magento\Multishipping\Block\Checkout\Shipping
 */
?>
<form action="<?php /* @escapeNotVerified */ echo $block->getPostActionUrl() ?>" method="post" id="shipping_method_form" class="form multicheckout shipping">
    <?php foreach ($block->getAddresses() as $_index => $_address): ?>
    <div class="block block-shipping">
        <div class="block-title"><strong><?php /* @escapeNotVerified */ echo __('Address %1 <span>of %2</span>', ($_index+1), $block->getAddressCount()) ?></strong></div>
        <div class="block-content">
            <div class="box box-shipping-address">
                <strong class="box-title">
                    <span><?php /* @escapeNotVerified */ echo __('Shipping To') ?></span>
                    <a href="<?php /* @escapeNotVerified */ echo $block->getAddressEditUrl($_address) ?>" class="action edit"><span><?php /* @escapeNotVerified */ echo __('Change') ?></span></a>
                </strong>
                <div class="box-content">
                    <address><?php /* @escapeNotVerified */ echo $_address->format('html') ?></address>
                </div>
            </div>
            <div class="box box-shipping-method">
                <strong class="box-title">
                    <span><?php /* @escapeNotVerified */ echo __('Shipping Method') ?></span>
                </strong>
                <div class="box-content">
                    <?php if (!($_shippingRateGroups = $block->getShippingRates($_address))): ?>
                        <p><?php /* @escapeNotVerified */ echo __('Sorry, no quotes are available for this order right now.') ?></p>
                    <?php else: ?>
                    <dl class="items methods-shipping">
                        <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
                            <dt class="item-title"><?php echo $block->escapeHtml($block->getCarrierName($code)) ?></dt>
                            <dd class="item-content">
                                <fieldset class="fieldset">
                                    <legend class="legend">
                                        <span><?php echo $block->escapeHtml($block->getCarrierName($code)) ?></span>
                                    </legend><br>
                                    <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
                                    <div class="field choice">
                                    <?php if ($_rate->getErrorMessage()): ?>
                                        <strong><?php echo $block->escapeHtml($_rate->getCarrierTitle()) ?>: <?php echo $block->escapeHtml($_rate->getErrorMessage()) ?></strong>
                                    <?php else: ?>
                                        <div class="control">
                                            <?php if ($_sole) : ?>
                                                <input type="radio" name="shipping_method[<?php /* @escapeNotVerified */ echo $_address->getId() ?>]" value="<?php echo $block->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php /* @escapeNotVerified */ echo $_address->getId() ?>_<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>" class="radio solo method" checked="checked"/>
                                            <?php else: ?>
                                                <input type="radio" name="shipping_method[<?php /* @escapeNotVerified */ echo $_address->getId() ?>]" value="<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>" id="s_method_<?php /* @escapeNotVerified */ echo $_address->getId() ?>_<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$block->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" />
                                            <?php endif; ?>
                                        </div>
                                        <label for="s_method_<?php /* @escapeNotVerified */ echo $_address->getId() ?>_<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>"><?php echo $block->escapeHtml($_rate->getMethodTitle()) ?>
                                            <?php $_excl = $block->getShippingPrice($_address, $_rate->getPrice(), $this->helper('Magento\Tax\Helper\Data')->displayShippingPriceIncludingTax()); ?>
                                            <?php $_incl = $block->getShippingPrice($_address, $_rate->getPrice(), true); ?>
                                        <?php if ($this->helper('Magento\Tax\Helper\Data')->displayShippingBothPrices() && $_incl != $_excl): ?>
                                            <span class="price-including-tax" data-label="<?php /* @escapeNotVerified */ echo __('Incl. Tax'); ?>">
                                        <?php endif; ?>
                                            <?php /* @escapeNotVerified */ echo $_incl; ?>
                                        <?php if ($this->helper('Magento\Tax\Helper\Data')->displayShippingBothPrices() && $_incl != $_excl): ?>
                                            </span>
                                        <?php endif; ?>
                                        <?php if ($this->helper('Magento\Tax\Helper\Data')->displayShippingBothPrices() && $_incl != $_excl): ?>
                                            <span class="price-excluding-tax" data-label="<?php /* @escapeNotVerified */ echo __('Excl. Tax'); ?>"><?php /* @escapeNotVerified */ echo $_excl; ?></span>
                                        <?php endif; ?>
                                        </label>
                                    <?php endif ?>
                                    </div>
                                    <?php endforeach; ?>
                                </fieldset>
                            </dd>
                        <?php endforeach; ?>
                    </dl>
                    <?php endif; ?>
                    <?php /* @escapeNotVerified */ echo $block->getItemsBoxTextAfter($_address); ?>
                </div>
            </div>
            <div class="box box-items">
                <strong class="box-title">
                    <span><?php /* @escapeNotVerified */ echo __('Items') ?></span>
                    <a href="<?php /* @escapeNotVerified */ echo $block->getItemsEditUrl($_address) ?>" class="action edit"><span><?php /* @escapeNotVerified */ echo __('Edit Items') ?></span></a>
                </strong>
                <div class="box-content">
                    <div class="table-wrapper">
                        <table class="items data table" id="shipping-table-<?php /* @escapeNotVerified */ echo $_address->getId() ?>">
                            <caption class="table-caption"><?php /* @escapeNotVerified */ echo __('Items') ?></caption>
                            <thead>
                            <tr>
                                <th class="col item" scope="col"><?php /* @escapeNotVerified */ echo __('Product Name') ?></th>
                                <th class="col qty" scope="col"><?php /* @escapeNotVerified */ echo __('Qty') ?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($block->getAddressItems($_address) as $_item): ?>
                                <tr>
                                    <td class="col item" data-th="<?php echo $block->escapeHtml(__('Product Name'));?>"><?php echo $block->getItemHtml($_item->getQuoteItem()) ?></td>
                                    <td class="col qty" data-th="<?php echo $block->escapeHtml(__('Qty'));?>"><?php /* @escapeNotVerified */ echo $_item->getQty() ?></td>
                                </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php endforeach; ?>
    <?php echo $block->getChildHtml('checkout_billing_items') ?>
    <div class="actions-toolbar">
        <div class="primary">
            <button class="action primary continue" type="submit"><span><?php /* @escapeNotVerified */ echo __('Continue to Billing Information') ?></span></button>
        </div>
        <div class="secondary">
            <a href="<?php /* @escapeNotVerified */ echo $block->getBackUrl() ?>" class="action back"><span><?php /* @escapeNotVerified */ echo __('Back to Select Addresses') ?></span></a>
        </div>
    </div>
</form>
