<?php

namespace PHPMaker2021\rdigital21;

// Page object
$PenilaianList = &$Page;
?>
<?php if (!$Page->isExport()) { ?>
<script>
var currentForm, currentPageID;
var fpenilaianlist;
loadjs.ready("head", function () {
    var $ = jQuery;
    // Form object
    currentPageID = ew.PAGE_ID = "list";
    fpenilaianlist = currentForm = new ew.Form("fpenilaianlist", "list");
    fpenilaianlist.formKeyCountName = '<?= $Page->FormKeyCountName ?>';
    loadjs.done("fpenilaianlist");
});
var fpenilaianlistsrch, currentSearchForm, currentAdvancedSearchForm;
loadjs.ready("head", function () {
    var $ = jQuery;
    // Form object for search
    fpenilaianlistsrch = currentSearchForm = new ew.Form("fpenilaianlistsrch");

    // Dynamic selection lists

    // Filters
    fpenilaianlistsrch.filterList = <?= $Page->getFilterList() ?>;

    // Init search panel as collapsed
    fpenilaianlistsrch.initSearchPanel = true;
    loadjs.done("fpenilaianlistsrch");
});
</script>
<script>
loadjs.ready("head", function () {
    // Write your table-specific client script here, no need to add script tags.
});
</script>
<?php } ?>
<?php if (!$Page->isExport()) { ?>
<div class="btn-toolbar ew-toolbar">
<?php if ($Page->TotalRecords > 0 && $Page->ExportOptions->visible()) { ?>
<?php $Page->ExportOptions->render("body") ?>
<?php } ?>
<?php if ($Page->ImportOptions->visible()) { ?>
<?php $Page->ImportOptions->render("body") ?>
<?php } ?>
<?php if ($Page->SearchOptions->visible()) { ?>
<?php $Page->SearchOptions->render("body") ?>
<?php } ?>
<?php if ($Page->FilterOptions->visible()) { ?>
<?php $Page->FilterOptions->render("body") ?>
<?php } ?>
<div class="clearfix"></div>
</div>
<?php } ?>
<?php
$Page->renderOtherOptions();
?>
<?php if ($Security->canSearch()) { ?>
<?php if (!$Page->isExport() && !$Page->CurrentAction) { ?>
<form name="fpenilaianlistsrch" id="fpenilaianlistsrch" class="form-inline ew-form ew-ext-search-form" action="<?= CurrentPageUrl(false) ?>">
<div id="fpenilaianlistsrch-search-panel" class="<?= $Page->SearchPanelClass ?>">
<input type="hidden" name="cmd" value="search">
<input type="hidden" name="t" value="penilaian">
    <div class="ew-extended-search">
<div id="xsr_<?= $Page->SearchRowCount + 1 ?>" class="ew-row d-sm-flex">
    <div class="ew-quick-search input-group">
        <input type="text" name="<?= Config("TABLE_BASIC_SEARCH") ?>" id="<?= Config("TABLE_BASIC_SEARCH") ?>" class="form-control" value="<?= HtmlEncode($Page->BasicSearch->getKeyword()) ?>">
        <input type="hidden" name="<?= Config("TABLE_BASIC_SEARCH_TYPE") ?>" id="<?= Config("TABLE_BASIC_SEARCH_TYPE") ?>" value="<?= HtmlEncode($Page->BasicSearch->getType()) ?>">
        <div class="input-group-append">
            <button class="btn btn-primary" name="btn-submit" id="btn-submit" type="submit"><?= $Language->phrase("SearchBtn") ?></button>
            <button type="button" data-toggle="dropdown" class="btn btn-primary dropdown-toggle dropdown-toggle-split" aria-haspopup="true" aria-expanded="false"><span id="searchtype"><?= $Page->BasicSearch->getTypeNameShort() ?></span></button>
            <div class="dropdown-menu dropdown-menu-right">
                <a class="dropdown-item<?php if ($Page->BasicSearch->getType() == "") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this);"><?= $Language->phrase("QuickSearchAuto") ?></a>
                <a class="dropdown-item<?php if ($Page->BasicSearch->getType() == "=") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this, '=');"><?= $Language->phrase("QuickSearchExact") ?></a>
                <a class="dropdown-item<?php if ($Page->BasicSearch->getType() == "AND") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this, 'AND');"><?= $Language->phrase("QuickSearchAll") ?></a>
                <a class="dropdown-item<?php if ($Page->BasicSearch->getType() == "OR") { ?> active<?php } ?>" href="#" onclick="return ew.setSearchType(this, 'OR');"><?= $Language->phrase("QuickSearchAny") ?></a>
            </div>
        </div>
    </div>
</div>
    </div><!-- /.ew-extended-search -->
</div><!-- /.ew-search-panel -->
</form>
<?php } ?>
<?php } ?>
<?php $Page->showPageHeader(); ?>
<?php
$Page->showMessage();
?>
<?php if ($Page->TotalRecords > 0 || $Page->CurrentAction) { ?>
<div class="card ew-card ew-grid<?php if ($Page->isAddOrEdit()) { ?> ew-grid-add-edit<?php } ?> penilaian">
<?php if (!$Page->isExport()) { ?>
<div class="card-header ew-grid-upper-panel">
<?php if (!$Page->isGridAdd()) { ?>
<form name="ew-pager-form" class="form-inline ew-form ew-pager-form" action="<?= CurrentPageUrl(false) ?>">
<?= $Page->Pager->render() ?>
</form>
<?php } ?>
<div class="ew-list-other-options">
<?php $Page->OtherOptions->render("body") ?>
</div>
<div class="clearfix"></div>
</div>
<?php } ?>
<form name="fpenilaianlist" id="fpenilaianlist" class="form-inline ew-form ew-list-form" action="<?= CurrentPageUrl(false) ?>" method="post">
<?php if (Config("CHECK_TOKEN")) { ?>
<input type="hidden" name="<?= $TokenNameKey ?>" value="<?= $TokenName ?>"><!-- CSRF token name -->
<input type="hidden" name="<?= $TokenValueKey ?>" value="<?= $TokenValue ?>"><!-- CSRF token value -->
<?php } ?>
<input type="hidden" name="t" value="penilaian">
<div id="gmp_penilaian" class="<?= ResponsiveTableClass() ?>card-body ew-grid-middle-panel">
<?php if ($Page->TotalRecords > 0 || $Page->isGridEdit()) { ?>
<table id="tbl_penilaianlist" class="table ew-table"><!-- .ew-table -->
<thead>
    <tr class="ew-table-header">
<?php
// Header row
$Page->RowType = ROWTYPE_HEADER;

// Render list options
$Page->renderListOptions();

// Render list options (header, left)
$Page->ListOptions->render("header", "left");
?>
<?php if ($Page->penilaian_id->Visible) { // penilaian_id ?>
        <th data-name="penilaian_id" class="<?= $Page->penilaian_id->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_penilaian_penilaian_id" class="penilaian_penilaian_id"><?= $Page->renderSort($Page->penilaian_id) ?></div></th>
<?php } ?>
<?php if ($Page->kode_tapel->Visible) { // kode_tapel ?>
        <th data-name="kode_tapel" class="<?= $Page->kode_tapel->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_penilaian_kode_tapel" class="penilaian_kode_tapel"><?= $Page->renderSort($Page->kode_tapel) ?></div></th>
<?php } ?>
<?php if ($Page->guru_id->Visible) { // guru_id ?>
        <th data-name="guru_id" class="<?= $Page->guru_id->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_penilaian_guru_id" class="penilaian_guru_id"><?= $Page->renderSort($Page->guru_id) ?></div></th>
<?php } ?>
<?php if ($Page->mapel_id->Visible) { // mapel_id ?>
        <th data-name="mapel_id" class="<?= $Page->mapel_id->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_penilaian_mapel_id" class="penilaian_mapel_id"><?= $Page->renderSort($Page->mapel_id) ?></div></th>
<?php } ?>
<?php if ($Page->kelas->Visible) { // kelas ?>
        <th data-name="kelas" class="<?= $Page->kelas->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_penilaian_kelas" class="penilaian_kelas"><?= $Page->renderSort($Page->kelas) ?></div></th>
<?php } ?>
<?php if ($Page->fase->Visible) { // fase ?>
        <th data-name="fase" class="<?= $Page->fase->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_penilaian_fase" class="penilaian_fase"><?= $Page->renderSort($Page->fase) ?></div></th>
<?php } ?>
<?php
// Render list options (header, right)
$Page->ListOptions->render("header", "right");
?>
    </tr>
</thead>
<tbody>
<?php
if ($Page->ExportAll && $Page->isExport()) {
    $Page->StopRecord = $Page->TotalRecords;
} else {
    // Set the last record to display
    if ($Page->TotalRecords > $Page->StartRecord + $Page->DisplayRecords - 1) {
        $Page->StopRecord = $Page->StartRecord + $Page->DisplayRecords - 1;
    } else {
        $Page->StopRecord = $Page->TotalRecords;
    }
}
$Page->RecordCount = $Page->StartRecord - 1;
if ($Page->Recordset && !$Page->Recordset->EOF) {
    // Nothing to do
} elseif (!$Page->AllowAddDeleteRow && $Page->StopRecord == 0) {
    $Page->StopRecord = $Page->GridAddRowCount;
}

// Initialize aggregate
$Page->RowType = ROWTYPE_AGGREGATEINIT;
$Page->resetAttributes();
$Page->renderRow();
while ($Page->RecordCount < $Page->StopRecord) {
    $Page->RecordCount++;
    if ($Page->RecordCount >= $Page->StartRecord) {
        $Page->RowCount++;

        // Set up key count
        $Page->KeyCount = $Page->RowIndex;

        // Init row class and style
        $Page->resetAttributes();
        $Page->CssClass = "";
        if ($Page->isGridAdd()) {
            $Page->loadRowValues(); // Load default values
            $Page->OldKey = "";
            $Page->setKey($Page->OldKey);
        } else {
            $Page->loadRowValues($Page->Recordset); // Load row values
            if ($Page->isGridEdit()) {
                $Page->OldKey = $Page->getKey(true); // Get from CurrentValue
                $Page->setKey($Page->OldKey);
            }
        }
        $Page->RowType = ROWTYPE_VIEW; // Render view

        // Set up row id / data-rowindex
        $Page->RowAttrs->merge(["data-rowindex" => $Page->RowCount, "id" => "r" . $Page->RowCount . "_penilaian", "data-rowtype" => $Page->RowType]);

        // Render row
        $Page->renderRow();

        // Render list options
        $Page->renderListOptions();
?>
    <tr <?= $Page->rowAttributes() ?>>
<?php
// Render list options (body, left)
$Page->ListOptions->render("body", "left", $Page->RowCount);
?>
    <?php if ($Page->penilaian_id->Visible) { // penilaian_id ?>
        <td data-name="penilaian_id" <?= $Page->penilaian_id->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_penilaian_penilaian_id">
<span<?= $Page->penilaian_id->viewAttributes() ?>><div class="btn-group" role="group" aria-label="Basic example">
    <?php
    $kode_tapel=$penilaian->kode_tapel->getViewValue();
    $penilaian_id=$penilaian->penilaian_id->getViewValue();
    $guru_id=$penilaian->guru_id->getViewValue();
    $kode_mapel=$penilaian->mapel_id->getViewValue();
    $kelas=$penilaian->kelas->getViewValue();
    $materi=$penilaian->materi->getViewValue();
    $tujuan_pembelajaran=$penilaian->tujuan_pembelajaran->getViewValue();
    $txt=$kode_tapel."|".$penilaian_id."|".$guru_id."|".$kode_mapel."|".$kelas."|".$materi."|".$tujuan_pembelajaran;
    $formatif = ExecuteScalar("SELECT COUNT(f1) FROM nilai_formatif WHERE penilaian_id='$penilaian_id'");
    $cek = ExecuteScalar("SELECT COUNT(*) FROM nilai_formatif WHERE penilaian_id='$penilaian_id'");
    $ctp= ExecuteScalar("SELECT COUNT(tujuan_pembelajaran) FROM penilaian WHERE penilaian_id='$penilaian_id'");
    $ctm= ExecuteScalar("SELECT COUNT(materi) FROM penilaian WHERE penilaian_id='$penilaian_id'");
    if ($ctp==0 && $ctm==0) {
       echo '<a href="javascript:void(0);" class="btn bg-secondary" onclick="tpm()"><i class="fas fa-remove"></i> Formatif</a>&nbsp;';
       echo '<a href="javascript:void(0);" class="btn bg-secondary" onclick="tpm()"><i class="fas fa-remove"></i> Sumatif</a>&nbsp;';
   } else {
    if ($formatif<=0 && $cek<=0) {
        echo '<a href="tool/buat_nilai_f.php?penilaian='.base64_encode($txt).'" class="btn bg-danger"><i class="fas fa-refresh"></i> Formatif</a>&nbsp;';
    } else {
        echo '<a href="" class="btn bg-success" disabled><i class="fas fa-check-square"></i> Formatif</a>&nbsp;';
    }                 
    $sumatif = ExecuteScalar("SELECT COUNT(*) FROM nilai_sumatif WHERE penilaian_id='$penilaian_id'");
    if ($sumatif<=0 && $formatif<=0) {
       echo '<a href="javascript:void(0);" class="btn bg-warning btn-sm" onclick="formatif()"><i class="fas fa-remove"></i> Sumatif</a>&nbsp;';
   } else if ($sumatif<=0 && $formatif>=0) {
    echo '<a href="tool/buat_nilai_s.php?penilaian='.base64_encode($txt).'" class="btn bg-danger"><i class="fas fa-refresh"></i> Sumatif</a>&nbsp;';
} else {
    echo '<a href="" class="btn bg-success" disabled><i class="fas fa-check-square"></i> Sumatif</a>&nbsp;';
} 
}
?>
</div>
<script>

    function formatif() { 
        alert('Pastikan Nilai Formatif Sudah Terisi');
    }

    function tpm() { 
        alert('Pastikan Tujuan Pembelajaran dan Materi Sudah Terisi');
    }
</script>
</span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->kode_tapel->Visible) { // kode_tapel ?>
        <td data-name="kode_tapel" <?= $Page->kode_tapel->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_penilaian_kode_tapel">
<span<?= $Page->kode_tapel->viewAttributes() ?>>
<?= $Page->kode_tapel->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->guru_id->Visible) { // guru_id ?>
        <td data-name="guru_id" <?= $Page->guru_id->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_penilaian_guru_id">
<span<?= $Page->guru_id->viewAttributes() ?>>
<?= $Page->guru_id->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->mapel_id->Visible) { // mapel_id ?>
        <td data-name="mapel_id" <?= $Page->mapel_id->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_penilaian_mapel_id">
<span<?= $Page->mapel_id->viewAttributes() ?>><?php
$penilaian_id=$penilaian->penilaian_id->getViewValue();
echo $kode_mapel=ExecuteScalar("SELECT mapel_id FROM penilaian WHERE penilaian_id='$penilaian_id'");
?>
</span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->kelas->Visible) { // kelas ?>
        <td data-name="kelas" <?= $Page->kelas->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_penilaian_kelas">
<span<?= $Page->kelas->viewAttributes() ?>>
<?= $Page->kelas->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->fase->Visible) { // fase ?>
        <td data-name="fase" <?= $Page->fase->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_penilaian_fase">
<span<?= $Page->fase->viewAttributes() ?>>
<?= $Page->fase->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
<?php
// Render list options (body, right)
$Page->ListOptions->render("body", "right", $Page->RowCount);
?>
    </tr>
<?php
    }
    if (!$Page->isGridAdd()) {
        $Page->Recordset->moveNext();
    }
}
?>
</tbody>
</table><!-- /.ew-table -->
<?php } ?>
</div><!-- /.ew-grid-middle-panel -->
<?php if (!$Page->CurrentAction) { ?>
<input type="hidden" name="action" id="action" value="">
<?php } ?>
</form><!-- /.ew-list-form -->
<?php
// Close recordset
if ($Page->Recordset) {
    $Page->Recordset->close();
}
?>
<?php if (!$Page->isExport()) { ?>
<div class="card-footer ew-grid-lower-panel">
<?php if (!$Page->isGridAdd()) { ?>
<form name="ew-pager-form" class="form-inline ew-form ew-pager-form" action="<?= CurrentPageUrl(false) ?>">
<?= $Page->Pager->render() ?>
</form>
<?php } ?>
<div class="ew-list-other-options">
<?php $Page->OtherOptions->render("body", "bottom") ?>
</div>
<div class="clearfix"></div>
</div>
<?php } ?>
</div><!-- /.ew-grid -->
<?php } ?>
<?php if ($Page->TotalRecords == 0 && !$Page->CurrentAction) { // Show other options ?>
<div class="ew-list-other-options">
<?php $Page->OtherOptions->render("body") ?>
</div>
<div class="clearfix"></div>
<?php } ?>
<?php
$Page->showPageFooter();
echo GetDebugMessage();
?>
<?php if (!$Page->isExport()) { ?>
<script>
// Field event handlers
loadjs.ready("head", function() {
    ew.addEventHandlers("penilaian");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
<?php } ?>
