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

/* @var \Magento\Sales\Block\Adminhtml\Order\Totals $block */

$priceHelper = $this->helper('Magento\Framework\Pricing\Helper\Data');
/** @var \Magetop\Advancepreview\Helper\OrderHelper $previewOrderHelper */
$previewOrderHelper = $this->helper('\Magetop\Advancepreview\Helper\OrderHelper');
$order = $block->getSource();
$priceItem = 0;
if($order && $order->getItems()) {
    $items = $order->getItems();
    foreach ($items as $item) {
        $infoRequest = $previewOrderHelper->getPreviewOrderItemDetail($item);
        if (isset($infoRequest['txt_project_final_price'])) {
            $priceItem += round($infoRequest['txt_project_final_price'],2);
        }
    }
}
$_totals = $block->getTotals('footer')
?>
<table class="data-table admin__table-secondary order-subtotal-table">
    <?php if ($_totals) : ?>
        <tbody>
            <tr>
                <td>
                    <?php echo __('Grand Total') ?>
                </td>
                <td>
                    <b><?php echo $priceHelper->currency($priceItem,true, false); ?></b>
                </td>
            </tr>
        </tbody>
    <?php endif; ?>
</table>
