<?php
namespace PHPMaker2020\project2;

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

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

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

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

// Page Rendering event
$kp_logs_add->Page_Render();
?>
<?php include_once "header.php"; ?>
<script>
var fkp_logsadd, currentPageID;
loadjs.ready("head", function() {

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

	// Validate form
	fkp_logsadd.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 ($kp_logs_add->tipo->Required) { ?>
				elm = this.getElements("x" + infix + "_tipo");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->tipo->caption(), $kp_logs_add->tipo->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_logs_add->detalle->Required) { ?>
				elm = this.getElements("x" + infix + "_detalle");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->detalle->caption(), $kp_logs_add->detalle->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_logs_add->codlogin->Required) { ?>
				elm = this.getElements("x" + infix + "_codlogin");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->codlogin->caption(), $kp_logs_add->codlogin->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_logs_add->ip->Required) { ?>
				elm = this.getElements("x" + infix + "_ip");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->ip->caption(), $kp_logs_add->ip->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_logs_add->alerta->Required) { ?>
				elm = this.getElements("x" + infix + "_alerta[]");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->alerta->caption(), $kp_logs_add->alerta->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_logs_add->valoranterior->Required) { ?>
				elm = this.getElements("x" + infix + "_valoranterior");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->valoranterior->caption(), $kp_logs_add->valoranterior->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_logs_add->valoractual->Required) { ?>
				elm = this.getElements("x" + infix + "_valoractual");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_logs_add->valoractual->caption(), $kp_logs_add->valoractual->RequiredErrorMessage)) ?>");
			<?php } ?>

				// Call 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
	fkp_logsadd.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
	fkp_logsadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

	// Dynamic selection lists
	fkp_logsadd.lists["x_alerta[]"] = <?php echo $kp_logs_add->alerta->Lookup->toClientList($kp_logs_add) ?>;
	fkp_logsadd.lists["x_alerta[]"].options = <?php echo JsonEncode($kp_logs_add->alerta->options(FALSE, TRUE)) ?>;
	loadjs.done("fkp_logsadd");
});
</script>
<script>
loadjs.ready("head", function() {

	// Client script
	// Write your client script here, no need to add script tags.

});
</script>
<?php $kp_logs_add->showPageHeader(); ?>
<?php
$kp_logs_add->showMessage();
?>
<form name="fkp_logsadd" id="fkp_logsadd" class="<?php echo $kp_logs_add->FormClassName ?>" action="<?php echo CurrentPageName() ?>" method="post">
<?php if ($Page->CheckToken) { ?>
<input type="hidden" name="<?php echo Config("TOKEN_NAME") ?>" value="<?php echo $Page->Token ?>">
<?php } ?>
<input type="hidden" name="t" value="kp_logs">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$kp_logs_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($kp_logs_add->tipo->Visible) { // tipo ?>
	<div id="r_tipo" class="form-group row">
		<label id="elh_kp_logs_tipo" for="x_tipo" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->tipo->caption() ?><?php echo $kp_logs_add->tipo->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->tipo->cellAttributes() ?>>
<span id="el_kp_logs_tipo">
<input type="text" data-table="kp_logs" data-field="x_tipo" name="x_tipo" id="x_tipo" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($kp_logs_add->tipo->getPlaceHolder()) ?>" value="<?php echo $kp_logs_add->tipo->EditValue ?>"<?php echo $kp_logs_add->tipo->editAttributes() ?>>
</span>
<?php echo $kp_logs_add->tipo->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_logs_add->detalle->Visible) { // detalle ?>
	<div id="r_detalle" class="form-group row">
		<label id="elh_kp_logs_detalle" for="x_detalle" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->detalle->caption() ?><?php echo $kp_logs_add->detalle->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->detalle->cellAttributes() ?>>
<span id="el_kp_logs_detalle">
<textarea data-table="kp_logs" data-field="x_detalle" name="x_detalle" id="x_detalle" cols="35" rows="4" placeholder="<?php echo HtmlEncode($kp_logs_add->detalle->getPlaceHolder()) ?>"<?php echo $kp_logs_add->detalle->editAttributes() ?>><?php echo $kp_logs_add->detalle->EditValue ?></textarea>
</span>
<?php echo $kp_logs_add->detalle->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_logs_add->codlogin->Visible) { // codlogin ?>
	<div id="r_codlogin" class="form-group row">
		<label id="elh_kp_logs_codlogin" for="x_codlogin" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->codlogin->caption() ?><?php echo $kp_logs_add->codlogin->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->codlogin->cellAttributes() ?>>
<span id="el_kp_logs_codlogin">
<input type="text" data-table="kp_logs" data-field="x_codlogin" name="x_codlogin" id="x_codlogin" size="30" maxlength="12" placeholder="<?php echo HtmlEncode($kp_logs_add->codlogin->getPlaceHolder()) ?>" value="<?php echo $kp_logs_add->codlogin->EditValue ?>"<?php echo $kp_logs_add->codlogin->editAttributes() ?>>
</span>
<?php echo $kp_logs_add->codlogin->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_logs_add->ip->Visible) { // ip ?>
	<div id="r_ip" class="form-group row">
		<label id="elh_kp_logs_ip" for="x_ip" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->ip->caption() ?><?php echo $kp_logs_add->ip->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->ip->cellAttributes() ?>>
<span id="el_kp_logs_ip">
<input type="text" data-table="kp_logs" data-field="x_ip" name="x_ip" id="x_ip" size="30" maxlength="40" placeholder="<?php echo HtmlEncode($kp_logs_add->ip->getPlaceHolder()) ?>" value="<?php echo $kp_logs_add->ip->EditValue ?>"<?php echo $kp_logs_add->ip->editAttributes() ?>>
</span>
<?php echo $kp_logs_add->ip->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_logs_add->alerta->Visible) { // alerta ?>
	<div id="r_alerta" class="form-group row">
		<label id="elh_kp_logs_alerta" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->alerta->caption() ?><?php echo $kp_logs_add->alerta->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->alerta->cellAttributes() ?>>
<span id="el_kp_logs_alerta">
<?php
$selwrk = ConvertToBool($kp_logs_add->alerta->CurrentValue) ? " checked" : "";
?>
<div class="custom-control custom-checkbox d-inline-block">
	<input type="checkbox" class="custom-control-input" data-table="kp_logs" data-field="x_alerta" name="x_alerta[]" id="x_alerta[]" value="1"<?php echo $selwrk ?><?php echo $kp_logs_add->alerta->editAttributes() ?>>
	<label class="custom-control-label" for="x_alerta[]"></label>
</div>
</span>
<?php echo $kp_logs_add->alerta->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_logs_add->valoranterior->Visible) { // valoranterior ?>
	<div id="r_valoranterior" class="form-group row">
		<label id="elh_kp_logs_valoranterior" for="x_valoranterior" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->valoranterior->caption() ?><?php echo $kp_logs_add->valoranterior->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->valoranterior->cellAttributes() ?>>
<span id="el_kp_logs_valoranterior">
<textarea data-table="kp_logs" data-field="x_valoranterior" name="x_valoranterior" id="x_valoranterior" cols="35" rows="4" placeholder="<?php echo HtmlEncode($kp_logs_add->valoranterior->getPlaceHolder()) ?>"<?php echo $kp_logs_add->valoranterior->editAttributes() ?>><?php echo $kp_logs_add->valoranterior->EditValue ?></textarea>
</span>
<?php echo $kp_logs_add->valoranterior->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_logs_add->valoractual->Visible) { // valoractual ?>
	<div id="r_valoractual" class="form-group row">
		<label id="elh_kp_logs_valoractual" for="x_valoractual" class="<?php echo $kp_logs_add->LeftColumnClass ?>"><?php echo $kp_logs_add->valoractual->caption() ?><?php echo $kp_logs_add->valoractual->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_logs_add->RightColumnClass ?>"><div <?php echo $kp_logs_add->valoractual->cellAttributes() ?>>
<span id="el_kp_logs_valoractual">
<textarea data-table="kp_logs" data-field="x_valoractual" name="x_valoractual" id="x_valoractual" cols="35" rows="4" placeholder="<?php echo HtmlEncode($kp_logs_add->valoractual->getPlaceHolder()) ?>"<?php echo $kp_logs_add->valoractual->editAttributes() ?>><?php echo $kp_logs_add->valoractual->EditValue ?></textarea>
</span>
<?php echo $kp_logs_add->valoractual->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_logs_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_logs_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 $kp_logs_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_logs_add->showPageFooter();
if (Config("DEBUG"))
	echo GetDebugMessage();
?>
<script>
loadjs.ready("load", function() {

	// Startup script
	// Write your table-specific startup script here
	// console.log("page loaded");

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