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

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

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

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

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

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

// Validate form
flawyercontactadd.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 ($lawyercontact_add->LawyerID->Required) { ?>
			elm = this.getElements("x" + infix + "_LawyerID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $lawyercontact->LawyerID->caption(), $lawyercontact->LawyerID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($lawyercontact_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", $lawyercontact->ContactTypeID->caption(), $lawyercontact->ContactTypeID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($lawyercontact_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", $lawyercontact->Contact->caption(), $lawyercontact->Contact->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($lawyercontact_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", $lawyercontact->Notes->caption(), $lawyercontact->Notes->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($lawyercontact_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", $lawyercontact->Primary->caption(), $lawyercontact->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
flawyercontactadd.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
flawyercontactadd.validateRequired = <?php echo json_encode(CLIENT_VALIDATE) ?>;

// Dynamic selection lists
flawyercontactadd.lists["x_LawyerID"] = <?php echo $lawyercontact_add->LawyerID->Lookup->toClientList() ?>;
flawyercontactadd.lists["x_LawyerID"].options = <?php echo JsonEncode($lawyercontact_add->LawyerID->lookupOptions()) ?>;
flawyercontactadd.lists["x_ContactTypeID"] = <?php echo $lawyercontact_add->ContactTypeID->Lookup->toClientList() ?>;
flawyercontactadd.lists["x_ContactTypeID"].options = <?php echo JsonEncode($lawyercontact_add->ContactTypeID->lookupOptions()) ?>;
flawyercontactadd.lists["x_Primary[]"] = <?php echo $lawyercontact_add->Primary->Lookup->toClientList() ?>;
flawyercontactadd.lists["x_Primary[]"].options = <?php echo JsonEncode($lawyercontact_add->Primary->options(FALSE, TRUE)) ?>;

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

// Write your client script here, no need to add script tags.
</script>
<?php $lawyercontact_add->showPageHeader(); ?>
<?php
$lawyercontact_add->showMessage();
?>
<form name="flawyercontactadd" id="flawyercontactadd" class="<?php echo $lawyercontact_add->FormClassName ?>" action="<?php echo CurrentPageName() ?>" method="post">
<?php if ($lawyercontact_add->CheckToken) { ?>
<input type="hidden" name="<?php echo TOKEN_NAME ?>" value="<?php echo $lawyercontact_add->Token ?>">
<?php } ?>
<input type="hidden" name="t" value="lawyercontact">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$lawyercontact_add->IsModal ?>">
<?php if ($lawyercontact->getCurrentMasterTable() == "lawyers") { ?>
<input type="hidden" name="<?php echo TABLE_SHOW_MASTER ?>" value="lawyers">
<input type="hidden" name="fk_LawyerID" value="<?php echo $lawyercontact->LawyerID->getSessionValue() ?>">
<?php } ?>
<?php if (!$lawyercontact_add->IsMobileOrModal) { ?>
<div class="ew-desktop"><!-- desktop -->
<?php } ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
<div class="ew-add-div"><!-- page* -->
<?php } else { ?>
<table id="tbl_lawyercontactadd" class="table table-striped table-sm ew-desktop-table"><!-- table* -->
<?php } ?>
<?php if ($lawyercontact->LawyerID->Visible) { // LawyerID ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
	<div id="r_LawyerID" class="form-group row">
		<label id="elh_lawyercontact_LawyerID" for="x_LawyerID" class="<?php echo $lawyercontact_add->LeftColumnClass ?>"><?php echo $lawyercontact->LawyerID->caption() ?><?php echo ($lawyercontact->LawyerID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $lawyercontact_add->RightColumnClass ?>"><div<?php echo $lawyercontact->LawyerID->cellAttributes() ?>>
<?php if ($lawyercontact->LawyerID->getSessionValue() <> "") { ?>
<span id="el_lawyercontact_LawyerID">
<span<?php echo $lawyercontact->LawyerID->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?php echo RemoveHtml($lawyercontact->LawyerID->ViewValue) ?>"></span>
</span>
<input type="hidden" id="x_LawyerID" name="x_LawyerID" value="<?php echo HtmlEncode($lawyercontact->LawyerID->CurrentValue) ?>">
<?php } else { ?>
<span id="el_lawyercontact_LawyerID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="lawyercontact" data-field="x_LawyerID" data-value-separator="<?php echo $lawyercontact->LawyerID->displayValueSeparatorAttribute() ?>" id="x_LawyerID" name="x_LawyerID"<?php echo $lawyercontact->LawyerID->editAttributes() ?>>
		<?php echo $lawyercontact->LawyerID->selectOptionListHtml("x_LawyerID") ?>
	</select>
</div>
<?php echo $lawyercontact->LawyerID->Lookup->getParamTag("p_x_LawyerID") ?>
</span>
<?php } ?>
<?php echo $lawyercontact->LawyerID->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_LawyerID">
		<td class="<?php echo $lawyercontact_add->TableLeftColumnClass ?>"><span id="elh_lawyercontact_LawyerID"><?php echo $lawyercontact->LawyerID->caption() ?><?php echo ($lawyercontact->LawyerID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $lawyercontact->LawyerID->cellAttributes() ?>>
<?php if ($lawyercontact->LawyerID->getSessionValue() <> "") { ?>
<span id="el_lawyercontact_LawyerID">
<span<?php echo $lawyercontact->LawyerID->viewAttributes() ?>>
<input type="text" readonly class="form-control-plaintext" value="<?php echo RemoveHtml($lawyercontact->LawyerID->ViewValue) ?>"></span>
</span>
<input type="hidden" id="x_LawyerID" name="x_LawyerID" value="<?php echo HtmlEncode($lawyercontact->LawyerID->CurrentValue) ?>">
<?php } else { ?>
<span id="el_lawyercontact_LawyerID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="lawyercontact" data-field="x_LawyerID" data-value-separator="<?php echo $lawyercontact->LawyerID->displayValueSeparatorAttribute() ?>" id="x_LawyerID" name="x_LawyerID"<?php echo $lawyercontact->LawyerID->editAttributes() ?>>
		<?php echo $lawyercontact->LawyerID->selectOptionListHtml("x_LawyerID") ?>
	</select>
</div>
<?php echo $lawyercontact->LawyerID->Lookup->getParamTag("p_x_LawyerID") ?>
</span>
<?php } ?>
<?php echo $lawyercontact->LawyerID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($lawyercontact->ContactTypeID->Visible) { // ContactTypeID ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
	<div id="r_ContactTypeID" class="form-group row">
		<label id="elh_lawyercontact_ContactTypeID" for="x_ContactTypeID" class="<?php echo $lawyercontact_add->LeftColumnClass ?>"><?php echo $lawyercontact->ContactTypeID->caption() ?><?php echo ($lawyercontact->ContactTypeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $lawyercontact_add->RightColumnClass ?>"><div<?php echo $lawyercontact->ContactTypeID->cellAttributes() ?>>
<span id="el_lawyercontact_ContactTypeID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="lawyercontact" data-field="x_ContactTypeID" data-value-separator="<?php echo $lawyercontact->ContactTypeID->displayValueSeparatorAttribute() ?>" id="x_ContactTypeID" name="x_ContactTypeID"<?php echo $lawyercontact->ContactTypeID->editAttributes() ?>>
		<?php echo $lawyercontact->ContactTypeID->selectOptionListHtml("x_ContactTypeID") ?>
	</select>
</div>
<?php echo $lawyercontact->ContactTypeID->Lookup->getParamTag("p_x_ContactTypeID") ?>
</span>
<?php echo $lawyercontact->ContactTypeID->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_ContactTypeID">
		<td class="<?php echo $lawyercontact_add->TableLeftColumnClass ?>"><span id="elh_lawyercontact_ContactTypeID"><?php echo $lawyercontact->ContactTypeID->caption() ?><?php echo ($lawyercontact->ContactTypeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $lawyercontact->ContactTypeID->cellAttributes() ?>>
<span id="el_lawyercontact_ContactTypeID">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="lawyercontact" data-field="x_ContactTypeID" data-value-separator="<?php echo $lawyercontact->ContactTypeID->displayValueSeparatorAttribute() ?>" id="x_ContactTypeID" name="x_ContactTypeID"<?php echo $lawyercontact->ContactTypeID->editAttributes() ?>>
		<?php echo $lawyercontact->ContactTypeID->selectOptionListHtml("x_ContactTypeID") ?>
	</select>
</div>
<?php echo $lawyercontact->ContactTypeID->Lookup->getParamTag("p_x_ContactTypeID") ?>
</span>
<?php echo $lawyercontact->ContactTypeID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($lawyercontact->Contact->Visible) { // Contact ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
	<div id="r_Contact" class="form-group row">
		<label id="elh_lawyercontact_Contact" for="x_Contact" class="<?php echo $lawyercontact_add->LeftColumnClass ?>"><?php echo $lawyercontact->Contact->caption() ?><?php echo ($lawyercontact->Contact->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $lawyercontact_add->RightColumnClass ?>"><div<?php echo $lawyercontact->Contact->cellAttributes() ?>>
<span id="el_lawyercontact_Contact">
<input type="text" data-table="lawyercontact" data-field="x_Contact" name="x_Contact" id="x_Contact" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($lawyercontact->Contact->getPlaceHolder()) ?>" value="<?php echo $lawyercontact->Contact->EditValue ?>"<?php echo $lawyercontact->Contact->editAttributes() ?>>
</span>
<?php echo $lawyercontact->Contact->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_Contact">
		<td class="<?php echo $lawyercontact_add->TableLeftColumnClass ?>"><span id="elh_lawyercontact_Contact"><?php echo $lawyercontact->Contact->caption() ?><?php echo ($lawyercontact->Contact->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $lawyercontact->Contact->cellAttributes() ?>>
<span id="el_lawyercontact_Contact">
<input type="text" data-table="lawyercontact" data-field="x_Contact" name="x_Contact" id="x_Contact" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($lawyercontact->Contact->getPlaceHolder()) ?>" value="<?php echo $lawyercontact->Contact->EditValue ?>"<?php echo $lawyercontact->Contact->editAttributes() ?>>
</span>
<?php echo $lawyercontact->Contact->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($lawyercontact->Notes->Visible) { // Notes ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
	<div id="r_Notes" class="form-group row">
		<label id="elh_lawyercontact_Notes" for="x_Notes" class="<?php echo $lawyercontact_add->LeftColumnClass ?>"><?php echo $lawyercontact->Notes->caption() ?><?php echo ($lawyercontact->Notes->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $lawyercontact_add->RightColumnClass ?>"><div<?php echo $lawyercontact->Notes->cellAttributes() ?>>
<span id="el_lawyercontact_Notes">
<input type="text" data-table="lawyercontact" data-field="x_Notes" name="x_Notes" id="x_Notes" size="30" maxlength="100" placeholder="<?php echo HtmlEncode($lawyercontact->Notes->getPlaceHolder()) ?>" value="<?php echo $lawyercontact->Notes->EditValue ?>"<?php echo $lawyercontact->Notes->editAttributes() ?>>
</span>
<?php echo $lawyercontact->Notes->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_Notes">
		<td class="<?php echo $lawyercontact_add->TableLeftColumnClass ?>"><span id="elh_lawyercontact_Notes"><?php echo $lawyercontact->Notes->caption() ?><?php echo ($lawyercontact->Notes->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $lawyercontact->Notes->cellAttributes() ?>>
<span id="el_lawyercontact_Notes">
<input type="text" data-table="lawyercontact" data-field="x_Notes" name="x_Notes" id="x_Notes" size="30" maxlength="100" placeholder="<?php echo HtmlEncode($lawyercontact->Notes->getPlaceHolder()) ?>" value="<?php echo $lawyercontact->Notes->EditValue ?>"<?php echo $lawyercontact->Notes->editAttributes() ?>>
</span>
<?php echo $lawyercontact->Notes->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($lawyercontact->Primary->Visible) { // Primary ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
	<div id="r_Primary" class="form-group row">
		<label id="elh_lawyercontact_Primary" class="<?php echo $lawyercontact_add->LeftColumnClass ?>"><?php echo $lawyercontact->Primary->caption() ?><?php echo ($lawyercontact->Primary->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $lawyercontact_add->RightColumnClass ?>"><div<?php echo $lawyercontact->Primary->cellAttributes() ?>>
<span id="el_lawyercontact_Primary">
<?php
$selwrk = (ConvertToBool($lawyercontact->Primary->CurrentValue)) ? " checked" : "";
?>
<input type="checkbox" data-table="lawyercontact" data-field="x_Primary" name="x_Primary[]" id="x_Primary[]" value="1"<?php echo $selwrk ?><?php echo $lawyercontact->Primary->editAttributes() ?>>
</span>
<?php echo $lawyercontact->Primary->CustomMsg ?></div></div>
	</div>
<?php } else { ?>
	<tr id="r_Primary">
		<td class="<?php echo $lawyercontact_add->TableLeftColumnClass ?>"><span id="elh_lawyercontact_Primary"><?php echo $lawyercontact->Primary->caption() ?><?php echo ($lawyercontact->Primary->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></span></td>
		<td<?php echo $lawyercontact->Primary->cellAttributes() ?>>
<span id="el_lawyercontact_Primary">
<?php
$selwrk = (ConvertToBool($lawyercontact->Primary->CurrentValue)) ? " checked" : "";
?>
<input type="checkbox" data-table="lawyercontact" data-field="x_Primary" name="x_Primary[]" id="x_Primary[]" value="1"<?php echo $selwrk ?><?php echo $lawyercontact->Primary->editAttributes() ?>>
</span>
<?php echo $lawyercontact->Primary->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php } ?>
<?php if ($lawyercontact_add->IsMobileOrModal) { ?>
</div><!-- /page* -->
<?php } else { ?>
</table><!-- /table* -->
<?php } ?>
<?php if (!$lawyercontact_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $lawyercontact_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 $lawyercontact_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
<?php if (!$lawyercontact_add->IsMobileOrModal) { ?>
</div><!-- /desktop -->
<?php } ?>
</form>
<?php
$lawyercontact_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
$lawyercontact_add->terminate();
?>
