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

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

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

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

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

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

	// Validate form
	finvolvementadd.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 ($involvement_add->Activity->Required) { ?>
				elm = this.getElements("x" + infix + "_Activity");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $involvement_add->Activity->caption(), $involvement_add->Activity->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($involvement_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", $involvement_add->Status->caption(), $involvement_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
	finvolvementadd.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
	finvolvementadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $involvement_add->showPageHeader(); ?>
<?php
$involvement_add->showMessage();
?>
<form name="finvolvementadd" id="finvolvementadd" class="<?php echo $involvement_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="involvement">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$involvement_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($involvement_add->Activity->Visible) { // Activity ?>
	<div id="r_Activity" class="form-group row">
		<label id="elh_involvement_Activity" for="x_Activity" class="<?php echo $involvement_add->LeftColumnClass ?>"><?php echo $involvement_add->Activity->caption() ?><?php echo $involvement_add->Activity->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $involvement_add->RightColumnClass ?>"><div <?php echo $involvement_add->Activity->cellAttributes() ?>>
<span id="el_involvement_Activity">
<input type="text" data-table="involvement" data-field="x_Activity" name="x_Activity" id="x_Activity" size="30" maxlength="55" placeholder="<?php echo HtmlEncode($involvement_add->Activity->getPlaceHolder()) ?>" value="<?php echo $involvement_add->Activity->EditValue ?>"<?php echo $involvement_add->Activity->editAttributes() ?>>
</span>
<?php echo $involvement_add->Activity->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($involvement_add->Status->Visible) { // Status ?>
	<div id="r_Status" class="form-group row">
		<label id="elh_involvement_Status" class="<?php echo $involvement_add->LeftColumnClass ?>"><?php echo $involvement_add->Status->caption() ?><?php echo $involvement_add->Status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $involvement_add->RightColumnClass ?>"><div <?php echo $involvement_add->Status->cellAttributes() ?>>
<span id="el_involvement_Status">
<div id="tp_x_Status" class="ew-template"><input type="radio" class="custom-control-input" data-table="involvement" data-field="x_Status" data-value-separator="<?php echo $involvement_add->Status->displayValueSeparatorAttribute() ?>" name="x_Status" id="x_Status" value="{value}"<?php echo $involvement_add->Status->editAttributes() ?>></div>
<div id="dsl_x_Status" data-repeatcolumn="5" class="ew-item-list d-none"><div>
<?php echo $involvement_add->Status->radioButtonListHtml(FALSE, "x_Status") ?>
</div></div>
</span>
<?php echo $involvement_add->Status->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$involvement_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $involvement_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 $involvement_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$involvement_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
$involvement_add->terminate();
?>