<?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
$academic_addopt = new academic_addopt();

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

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

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

// Page Rendering event
$academic_addopt->Page_Render();
?>
<script>
var facademicaddopt, currentPageID;
loadjs.ready("head", function() {

	// Form object
	currentPageID = ew.PAGE_ID = "addopt";
	facademicaddopt = currentForm = new ew.Form("facademicaddopt", "addopt");

	// Validate form
	facademicaddopt.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 ($academic_addopt->Academic->Required) { ?>
				elm = this.getElements("x" + infix + "_Academic");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $academic_addopt->Academic->caption(), $academic_addopt->Academic->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($academic_addopt->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", $academic_addopt->Status->caption(), $academic_addopt->Status->RequiredErrorMessage)) ?>");
			<?php } ?>

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

	// Form_CustomValidate
	facademicaddopt.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
	facademicaddopt.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $academic_addopt->showPageHeader(); ?>
<?php
$academic_addopt->showMessage();
?>
<form name="facademicaddopt" id="facademicaddopt" class="ew-form ew-horizontal" action="<?php echo Config("API_URL") ?>" 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="<?php echo Config("API_ACTION_NAME") ?>" id="<?php echo Config("API_ACTION_NAME") ?>" value="<?php echo Config("API_ADD_ACTION") ?>">
<input type="hidden" name="<?php echo Config("API_OBJECT_NAME") ?>" id="<?php echo Config("API_OBJECT_NAME") ?>" value="<?php echo $academic_addopt->TableVar ?>">
<?php if ($academic_addopt->Academic->Visible) { // Academic ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_Academic"><?php echo $academic_addopt->Academic->caption() ?><?php echo $academic_addopt->Academic->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="academic" data-field="x_Academic" name="x_Academic" id="x_Academic" size="30" maxlength="7" placeholder="<?php echo HtmlEncode($academic_addopt->Academic->getPlaceHolder()) ?>" value="<?php echo $academic_addopt->Academic->EditValue ?>"<?php echo $academic_addopt->Academic->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($academic_addopt->Status->Visible) { // Status ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label"><?php echo $academic_addopt->Status->caption() ?><?php echo $academic_addopt->Status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<div id="tp_x_Status" class="ew-template"><input type="checkbox" class="custom-control-input" data-table="academic" data-field="x_Status" data-value-separator="<?php echo $academic_addopt->Status->displayValueSeparatorAttribute() ?>" name="x_Status[]" id="x_Status[]" value="{value}"<?php echo $academic_addopt->Status->editAttributes() ?>></div>
<div id="dsl_x_Status" data-repeatcolumn="5" class="ew-item-list d-none"><div>
<?php echo $academic_addopt->Status->checkBoxListHtml(FALSE, "x_Status[]") ?>
</div></div>
</div>
	</div>
<?php } ?>
</form>
<?php
$academic_addopt->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
$academic_addopt->terminate();
?>