<?php

namespace PHPMaker2021\rdigital21;

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

    // Add fields
    var currentTable = <?= JsonEncode(GetClientVar("tables", "kktp_sumatif")) ?>,
        fields = currentTable.fields;
    if (!ew.vars.tables.kktp_sumatif)
        ew.vars.tables.kktp_sumatif = currentTable;
    fkktp_sumatifedit.addFields([
        ["desk_id", [fields.desk_id.visible && fields.desk_id.required ? ew.Validators.required(fields.desk_id.caption) : null], fields.desk_id.isInvalid],
        ["tahun_pelajaran", [fields.tahun_pelajaran.visible && fields.tahun_pelajaran.required ? ew.Validators.required(fields.tahun_pelajaran.caption) : null], fields.tahun_pelajaran.isInvalid],
        ["abjad", [fields.abjad.visible && fields.abjad.required ? ew.Validators.required(fields.abjad.caption) : null], fields.abjad.isInvalid],
        ["min", [fields.min.visible && fields.min.required ? ew.Validators.required(fields.min.caption) : null], fields.min.isInvalid],
        ["max", [fields.max.visible && fields.max.required ? ew.Validators.required(fields.max.caption) : null], fields.max.isInvalid],
        ["ket", [fields.ket.visible && fields.ket.required ? ew.Validators.required(fields.ket.caption) : null], fields.ket.isInvalid]
    ]);

    // Set invalid fields
    $(function() {
        var f = fkktp_sumatifedit,
            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
    fkktp_sumatifedit.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
    fkktp_sumatifedit.customValidate = function(fobj) { // DO NOT CHANGE THIS LINE!
        // Your custom validation code here, return false if invalid.
        return true;
    }

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

    // Dynamic selection lists
    loadjs.done("fkktp_sumatifedit");
});
</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="fkktp_sumatifedit" id="fkktp_sumatifedit" 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="kktp_sumatif">
<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 ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($Page->desk_id->Visible) { // desk_id ?>
    <div id="r_desk_id" class="form-group row">
        <label id="elh_kktp_sumatif_desk_id" class="<?= $Page->LeftColumnClass ?>"><?= $Page->desk_id->caption() ?><?= $Page->desk_id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->desk_id->cellAttributes() ?>>
<span id="el_kktp_sumatif_desk_id">
<span<?= $Page->desk_id->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->desk_id->getDisplayValue($Page->desk_id->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="kktp_sumatif" data-field="x_desk_id" data-hidden="1" name="x_desk_id" id="x_desk_id" value="<?= HtmlEncode($Page->desk_id->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->tahun_pelajaran->Visible) { // tahun_pelajaran ?>
    <div id="r_tahun_pelajaran" class="form-group row">
        <label id="elh_kktp_sumatif_tahun_pelajaran" for="x_tahun_pelajaran" class="<?= $Page->LeftColumnClass ?>"><?= $Page->tahun_pelajaran->caption() ?><?= $Page->tahun_pelajaran->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->tahun_pelajaran->cellAttributes() ?>>
<span id="el_kktp_sumatif_tahun_pelajaran">
<span<?= $Page->tahun_pelajaran->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->tahun_pelajaran->getDisplayValue($Page->tahun_pelajaran->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="kktp_sumatif" data-field="x_tahun_pelajaran" data-hidden="1" name="x_tahun_pelajaran" id="x_tahun_pelajaran" value="<?= HtmlEncode($Page->tahun_pelajaran->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->abjad->Visible) { // abjad ?>
    <div id="r_abjad" class="form-group row">
        <label id="elh_kktp_sumatif_abjad" for="x_abjad" class="<?= $Page->LeftColumnClass ?>"><?= $Page->abjad->caption() ?><?= $Page->abjad->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->abjad->cellAttributes() ?>>
<span id="el_kktp_sumatif_abjad">
<span<?= $Page->abjad->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?= HtmlEncode(RemoveHtml($Page->abjad->getDisplayValue($Page->abjad->EditValue))) ?>"></span>
</span>
<input type="hidden" data-table="kktp_sumatif" data-field="x_abjad" data-hidden="1" name="x_abjad" id="x_abjad" value="<?= HtmlEncode($Page->abjad->CurrentValue) ?>">
</div></div>
    </div>
<?php } ?>
<?php if ($Page->min->Visible) { // min ?>
    <div id="r_min" class="form-group row">
        <label id="elh_kktp_sumatif_min" for="x_min" class="<?= $Page->LeftColumnClass ?>"><?= $Page->min->caption() ?><?= $Page->min->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->min->cellAttributes() ?>>
<span id="el_kktp_sumatif_min">
<input type="<?= $Page->min->getInputTextType() ?>" data-table="kktp_sumatif" data-field="x_min" name="x_min" id="x_min" value="<?= $Page->min->EditValue ?>"<?= $Page->min->editAttributes() ?> aria-describedby="x_min_help">
<?= $Page->min->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->min->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->max->Visible) { // max ?>
    <div id="r_max" class="form-group row">
        <label id="elh_kktp_sumatif_max" for="x_max" class="<?= $Page->LeftColumnClass ?>"><?= $Page->max->caption() ?><?= $Page->max->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->max->cellAttributes() ?>>
<span id="el_kktp_sumatif_max">
<input type="<?= $Page->max->getInputTextType() ?>" data-table="kktp_sumatif" data-field="x_max" name="x_max" id="x_max" value="<?= $Page->max->EditValue ?>"<?= $Page->max->editAttributes() ?> aria-describedby="x_max_help">
<?= $Page->max->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->max->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->ket->Visible) { // ket ?>
    <div id="r_ket" class="form-group row">
        <label id="elh_kktp_sumatif_ket" for="x_ket" class="<?= $Page->LeftColumnClass ?>"><?= $Page->ket->caption() ?><?= $Page->ket->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->ket->cellAttributes() ?>>
<span id="el_kktp_sumatif_ket">
<textarea data-table="kktp_sumatif" data-field="x_ket" name="x_ket" id="x_ket" cols="35" rows="4"<?= $Page->ket->editAttributes() ?> aria-describedby="x_ket_help"><?= $Page->ket->EditValue ?></textarea>
<?= $Page->ket->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->ket->getErrorMessage() ?></div>
</span>
</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("kktp_sumatif");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
