<?php
namespace PHPMaker2020\hostelmgr20;

// Session
if (session_status() !== PHP_SESSION_ACTIVE)
	session_start(); // Init session data

// Output buffering
ob_start();

// Autoload
include_once "autoload.php";
?>
<?php

// Write header
WriteHeader(FALSE);

// Create page object
$indiscipline_edit = new indiscipline_edit();

// Run the page
$indiscipline_edit->run();

// Setup login status
SetupLoginStatus();
SetClientVar("login", LoginStatus());

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$indiscipline_edit->Page_Render();
?>
<?php include_once "header.php"; ?>
<script>
var findisciplineedit, currentPageID;
loadjs.ready("head", function() {

	// Form object
	currentPageID = ew.PAGE_ID = "edit";
	findisciplineedit = currentForm = new ew.Form("findisciplineedit", "edit");

	// Validate form
	findisciplineedit.validate = function() {
		if (!this.validateRequired)
			return true; // Ignore validation
		var $ = jQuery, fobj = this.getForm(), $fobj = $(fobj);
		if ($fobj.find("#confirm").val() == "F")
			return true;
		var elm, felm, uelm, addcnt = 0;
		var $k = $fobj.find("#" + this.formKeyCountName); // Get key_count
		var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
		var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
		var gridinsert = ["insert", "gridinsert"].includes($fobj.find("#action").val()) && $k[0];
		for (var i = startcnt; i <= rowcnt; i++) {
			var infix = ($k[0]) ? String(i) : "";
			$fobj.data("rowindex", infix);
			<?php if ($indiscipline_edit->id->Required) { ?>
				elm = this.getElements("x" + infix + "_id");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $indiscipline_edit->id->caption(), $indiscipline_edit->id->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($indiscipline_edit->Indiscipline_activity->Required) { ?>
				elm = this.getElements("x" + infix + "_Indiscipline_activity");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $indiscipline_edit->Indiscipline_activity->caption(), $indiscipline_edit->Indiscipline_activity->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($indiscipline_edit->Status->Required) { ?>
				elm = this.getElements("x" + infix + "_Status");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $indiscipline_edit->Status->caption(), $indiscipline_edit->Status->RequiredErrorMessage)) ?>");
			<?php } ?>

				// Call Form_CustomValidate event
				if (!this.Form_CustomValidate(fobj))
					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;
			if (val && ew.forms[val])
				if (!ew.forms[val].validate())
					return false;
		}
		return true;
	}

	// Form_CustomValidate
	findisciplineedit.Form_CustomValidate = function(fobj) { // DO NOT CHANGE THIS LINE!

		// Your custom validation code here, return false if invalid.
		return true;
	}

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

	// Dynamic selection lists
	findisciplineedit.lists["x_Status"] = <?php echo $indiscipline_edit->Status->Lookup->toClientList($indiscipline_edit) ?>;
	findisciplineedit.lists["x_Status"].options = <?php echo JsonEncode($indiscipline_edit->Status->options(FALSE, TRUE)) ?>;
	loadjs.done("findisciplineedit");
});
</script>
<script>
loadjs.ready("head", function() {

	// Client script
	// Write your client script here, no need to add script tags.

});
</script>
<?php $indiscipline_edit->showPageHeader(); ?>
<?php
$indiscipline_edit->showMessage();
?>
<form name="findisciplineedit" id="findisciplineedit" class="<?php echo $indiscipline_edit->FormClassName ?>" action="<?php echo CurrentPageName() ?>" method="post">
<?php if ($Page->CheckToken) { ?>
<input type="hidden" name="<?php echo Config("TOKEN_NAME") ?>" value="<?php echo $Page->Token ?>">
<?php } ?>
<input type="hidden" name="t" value="indiscipline">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$indiscipline_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($indiscipline_edit->id->Visible) { // id ?>
	<div id="r_id" class="form-group row">
		<label id="elh_indiscipline_id" class="<?php echo $indiscipline_edit->LeftColumnClass ?>"><?php echo $indiscipline_edit->id->caption() ?><?php echo $indiscipline_edit->id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $indiscipline_edit->RightColumnClass ?>"><div <?php echo $indiscipline_edit->id->cellAttributes() ?>>
<span id="el_indiscipline_id">
<span<?php echo $indiscipline_edit->id->viewAttributes() ?>><input type="text" readonly class="form-control-plaintext" value="<?php echo HtmlEncode(RemoveHtml($indiscipline_edit->id->EditValue)) ?>"></span>
</span>
<input type="hidden" data-table="indiscipline" data-field="x_id" name="x_id" id="x_id" value="<?php echo HtmlEncode($indiscipline_edit->id->CurrentValue) ?>">
<?php echo $indiscipline_edit->id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($indiscipline_edit->Indiscipline_activity->Visible) { // Indiscipline_activity ?>
	<div id="r_Indiscipline_activity" class="form-group row">
		<label id="elh_indiscipline_Indiscipline_activity" for="x_Indiscipline_activity" class="<?php echo $indiscipline_edit->LeftColumnClass ?>"><?php echo $indiscipline_edit->Indiscipline_activity->caption() ?><?php echo $indiscipline_edit->Indiscipline_activity->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $indiscipline_edit->RightColumnClass ?>"><div <?php echo $indiscipline_edit->Indiscipline_activity->cellAttributes() ?>>
<span id="el_indiscipline_Indiscipline_activity">
<input type="text" data-table="indiscipline" data-field="x_Indiscipline_activity" name="x_Indiscipline_activity" id="x_Indiscipline_activity" size="30" maxlength="55" placeholder="<?php echo HtmlEncode($indiscipline_edit->Indiscipline_activity->getPlaceHolder()) ?>" value="<?php echo $indiscipline_edit->Indiscipline_activity->EditValue ?>"<?php echo $indiscipline_edit->Indiscipline_activity->editAttributes() ?>>
</span>
<?php echo $indiscipline_edit->Indiscipline_activity->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($indiscipline_edit->Status->Visible) { // Status ?>
	<div id="r_Status" class="form-group row">
		<label id="elh_indiscipline_Status" class="<?php echo $indiscipline_edit->LeftColumnClass ?>"><?php echo $indiscipline_edit->Status->caption() ?><?php echo $indiscipline_edit->Status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $indiscipline_edit->RightColumnClass ?>"><div <?php echo $indiscipline_edit->Status->cellAttributes() ?>>
<span id="el_indiscipline_Status">
<div id="tp_x_Status" class="ew-template"><input type="radio" class="custom-control-input" data-table="indiscipline" data-field="x_Status" data-value-separator="<?php echo $indiscipline_edit->Status->displayValueSeparatorAttribute() ?>" name="x_Status" id="x_Status" value="{value}"<?php echo $indiscipline_edit->Status->editAttributes() ?>></div>
<div id="dsl_x_Status" data-repeatcolumn="5" class="ew-item-list d-none"><div>
<?php echo $indiscipline_edit->Status->radioButtonListHtml(FALSE, "x_Status") ?>
</div></div>
</span>
<?php echo $indiscipline_edit->Status->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php
	if (in_array("activity", explode(",", $indiscipline->getCurrentDetailTable())) && $activity->DetailEdit) {
?>
<?php if ($indiscipline->getCurrentDetailTable() != "") { ?>
<h4 class="ew-detail-caption"><?php echo $Language->tablePhrase("activity", "TblCaption") ?></h4>
<?php } ?>
<?php include_once "activitygrid.php" ?>
<?php } ?>
<?php if (!$indiscipline_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $indiscipline_edit->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit"><?php echo $Language->phrase("SaveBtn") ?></button>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" data-href="<?php echo $indiscipline_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$indiscipline_edit->showPageFooter();
if (Config("DEBUG"))
	echo GetDebugMessage();
?>
<script>
loadjs.ready("load", function() {

	// Startup script
	// Write your table-specific startup script here
	// console.log("page loaded");

});
</script>
<?php include_once "footer.php"; ?>
<?php
$indiscipline_edit->terminate();
?>