<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Adminhtml_Block_Widget_Grid $this */

$numColumns = count($this->getColumns());
?>
<?php if($this->getCollection()): ?>
<div class="grid np">
<table cellspacing="0" style="border:0;" id="<?= $this->getId() ?>_table">
    <?php foreach ($this->getColumns() as $_column): ?>
    <col <?= $_column->getHtmlProperty() ?> />
    <?php endforeach ?>
    <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
        <thead>
            <?php if ($this->getHeadersVisibility()): ?>
                <tr class="headings">
                <?php foreach ($this->getColumns() as $_column): ?>
                    <th <?= $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?= $_column->getHeaderHtml() ?></span></th>
                <?php endforeach ?>
                </tr>
            <?php endif ?>
        </thead>
    <?php endif ?>
    <tbody>
    <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
    <?php foreach ($this->getCollection() as $_index=>$_item): ?>
        <tr title="<?= $this->getRowId($_item) ?>">
        <?php $i=0;foreach ($this->getColumns() as $_column): ?>
            <td class="<?= $_column->getCssProperty() ?> <?= ++$i==$numColumns?'last':'' ?>"><?= (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?></td>
        <?php endforeach ?>
        </tr>
    <?php endforeach ?>
    <?php elseif ($this->getEmptyText()): ?>
        <tr>
            <td class="empty-text <?= $this->getEmptyTextClass() ?>" colspan="100"><?= $this->getEmptyText() ?></td>
        </tr>
    <?php endif ?>
    </tbody>
</table>
</div>
<?php if($this->canDisplayContainer()): ?>
<script type="text/javascript">
//<![CDATA[
    <?= $this->getJsObjectName() ?> = new varienGrid('<?= $this->getId() ?>', '<?= $this->getGridUrl() ?>', '<?= $this->getVarNamePage() ?>', '<?= $this->getVarNameSort() ?>', '<?= $this->getVarNameDir() ?>', '<?= $this->getVarNameFilter() ?>');
    <?= $this->getJsObjectName() ?>.useAjax = '<?= $this->getUseAjax() ?>';
    <?php if($this->getRowClickCallback()): ?>
        <?= $this->getJsObjectName() ?>.rowClickCallback = <?= $this->getRowClickCallback() ?>;
    <?php endif ?>
    <?php if($this->getCheckboxCheckCallback()): ?>
        <?= $this->getJsObjectName() ?>.checkboxCheckCallback = <?= $this->getCheckboxCheckCallback() ?>;
    <?php endif ?>
    <?php if($this->getRowInitCallback()): ?>
        <?= $this->getJsObjectName() ?>.initRowCallback = <?= $this->getRowInitCallback() ?>;
        <?= $this->getJsObjectName() ?>.rows.each(function(row){<?= $this->getRowInitCallback() ?>(<?= $this->getJsObjectName() ?>, row)});
    <?php endif ?>
    <?php if($this->getMassactionBlock()->isAvailable()): ?>
    <?= $this->getMassactionBlock()->getJavaScript() ?>
    <?php endif ?>
//]]>
</script>
<?php endif ?>
<?php endif ?>
