<?php

namespace PHPMaker2021\rkm21;

// Page object
$NilaiP5Edit = &$Page;
?>
<script>
var currentForm, currentPageID;
var fnilai_p5edit;
loadjs.ready("head", function () {
    var $ = jQuery;
    // Form object
    currentPageID = ew.PAGE_ID = "edit";
    fnilai_p5edit = currentForm = new ew.Form("fnilai_p5edit", "edit");

    // Add fields
    var currentTable = <?= JsonEncode(GetClientVar("tables", "nilai_p5")) ?>,
        fields = currentTable.fields;
    if (!ew.vars.tables.nilai_p5)
        ew.vars.tables.nilai_p5 = currentTable;
    fnilai_p5edit.addFields([
        ["nilai_p5", [fields.nilai_p5.visible && fields.nilai_p5.required ? ew.Validators.required(fields.nilai_p5.caption) : null], fields.nilai_p5.isInvalid],
        ["project_id", [fields.project_id.visible && fields.project_id.required ? ew.Validators.required(fields.project_id.caption) : null], fields.project_id.isInvalid],
        ["kelas", [fields.kelas.visible && fields.kelas.required ? ew.Validators.required(fields.kelas.caption) : null], fields.kelas.isInvalid],
        ["nis", [fields.nis.visible && fields.nis.required ? ew.Validators.required(fields.nis.caption) : null], fields.nis.isInvalid],
        ["proyek", [fields.proyek.visible && fields.proyek.required ? ew.Validators.required(fields.proyek.caption) : null], fields.proyek.isInvalid],
        ["dimensi", [fields.dimensi.visible && fields.dimensi.required ? ew.Validators.required(fields.dimensi.caption) : null], fields.dimensi.isInvalid],
        ["sub_elemen", [fields.sub_elemen.visible && fields.sub_elemen.required ? ew.Validators.required(fields.sub_elemen.caption) : null], fields.sub_elemen.isInvalid],
        ["nilai", [fields.nilai.visible && fields.nilai.required ? ew.Validators.required(fields.nilai.caption) : null], fields.nilai.isInvalid],
        ["tapel_id", [fields.tapel_id.visible && fields.tapel_id.required ? ew.Validators.required(fields.tapel_id.caption) : null], fields.tapel_id.isInvalid]
    ]);

    // Set invalid fields
    $(function() {
        var f = fnilai_p5edit,
            fobj = f.getForm(),
            $fobj = $(fobj),
            $k = $fobj.find("#" + f.formKeyCountName), // Get key_count
            rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1,
            startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
        for (var i = startcnt; i <= rowcnt; i++) {
            var rowIndex = ($k[0]) ? String(i) : "";
            f.setInvalid(rowIndex);
        }
    });

    // Validate form
    fnilai_p5edit.validate = function () {
        if (!this.validateRequired)
            return true; // Ignore validation
        var fobj = this.getForm(),
            $fobj = $(fobj);
        if ($fobj.find("#confirm").val() == "confirm")
            return true;
        var addcnt = 0,
            $k = $fobj.find("#" + this.formKeyCountName), // Get key_count
            rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1,
            startcnt = (rowcnt == 0) ? 0 : 1, // Check rowcnt == 0 => Inline-Add
            gridinsert = ["insert", "gridinsert"].includes($fobj.find("#action").val()) && $k[0];
        for (var i = startcnt; i <= rowcnt; i++) {
            var rowIndex = ($k[0]) ? String(i) : "";
            $fobj.data("rowindex", rowIndex);

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

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

        // Process detail forms
        var dfs = $fobj.find("input[name='detailpage']").get();
        for (var i = 0; i < dfs.length; i++) {
            var df = dfs[i],
                val = df.value,
                frm = ew.forms.get(val);
            if (val && frm && !frm.validate())
                return false;
        }
        return true;
    }

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

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

    // Dynamic selection lists
    fnilai_p5edit.lists.nilai = <?= $Page->nilai->toClientList($Page) ?>;
    loadjs.done("fnilai_p5edit");
});
</script>
<script>
loadjs.ready("head", function () {
    // Write your table-specific client script here, no need to add script tags.
});
</script>
<?php $Page->showPageHeader(); ?>
<?php
$Page->showMessage();
?>
<form name="fnilai_p5edit" id="fnilai_p5edit" class="<?= $Page->FormClassName ?>" 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="nilai_p5">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?= (int)$Page->IsModal ?>">
<input type="hidden" name="<?= $Page->OldKeyName ?>" value="<?= $Page->OldKey ?>">
<?php if ($Page->getCurrentMasterTable() == "penilaian_p5") { ?>
<input type="hidden" name="<?= Config("TABLE_SHOW_MASTER") ?>" value="penilaian_p5">
<input type="hidden" name="fk_nis" value="<?= HtmlEncode($Page->nis->getSessionValue()) ?>">
<?php } ?>
<div class="ew-edit-div"><!-- page* -->
<?php if ($Page->nilai_p5->Visible) { // nilai_p5 ?>
    <div id="r_nilai_p5" class="form-group row">
        <label id="elh_nilai_p5_nilai_p5" class="<?= $Page->LeftColumnClass ?>"><?= $Page->nilai_p5->caption() ?><?= $Page->nilai_p5->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->nilai_p5->cellAttributes() ?>>
<span id="el_nilai_p5_nilai_p5">
<span<?= $Page->nilai_p5->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->nilai_p5->getDisplayValue($Page->nilai_p5->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_nilai_p5" data-hidden="1" name="x_nilai_p5" id="x_nilai_p5" value="<?= HtmlEncode($Page->nilai_p5->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->project_id->Visible) { // project_id ?>
    <div id="r_project_id" class="form-group row">
        <label id="elh_nilai_p5_project_id" for="x_project_id" class="<?= $Page->LeftColumnClass ?>"><?= $Page->project_id->caption() ?><?= $Page->project_id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->project_id->cellAttributes() ?>>
<span id="el_nilai_p5_project_id">
<span<?= $Page->project_id->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->project_id->getDisplayValue($Page->project_id->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_project_id" data-hidden="1" name="x_project_id" id="x_project_id" value="<?= HtmlEncode($Page->project_id->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->kelas->Visible) { // kelas ?>
    <div id="r_kelas" class="form-group row">
        <label id="elh_nilai_p5_kelas" for="x_kelas" class="<?= $Page->LeftColumnClass ?>"><?= $Page->kelas->caption() ?><?= $Page->kelas->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->kelas->cellAttributes() ?>>
<span id="el_nilai_p5_kelas">
<span<?= $Page->kelas->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->kelas->getDisplayValue($Page->kelas->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_kelas" data-hidden="1" name="x_kelas" id="x_kelas" value="<?= HtmlEncode($Page->kelas->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->nis->Visible) { // nis ?>
    <div id="r_nis" class="form-group row">
        <label id="elh_nilai_p5_nis" class="<?= $Page->LeftColumnClass ?>"><?= $Page->nis->caption() ?><?= $Page->nis->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->nis->cellAttributes() ?>>
<span id="el_nilai_p5_nis">
<span<?= $Page->nis->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->nis->getDisplayValue($Page->nis->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_nis" data-hidden="1" name="x_nis" id="x_nis" value="<?= HtmlEncode($Page->nis->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->proyek->Visible) { // proyek ?>
    <div id="r_proyek" class="form-group row">
        <label id="elh_nilai_p5_proyek" for="x_proyek" class="<?= $Page->LeftColumnClass ?>"><?= $Page->proyek->caption() ?><?= $Page->proyek->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->proyek->cellAttributes() ?>>
<span id="el_nilai_p5_proyek">
<span<?= $Page->proyek->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->proyek->getDisplayValue($Page->proyek->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_proyek" data-hidden="1" name="x_proyek" id="x_proyek" value="<?= HtmlEncode($Page->proyek->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->dimensi->Visible) { // dimensi ?>
    <div id="r_dimensi" class="form-group row">
        <label id="elh_nilai_p5_dimensi" for="x_dimensi" class="<?= $Page->LeftColumnClass ?>"><?= $Page->dimensi->caption() ?><?= $Page->dimensi->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->dimensi->cellAttributes() ?>>
<span id="el_nilai_p5_dimensi">
<span<?= $Page->dimensi->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->dimensi->getDisplayValue($Page->dimensi->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_dimensi" data-hidden="1" name="x_dimensi" id="x_dimensi" value="<?= HtmlEncode($Page->dimensi->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->sub_elemen->Visible) { // sub_elemen ?>
    <div id="r_sub_elemen" class="form-group row">
        <label id="elh_nilai_p5_sub_elemen" for="x_sub_elemen" class="<?= $Page->LeftColumnClass ?>"><?= $Page->sub_elemen->caption() ?><?= $Page->sub_elemen->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->sub_elemen->cellAttributes() ?>>
<span id="el_nilai_p5_sub_elemen">
<span<?= $Page->sub_elemen->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->sub_elemen->getDisplayValue($Page->sub_elemen->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_sub_elemen" data-hidden="1" name="x_sub_elemen" id="x_sub_elemen" value="<?= HtmlEncode($Page->sub_elemen->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->nilai->Visible) { // nilai ?>
    <div id="r_nilai" class="form-group row">
        <label id="elh_nilai_p5_nilai" class="<?= $Page->LeftColumnClass ?>"><?= $Page->nilai->caption() ?><?= $Page->nilai->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->nilai->cellAttributes() ?>>
<span id="el_nilai_p5_nilai">
<template id="tp_x_nilai">
    <div class="custom-control custom-radio">
        <input type="radio" class="custom-control-input" data-table="nilai_p5" data-field="x_nilai" name="x_nilai" id="x_nilai"<?= $Page->nilai->editAttributes() ?>>
        <label class="custom-control-label"></label>
    </div>
</template>
<div id="dsl_x_nilai" class="ew-item-list"></div>
<input type="hidden"
    is="selection-list"
    id="x_nilai"
    name="x_nilai"
    value="<?= HtmlEncode($Page->nilai->CurrentValue) ?>"
    data-type="select-one"
    data-template="tp_x_nilai"
    data-target="dsl_x_nilai"
    data-repeatcolumn="5"
    class="form-control<?= $Page->nilai->isInvalidClass() ?>"
    data-table="nilai_p5"
    data-field="x_nilai"
    data-value-separator="<?= $Page->nilai->displayValueSeparatorAttribute() ?>"
    <?= $Page->nilai->editAttributes() ?>>
<?= $Page->nilai->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->nilai->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->tapel_id->Visible) { // tapel_id ?>
    <div id="r_tapel_id" class="form-group row">
        <label id="elh_nilai_p5_tapel_id" for="x_tapel_id" class="<?= $Page->LeftColumnClass ?>"><?= $Page->tapel_id->caption() ?><?= $Page->tapel_id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->tapel_id->cellAttributes() ?>>
<span id="el_nilai_p5_tapel_id">
<span<?= $Page->tapel_id->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->tapel_id->getDisplayValue($Page->tapel_id->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="nilai_p5" data-field="x_tapel_id" data-hidden="1" name="x_tapel_id" id="x_tapel_id" value="<?= HtmlEncode($Page->tapel_id->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$Page->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
    <div class="<?= $Page->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit"><?= $Language->phrase("SaveBtn") ?></button>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" data-href="<?= HtmlEncode(GetUrl($Page->getReturnUrl())) ?>"><?= $Language->phrase("CancelBtn") ?></button>
    </div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$Page->showPageFooter();
echo GetDebugMessage();
?>
<script>
// Field event handlers
loadjs.ready("head", function() {
    ew.addEventHandlers("nilai_p5");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
