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

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

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

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

// Page Rendering event
$litigants_addopt->Page_Render();
?>
<script>

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

// Validate form
flitigantsaddopt.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 ($litigants_addopt->LitigantTypeID->Required) { ?>
			elm = this.getElements("x" + infix + "_LitigantTypeID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->LitigantTypeID->caption(), $litigants->LitigantTypeID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->LitigantGroupID->Required) { ?>
			elm = this.getElements("x" + infix + "_LitigantGroupID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->LitigantGroupID->caption(), $litigants->LitigantGroupID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->WorkNature->Required) { ?>
			elm = this.getElements("x" + infix + "_WorkNature");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->WorkNature->caption(), $litigants->WorkNature->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->TitleID->Required) { ?>
			elm = this.getElements("x" + infix + "_TitleID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->TitleID->caption(), $litigants->TitleID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->FirstName->Required) { ?>
			elm = this.getElements("x" + infix + "_FirstName");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->FirstName->caption(), $litigants->FirstName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->MiddleName->Required) { ?>
			elm = this.getElements("x" + infix + "_MiddleName");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->MiddleName->caption(), $litigants->MiddleName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->LastName->Required) { ?>
			elm = this.getElements("x" + infix + "_LastName");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->LastName->caption(), $litigants->LastName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->PartnersName->Required) { ?>
			elm = this.getElements("x" + infix + "_PartnersName");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->PartnersName->caption(), $litigants->PartnersName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->CompanyName->Required) { ?>
			elm = this.getElements("x" + infix + "_CompanyName");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->CompanyName->caption(), $litigants->CompanyName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->ContactPerson->Required) { ?>
			elm = this.getElements("x" + infix + "_ContactPerson");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->ContactPerson->caption(), $litigants->ContactPerson->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->JobTitle->Required) { ?>
			elm = this.getElements("x" + infix + "_JobTitle");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->JobTitle->caption(), $litigants->JobTitle->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->Gender->Required) { ?>
			elm = this.getElements("x" + infix + "_Gender");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->Gender->caption(), $litigants->Gender->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->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", $litigants->Notes->caption(), $litigants->Notes->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($litigants_addopt->NotesConv->Required) { ?>
			elm = this.getElements("x" + infix + "_NotesConv");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $litigants->NotesConv->caption(), $litigants->NotesConv->RequiredErrorMessage)) ?>");
		<?php } ?>

			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}
	return true;
}

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

// Dynamic selection lists
flitigantsaddopt.lists["x_LitigantTypeID"] = <?php echo $litigants_addopt->LitigantTypeID->Lookup->toClientList() ?>;
flitigantsaddopt.lists["x_LitigantTypeID"].options = <?php echo JsonEncode($litigants_addopt->LitigantTypeID->lookupOptions()) ?>;
flitigantsaddopt.lists["x_LitigantGroupID"] = <?php echo $litigants_addopt->LitigantGroupID->Lookup->toClientList() ?>;
flitigantsaddopt.lists["x_LitigantGroupID"].options = <?php echo JsonEncode($litigants_addopt->LitigantGroupID->lookupOptions()) ?>;
flitigantsaddopt.autoSuggests["x_LitigantGroupID"] = <?php echo json_encode(["data" => "ajax=autosuggest"]) ?>;
flitigantsaddopt.lists["x_TitleID"] = <?php echo $litigants_addopt->TitleID->Lookup->toClientList() ?>;
flitigantsaddopt.lists["x_TitleID"].options = <?php echo JsonEncode($litigants_addopt->TitleID->lookupOptions()) ?>;
flitigantsaddopt.lists["x_Gender"] = <?php echo $litigants_addopt->Gender->Lookup->toClientList() ?>;
flitigantsaddopt.lists["x_Gender"].options = <?php echo JsonEncode($litigants_addopt->Gender->options(FALSE, TRUE)) ?>;

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

