<?php

namespace ProjectManagement\prjProjectManagement;

// Page object
$ProjectmomPreview = &$Page;
?>
<script>
ew.deepAssign(ew.vars, { tables: { projectmom: <?= JsonEncode($Page->toClientVar()) ?> } });
</script>
<script>
loadjs.ready("head", function () {
    // Write your table-specific client script here, no need to add script tags.
});
</script>
<?php $Page->showPageHeader(); ?>
<?php if ($Page->TotalRecords > 0) { ?>
<div class="card ew-grid <?= $Page->TableGridClass ?>"><!-- .card -->
<div class="card-body ew-preview-middle-panel ew-grid-middle-panel <?= $Page->TableContainerClass ?>" style="<?= $Page->TableContainerStyle ?>"><!-- .card-body -->
<table class="<?= $Page->TableClass ?>"><!-- .table -->
    <thead><!-- Table header -->
        <tr class="ew-table-header">
<?php
// Render list options
$Page->renderListOptions();

// Render list options (header, left)
$Page->ListOptions->render("header", "left");
?>
<?php if ($Page->MomDate->Visible) { // MomDate ?>
    <?php if (!$Page->MomDate->Sortable || !$Page->sortUrl($Page->MomDate)) { ?>
        <th class="<?= $Page->MomDate->headerCellClass() ?>"><?= $Page->MomDate->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->MomDate->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->MomDate->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->MomDate->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->MomDate->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->MomDate->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->MomTitle->Visible) { // MomTitle ?>
    <?php if (!$Page->MomTitle->Sortable || !$Page->sortUrl($Page->MomTitle)) { ?>
        <th class="<?= $Page->MomTitle->headerCellClass() ?>"><?= $Page->MomTitle->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->MomTitle->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->MomTitle->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->MomTitle->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->MomTitle->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->MomTitle->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->Internal->Visible) { // Internal ?>
    <?php if (!$Page->Internal->Sortable || !$Page->sortUrl($Page->Internal)) { ?>
        <th class="<?= $Page->Internal->headerCellClass() ?>"><?= $Page->Internal->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->Internal->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->Internal->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->Internal->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->Internal->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->Internal->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->_ProjectID->Visible) { // ProjectID ?>
    <?php if (!$Page->_ProjectID->Sortable || !$Page->sortUrl($Page->_ProjectID)) { ?>
        <th class="<?= $Page->_ProjectID->headerCellClass() ?>"><?= $Page->_ProjectID->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->_ProjectID->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->_ProjectID->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->_ProjectID->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->_ProjectID->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->_ProjectID->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->Created_Date->Visible) { // Created_Date ?>
    <?php if (!$Page->Created_Date->Sortable || !$Page->sortUrl($Page->Created_Date)) { ?>
        <th class="<?= $Page->Created_Date->headerCellClass() ?>"><?= $Page->Created_Date->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->Created_Date->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->Created_Date->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->Created_Date->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->Created_Date->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->Created_Date->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->Created_By->Visible) { // Created_By ?>
    <?php if (!$Page->Created_By->Sortable || !$Page->sortUrl($Page->Created_By)) { ?>
        <th class="<?= $Page->Created_By->headerCellClass() ?>"><?= $Page->Created_By->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->Created_By->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->Created_By->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->Created_By->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->Created_By->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->Created_By->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->Last_Updated_Date->Visible) { // Last_Updated_Date ?>
    <?php if (!$Page->Last_Updated_Date->Sortable || !$Page->sortUrl($Page->Last_Updated_Date)) { ?>
        <th class="<?= $Page->Last_Updated_Date->headerCellClass() ?>"><?= $Page->Last_Updated_Date->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->Last_Updated_Date->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->Last_Updated_Date->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->Last_Updated_Date->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->Last_Updated_Date->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->Last_Updated_Date->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php if ($Page->Last_Updated_By->Visible) { // Last_Updated_By ?>
    <?php if (!$Page->Last_Updated_By->Sortable || !$Page->sortUrl($Page->Last_Updated_By)) { ?>
        <th class="<?= $Page->Last_Updated_By->headerCellClass() ?>"><?= $Page->Last_Updated_By->caption() ?></th>
    <?php } else { ?>
        <th class="<?= $Page->Last_Updated_By->headerCellClass() ?>"><div role="button" data-table="projectmom" data-sort="<?= HtmlEncode($Page->Last_Updated_By->Name) ?>" data-sort-type="1" data-sort-order="<?= $Page->Last_Updated_By->getNextSort() ?>">
            <div class="ew-table-header-btn">
                <span class="ew-table-header-caption"><?= $Page->Last_Updated_By->caption() ?></span>
                <span class="ew-table-header-sort"><?= $Page->Last_Updated_By->getSortIcon() ?></span>
            </div>
        </th>
    <?php } ?>
<?php } ?>
<?php
// Render list options (header, right)
$Page->ListOptions->render("header", "right");
?>
        </tr>
    </thead>
    <tbody><!-- Table body -->
<?php
$Page->RecordCount = 0;
$Page->RowCount = 0;
while ($Page->fetch()) {
    // Init row class and style
    $Page->RecordCount++;
    $Page->RowCount++;
    $Page->CssStyle = "";
    $Page->loadListRowValues($Page->CurrentRow);

    // Render row
    $Page->RowType = RowType::PREVIEW; // Preview record
    $Page->resetAttributes();
    $Page->renderListRow();

    // Set up row attributes
    $Page->RowAttrs->merge([
        "data-rowindex" => $Page->RowCount,
        "class" => ($Page->RowCount % 2 != 1) ? "ew-table-alt-row" : "",

        // Add row attributes for expandable row
        "data-widget" => "expandable-table",
        "aria-expanded" => "false",
    ]);

    // Render list options
    $Page->renderListOptions();
?>
    <tr <?= $Page->rowAttributes() ?>>
<?php
// Render list options (body, left)
$Page->ListOptions->render("body", "left", $Page->RowCount);
?>
<?php if ($Page->MomDate->Visible) { // MomDate ?>
        <!-- MomDate -->
        <td<?= $Page->MomDate->cellAttributes() ?>>
<span<?= $Page->MomDate->viewAttributes() ?>>
<?= $Page->MomDate->getViewValue() ?></span>
</td>
<?php } ?>
<?php if ($Page->MomTitle->Visible) { // MomTitle ?>
        <!-- MomTitle -->
        <td<?= $Page->MomTitle->cellAttributes() ?>>
<span<?= $Page->MomTitle->viewAttributes() ?>>
<?= $Page->MomTitle->getViewValue() ?></span>
</td>
<?php } ?>
<?php if ($Page->Internal->Visible) { // Internal ?>
        <!-- Internal -->
        <td<?= $Page->Internal->cellAttributes() ?>>
<span<?= $Page->Internal->viewAttributes() ?>>
<i class="fa-regular fa-square<?php if (ConvertToBool($Page->Internal->CurrentValue)) { ?>-check<?php } ?> ew-icon ew-boolean"></i>
</span>
</td>
<?php } ?>
<?php if ($Page->_ProjectID->Visible) { // ProjectID ?>
        <!-- ProjectID -->
        <td<?= $Page->_ProjectID->cellAttributes() ?>>
<span<?= $Page->_ProjectID->viewAttributes() ?>>
<?= $Page->_ProjectID->getViewValue() ?></span>
</td>
<?php } ?>
<?php if ($Page->Created_Date->Visible) { // Created_Date ?>
        <!-- Created_Date -->
        <td<?= $Page->Created_Date->cellAttributes() ?>>
<span<?= $Page->Created_Date->viewAttributes() ?>>
<?= $Page->Created_Date->getViewValue() ?></span>
</td>
<?php } ?>
<?php if ($Page->Created_By->Visible) { // Created_By ?>
        <!-- Created_By -->
        <td<?= $Page->Created_By->cellAttributes() ?>>
<span<?= $Page->Created_By->viewAttributes() ?>>
<?= $Page->Created_By->getViewValue() ?></span>
</td>
<?php } ?>
<?php if ($Page->Last_Updated_Date->Visible) { // Last_Updated_Date ?>
        <!-- Last_Updated_Date -->
        <td<?= $Page->Last_Updated_Date->cellAttributes() ?>>
<span<?= $Page->Last_Updated_Date->viewAttributes() ?>>
<?= $Page->Last_Updated_Date->getViewValue() ?></span>
</td>
<?php } ?>
<?php if ($Page->Last_Updated_By->Visible) { // Last_Updated_By ?>
        <!-- Last_Updated_By -->
        <td<?= $Page->Last_Updated_By->cellAttributes() ?>>
<span<?= $Page->Last_Updated_By->viewAttributes() ?>>
<?= $Page->Last_Updated_By->getViewValue() ?></span>
</td>
<?php } ?>
<?php
// Render list options (body, right)
$Page->ListOptions->render("body", "right", $Page->RowCount);
?>
    </tr>
<?php
} // while
?>
    </tbody>
</table><!-- /.table -->
</div><!-- /.card-body -->
<div class="card-footer ew-grid-lower-panel ew-preview-lower-panel"><!-- .card-footer -->
<?= $Page->Pager->render() ?>
<?php if ($Page->OtherOptions->visible()) { ?>
<div class="ew-preview-other-options">
<?php
    foreach ($Page->OtherOptions as $option) {
        $option->render("body");
    }
?>
</div>
<?php } ?>
</div><!-- /.card-footer -->
</div><!-- /.card -->
<?php } else { // No record ?>
<div class="card border-0"><!-- .card -->
<div class="ew-detail-count"><?= $Language->phrase("NoRecord") ?></div>
<?php if ($Page->OtherOptions->visible()) { ?>
<div class="ew-preview-other-options">
<?php
    foreach ($Page->OtherOptions as $option) {
        $option->render("body");
    }
?>
</div>
<?php } ?>
</div><!-- /.card -->
<?php } ?>
<?php
foreach ($Page->DetailCounts as $detailTblVar => $detailCount) {
?>
<div class="ew-detail-count d-none" data-table="<?= $detailTblVar ?>" data-count="<?= $detailCount ?>"><?= FormatInteger($detailCount) ?></div>
<?php
}
?>
<?php
$Page->showPageFooter();
echo GetDebugMessage();
?>
<?php
$Page->Recordset?->free();
?>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
