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

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

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

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

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

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

// Validate form
fclientsaddopt.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 ($clients_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", $clients->ClientTypeID->caption(), $clients->ClientTypeID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->ClientGroupID->caption(), $clients->ClientGroupID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->TitleID->caption(), $clients->TitleID->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->FirstName->caption(), $clients->FirstName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->MiddleName->caption(), $clients->MiddleName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->LastName->caption(), $clients->LastName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->PartnersName->caption(), $clients->PartnersName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->CompanyName->caption(), $clients->CompanyName->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->ContactPerson->caption(), $clients->ContactPerson->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->WorkNature->caption(), $clients->WorkNature->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->JobTitle->caption(), $clients->JobTitle->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->Gender->caption(), $clients->Gender->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->Notes->caption(), $clients->Notes->RequiredErrorMessage)) ?>");
		<?php } ?>
		<?php if ($clients_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", $clients->NotesConv->caption(), $clients->NotesConv->RequiredErrorMessage)) ?>");
		<?php } ?>

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

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

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

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

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

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

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