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

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

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

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

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

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

	// Validate form
	froomsadd.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 ($rooms_add->Hostel_Name->Required) { ?>
				elm = this.getElements("x" + infix + "_Hostel_Name");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $rooms_add->Hostel_Name->caption(), $rooms_add->Hostel_Name->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($rooms_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", $rooms_add->Floor->caption(), $rooms_add->Floor->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($rooms_add->Room_No->Required) { ?>
				elm = this.getElements("x" + infix + "_Room_No");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $rooms_add->Room_No->caption(), $rooms_add->Room_No->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Room_No");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_add->Room_No->errorMessage()) ?>");
			<?php if ($rooms_add->Bed->Required) { ?>
				elm = this.getElements("x" + infix + "_Bed");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $rooms_add->Bed->caption(), $rooms_add->Bed->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Bed");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_add->Bed->errorMessage()) ?>");
			<?php if ($rooms_add->Filled->Required) { ?>
				elm = this.getElements("x" + infix + "_Filled");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $rooms_add->Filled->caption(), $rooms_add->Filled->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Filled");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_add->Filled->errorMessage()) ?>");
			<?php if ($rooms_add->Vacant->Required) { ?>
				elm = this.getElements("x" + infix + "_Vacant");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $rooms_add->Vacant->caption(), $rooms_add->Vacant->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Vacant");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_add->Vacant->errorMessage()) ?>");
			<?php if ($rooms_add->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", $rooms_add->Status->caption(), $rooms_add->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
	froomsadd.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
	froomsadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $rooms_add->showPageHeader(); ?>
<?php
$rooms_add->showMessage();
?>
<form name="froomsadd" id="froomsadd" class="<?php echo $rooms_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="rooms">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$rooms_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($rooms_add->Hostel_Name->Visible) { // Hostel_Name ?>
	<div id="r_Hostel_Name" class="form-group row">
		<label id="elh_rooms_Hostel_Name" for="x_Hostel_Name" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Hostel_Name->caption() ?><?php echo $rooms_add->Hostel_Name->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Hostel_Name->cellAttributes() ?>>
<span id="el_rooms_Hostel_Name">
<?php $rooms_add->Hostel_Name->EditAttrs->prepend("onchange", "ew.updateOptions.call(this);"); ?>
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="rooms" data-field="x_Hostel_Name" data-value-separator="<?php echo $rooms_add->Hostel_Name->displayValueSeparatorAttribute() ?>" id="x_Hostel_Name" name="x_Hostel_Name"<?php echo $rooms_add->Hostel_Name->editAttributes() ?>>
			<?php echo $rooms_add->Hostel_Name->selectOptionListHtml("x_Hostel_Name") ?>
		</select>
</div>
<?php echo $rooms_add->Hostel_Name->Lookup->getParamTag($rooms_add, "p_x_Hostel_Name") ?>
</span>
<?php echo $rooms_add->Hostel_Name->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_add->Floor->Visible) { // Floor ?>
	<div id="r_Floor" class="form-group row">
		<label id="elh_rooms_Floor" for="x_Floor" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Floor->caption() ?><?php echo $rooms_add->Floor->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Floor->cellAttributes() ?>>
<span id="el_rooms_Floor">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="rooms" data-field="x_Floor" data-value-separator="<?php echo $rooms_add->Floor->displayValueSeparatorAttribute() ?>" id="x_Floor" name="x_Floor"<?php echo $rooms_add->Floor->editAttributes() ?>>
			<?php echo $rooms_add->Floor->selectOptionListHtml("x_Floor") ?>
		</select>
</div>
<?php echo $rooms_add->Floor->Lookup->getParamTag($rooms_add, "p_x_Floor") ?>
</span>
<?php echo $rooms_add->Floor->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_add->Room_No->Visible) { // Room_No ?>
	<div id="r_Room_No" class="form-group row">
		<label id="elh_rooms_Room_No" for="x_Room_No" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Room_No->caption() ?><?php echo $rooms_add->Room_No->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Room_No->cellAttributes() ?>>
<span id="el_rooms_Room_No">
<input type="text" data-table="rooms" data-field="x_Room_No" name="x_Room_No" id="x_Room_No" size="30" placeholder="<?php echo HtmlEncode($rooms_add->Room_No->getPlaceHolder()) ?>" value="<?php echo $rooms_add->Room_No->EditValue ?>"<?php echo $rooms_add->Room_No->editAttributes() ?>>
</span>
<?php echo $rooms_add->Room_No->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_add->Bed->Visible) { // Bed ?>
	<div id="r_Bed" class="form-group row">
		<label id="elh_rooms_Bed" for="x_Bed" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Bed->caption() ?><?php echo $rooms_add->Bed->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Bed->cellAttributes() ?>>
<span id="el_rooms_Bed">
<input type="text" data-table="rooms" data-field="x_Bed" name="x_Bed" id="x_Bed" size="30" placeholder="<?php echo HtmlEncode($rooms_add->Bed->getPlaceHolder()) ?>" value="<?php echo $rooms_add->Bed->EditValue ?>"<?php echo $rooms_add->Bed->editAttributes() ?>>
</span>
<?php echo $rooms_add->Bed->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_add->Filled->Visible) { // Filled ?>
	<div id="r_Filled" class="form-group row">
		<label id="elh_rooms_Filled" for="x_Filled" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Filled->caption() ?><?php echo $rooms_add->Filled->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Filled->cellAttributes() ?>>
<span id="el_rooms_Filled">
<input type="text" data-table="rooms" data-field="x_Filled" name="x_Filled" id="x_Filled" size="30" placeholder="<?php echo HtmlEncode($rooms_add->Filled->getPlaceHolder()) ?>" value="<?php echo $rooms_add->Filled->EditValue ?>"<?php echo $rooms_add->Filled->editAttributes() ?>>
</span>
<?php echo $rooms_add->Filled->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_add->Vacant->Visible) { // Vacant ?>
	<div id="r_Vacant" class="form-group row">
		<label id="elh_rooms_Vacant" for="x_Vacant" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Vacant->caption() ?><?php echo $rooms_add->Vacant->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Vacant->cellAttributes() ?>>
<span id="el_rooms_Vacant">
<input type="text" data-table="rooms" data-field="x_Vacant" name="x_Vacant" id="x_Vacant" size="30" placeholder="<?php echo HtmlEncode($rooms_add->Vacant->getPlaceHolder()) ?>" value="<?php echo $rooms_add->Vacant->EditValue ?>"<?php echo $rooms_add->Vacant->editAttributes() ?>>
</span>
<?php echo $rooms_add->Vacant->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_add->Status->Visible) { // Status ?>
	<div id="r_Status" class="form-group row">
		<label id="elh_rooms_Status" for="x_Status" class="<?php echo $rooms_add->LeftColumnClass ?>"><?php echo $rooms_add->Status->caption() ?><?php echo $rooms_add->Status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_add->RightColumnClass ?>"><div <?php echo $rooms_add->Status->cellAttributes() ?>>
<span id="el_rooms_Status">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="rooms" data-field="x_Status" data-value-separator="<?php echo $rooms_add->Status->displayValueSeparatorAttribute() ?>" id="x_Status" name="x_Status"<?php echo $rooms_add->Status->editAttributes() ?>>
			<?php echo $rooms_add->Status->selectOptionListHtml("x_Status") ?>
		</select>
</div>
</span>
<?php echo $rooms_add->Status->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$rooms_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $rooms_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 $rooms_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$rooms_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
$rooms_add->terminate();
?>