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

// @codingStandardsIgnoreFile

/** @var $block \Magento\Sales\Block\Adminhtml\Order\Totals\Tax */
?>
<?php
/** @var $_source \Magento\Sales\Model\Order\Invoice */
$_source    = $block->getSource();
$_order     = $block->getOrder();
$_fullInfo  = $block->getFullTaxInfo();
?>

<?php if ($block->displayFullSummary()): ?>
    <?php $isTop = 1; ?>
    <?php if (isset($_fullInfo[0]['rates'])): ?>
        <?php foreach ($_fullInfo as $info): ?>
            <?php if (isset($info['hidden']) && $info['hidden']) {
    continue;
} ?>
            <?php
                $percent    = $info['percent'];
                $amount     = $info['amount'];
                $baseAmount = $info['base_amount'];
                $rates      = $info['rates'];
                $isFirst    = 1;
            ?>

            <?php foreach ($rates as $rate): ?>
            <tr class="summary-details<?php if ($isTop): echo ' summary-details-first'; endif; ?>" style="display:none;">
                <?php if (!is_null($rate['percent'])): ?>
                    <td class="label"><?php /* @escapeNotVerified */ echo $rate['title']; ?> (<?php echo (float)$rate['percent']; ?>%)<br /></td>
                <?php else: ?>
                    <td class="label"><?php /* @escapeNotVerified */ echo $rate['title']; ?><br /></td>
                <?php endif; ?>
                <?php if ($isFirst): ?>
                    <td rowspan="<?php echo count($rates); ?>"><?php /* @escapeNotVerified */ echo $block->displayAmount($amount, $baseAmount); ?></td>
                <?php endif; ?>
            </tr>
            <?php
                $isFirst = 0;
                $isTop = 0;
            ?>
            <?php endforeach; ?>
        <?php endforeach; ?>
    <?php else: ?>
        <?php foreach ($_fullInfo as $info): ?>
            <?php
                $percent    = $info['percent'];
                $amount     = $info['tax_amount'];
                $baseAmount = $info['base_tax_amount'];
                $isFirst    = 1;
            ?>

            <tr class="summary-details<?php if ($isTop): echo ' summary-details-first'; endif; ?>" style="display:none;">
                <?php if (!is_null($info['percent'])): ?>
                    <td class="label"><?php echo $block->escapeHtml($info['title']); ?> (<?php echo (float)$info['percent']; ?>%)<br /></td>
                <?php else: ?>
                    <td class="label"><?php echo $block->escapeHtml($info['title']); ?><br /></td>
                <?php endif; ?>
                    <td><?php /* @escapeNotVerified */ echo $block->displayAmount($amount, $baseAmount); ?></td>
            </tr>
            <?php
                $isFirst = 0;
                $isTop = 0;
            ?>
        <?php endforeach; ?>
    <?php endif; ?>
<?php endif;?>
<?php if ($block->displayFullSummary() && $_fullInfo): ?>
<tr class="summary-total" onclick="expandDetails(this, '.summary-details')">
<?php else: ?>
<tr>
<?php endif; ?>
    <td class="label">
        <div class="summary-collapse">
        <?php if ($this->helper('Magento\Tax\Helper\Data')->displayFullSummary()): ?>
            <?php /* @escapeNotVerified */ echo __('Total Tax') ?>
        <?php else: ?>
            <?php /* @escapeNotVerified */ echo __('Tax') ?>
        <?php endif;?>
        </div>
    </td>
    <td>
        <?php /* @escapeNotVerified */ echo $block->displayAmount($_source->getTaxAmount(), $_source->getBaseTaxAmount()); ?>
    </td>
</tr>
