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

// @codingStandardsIgnoreFile

?>
<?php
/**
 * Template for \Magento\Backend\Block\Widget\Grid\ColumnSet
 * @var $block \Magento\Backend\Block\Widget\Grid\ColumnSet
 */
$numColumns = sizeof($block->getColumns());
?>
<?php if ($block->getCollection()): ?>
    <?php
    /* This part is commented to remove all <col> tags from the code. */
    /* foreach ($block->getColumns() as $_column): ?>
        <col <?php echo $_column->getHtmlProperty() ?> />
    <?php endforeach; */ ?>
    <?php if ($block->isHeaderVisible()): ?>
        <thead>
            <?php if ($block->isHeaderVisible() || $block->getFilterVisibility()): ?>
                <tr>
                <?php foreach ($block->getColumns() as $_column): ?>
                <?php /* @var $_column \Magento\Backend\Block\Widget\Grid\Column */ ?>
                    <?php if ($_column->getHeaderHtml() == '&nbsp;'):?>
                        <th class="data-grid-th" data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                            <?php echo $_column->getHeaderHtmlProperty() ?>>&nbsp;</th>
                    <?php else: ?>
                        <?php echo $_column->getHeaderHtml()?>
                    <?php endif; ?>
                <?php endforeach; ?>
                </tr>
            <?php endif; ?>
            <?php if ($block->isFilterVisible()): ?>
                <tr class="data-grid-filters" data-role="filter-form">
                    <?php $i = 0; foreach ($block->getColumns() as $_column): ?>
                        <td data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>" <?php echo $_column->getHeaderHtmlProperty() ?>>
                            <?php echo $_column->getFilterHtml() ?>
                        </td>
                    <?php endforeach; ?>
                </tr>
            <?php endif ?>
        </thead>
    <?php endif; ?>

    <tbody>

        <?php if ($block->getCollection()->getSize() > 0 && !$block->getIsCollapsed()): ?>
        <?php foreach ($block->getCollection() as $_index => $_item): ?>
            <?php if ($block->hasMultipleRows($_item)) :?>
                <?php $block->updateItemByFirstMultiRow($_item); ?>
                <tr title="<?php /* @escapeNotVerified */ echo $block->getRowUrl($_item) ?>" data-role="row"
                    <?php if ($_class = $block->getRowClass($_item)):?> class="<?php /* @escapeNotVerified */ echo $_class; ?>"<?php endif;?>
                ><?php $i = 0; foreach ($block->getColumns() as $_column):
                      if ($block->shouldRenderCell($_item, $_column)):
                            $_rowspan = $block->getRowspan($_item, $_column);
                          ?><td data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                                <?php echo($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>
                                class="<?php /* @escapeNotVerified */ echo $_column->getCssProperty() ?> <?php /* @escapeNotVerified */ echo $_column->getId() == 'massaction' ? 'data-grid-checkbox-cell': ''?> <?php echo ++$i == $numColumns ? 'last' : '' ?>"
                            >
                                <?php echo(($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
                            </td><?php
                            if ($block->shouldRenderEmptyCell($_item, $_column)):?>
                                <td colspan="<?php /* @escapeNotVerified */ echo $block->getEmptyCellColspan($_item)?>" class="last">
                                <?php /* @escapeNotVerified */ echo $block->getEmptyCellLabel()?>
                                </td><?php
                            endif;
                        endif;
                    endforeach;
                ?></tr>
                <?php $_isFirstRow = true; ?>
                <?php foreach ($block->getMultipleRows($_item) as $_i):?>
                    <?php if ($_isFirstRow) : ?>
                        <?php $_isFirstRow = false; continue; ?>
                    <?php endif; ?>
                    <tr data-role="row">
                        <?php $i = 0; foreach ($block->getMultipleRowColumns($_i) as $_column):
                            ?><td data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                            class="<?php /* @escapeNotVerified */ echo $_column->getCssProperty() ?> <?php /* @escapeNotVerified */ echo $_column->getId() == 'massaction' ? 'data-grid-checkbox-cell': ''?> <?php echo ++$i == $numColumns-1 ? 'last' : '' ?>"
                        >
                            <?php echo(($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
                        </td><?php
                        endforeach; ?>
                    </tr>
                <?php endforeach;?>

                <?php if ($block->shouldRenderSubTotal($_item)): ?>
                    <tr class="subtotals">
                        <?php $i = 0; foreach ($block->getMultipleRowColumns() as $_column): ?>
                            <td data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                                class="<?php /* @escapeNotVerified */ echo $_column->getCssProperty() ?> <?php /* @escapeNotVerified */ echo $_column->getId() == 'massaction' ? 'data-grid-checkbox-cell': ''?> <?php echo ++$i == $numColumns ? 'last' : '' ?>"
                            >
                                <?php /* @escapeNotVerified */ echo $_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel()
                                    : $_column->getRowField($block->getSubTotals($_item));
                                ?>
                            </td>
                        <?php endforeach; ?>
                    </tr>
                <?php endif; ?>
            <?php else: ?>
                <tr data-role="row" title="<?php /* @escapeNotVerified */ echo $block->getRowUrl($_item) ?>"<?php if ($_class = $block->getRowClass($_item)):?>
                    class="<?php /* @escapeNotVerified */ echo $_class; ?>"<?php endif;?>
                >
                    <?php $i = 0; foreach ($block->getColumns() as $_column): ?>
                        <?php if ($block->shouldRenderCell($_item, $_column)):?>
                            <td data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                                class="<?php /* @escapeNotVerified */ echo $_column->getCssProperty() ?> <?php /* @escapeNotVerified */ echo $_column->getId() == 'massaction' ? 'data-grid-checkbox-cell': ''?> <?php echo ++$i == $numColumns ? 'last' : '' ?>"
                            >
                                <?php echo(($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
                            </td>
                            <?php if ($block->shouldRenderEmptyCell($_item, $_column)):?>
                                <td data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                                    colspan="<?php /* @escapeNotVerified */ echo $block->getEmptyCellColspan($_item)?>"
                                    class="col-no-records <?php /* @escapeNotVerified */ echo $block->getEmptyTextClass() ?> last"
                                >
                                    <?php /* @escapeNotVerified */ echo $block->getEmptyCellLabel()?>
                                </td>
                            <?php endif;?>
                        <?php endif;?>
                    <?php endforeach; ?>
                </tr>
            <?php endif; ?>
        <?php endforeach; ?>
        <?php elseif ($block->getEmptyText()): ?>
            <tr class="data-grid-tr-no-data" data-role="row">
                <td class="<?php /* @escapeNotVerified */ echo $block->getEmptyTextClass() ?>"
                    colspan="<?php /* @escapeNotVerified */ echo $numColumns ?>"><?php /* @escapeNotVerified */ echo $block->getEmptyText() ?></td>
            </tr>
        <?php endif; ?>
    </tbody>

    <?php if ($block->shouldRenderTotal()): ?>
    <tfoot>
        <tr class="totals" data-role="row">
            <?php foreach ($block->getColumns() as $_column): ?>
                <th data-column="<?php /* @escapeNotVerified */ echo $_column->getId() ?>"
                    class="<?php /* @escapeNotVerified */ echo $_column->getCssProperty() ?>"
                >
                    <?php /* @escapeNotVerified */ echo($_column->hasTotalsLabel()) ? $_column->getTotalsLabel()
                        : $_column->getRowField($block->getTotals()) ?>
                </th>
            <?php endforeach; ?>
        </tr>
    </tfoot>
    <?php endif; ?>
<?php endif ?>
