<?php

namespace PHPMaker2021\rdigital21;

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

    // Add fields
    var currentTable = <?= JsonEncode(GetClientVar("tables", "proyek")) ?>,
        fields = currentTable.fields;
    fproyeklistsrch.addFields([
        ["project_id", [], fields.project_id.isInvalid],
        ["tahun_pelajaran", [], fields.tahun_pelajaran.isInvalid],
        ["kelas", [], fields.kelas.isInvalid],
        ["project", [], fields.project.isInvalid],
        ["nama_proyek", [], fields.nama_proyek.isInvalid],
        ["tema", [], fields.tema.isInvalid],
        ["dimensi", [], fields.dimensi.isInvalid]
    ]);

    // Set invalid fields
    $(function() {
        fproyeklistsrch.setInvalid();
    });

    // Validate form
    fproyeklistsrch.validate = function () {
        if (!this.validateRequired)
            return true; // Ignore validation
        var fobj = this.getForm(),
            $fobj = $(fobj),
            rowIndex = "";
        $fobj.data("rowindex", rowIndex);

        // Validate fields
        if (!this.validateFields(rowIndex))
            return false;

        // Call Form_CustomValidate event
        if (!this.customValidate(fobj)) {
            this.focus();
            return false;
        }
        return true;
    }

    // Form_CustomValidate
    fproyeklistsrch.customValidate = function(fobj) { // DO NOT CHANGE THIS LINE!
        // Your custom validation code here, return false if invalid.
        return true;
    }

    // Use JavaScript validation or not
    fproyeklistsrch.validateRequired = <?= Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

    // Dynamic selection lists
    fproyeklistsrch.lists.kelas = <?= $Page->kelas->toClientList($Page) ?>;

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

    // Init search panel as collapsed
    fproyeklistsrch.initSearchPanel = true;
    loadjs.done("fproyeklistsrch");
});
</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="fproyeklistsrch" id="fproyeklistsrch" class="form-inline ew-form ew-ext-search-form" action="<?= CurrentPageUrl(false) ?>">
<div id="fproyeklistsrch-search-panel" class="<?= $Page->SearchPanelClass ?>">
<input type="hidden" name="cmd" value="search">
<input type="hidden" name="t" value="proyek">
    <div class="ew-extended-search">
<?php
// Render search row
$Page->RowType = ROWTYPE_SEARCH;
$Page->resetAttributes();
$Page->renderRow();
?>
<?php if ($Page->kelas->Visible) { // kelas ?>
    <?php
        $Page->SearchColumnCount++;
        if (($Page->SearchColumnCount - 1) % $Page->SearchFieldsPerRow == 0) {
            $Page->SearchRowCount++;
    ?>
<div id="xsr_<?= $Page->SearchRowCount ?>" class="ew-row d-sm-flex">
    <?php
        }
     ?>
    <div id="xsc_kelas" class="ew-cell form-group">
        <label for="x_kelas" class="ew-search-caption ew-label"><?= $Page->kelas->caption() ?></label>
        <span class="ew-search-operator">
<?= $Language->phrase("LIKE") ?>
<input type="hidden" name="z_kelas" id="z_kelas" value="LIKE">
</span>
        <span id="el_proyek_kelas" class="ew-search-field">
<?php if (!$Security->isAdmin() && $Security->isLoggedIn() && !$Page->userIDAllow($Page->CurrentAction)) { // Non system admin ?>
<span<?= $Page->kelas->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->kelas->getDisplayValue($Page->kelas->EditValue))) ?>"></span>
<input type="hidden" data-table="proyek" data-field="x_kelas" data-hidden="1" name="x_kelas" id="x_kelas" value="<?= HtmlEncode($Page->kelas->AdvancedSearch->SearchValue) ?>">
<?php } else { ?>
    <select
        id="x_kelas"
        name="x_kelas"
        class="form-control ew-select<?= $Page->kelas->isInvalidClass() ?>"
        data-select2-id="proyek_x_kelas"
        data-table="proyek"
        data-field="x_kelas"
        data-value-separator="<?= $Page->kelas->displayValueSeparatorAttribute() ?>"
        <?= $Page->kelas->editAttributes() ?>>
        <?= $Page->kelas->selectOptionListHtml("x_kelas") ?>
    </select>
    <div class="invalid-feedback"><?= $Page->kelas->getErrorMessage(false) ?></div>
<?= $Page->kelas->Lookup->getParamTag($Page, "p_x_kelas") ?>
<script>
loadjs.ready("head", function() {
    var el = document.querySelector("select[data-select2-id='proyek_x_kelas']"),
        options = { name: "x_kelas", selectId: "proyek_x_kelas", language: ew.LANGUAGE_ID, dir: ew.IS_RTL ? "rtl" : "ltr" };
    options.dropdownParent = $(el).closest("#ew-modal-dialog, #ew-add-opt-dialog")[0];
    Object.assign(options, ew.vars.tables.proyek.fields.kelas.selectOptions);
    ew.createSelect(options);
});
</script>
<?php } ?>
</span>
    </div>
    <?php if ($Page->SearchColumnCount % $Page->SearchFieldsPerRow == 0) { ?>
</div>
    <?php } ?>
<?php } ?>
    <?php if ($Page->SearchColumnCount % $Page->SearchFieldsPerRow > 0) { ?>
</div>
    <?php } ?>
