<?php
namespace PHPMaker2019\project_germanos;

// 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
$employeecontact_add = new employeecontact_add();

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

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

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

// Page Rendering event
$employeecontact_add->Page_Render();
?>
<?php include_once "header.php" ?>
<script>

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

// Validate form
femployeecontactadd.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 ($employeecontact_add->EmployeeID->Required) { ?>
			elm = this.getElements("x" + infix + "_EmployeeID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $employeecontact->EmployeeID->caption(), $employeecontact->EmployeeID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($employeecontact_add->ContactTypeID->Required) { ?>
			elm = this.getElements("x" + infix + "_ContactTypeID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $employeecontact->ContactTypeID->caption(), $employeecontact->ContactTypeID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($employeecontact_add->Contact->Required) { ?>
			elm = this.getElements("x" + infix + "_Contact");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $employeecontact->Contact->caption(), $employeecontact->Contact->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($employeecontact_add->Notes->Required) { ?>
			elm = this.getElements("x" + infix + "_Notes");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $employeecontact->Notes->caption(), $employeecontact->Notes->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($employeecontact_add->Primary->Required) { ?>
			elm = this.getElements("x" + infix + "_Primary[]");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $employeecontact->Primary->caption(), $employeecontact->Primary->RequiredErrorMessage)) ?>");
		<?php } ?>

			// Fire 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 event
femployeecontactadd.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
femployeecontactadd.validateRequired = <?php echo json_encode(CLIENT_VALIDATE) ?>;

// Dynamic selection lists
femployeecontactadd.lists["x_EmployeeID"] = <?php echo $employeecontact_add->EmployeeID->Lookup->toClientList() ?>;
femployeecontactadd.lists["x_EmployeeID"].options = <?php echo JsonEncode($employeecontact_add->EmployeeID->lookupOptions()) ?>;
femployeecontactadd.lists["x_ContactTypeID"] = <?php echo $employeecontact_add->ContactTypeID->Lookup->toClientList() ?>;
femployeecontactadd.lists["x_ContactTypeID"].options = <?php echo JsonEncode($employeecontact_add->ContactTypeID->lookupOptions()) ?>;
femployeecontactadd.lists["x_Primary[]"] = <?php echo $employeecontact_add->Primary->Lookup->toClientList() ?>;
femployeecontactadd.lists["x_Primary[]"].options = <?php echo JsonEncode($employeecontact_add->Primary->options(FALSE, TRUE)) ?>;

// Form object for search
</script>
<script>

// Write your client script here, no need to add script tags.
</script>
<?php $employeecontact_add->showPageHeader(); ?>
<?php
$employeecontact_add->showMessage();
?>
<form name="femployeecontactadd" id="femployeecontactadd" class="<?php echo $employeecontact_add->FormClassName ?>" action="<?php echo CurrentPageName() ?>" method="post">
<?php if ($employeecontact_add->CheckToken) { ?>
<input type="hidden" name="<?php echo TOKEN_NAME ?>" value="<?php echo $employeecontact_add->Token ?>">
<?php } ?>
<input type="hidden" name="t" value="employeecontact">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$employeecontact_add->IsModal ?>">
<?php if ($employeecontact->getCurrentMasterTable() == "employees") { ?>
<input type="hidden" name="<?php echo TABLE_SHOW_MASTER ?>" value="employees">
<input type="hidden" name="fk_EmployeeID" value="<?php echo $employeecontact->EmployeeID->getSessionValue() ?>">
<?php } ?>
<?php if (!$employeecontact_add->IsMobileOrModal) { ?>
<div class="ew-desktop"><!-- desktop -->
<?php } ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
<div class="ew-add-div"><!-- page* -->
<?php } else { ?>
<table id="tbl_employeecontactadd" class="table table-striped table-sm ew-desktop-table"><!-- table* -->
<?php } ?>
<?php if ($employeecontact->EmployeeID->Visible) { // EmployeeID ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
	<div id="r_EmployeeID" class="form-group row">
		<label id="elh_employeecontact_EmployeeID" for="x_EmployeeID" class="<?php echo $employeecontact_add->LeftColumnClass ?>"><?php echo $employeecontact->EmployeeID->caption() ?><?php echo ($employeecontact->EmployeeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $employeecontact_add->RightColumnClass ?>"><div<?php echo $employeecontact->EmployeeID->cellAttributes() ?>>
<?php if ($employeecontact->EmployeeID->getSessionValue() <> "") { ?>
<span id="el_employeecontact_EmployeeID">
<span<?php echo $employeecontact->EmployeeID->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?php echo RemoveHtml($employeecontact->EmployeeID->ViewValue) ?>"></span>
</span>
<input type="hidden" id="x_EmployeeID" name="x_EmployeeID" value="<?php echo HtmlEncode($employeecontact->EmployeeID->CurrentValue) ?>">
<?php } else { ?>
<span id="el_employeecontact_EmployeeID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="employeecontact" data-field="x_EmployeeID" data-value-separator="<?php echo $employeecontact->EmployeeID->displayValueSeparatorAttribute() ?>" id="x_EmployeeID" name="x_EmployeeID"<?php echo $employeecontact->EmployeeID->editAttributes() ?>>
		<?php echo $employeecontact->EmployeeID->selectOptionListHtml("x_EmployeeID") ?>
	</select>
</div>
<?php echo $employeecontact->EmployeeID->Lookup->getParamTag("p_x_EmployeeID") ?>
</span>
<?php } ?>
<?php echo $employeecontact->EmployeeID->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_EmployeeID">
		<td class="<?php echo $employeecontact_add->TableLeftColumnClass ?>"><span id="elh_employeecontact_EmployeeID"><?php echo $employeecontact->EmployeeID->caption() ?><?php echo ($employeecontact->EmployeeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $employeecontact->EmployeeID->cellAttributes() ?>>
<?php if ($employeecontact->EmployeeID->getSessionValue() <> "") { ?>
<span id="el_employeecontact_EmployeeID">
<span<?php echo $employeecontact->EmployeeID->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?php echo RemoveHtml($employeecontact->EmployeeID->ViewValue) ?>"></span>
</span>
<input type="hidden" id="x_EmployeeID" name="x_EmployeeID" value="<?php echo HtmlEncode($employeecontact->EmployeeID->CurrentValue) ?>">
<?php } else { ?>
<span id="el_employeecontact_EmployeeID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="employeecontact" data-field="x_EmployeeID" data-value-separator="<?php echo $employeecontact->EmployeeID->displayValueSeparatorAttribute() ?>" id="x_EmployeeID" name="x_EmployeeID"<?php echo $employeecontact->EmployeeID->editAttributes() ?>>
		<?php echo $employeecontact->EmployeeID->selectOptionListHtml("x_EmployeeID") ?>
	</select>
</div>
<?php echo $employeecontact->EmployeeID->Lookup->getParamTag("p_x_EmployeeID") ?>
</span>
<?php } ?>
<?php echo $employeecontact->EmployeeID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($employeecontact->ContactTypeID->Visible) { // ContactTypeID ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
	<div id="r_ContactTypeID" class="form-group row">
		<label id="elh_employeecontact_ContactTypeID" for="x_ContactTypeID" class="<?php echo $employeecontact_add->LeftColumnClass ?>"><?php echo $employeecontact->ContactTypeID->caption() ?><?php echo ($employeecontact->ContactTypeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $employeecontact_add->RightColumnClass ?>"><div<?php echo $employeecontact->ContactTypeID->cellAttributes() ?>>
<span id="el_employeecontact_ContactTypeID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="employeecontact" data-field="x_ContactTypeID" data-value-separator="<?php echo $employeecontact->ContactTypeID->displayValueSeparatorAttribute() ?>" id="x_ContactTypeID" name="x_ContactTypeID"<?php echo $employeecontact->ContactTypeID->editAttributes() ?>>
		<?php echo $employeecontact->ContactTypeID->selectOptionListHtml("x_ContactTypeID") ?>
	</select>
</div>
<?php echo $employeecontact->ContactTypeID->Lookup->getParamTag("p_x_ContactTypeID") ?>
</span>
<?php echo $employeecontact->ContactTypeID->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_ContactTypeID">
		<td class="<?php echo $employeecontact_add->TableLeftColumnClass ?>"><span id="elh_employeecontact_ContactTypeID"><?php echo $employeecontact->ContactTypeID->caption() ?><?php echo ($employeecontact->ContactTypeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $employeecontact->ContactTypeID->cellAttributes() ?>>
<span id="el_employeecontact_ContactTypeID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="employeecontact" data-field="x_ContactTypeID" data-value-separator="<?php echo $employeecontact->ContactTypeID->displayValueSeparatorAttribute() ?>" id="x_ContactTypeID" name="x_ContactTypeID"<?php echo $employeecontact->ContactTypeID->editAttributes() ?>>
		<?php echo $employeecontact->ContactTypeID->selectOptionListHtml("x_ContactTypeID") ?>
	</select>
</div>
<?php echo $employeecontact->ContactTypeID->Lookup->getParamTag("p_x_ContactTypeID") ?>
</span>
<?php echo $employeecontact->ContactTypeID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($employeecontact->Contact->Visible) { // Contact ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
	<div id="r_Contact" class="form-group row">
		<label id="elh_employeecontact_Contact" for="x_Contact" class="<?php echo $employeecontact_add->LeftColumnClass ?>"><?php echo $employeecontact->Contact->caption() ?><?php echo ($employeecontact->Contact->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $employeecontact_add->RightColumnClass ?>"><div<?php echo $employeecontact->Contact->cellAttributes() ?>>
<span id="el_employeecontact_Contact">
<input type="text" data-table="employeecontact" data-field="x_Contact" name="x_Contact" id="x_Contact" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($employeecontact->Contact->getPlaceHolder()) ?>" value="<?php echo $employeecontact->Contact->EditValue ?>"<?php echo $employeecontact->Contact->editAttributes() ?>>
</span>
<?php echo $employeecontact->Contact->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_Contact">
		<td class="<?php echo $employeecontact_add->TableLeftColumnClass ?>"><span id="elh_employeecontact_Contact"><?php echo $employeecontact->Contact->caption() ?><?php echo ($employeecontact->Contact->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $employeecontact->Contact->cellAttributes() ?>>
<span id="el_employeecontact_Contact">
<input type="text" data-table="employeecontact" data-field="x_Contact" name="x_Contact" id="x_Contact" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($employeecontact->Contact->getPlaceHolder()) ?>" value="<?php echo $employeecontact->Contact->EditValue ?>"<?php echo $employeecontact->Contact->editAttributes() ?>>
</span>
<?php echo $employeecontact->Contact->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($employeecontact->Notes->Visible) { // Notes ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
	<div id="r_Notes" class="form-group row">
		<label id="elh_employeecontact_Notes" for="x_Notes" class="<?php echo $employeecontact_add->LeftColumnClass ?>"><?php echo $employeecontact->Notes->caption() ?><?php echo ($employeecontact->Notes->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $employeecontact_add->RightColumnClass ?>"><div<?php echo $employeecontact->Notes->cellAttributes() ?>>
<span id="el_employeecontact_Notes">
<input type="text" data-table="employeecontact" data-field="x_Notes" name="x_Notes" id="x_Notes" size="30" maxlength="100" placeholder="<?php echo HtmlEncode($employeecontact->Notes->getPlaceHolder()) ?>" value="<?php echo $employeecontact->Notes->EditValue ?>"<?php echo $employeecontact->Notes->editAttributes() ?>>
</span>
<?php echo $employeecontact->Notes->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_Notes">
		<td class="<?php echo $employeecontact_add->TableLeftColumnClass ?>"><span id="elh_employeecontact_Notes"><?php echo $employeecontact->Notes->caption() ?><?php echo ($employeecontact->Notes->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $employeecontact->Notes->cellAttributes() ?>>
<span id="el_employeecontact_Notes">
<input type="text" data-table="employeecontact" data-field="x_Notes" name="x_Notes" id="x_Notes" size="30" maxlength="100" placeholder="<?php echo HtmlEncode($employeecontact->Notes->getPlaceHolder()) ?>" value="<?php echo $employeecontact->Notes->EditValue ?>"<?php echo $employeecontact->Notes->editAttributes() ?>>
</span>
<?php echo $employeecontact->Notes->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($employeecontact->Primary->Visible) { // Primary ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
	<div id="r_Primary" class="form-group row">
		<label id="elh_employeecontact_Primary" class="<?php echo $employeecontact_add->LeftColumnClass ?>"><?php echo $employeecontact->Primary->caption() ?><?php echo ($employeecontact->Primary->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $employeecontact_add->RightColumnClass ?>"><div<?php echo $employeecontact->Primary->cellAttributes() ?>>
<span id="el_employeecontact_Primary">
<?php
$selwrk = (ConvertToBool($employeecontact->Primary->CurrentValue)) ? " checked" : "";
?>
<input type="checkbox" data-table="employeecontact" data-field="x_Primary" name="x_Primary[]" id="x_Primary[]" value="1"<?php echo $selwrk ?><?php echo $employeecontact->Primary->editAttributes() ?>>
</span>
<?php echo $employeecontact->Primary->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_Primary">
		<td class="<?php echo $employeecontact_add->TableLeftColumnClass ?>"><span id="elh_employeecontact_Primary"><?php echo $employeecontact->Primary->caption() ?><?php echo ($employeecontact->Primary->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $employeecontact->Primary->cellAttributes() ?>>
<span id="el_employeecontact_Primary">
<?php
$selwrk = (ConvertToBool($employeecontact->Primary->CurrentValue)) ? " checked" : "";
?>
<input type="checkbox" data-table="employeecontact" data-field="x_Primary" name="x_Primary[]" id="x_Primary[]" value="1"<?php echo $selwrk ?><?php echo $employeecontact->Primary->editAttributes() ?>>
</span>
<?php echo $employeecontact->Primary->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($employeecontact_add->IsMobileOrModal) { ?>
</div><!-- /page* -->
<?php } else { ?>
</table><!-- /table* -->
<?php } ?>
<?php if (!$employeecontact_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $employeecontact_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 $employeecontact_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
<?php if (!$employeecontact_add->IsMobileOrModal) { ?>
</div><!-- /desktop -->
<?php } ?>
</form>
<?php
$employeecontact_add->showPageFooter();
if (DEBUG_ENABLED)
	echo GetDebugMessage();
?>
<script>

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php include_once "footer.php" ?>
<?php
$employeecontact_add->terminate();
?>