// Write your client script here, no need to add script tags.
</script>
<?php $litigants_addopt->showPageHeader(); ?>
<?php
$litigants_addopt->showMessage();
?>
<form name="flitigantsaddopt" id="flitigantsaddopt" class="ew-form ew-horizontal" action="<?php echo API_URL ?>" method="post">
<?php //if ($litigants_addopt->CheckToken) { ?>
<input type="hidden" name="<?php echo TOKEN_NAME ?>" value="<?php echo $litigants_addopt->Token ?>">
<?php //} ?>
<input type="hidden" name="<?php echo API_ACTION_NAME ?>" id="<?php echo API_ACTION_NAME ?>" value="<?php echo API_ADD_ACTION ?>">
<input type="hidden" name="<?php echo API_OBJECT_NAME ?>" id="<?php echo API_OBJECT_NAME ?>" value="<?php echo $litigants_addopt->TableVar ?>">
<?php if ($litigants->LitigantTypeID->Visible) { // LitigantTypeID ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_LitigantTypeID"><?php echo $litigants->LitigantTypeID->caption() ?><?php echo ($litigants->LitigantTypeID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="litigants" data-field="x_LitigantTypeID" data-value-separator="<?php echo $litigants->LitigantTypeID->displayValueSeparatorAttribute() ?>" id="x_LitigantTypeID" name="x_LitigantTypeID"<?php echo $litigants->LitigantTypeID->editAttributes() ?>>
		<?php echo $litigants->LitigantTypeID->selectOptionListHtml("x_LitigantTypeID") ?>
	</select>
</div>
<?php echo $litigants->LitigantTypeID->Lookup->getParamTag("p_x_LitigantTypeID") ?>
</div>
	</div>
<?php } ?>
<?php if ($litigants->LitigantGroupID->Visible) { // LitigantGroupID ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label"><?php echo $litigants->LitigantGroupID->caption() ?><?php echo ($litigants->LitigantGroupID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<?php
$wrkonchange = "" . trim(@$litigants->LitigantGroupID->EditAttrs["onchange"]);
if (trim($wrkonchange) <> "") $wrkonchange = " onchange=\"" . JsEncode($wrkonchange) . "\"";
$litigants->LitigantGroupID->EditAttrs["onchange"] = "";
?>
<span id="as_x_LitigantGroupID" class="text-nowrap" style="z-index: 8970">
	<div class="input-group mb-3">
		<input type="text" class="form-control" name="sv_x_LitigantGroupID" id="sv_x_LitigantGroupID" value="<?php echo RemoveHtml($litigants->LitigantGroupID->EditValue) ?>" size="30" placeholder="<?php echo HtmlEncode($litigants->LitigantGroupID->getPlaceHolder()) ?>" data-placeholder="<?php echo HtmlEncode($litigants->LitigantGroupID->getPlaceHolder()) ?>"<?php echo $litigants->LitigantGroupID->editAttributes() ?>>
		<div class="input-group-append">
			<button type="button" title="<?php echo HtmlEncode(str_replace("%s", RemoveHtml($litigants->LitigantGroupID->caption()), $Language->phrase("LookupLink", TRUE))) ?>" onclick="ew.modalLookupShow({lnk:this,el:'x_LitigantGroupID',m:0,n:10,srch:false});" class="ew-lookup-btn btn btn-default"<?php echo (($litigants->LitigantGroupID->ReadOnly || $litigants->LitigantGroupID->Disabled) ? " disabled" : "")?>><i class="fa fa-search ew-icon"></i></button>
		</div>
	</div>
</span>
<input type="hidden" data-table="litigants" data-field="x_LitigantGroupID" data-multiple="0" data-lookup="1" data-value-separator="<?php echo $litigants->LitigantGroupID->displayValueSeparatorAttribute() ?>" name="x_LitigantGroupID" id="x_LitigantGroupID" value="<?php echo HtmlEncode($litigants->LitigantGroupID->CurrentValue) ?>"<?php echo $wrkonchange ?>>
<script>
flitigantsaddopt.createAutoSuggest({"id":"x_LitigantGroupID","forceSelect":true});
</script>
<?php echo $litigants->LitigantGroupID->Lookup->getParamTag("p_x_LitigantGroupID") ?>
</div>
	</div>
<?php } ?>
<?php if ($litigants->WorkNature->Visible) { // WorkNature ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_WorkNature"><?php echo $litigants->WorkNature->caption() ?><?php echo ($litigants->WorkNature->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_WorkNature" name="x_WorkNature" id="x_WorkNature" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($litigants->WorkNature->getPlaceHolder()) ?>" value="<?php echo $litigants->WorkNature->EditValue ?>"<?php echo $litigants->WorkNature->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->TitleID->Visible) { // TitleID ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_TitleID"><?php echo $litigants->TitleID->caption() ?><?php echo ($litigants->TitleID->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<div class="input-group">
	<select class="custom-select ew-custom-select" data-table="litigants" data-field="x_TitleID" data-value-separator="<?php echo $litigants->TitleID->displayValueSeparatorAttribute() ?>" id="x_TitleID" name="x_TitleID"<?php echo $litigants->TitleID->editAttributes() ?>>
		<?php echo $litigants->TitleID->selectOptionListHtml("x_TitleID") ?>
	</select>
</div>
<?php echo $litigants->TitleID->Lookup->getParamTag("p_x_TitleID") ?>
</div>
	</div>
<?php } ?>
<?php if ($litigants->FirstName->Visible) { // FirstName ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_FirstName"><?php echo $litigants->FirstName->caption() ?><?php echo ($litigants->FirstName->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_FirstName" name="x_FirstName" id="x_FirstName" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($litigants->FirstName->getPlaceHolder()) ?>" value="<?php echo $litigants->FirstName->EditValue ?>"<?php echo $litigants->FirstName->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->MiddleName->Visible) { // MiddleName ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_MiddleName"><?php echo $litigants->MiddleName->caption() ?><?php echo ($litigants->MiddleName->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_MiddleName" name="x_MiddleName" id="x_MiddleName" size="30" maxlength="30" placeholder="<?php echo HtmlEncode($litigants->MiddleName->getPlaceHolder()) ?>" value="<?php echo $litigants->MiddleName->EditValue ?>"<?php echo $litigants->MiddleName->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->LastName->Visible) { // LastName ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_LastName"><?php echo $litigants->LastName->caption() ?><?php echo ($litigants->LastName->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_LastName" name="x_LastName" id="x_LastName" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($litigants->LastName->getPlaceHolder()) ?>" value="<?php echo $litigants->LastName->EditValue ?>"<?php echo $litigants->LastName->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->PartnersName->Visible) { // PartnersName ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_PartnersName"><?php echo $litigants->PartnersName->caption() ?><?php echo ($litigants->PartnersName->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_PartnersName" name="x_PartnersName" id="x_PartnersName" size="30" maxlength="100" placeholder="<?php echo HtmlEncode($litigants->PartnersName->getPlaceHolder()) ?>" value="<?php echo $litigants->PartnersName->EditValue ?>"<?php echo $litigants->PartnersName->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->CompanyName->Visible) { // CompanyName ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_CompanyName"><?php echo $litigants->CompanyName->caption() ?><?php echo ($litigants->CompanyName->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_CompanyName" name="x_CompanyName" id="x_CompanyName" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($litigants->CompanyName->getPlaceHolder()) ?>" value="<?php echo $litigants->CompanyName->EditValue ?>"<?php echo $litigants->CompanyName->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->ContactPerson->Visible) { // ContactPerson ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_ContactPerson"><?php echo $litigants->ContactPerson->caption() ?><?php echo ($litigants->ContactPerson->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_ContactPerson" name="x_ContactPerson" id="x_ContactPerson" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($litigants->ContactPerson->getPlaceHolder()) ?>" value="<?php echo $litigants->ContactPerson->EditValue ?>"<?php echo $litigants->ContactPerson->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->JobTitle->Visible) { // JobTitle ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_JobTitle"><?php echo $litigants->JobTitle->caption() ?><?php echo ($litigants->JobTitle->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_JobTitle" name="x_JobTitle" id="x_JobTitle" size="30" maxlength="25" placeholder="<?php echo HtmlEncode($litigants->JobTitle->getPlaceHolder()) ?>" value="<?php echo $litigants->JobTitle->EditValue ?>"<?php echo $litigants->JobTitle->editAttributes() ?>>
</div>
	</div>
<?php } ?>
<?php if ($litigants->Gender->Visible) { // Gender ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label"><?php echo $litigants->Gender->caption() ?><?php echo ($litigants->Gender->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<div id="tp_x_Gender" class="ew-template"><input type="radio" class="form-check-input" data-table="litigants" data-field="x_Gender" data-value-separator="<?php echo $litigants->Gender->displayValueSeparatorAttribute() ?>" name="x_Gender" id="x_Gender" value="{value}"<?php echo $litigants->Gender->editAttributes() ?>></div>
<div id="dsl_x_Gender" data-repeatcolumn="5" class="ew-item-list d-none"><div>
<?php echo $litigants->Gender->radioButtonListHtml(FALSE, "x_Gender") ?>
</div></div>
</div>
	</div>
<?php } ?>
<?php if ($litigants->Notes->Visible) { // Notes ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_Notes"><?php echo $litigants->Notes->caption() ?><?php echo ($litigants->Notes->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<textarea data-table="litigants" data-field="x_Notes" name="x_Notes" id="x_Notes" cols="35" rows="4" placeholder="<?php echo HtmlEncode($litigants->Notes->getPlaceHolder()) ?>"<?php echo $litigants->Notes->editAttributes() ?>><?php echo $litigants->Notes->EditValue ?></textarea>
</div>
	</div>
<?php } ?>
<?php if ($litigants->NotesConv->Visible) { // NotesConv ?>
	<div class="form-group row">
		<label class="col-sm-2 col-form-label ew-label" for="x_NotesConv"><?php echo $litigants->NotesConv->caption() ?><?php echo ($litigants->NotesConv->Required) ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="col-sm-10">
<input type="text" data-table="litigants" data-field="x_NotesConv" name="x_NotesConv" id="x_NotesConv" size="30" maxlength="200" placeholder="<?php echo HtmlEncode($litigants->NotesConv->getPlaceHolder()) ?>" value="<?php echo $litigants->NotesConv->EditValue ?>"<?php echo $litigants->NotesConv->editAttributes() ?>>
</div>
	</div>
<?php } ?>
</form>
<?php
$litigants_addopt->showPageFooter();
if (DEBUG_ENABLED)
	echo GetDebugMessage();
?>
<script>

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

</script>
<?php
$litigants_addopt->terminate();
?>
