<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php $_order = $block->getOrder() ?>
<div class="actions-toolbar">
    <a href="<?= $block->escapeUrl($block->getPrintAllInvoicesUrl($_order)) ?>"
       target="_blank"
       class="action print">
        <span><?= $block->escapeHtml(__('Print All Invoices')) ?></span>
    </a>
</div>
<?php foreach ($_order->getInvoiceCollection() as $_invoice) : ?>
    <div class="order-title">
        <strong><?= $block->escapeHtml(__('Invoice #')) ?><?= $block->escapeHtml($_invoice->getIncrementId()) ?></strong>
        <a href="<?= $block->escapeUrl($block->getPrintInvoiceUrl($_invoice)) ?>"
           onclick="this.target='_blank'"
           class="action print">
            <span><?= $block->escapeHtml(__('Print Invoice')) ?></span>
        </a>
    </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->getAllItems(); ?>
            <?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>
    <?= $block->getInvoiceCommentsHtml($_invoice) ?>
<?php endforeach; ?>
