<?php

namespace PHPMaker2021\rdigital21;

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

    // Add fields
    var currentTable = <?= JsonEncode(GetClientVar("tables", "tahun_pelajaran")) ?>,
        fields = currentTable.fields;
    if (!ew.vars.tables.tahun_pelajaran)
        ew.vars.tables.tahun_pelajaran = currentTable;
    ftahun_pelajaranedit.addFields([
        ["tapel_id", [fields.tapel_id.visible && fields.tapel_id.required ? ew.Validators.required(fields.tapel_id.caption) : null], fields.tapel_id.isInvalid],
        ["tahun_pelajaran", [fields.tahun_pelajaran.visible && fields.tahun_pelajaran.required ? ew.Validators.required(fields.tahun_pelajaran.caption) : null], fields.tahun_pelajaran.isInvalid],
        ["kode_tapel", [fields.kode_tapel.visible && fields.kode_tapel.required ? ew.Validators.required(fields.kode_tapel.caption) : null], fields.kode_tapel.isInvalid],
        ["semester", [fields.semester.visible && fields.semester.required ? ew.Validators.required(fields.semester.caption) : null], fields.semester.isInvalid],
        ["status", [fields.status.visible && fields.status.required ? ew.Validators.required(fields.status.caption) : null], fields.status.isInvalid],
        ["tanggal_identitas", [fields.tanggal_identitas.visible && fields.tanggal_identitas.required ? ew.Validators.required(fields.tanggal_identitas.caption) : null], fields.tanggal_identitas.isInvalid],
        ["tanggal_rapor", [fields.tanggal_rapor.visible && fields.tanggal_rapor.required ? ew.Validators.required(fields.tanggal_rapor.caption) : null], fields.tanggal_rapor.isInvalid]
    ]);

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

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

    // Dynamic selection lists
    ftahun_pelajaranedit.lists.semester = <?= $Page->semester->toClientList($Page) ?>;
    ftahun_pelajaranedit.lists.status = <?= $Page->status->toClientList($Page) ?>;
    loadjs.done("ftahun_pelajaranedit");
});
</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="ftahun_pelajaranedit" id="ftahun_pelajaranedit" 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="tahun_pelajaran">
<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->tapel_id->Visible) { // tapel_id ?>
    <div id="r_tapel_id" class="form-group row">
        <label id="elh_tahun_pelajaran_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_tahun_pelajaran_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="tahun_pelajaran" 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 } ?>
<?php if ($Page->tahun_pelajaran->Visible) { // tahun_pelajaran ?>
    <div id="r_tahun_pelajaran" class="form-group row">
        <label id="elh_tahun_pelajaran_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_tahun_pelajaran_tahun_pelajaran">
<input type="<?= $Page->tahun_pelajaran->getInputTextType() ?>" data-table="tahun_pelajaran" data-field="x_tahun_pelajaran" name="x_tahun_pelajaran" id="x_tahun_pelajaran" size="30" maxlength="255" value="<?= $Page->tahun_pelajaran->EditValue ?>"<?= $Page->tahun_pelajaran->editAttributes() ?> aria-describedby="x_tahun_pelajaran_help">
<?= $Page->tahun_pelajaran->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->tahun_pelajaran->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->kode_tapel->Visible) { // kode_tapel ?>
    <div id="r_kode_tapel" class="form-group row">
        <label id="elh_tahun_pelajaran_kode_tapel" for="x_kode_tapel" class="<?= $Page->LeftColumnClass ?>"><?= $Page->kode_tapel->caption() ?><?= $Page->kode_tapel->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->kode_tapel->cellAttributes() ?>>
<span id="el_tahun_pelajaran_kode_tapel">
<input type="<?= $Page->kode_tapel->getInputTextType() ?>" data-table="tahun_pelajaran" data-field="x_kode_tapel" name="x_kode_tapel" id="x_kode_tapel" size="30" maxlength="255" value="<?= $Page->kode_tapel->EditValue ?>"<?= $Page->kode_tapel->editAttributes() ?> aria-describedby="x_kode_tapel_help">
<?= $Page->kode_tapel->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->kode_tapel->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->semester->Visible) { // semester ?>
    <div id="r_semester" class="form-group row">
        <label id="elh_tahun_pelajaran_semester" class="<?= $Page->LeftColumnClass ?>"><?= $Page->semester->caption() ?><?= $Page->semester->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->semester->cellAttributes() ?>>
<span id="el_tahun_pelajaran_semester">
<template id="tp_x_semester">
    <div class="custom-control custom-radio">
        <input type="radio" class="custom-control-input" data-table="tahun_pelajaran" data-field="x_semester" name="x_semester" id="x_semester"<?= $Page->semester->editAttributes() ?>>
        <label class="custom-control-label"></label>
    </div>
</template>
<div id="dsl_x_semester" class="ew-item-list"></div>
<input type="hidden"
    is="selection-list"
    id="x_semester"
    name="x_semester"
    value="<?= HtmlEncode($Page->semester->CurrentValue) ?>"
    data-type="select-one"
    data-template="tp_x_semester"
    data-target="dsl_x_semester"
    data-repeatcolumn="5"
    class="form-control<?= $Page->semester->isInvalidClass() ?>"
    data-table="tahun_pelajaran"
    data-field="x_semester"
    data-value-separator="<?= $Page->semester->displayValueSeparatorAttribute() ?>"
    <?= $Page->semester->editAttributes() ?>>
<?= $Page->semester->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->semester->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->status->Visible) { // status ?>
    <div id="r_status" class="form-group row">
        <label id="elh_tahun_pelajaran_status" class="<?= $Page->LeftColumnClass ?>"><?= $Page->status->caption() ?><?= $Page->status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->status->cellAttributes() ?>>
<span id="el_tahun_pelajaran_status">
<template id="tp_x_status">
    <div class="custom-control custom-radio">
        <input type="radio" class="custom-control-input" data-table="tahun_pelajaran" data-field="x_status" name="x_status" id="x_status"<?= $Page->status->editAttributes() ?>>
        <label class="custom-control-label"></label>
    </div>
</template>
<div id="dsl_x_status" class="ew-item-list"></div>
<input type="hidden"
    is="selection-list"
    id="x_status"
    name="x_status"
    value="<?= HtmlEncode($Page->status->CurrentValue) ?>"
    data-type="select-one"
    data-template="tp_x_status"
    data-target="dsl_x_status"
    data-repeatcolumn="5"
    class="form-control<?= $Page->status->isInvalidClass() ?>"
    data-table="tahun_pelajaran"
    data-field="x_status"
    data-value-separator="<?= $Page->status->displayValueSeparatorAttribute() ?>"
    <?= $Page->status->editAttributes() ?>>
<?= $Page->status->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->status->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->tanggal_identitas->Visible) { // tanggal_identitas ?>
    <div id="r_tanggal_identitas" class="form-group row">
        <label id="elh_tahun_pelajaran_tanggal_identitas" for="x_tanggal_identitas" class="<?= $Page->LeftColumnClass ?>"><?= $Page->tanggal_identitas->caption() ?><?= $Page->tanggal_identitas->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->tanggal_identitas->cellAttributes() ?>>
<span id="el_tahun_pelajaran_tanggal_identitas">
<input type="<?= $Page->tanggal_identitas->getInputTextType() ?>" data-table="tahun_pelajaran" data-field="x_tanggal_identitas" name="x_tanggal_identitas" id="x_tanggal_identitas" size="30" maxlength="255" value="<?= $Page->tanggal_identitas->EditValue ?>"<?= $Page->tanggal_identitas->editAttributes() ?> aria-describedby="x_tanggal_identitas_help">
<?= $Page->tanggal_identitas->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->tanggal_identitas->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->tanggal_rapor->Visible) { // tanggal_rapor ?>
    <div id="r_tanggal_rapor" class="form-group row">
        <label id="elh_tahun_pelajaran_tanggal_rapor" for="x_tanggal_rapor" class="<?= $Page->LeftColumnClass ?>"><?= $Page->tanggal_rapor->caption() ?><?= $Page->tanggal_rapor->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->tanggal_rapor->cellAttributes() ?>>
<span id="el_tahun_pelajaran_tanggal_rapor">
<input type="<?= $Page->tanggal_rapor->getInputTextType() ?>" data-table="tahun_pelajaran" data-field="x_tanggal_rapor" name="x_tanggal_rapor" id="x_tanggal_rapor" size="30" maxlength="255" value="<?= $Page->tanggal_rapor->EditValue ?>"<?= $Page->tanggal_rapor->editAttributes() ?> aria-describedby="x_tanggal_rapor_help">
<?= $Page->tanggal_rapor->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->tanggal_rapor->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("tahun_pelajaran");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
