<?php
// @codingStandardsIgnoreFile

?>
<?php $order = $block->getOrder() ?>
<div class="cs-info-block | cs-dashboard__block">
    <div class="cs-info-block__buttons">
        <a href="<?php /* @escapeNotVerified */ echo $block->getPrintAllCreditmemosUrl($order) ?>"
           onclick="this.target='_blank'"
           class="cs-button cs-button--size_300 cs-button--look_default">
            <span class="cs-button__span"><?php /* @escapeNotVerified */ echo __('Print All Refunds') ?></span>
            <svg class="cs-button__icon">
                <use xlink:href="#arrow_next"></use>
            </svg>
        </a>
    </div>
    <?php foreach ($order->getCreditmemosCollection() as $creditmemo): ?>
        <div class="cs-info-block__title cs-info-block__title--space-top | cs-title-block cs-title-block--bordered">
            <div class="cs-title-block__span | cs-t-headline cs-t-headline--size_2 cs-t-headline--look_light">
                <?php /* @escapeNotVerified */ echo __('Refund #') ?><?php /* @escapeNotVerified */ echo $creditmemo->getIncrementId(); ?> 
            </div>
            <span class="cs-t-headline__span">
                <a 
                    href="<?php /* @escapeNotVerified */ echo $block->getPrintCreditmemoUrl($creditmemo) ?>"
                    onclick="this.target='_blank'"
                    class="cs-link"
                >
                    <?php /* @escapeNotVerified */ echo __('Print Refund') ?>
                </a>
            </span>

        </div>

        <div class="cs-table | order-items-creditmemo">
            <table class="cs-table__body | creditmemo" id="my-refund-table-<?php /* @escapeNotVerified */ echo $creditmemo->getId(); ?>">
                <caption class="cs-visually-hidden"><?php /* @escapeNotVerified */ echo __('Items Refunded') ?></caption>
                <thead class="cs-table__head">
                <tr>
                    <th class="cs-table__col-head | name"><?php /* @escapeNotVerified */ echo __('Product Name') ?></th>
                    <th class="cs-table__col-head | sku"><?php /* @escapeNotVerified */ echo __('SKU') ?></th>
                    <th class="cs-table__col-head | price"><?php /* @escapeNotVerified */ echo __('Price') ?></th>
                    <th class="cs-table__col-head | qty"><?php /* @escapeNotVerified */ echo __('Qty') ?></th>
                    <th class="cs-table__col-head | subtotal"><?php /* @escapeNotVerified */ echo __('Subtotal') ?></th>
                    <th class="cs-table__col-head | discount"><?php /* @escapeNotVerified */ echo __('Discount Amount') ?></th>
                    <th class="cs-table__col-head | total"><?php /* @escapeNotVerified */ echo __('Row Total') ?></th>
                </tr>
                </thead>
                <?php $items = $creditmemo->getAllItems(); ?>
                <?php $count = count($items) ?>
                <?php foreach ($items as $item): ?>
                    <?php if ($item->getOrderItem()->getParentItem()) {
                        continue;
                    } ?>
                    <tbody class="cs-table__tbody">
                    <?php echo $block->getItemHtml($item) ?>
                    </tbody>
                <?php endforeach; ?>
                <tfoot class="cs-table__foot">
                <?php echo $block->getTotalsHtml($creditmemo);?>
                </tfoot>
            </table>
        </div>
        <?php echo $block->getCommentsHtml($creditmemo)?>
    <?php endforeach; ?>

</div>
