<?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_edit = new rooms_edit();

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

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

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

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

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

	// Validate form
	froomsedit.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_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", $rooms_edit->id->caption(), $rooms_edit->id->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($rooms_edit->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_edit->Hostel_Name->caption(), $rooms_edit->Hostel_Name->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($rooms_edit->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_edit->Floor->caption(), $rooms_edit->Floor->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($rooms_edit->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_edit->Room_No->caption(), $rooms_edit->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_edit->Room_No->errorMessage()) ?>");
			<?php if ($rooms_edit->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_edit->Bed->caption(), $rooms_edit->Bed->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Bed");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_edit->Bed->errorMessage()) ?>");
			<?php if ($rooms_edit->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_edit->Filled->caption(), $rooms_edit->Filled->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Filled");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_edit->Filled->errorMessage()) ?>");
			<?php if ($rooms_edit->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_edit->Vacant->caption(), $rooms_edit->Vacant->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Vacant");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($rooms_edit->Vacant->errorMessage()) ?>");
			<?php if ($rooms_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", $rooms_edit->Status->caption(), $rooms_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
	froomsedit.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
	froomsedit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $rooms_edit->showPageHeader(); ?>
<?php
$rooms_edit->showMessage();
?>
<form name="froomsedit" id="froomsedit" class="<?php echo $rooms_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="rooms">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$rooms_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($rooms_edit->id->Visible) { // id ?>
	<div id="r_id" class="form-group row">
		<label id="elh_rooms_id" class="<?php echo $rooms_edit->LeftColumnClass ?>"><?php echo $rooms_edit->id->caption() ?><?php echo $rooms_edit->id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->id->cellAttributes() ?>>
<span id="el_rooms_id">
<span<?php echo $rooms_edit->id->viewAttributes() ?>><input type="text" readonly class="form-control-plaintext" value="<?php echo HtmlEncode(RemoveHtml($rooms_edit->id->EditValue)) ?>"></span>
</span>
<input type="hidden" data-table="rooms" data-field="x_id" name="x_id" id="x_id" value="<?php echo HtmlEncode($rooms_edit->id->CurrentValue) ?>">
<?php echo $rooms_edit->id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->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_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Hostel_Name->caption() ?><?php echo $rooms_edit->Hostel_Name->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->Hostel_Name->cellAttributes() ?>>
<span id="el_rooms_Hostel_Name">
<?php $rooms_edit->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_edit->Hostel_Name->displayValueSeparatorAttribute() ?>" id="x_Hostel_Name" name="x_Hostel_Name"<?php echo $rooms_edit->Hostel_Name->editAttributes() ?>>
			<?php echo $rooms_edit->Hostel_Name->selectOptionListHtml("x_Hostel_Name") ?>
		</select>
</div>
<?php echo $rooms_edit->Hostel_Name->Lookup->getParamTag($rooms_edit, "p_x_Hostel_Name") ?>
</span>
<?php echo $rooms_edit->Hostel_Name->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->Floor->Visible) { // Floor ?>
	<div id="r_Floor" class="form-group row">
		<label id="elh_rooms_Floor" for="x_Floor" class="<?php echo $rooms_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Floor->caption() ?><?php echo $rooms_edit->Floor->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->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_edit->Floor->displayValueSeparatorAttribute() ?>" id="x_Floor" name="x_Floor"<?php echo $rooms_edit->Floor->editAttributes() ?>>
			<?php echo $rooms_edit->Floor->selectOptionListHtml("x_Floor") ?>
		</select>
</div>
<?php echo $rooms_edit->Floor->Lookup->getParamTag($rooms_edit, "p_x_Floor") ?>
</span>
<?php echo $rooms_edit->Floor->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->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_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Room_No->caption() ?><?php echo $rooms_edit->Room_No->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->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_edit->Room_No->getPlaceHolder()) ?>" value="<?php echo $rooms_edit->Room_No->EditValue ?>"<?php echo $rooms_edit->Room_No->editAttributes() ?>>
</span>
<?php echo $rooms_edit->Room_No->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->Bed->Visible) { // Bed ?>
	<div id="r_Bed" class="form-group row">
		<label id="elh_rooms_Bed" for="x_Bed" class="<?php echo $rooms_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Bed->caption() ?><?php echo $rooms_edit->Bed->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->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_edit->Bed->getPlaceHolder()) ?>" value="<?php echo $rooms_edit->Bed->EditValue ?>"<?php echo $rooms_edit->Bed->editAttributes() ?>>
</span>
<?php echo $rooms_edit->Bed->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->Filled->Visible) { // Filled ?>
	<div id="r_Filled" class="form-group row">
		<label id="elh_rooms_Filled" for="x_Filled" class="<?php echo $rooms_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Filled->caption() ?><?php echo $rooms_edit->Filled->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->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_edit->Filled->getPlaceHolder()) ?>" value="<?php echo $rooms_edit->Filled->EditValue ?>"<?php echo $rooms_edit->Filled->editAttributes() ?>>
</span>
<?php echo $rooms_edit->Filled->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->Vacant->Visible) { // Vacant ?>
	<div id="r_Vacant" class="form-group row">
		<label id="elh_rooms_Vacant" for="x_Vacant" class="<?php echo $rooms_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Vacant->caption() ?><?php echo $rooms_edit->Vacant->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->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_edit->Vacant->getPlaceHolder()) ?>" value="<?php echo $rooms_edit->Vacant->EditValue ?>"<?php echo $rooms_edit->Vacant->editAttributes() ?>>
</span>
<?php echo $rooms_edit->Vacant->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($rooms_edit->Status->Visible) { // Status ?>
	<div id="r_Status" class="form-group row">
		<label id="elh_rooms_Status" for="x_Status" class="<?php echo $rooms_edit->LeftColumnClass ?>"><?php echo $rooms_edit->Status->caption() ?><?php echo $rooms_edit->Status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $rooms_edit->RightColumnClass ?>"><div <?php echo $rooms_edit->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_edit->Status->displayValueSeparatorAttribute() ?>" id="x_Status" name="x_Status"<?php echo $rooms_edit->Status->editAttributes() ?>>
			<?php echo $rooms_edit->Status->selectOptionListHtml("x_Status") ?>
		</select>
</div>
</span>
<?php echo $rooms_edit->Status->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$rooms_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $rooms_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 $rooms_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$rooms_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
$rooms_edit->terminate();
?>