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

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

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

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

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

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

	// Validate form
	fhealthedit.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 ($health_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", $health_edit->id->caption(), $health_edit->id->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_id");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($health_edit->id->errorMessage()) ?>");
			<?php if ($health_edit->Health_Issue->Required) { ?>
				elm = this.getElements("x" + infix + "_Health_Issue");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $health_edit->Health_Issue->caption(), $health_edit->Health_Issue->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($health_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", $health_edit->Status->caption(), $health_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
	fhealthedit.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
	fhealthedit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $health_edit->showPageHeader(); ?>
<?php
$health_edit->showMessage();
?>
<form name="fhealthedit" id="fhealthedit" class="<?php echo $health_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="health">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$health_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($health_edit->id->Visible) { // id ?>
	<div id="r_id" class="form-group row">
		<label id="elh_health_id" for="x_id" class="<?php echo $health_edit->LeftColumnClass ?>"><?php echo $health_edit->id->caption() ?><?php echo $health_edit->id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $health_edit->RightColumnClass ?>"><div <?php echo $health_edit->id->cellAttributes() ?>>
<span id="el_health_id">
<span<?php echo $health_edit->id->viewAttributes() ?>><input type="text" readonly class="form-control-plaintext" value="<?php echo HtmlEncode(RemoveHtml($health_edit->id->EditValue)) ?>"></span>
</span>
<input type="hidden" data-table="health" data-field="x_id" name="x_id" id="x_id" value="<?php echo HtmlEncode($health_edit->id->CurrentValue) ?>">
<?php echo $health_edit->id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($health_edit->Health_Issue->Visible) { // Health_Issue ?>
	<div id="r_Health_Issue" class="form-group row">
		<label id="elh_health_Health_Issue" for="x_Health_Issue" class="<?php echo $health_edit->LeftColumnClass ?>"><?php echo $health_edit->Health_Issue->caption() ?><?php echo $health_edit->Health_Issue->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $health_edit->RightColumnClass ?>"><div <?php echo $health_edit->Health_Issue->cellAttributes() ?>>
<span id="el_health_Health_Issue">
<input type="text" data-table="health" data-field="x_Health_Issue" name="x_Health_Issue" id="x_Health_Issue" size="30" maxlength="55" placeholder="<?php echo HtmlEncode($health_edit->Health_Issue->getPlaceHolder()) ?>" value="<?php echo $health_edit->Health_Issue->EditValue ?>"<?php echo $health_edit->Health_Issue->editAttributes() ?>>
</span>
<?php echo $health_edit->Health_Issue->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($health_edit->Status->Visible) { // Status ?>
	<div id="r_Status" class="form-group row">
		<label id="elh_health_Status" class="<?php echo $health_edit->LeftColumnClass ?>"><?php echo $health_edit->Status->caption() ?><?php echo $health_edit->Status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $health_edit->RightColumnClass ?>"><div <?php echo $health_edit->Status->cellAttributes() ?>>
<span id="el_health_Status">
<?php
$selwrk = ConvertToBool($health_edit->Status->CurrentValue) ? " checked" : "";
?>
<div class="custom-control custom-checkbox d-inline-block">
	<input type="checkbox" class="custom-control-input" data-table="health" data-field="x_Status" name="x_Status[]" id="x_Status[]" value="1"<?php echo $selwrk ?><?php echo $health_edit->Status->editAttributes() ?>>
	<label class="custom-control-label" for="x_Status[]"></label>
</div>
</span>
<?php echo $health_edit->Status->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$health_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $health_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 $health_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$health_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
$health_edit->terminate();
?>