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

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

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

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

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

	// Form object
	currentPageID = ew.PAGE_ID = "add";
	fabscountadd = currentForm = new ew.Form("fabscountadd", "add");

	// Validate form
	fabscountadd.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 ($abscount_add->Date->Required) { ?>
				elm = this.getElements("x" + infix + "_Date");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->Date->caption(), $abscount_add->Date->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Date");
				if (elm && !ew.checkDateDef(elm.value))
					return this.onError(elm, "<?php echo JsEncode($abscount_add->Date->errorMessage()) ?>");
			<?php if ($abscount_add->Hostel->Required) { ?>
				elm = this.getElements("x" + infix + "_Hostel");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->Hostel->caption(), $abscount_add->Hostel->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($abscount_add->Floor->Required) { ?>
				elm = this.getElements("x" + infix + "_Floor");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->Floor->caption(), $abscount_add->Floor->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($abscount_add->_RS->Required) { ?>
				elm = this.getElements("x" + infix + "__RS");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->_RS->caption(), $abscount_add->_RS->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($abscount_add->Absent->Required) { ?>
				elm = this.getElements("x" + infix + "_Absent");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->Absent->caption(), $abscount_add->Absent->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Absent");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($abscount_add->Absent->errorMessage()) ?>");
			<?php if ($abscount_add->Postedby->Required) { ?>
				elm = this.getElements("x" + infix + "_Postedby");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->Postedby->caption(), $abscount_add->Postedby->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($abscount_add->Updated_Date->Required) { ?>
				elm = this.getElements("x" + infix + "_Updated_Date");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $abscount_add->Updated_Date->caption(), $abscount_add->Updated_Date->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
	fabscountadd.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
	fabscountadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

	// Dynamic selection lists
	fabscountadd.lists["x_Hostel"] = <?php echo $abscount_add->Hostel->Lookup->toClientList($abscount_add) ?>;
	fabscountadd.lists["x_Hostel"].options = <?php echo JsonEncode($abscount_add->Hostel->lookupOptions()) ?>;
	fabscountadd.lists["x_Floor"] = <?php echo $abscount_add->Floor->Lookup->toClientList($abscount_add) ?>;
	fabscountadd.lists["x_Floor"].options = <?php echo JsonEncode($abscount_add->Floor->lookupOptions()) ?>;
	fabscountadd.lists["x__RS"] = <?php echo $abscount_add->_RS->Lookup->toClientList($abscount_add) ?>;
	fabscountadd.lists["x__RS"].options = <?php echo JsonEncode($abscount_add->_RS->lookupOptions()) ?>;
	loadjs.done("fabscountadd");
});
</script>
<script>
loadjs.ready("head", function() {

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

});
</script>
<?php $abscount_add->showPageHeader(); ?>
<?php
$abscount_add->showMessage();
?>
<form name="fabscountadd" id="fabscountadd" class="<?php echo $abscount_add->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="abscount">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$abscount_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($abscount_add->Date->Visible) { // Date ?>
	<div id="r_Date" class="form-group row">
		<label id="elh_abscount_Date" for="x_Date" class="<?php echo $abscount_add->LeftColumnClass ?>"><?php echo $abscount_add->Date->caption() ?><?php echo $abscount_add->Date->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $abscount_add->RightColumnClass ?>"><div <?php echo $abscount_add->Date->cellAttributes() ?>>
<span id="el_abscount_Date">
<input type="text" data-table="abscount" data-field="x_Date" name="x_Date" id="x_Date" placeholder="<?php echo HtmlEncode($abscount_add->Date->getPlaceHolder()) ?>" value="<?php echo $abscount_add->Date->EditValue ?>"<?php echo $abscount_add->Date->editAttributes() ?>>
<?php if (!$abscount_add->Date->ReadOnly && !$abscount_add->Date->Disabled && !isset($abscount_add->Date->EditAttrs["readonly"]) && !isset($abscount_add->Date->EditAttrs["disabled"])) { ?>
<script>
loadjs.ready(["fabscountadd", "datetimepicker"], function() {
	ew.createDateTimePicker("fabscountadd", "x_Date", {"ignoreReadonly":true,"useCurrent":false,"format":0});
});
</script>
<?php } ?>
</span>
<?php echo $abscount_add->Date->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($abscount_add->Hostel->Visible) { // Hostel ?>
	<div id="r_Hostel" class="form-group row">
		<label id="elh_abscount_Hostel" for="x_Hostel" class="<?php echo $abscount_add->LeftColumnClass ?>"><?php echo $abscount_add->Hostel->caption() ?><?php echo $abscount_add->Hostel->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $abscount_add->RightColumnClass ?>"><div <?php echo $abscount_add->Hostel->cellAttributes() ?>>
<span id="el_abscount_Hostel">
<?php $abscount_add->Hostel->EditAttrs->prepend("onchange", "ew.updateOptions.call(this);"); ?>
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="abscount" data-field="x_Hostel" data-value-separator="<?php echo $abscount_add->Hostel->displayValueSeparatorAttribute() ?>" id="x_Hostel" name="x_Hostel"<?php echo $abscount_add->Hostel->editAttributes() ?>>
			<?php echo $abscount_add->Hostel->selectOptionListHtml("x_Hostel") ?>
		</select>
</div>
<?php echo $abscount_add->Hostel->Lookup->getParamTag($abscount_add, "p_x_Hostel") ?>
</span>
<?php echo $abscount_add->Hostel->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($abscount_add->Floor->Visible) { // Floor ?>
	<div id="r_Floor" class="form-group row">
		<label id="elh_abscount_Floor" for="x_Floor" class="<?php echo $abscount_add->LeftColumnClass ?>"><?php echo $abscount_add->Floor->caption() ?><?php echo $abscount_add->Floor->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $abscount_add->RightColumnClass ?>"><div <?php echo $abscount_add->Floor->cellAttributes() ?>>
<span id="el_abscount_Floor">
<?php $abscount_add->Floor->EditAttrs->prepend("onchange", "ew.updateOptions.call(this);"); ?>
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="abscount" data-field="x_Floor" data-value-separator="<?php echo $abscount_add->Floor->displayValueSeparatorAttribute() ?>" id="x_Floor" name="x_Floor"<?php echo $abscount_add->Floor->editAttributes() ?>>
			<?php echo $abscount_add->Floor->selectOptionListHtml("x_Floor") ?>
		</select>
</div>
<?php echo $abscount_add->Floor->Lookup->getParamTag($abscount_add, "p_x_Floor") ?>
</span>
<?php echo $abscount_add->Floor->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($abscount_add->_RS->Visible) { // RS ?>
	<div id="r__RS" class="form-group row">
		<label id="elh_abscount__RS" for="x__RS" class="<?php echo $abscount_add->LeftColumnClass ?>"><?php echo $abscount_add->_RS->caption() ?><?php echo $abscount_add->_RS->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $abscount_add->RightColumnClass ?>"><div <?php echo $abscount_add->_RS->cellAttributes() ?>>
<span id="el_abscount__RS">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="abscount" data-field="x__RS" data-value-separator="<?php echo $abscount_add->_RS->displayValueSeparatorAttribute() ?>" id="x__RS" name="x__RS"<?php echo $abscount_add->_RS->editAttributes() ?>>
			<?php echo $abscount_add->_RS->selectOptionListHtml("x__RS") ?>
		</select>
</div>
<?php echo $abscount_add->_RS->Lookup->getParamTag($abscount_add, "p_x__RS") ?>
</span>
<?php echo $abscount_add->_RS->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($abscount_add->Absent->Visible) { // Absent ?>
	<div id="r_Absent" class="form-group row">
		<label id="elh_abscount_Absent" for="x_Absent" class="<?php echo $abscount_add->LeftColumnClass ?>"><?php echo $abscount_add->Absent->caption() ?><?php echo $abscount_add->Absent->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $abscount_add->RightColumnClass ?>"><div <?php echo $abscount_add->Absent->cellAttributes() ?>>
<span id="el_abscount_Absent">
<input type="text" data-table="abscount" data-field="x_Absent" name="x_Absent" id="x_Absent" size="30" placeholder="<?php echo HtmlEncode($abscount_add->Absent->getPlaceHolder()) ?>" value="<?php echo $abscount_add->Absent->EditValue ?>"<?php echo $abscount_add->Absent->editAttributes() ?>>
</span>
<?php echo $abscount_add->Absent->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$abscount_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $abscount_add->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit"><?php echo $Language->phrase("AddBtn") ?></button>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" data-href="<?php echo $abscount_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$abscount_add->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
$abscount_add->terminate();
?>