<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
// @codingStandardsIgnoreFile
?>
<?php $_order = $block->getOrder() ?>
<?php $_invoice = $block->getInvoice() ?>
<?php if ($_invoice) : ?>
    <?php $_invoices = [$_invoice]; ?>
<?php else : ?>
    <?php $_invoices = $_order->getInvoiceCollection() ?>
<?php endif; ?>
<?php foreach ($_invoices as $_invoice) : ?>
<div class="order-details-items invoice">
    <div class="order-title">
        <strong><?= $block->escapeHtml(__('Invoice #')) ?><?= $block->escapeHtml($_invoice->getIncrementId()) ?></strong>
    </div>
    <div class="table-wrapper table-order-items invoice">
        <table class="data table table-order-items invoice" id="my-invoice-table-<?= (int) $_invoice->getId() ?>">
            <caption class="table-caption"><?= $block->escapeHtml(__('Items Invoiced')) ?></caption>
            <thead>
            <tr>
                <th class="col name"><?= $block->escapeHtml(__('Product Name')) ?></th>
                <th class="col sku"><?= $block->escapeHtml(__('SKU')) ?></th>
                <th class="col price"><?= $block->escapeHtml(__('Price')) ?></th>
                <th class="col qty"><?= $block->escapeHtml(__('Qty Invoiced')) ?></th>
                <th class="col subtotal"><?= $block->escapeHtml(__('Subtotal')) ?></th>
            </tr>
            </thead>
            <?php $_items = $_invoice->getItemsCollection(); ?>
            <?php foreach ($_items as $_item) : ?>
                <?php if (!$_item->getOrderItem()->getParentItem()) : ?>
                    <tbody>
                        <?= $block->getItemHtml($_item) ?>
                    </tbody>
                <?php endif; ?>
            <?php endforeach; ?>
            <tfoot>
                <?= $block->getInvoiceTotalsHtml($_invoice) ?>
            </tfoot>
        </table>
    </div>
    <div class="block block-order-details-view">
        <div class="block-title">
            <strong><?= $block->escapeHtml(__('Order Information')) ?></strong>
        </div>
        <div class="block-content">
        <?php if (!$_order->getIsVirtual()) : ?>
            <div class="box box-order-shipping-address">
                <div class="box-title">
                    <strong><?= $block->escapeHtml(__('Shipping Address')) ?></strong>
                </div>
                <div class="box-content">
                    <?php $_shipping = $_invoice->getShippingAddress() ?>
                    <address><?= /* @noEscape */ $block->formatAddress($_shipping, 'html') ?></address>
                </div>
            </div>

            <div class="box box-order-shipping-method">
                <div class="box-title">
                    <strong><?= $block->escapeHtml(__('Shipping Method')) ?></strong>
                </div>
                <div class="box-content">
                    <?php if ($_order->getShippingDescription()) : ?>
                        <?= $block->escapeHtml($_order->getShippingDescription()) ?>
                    <?php else : ?>
                        <?= $block->escapeHtml(__('No shipping information available')) ?>
                    <?php endif; ?>
                </div>
            </div>
        <?php endif; ?>
            <div class="box box-order-billing-address">
                <div class="box-title">
                    <strong><?= $block->escapeHtml(__('Billing Address')) ?></strong>
                </div>
                <div class="box-content">
                    <?php $_billing = $_invoice->getbillingAddress() ?>
                    <address><?= /* @noEscape */ $block->formatAddress($_order->getBillingAddress(), 'html') ?></address>
                </div>
            </div>

            <div class="box box-order-billing-method">
                <div class="box-title">
                    <strong><?= $block->escapeHtml(__('Payment Method')) ?></strong>
                </div>
                <div class="box-content">
                    <?= $block->getPaymentInfoHtml() ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php endforeach; ?>