<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 } ?> proyek">
<?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="fproyeklist" id="fproyeklist" 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="proyek">
<div id="gmp_proyek" class="<?= ResponsiveTableClass() ?>card-body ew-grid-middle-panel">
<?php if ($Page->TotalRecords > 0 || $Page->isGridEdit()) { ?>
<table id="tbl_proyeklist" 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->project_id->Visible) { // project_id ?>
        <th data-name="project_id" class="<?= $Page->project_id->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_project_id" class="proyek_project_id"><?= $Page->renderSort($Page->project_id) ?></div></th>
<?php } ?>
<?php if ($Page->tahun_pelajaran->Visible) { // tahun_pelajaran ?>
        <th data-name="tahun_pelajaran" class="<?= $Page->tahun_pelajaran->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_tahun_pelajaran" class="proyek_tahun_pelajaran"><?= $Page->renderSort($Page->tahun_pelajaran) ?></div></th>
<?php } ?>
<?php if ($Page->kelas->Visible) { // kelas ?>
        <th data-name="kelas" class="<?= $Page->kelas->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_kelas" class="proyek_kelas"><?= $Page->renderSort($Page->kelas) ?></div></th>
<?php } ?>
<?php if ($Page->project->Visible) { // project ?>
        <th data-name="project" class="<?= $Page->project->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_project" class="proyek_project"><?= $Page->renderSort($Page->project) ?></div></th>
<?php } ?>
<?php if ($Page->nama_proyek->Visible) { // nama_proyek ?>
        <th data-name="nama_proyek" class="<?= $Page->nama_proyek->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_nama_proyek" class="proyek_nama_proyek"><?= $Page->renderSort($Page->nama_proyek) ?></div></th>
<?php } ?>
<?php if ($Page->tema->Visible) { // tema ?>
        <th data-name="tema" class="<?= $Page->tema->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_tema" class="proyek_tema"><?= $Page->renderSort($Page->tema) ?></div></th>
<?php } ?>
<?php if ($Page->dimensi->Visible) { // dimensi ?>
        <th data-name="dimensi" class="<?= $Page->dimensi->headerCellClass() ?>" style="white-space: nowrap;"><div id="elh_proyek_dimensi" class="proyek_dimensi"><?= $Page->renderSort($Page->dimensi) ?></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 . "_proyek", "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->project_id->Visible) { // project_id ?>
        <td data-name="project_id" <?= $Page->project_id->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_project_id">
<span<?= $Page->project_id->viewAttributes() ?>><?php
$project_id=$proyek->project_id->getViewValue();
$tahun_pelajaran=$proyek->tahun_pelajaran->getViewValue();
$project=$proyek->project->getViewValue();
$kelas=$proyek->kelas->getViewValue();
$gdimensi=ExecuteScalar("SELECT dimensi FROM proyek where project_id='$project_id'"); 
$txt=$project_id."|".$tahun_pelajaran."|".$project."|".$gdimensi."|".$kelas;
$cek = ExecuteScalar("SELECT COUNT(*) FROM nilai_p5 WHERE project_id='$project_id'");
if ($cek==0) {
    echo '<a href="act.php?p5='.base64_encode($txt).'" class="btn btn-success btn-sm">Generate Nilai P5</a>';
} else { ?>
   <button class="btn btn-secondary btn-sm" onclick="alert('Data Nilai Sudah Ada')">Generate Berhasil</button>
<?php } ?>
</span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->tahun_pelajaran->Visible) { // tahun_pelajaran ?>
        <td data-name="tahun_pelajaran" <?= $Page->tahun_pelajaran->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_tahun_pelajaran">
<span<?= $Page->tahun_pelajaran->viewAttributes() ?>>
<?= $Page->tahun_pelajaran->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->kelas->Visible) { // kelas ?>
        <td data-name="kelas" <?= $Page->kelas->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_kelas">
<span<?= $Page->kelas->viewAttributes() ?>>
<?= $Page->kelas->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->project->Visible) { // project ?>
        <td data-name="project" <?= $Page->project->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_project">
<span<?= $Page->project->viewAttributes() ?>>
<?= $Page->project->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->nama_proyek->Visible) { // nama_proyek ?>
        <td data-name="nama_proyek" <?= $Page->nama_proyek->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_nama_proyek">
<span<?= $Page->nama_proyek->viewAttributes() ?>>
<?= $Page->nama_proyek->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->tema->Visible) { // tema ?>
        <td data-name="tema" <?= $Page->tema->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_tema">
<span<?= $Page->tema->viewAttributes() ?>>
<?= $Page->tema->getViewValue() ?></span>
</span>
</td>
    <?php } ?>
    <?php if ($Page->dimensi->Visible) { // dimensi ?>
        <td data-name="dimensi" <?= $Page->dimensi->cellAttributes() ?>>
<span id="el<?= $Page->RowCount ?>_proyek_dimensi">
<span<?= $Page->dimensi->viewAttributes() ?>><?php
 $project_id=$proyek->project_id->getViewValue();
 $gdimensi=ExecuteScalar("SELECT dimensi FROM proyek where project_id='$project_id'");
 echo count($dimensi=explode(",",$gdimensi))." Dimensi"; 
?>
</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("proyek");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
<?php } ?>
