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

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

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

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

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

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

// Validate form
fclients2addopt.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 ($clients2_addopt->ClientTypeID->Required) { ?>
			elm = this.getElements("x" + infix + "_ClientTypeID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $clients2->ClientTypeID->caption(), $clients2->ClientTypeID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_addopt->ClientGroupID->Required) { ?>
			elm = this.getElements("x" + infix + "_ClientGroupID");
			if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
				return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $clients2->ClientGroupID->caption(), $clients2->ClientGroupID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->WorkNature->caption(), $clients2->WorkNature->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->CompanyName->caption(), $clients2->CompanyName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->TitleID->caption(), $clients2->TitleID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->FirstName->caption(), $clients2->FirstName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->MiddleName->caption(), $clients2->MiddleName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->LastName->caption(), $clients2->LastName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->PartnersName->caption(), $clients2->PartnersName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->ContactPerson->caption(), $clients2->ContactPerson->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->JobTitle->caption(), $clients2->JobTitle->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->Notes->caption(), $clients2->Notes->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->Gender->caption(), $clients2->Gender->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients2_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", $clients2->NotesConv->caption(), $clients2->NotesConv->RequiredErrorMessage)) ?>");
		<?php } ?>

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

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

// Dynamic selection lists
fclients2addopt.lists["x_ClientTypeID"] = <?php echo $clients2_addopt->ClientTypeID->Lookup->toClientList() ?>;
fclients2addopt.lists["x_ClientTypeID"].options = <?php echo JsonEncode($clients2_addopt->ClientTypeID->lookupOptions()) ?>;
fclients2addopt.lists["x_ClientGroupID"] = <?php echo $clients2_addopt->ClientGroupID->Lookup->toClientList() ?>;
fclients2addopt.lists["x_ClientGroupID"].options = <?php echo JsonEncode($clients2_addopt->ClientGroupID->lookupOptions()) ?>;
fclients2addopt.autoSuggests["x_ClientGroupID"] = <?php echo json_encode(["data" => "ajax=autosuggest"]) ?>;
fclients2addopt.lists["x_TitleID"] = <?php echo $clients2_addopt->TitleID->Lookup->toClientList() ?>;
fclients2addopt.lists["x_TitleID"].options = <?php echo JsonEncode($clients2_addopt->TitleID->lookupOptions()) ?>;
fclients2addopt.lists["x_Gender"] = <?php echo $clients2_addopt->Gender->Lookup->toClientList() ?>;
fclients2addopt.lists["x_Gender"].options = <?php echo JsonEncode($clients2_addopt->Gender->options(FALSE, TRUE)) ?>;

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

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

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

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