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

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

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

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

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

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

	// Validate form
	fhosteledit.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 ($hostel_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", $hostel_edit->id->caption(), $hostel_edit->id->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($hostel_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", $hostel_edit->Hostel_Name->caption(), $hostel_edit->Hostel_Name->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($hostel_edit->Fee->Required) { ?>
				elm = this.getElements("x" + infix + "_Fee");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $hostel_edit->Fee->caption(), $hostel_edit->Fee->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_Fee");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($hostel_edit->Fee->errorMessage()) ?>");
			<?php if ($hostel_edit->Remarks->Required) { ?>
				elm = this.getElements("x" + infix + "_Remarks");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $hostel_edit->Remarks->caption(), $hostel_edit->Remarks->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
	fhosteledit.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
	fhosteledit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

	// Dynamic selection lists
	loadjs.done("fhosteledit");
});
</script>
<script>
loadjs.ready("head", function() {

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

});
</script>
<?php $hostel_edit->showPageHeader(); ?>
<?php
$hostel_edit->showMessage();
?>
<form name="fhosteledit" id="fhosteledit" class="<?php echo $hostel_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="hostel">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$hostel_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($hostel_edit->id->Visible) { // id ?>
	<div id="r_id" class="form-group row">
		<label id="elh_hostel_id" class="<?php echo $hostel_edit->LeftColumnClass ?>"><?php echo $hostel_edit->id->caption() ?><?php echo $hostel_edit->id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $hostel_edit->RightColumnClass ?>"><div <?php echo $hostel_edit->id->cellAttributes() ?>>
<span id="el_hostel_id">
<span<?php echo $hostel_edit->id->viewAttributes() ?>><input type="text" readonly class="form-control-plaintext" value="<?php echo HtmlEncode(RemoveHtml($hostel_edit->id->EditValue)) ?>"></span>
</span>
<input type="hidden" data-table="hostel" data-field="x_id" name="x_id" id="x_id" value="<?php echo HtmlEncode($hostel_edit->id->CurrentValue) ?>">
<?php echo $hostel_edit->id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($hostel_edit->Hostel_Name->Visible) { // Hostel_Name ?>
	<div id="r_Hostel_Name" class="form-group row">
		<label id="elh_hostel_Hostel_Name" for="x_Hostel_Name" class="<?php echo $hostel_edit->LeftColumnClass ?>"><?php echo $hostel_edit->Hostel_Name->caption() ?><?php echo $hostel_edit->Hostel_Name->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $hostel_edit->RightColumnClass ?>"><div <?php echo $hostel_edit->Hostel_Name->cellAttributes() ?>>
<span id="el_hostel_Hostel_Name">
<input type="text" data-table="hostel" data-field="x_Hostel_Name" name="x_Hostel_Name" id="x_Hostel_Name" size="30" maxlength="55" placeholder="<?php echo HtmlEncode($hostel_edit->Hostel_Name->getPlaceHolder()) ?>" value="<?php echo $hostel_edit->Hostel_Name->EditValue ?>"<?php echo $hostel_edit->Hostel_Name->editAttributes() ?>>
</span>
<?php echo $hostel_edit->Hostel_Name->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($hostel_edit->Fee->Visible) { // Fee ?>
	<div id="r_Fee" class="form-group row">
		<label id="elh_hostel_Fee" for="x_Fee" class="<?php echo $hostel_edit->LeftColumnClass ?>"><?php echo $hostel_edit->Fee->caption() ?><?php echo $hostel_edit->Fee->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $hostel_edit->RightColumnClass ?>"><div <?php echo $hostel_edit->Fee->cellAttributes() ?>>
<span id="el_hostel_Fee">
<input type="text" data-table="hostel" data-field="x_Fee" name="x_Fee" id="x_Fee" size="30" placeholder="<?php echo HtmlEncode($hostel_edit->Fee->getPlaceHolder()) ?>" value="<?php echo $hostel_edit->Fee->EditValue ?>"<?php echo $hostel_edit->Fee->editAttributes() ?>>
</span>
<?php echo $hostel_edit->Fee->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($hostel_edit->Remarks->Visible) { // Remarks ?>
	<div id="r_Remarks" class="form-group row">
		<label id="elh_hostel_Remarks" for="x_Remarks" class="<?php echo $hostel_edit->LeftColumnClass ?>"><?php echo $hostel_edit->Remarks->caption() ?><?php echo $hostel_edit->Remarks->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $hostel_edit->RightColumnClass ?>"><div <?php echo $hostel_edit->Remarks->cellAttributes() ?>>
<span id="el_hostel_Remarks">
<input type="text" data-table="hostel" data-field="x_Remarks" name="x_Remarks" id="x_Remarks" size="30" maxlength="125" placeholder="<?php echo HtmlEncode($hostel_edit->Remarks->getPlaceHolder()) ?>" value="<?php echo $hostel_edit->Remarks->EditValue ?>"<?php echo $hostel_edit->Remarks->editAttributes() ?>>
</span>
<?php echo $hostel_edit->Remarks->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$hostel_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $hostel_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 $hostel_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$hostel_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
$hostel_edit->terminate();
?>