<?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_modulos_add = new kp_modulos_add();

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

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

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

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

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

	// Validate form
	fkp_modulosadd.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_modulos_add->nommodulo->Required) { ?>
				elm = this.getElements("x" + infix + "_nommodulo");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_modulos_add->nommodulo->caption(), $kp_modulos_add->nommodulo->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_modulos_add->modulo->Required) { ?>
				elm = this.getElements("x" + infix + "_modulo");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_modulos_add->modulo->caption(), $kp_modulos_add->modulo->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_modulos_add->estado->Required) { ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_modulos_add->estado->caption(), $kp_modulos_add->estado->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_modulos_add->estado->errorMessage()) ?>");
			<?php if ($kp_modulos_add->idmodulog->Required) { ?>
				elm = this.getElements("x" + infix + "_idmodulog");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_modulos_add->idmodulog->caption(), $kp_modulos_add->idmodulog->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_idmodulog");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_modulos_add->idmodulog->errorMessage()) ?>");
			<?php if ($kp_modulos_add->icon->Required) { ?>
				elm = this.getElements("x" + infix + "_icon");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_modulos_add->icon->caption(), $kp_modulos_add->icon->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_modulosadd.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_modulosadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

	// Dynamic selection lists
	loadjs.done("fkp_modulosadd");
});
</script>
<script>
loadjs.ready("head", function() {

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

});
</script>
<?php $kp_modulos_add->showPageHeader(); ?>
<?php
$kp_modulos_add->showMessage();
?>
<form name="fkp_modulosadd" id="fkp_modulosadd" class="<?php echo $kp_modulos_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_modulos">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$kp_modulos_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($kp_modulos_add->nommodulo->Visible) { // nommodulo ?>
	<div id="r_nommodulo" class="form-group row">
		<label id="elh_kp_modulos_nommodulo" for="x_nommodulo" class="<?php echo $kp_modulos_add->LeftColumnClass ?>"><?php echo $kp_modulos_add->nommodulo->caption() ?><?php echo $kp_modulos_add->nommodulo->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_modulos_add->RightColumnClass ?>"><div <?php echo $kp_modulos_add->nommodulo->cellAttributes() ?>>
<span id="el_kp_modulos_nommodulo">
<input type="text" data-table="kp_modulos" data-field="x_nommodulo" name="x_nommodulo" id="x_nommodulo" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($kp_modulos_add->nommodulo->getPlaceHolder()) ?>" value="<?php echo $kp_modulos_add->nommodulo->EditValue ?>"<?php echo $kp_modulos_add->nommodulo->editAttributes() ?>>
</span>
<?php echo $kp_modulos_add->nommodulo->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_modulos_add->modulo->Visible) { // modulo ?>
	<div id="r_modulo" class="form-group row">
		<label id="elh_kp_modulos_modulo" for="x_modulo" class="<?php echo $kp_modulos_add->LeftColumnClass ?>"><?php echo $kp_modulos_add->modulo->caption() ?><?php echo $kp_modulos_add->modulo->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_modulos_add->RightColumnClass ?>"><div <?php echo $kp_modulos_add->modulo->cellAttributes() ?>>
<span id="el_kp_modulos_modulo">
<input type="text" data-table="kp_modulos" data-field="x_modulo" name="x_modulo" id="x_modulo" size="30" maxlength="200" placeholder="<?php echo HtmlEncode($kp_modulos_add->modulo->getPlaceHolder()) ?>" value="<?php echo $kp_modulos_add->modulo->EditValue ?>"<?php echo $kp_modulos_add->modulo->editAttributes() ?>>
</span>
<?php echo $kp_modulos_add->modulo->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_modulos_add->estado->Visible) { // estado ?>
	<div id="r_estado" class="form-group row">
		<label id="elh_kp_modulos_estado" for="x_estado" class="<?php echo $kp_modulos_add->LeftColumnClass ?>"><?php echo $kp_modulos_add->estado->caption() ?><?php echo $kp_modulos_add->estado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_modulos_add->RightColumnClass ?>"><div <?php echo $kp_modulos_add->estado->cellAttributes() ?>>
<span id="el_kp_modulos_estado">
<input type="text" data-table="kp_modulos" data-field="x_estado" name="x_estado" id="x_estado" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_modulos_add->estado->getPlaceHolder()) ?>" value="<?php echo $kp_modulos_add->estado->EditValue ?>"<?php echo $kp_modulos_add->estado->editAttributes() ?>>
</span>
<?php echo $kp_modulos_add->estado->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_modulos_add->idmodulog->Visible) { // idmodulog ?>
	<div id="r_idmodulog" class="form-group row">
		<label id="elh_kp_modulos_idmodulog" for="x_idmodulog" class="<?php echo $kp_modulos_add->LeftColumnClass ?>"><?php echo $kp_modulos_add->idmodulog->caption() ?><?php echo $kp_modulos_add->idmodulog->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_modulos_add->RightColumnClass ?>"><div <?php echo $kp_modulos_add->idmodulog->cellAttributes() ?>>
<span id="el_kp_modulos_idmodulog">
<input type="text" data-table="kp_modulos" data-field="x_idmodulog" name="x_idmodulog" id="x_idmodulog" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_modulos_add->idmodulog->getPlaceHolder()) ?>" value="<?php echo $kp_modulos_add->idmodulog->EditValue ?>"<?php echo $kp_modulos_add->idmodulog->editAttributes() ?>>
</span>
<?php echo $kp_modulos_add->idmodulog->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_modulos_add->icon->Visible) { // icon ?>
	<div id="r_icon" class="form-group row">
		<label id="elh_kp_modulos_icon" for="x_icon" class="<?php echo $kp_modulos_add->LeftColumnClass ?>"><?php echo $kp_modulos_add->icon->caption() ?><?php echo $kp_modulos_add->icon->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_modulos_add->RightColumnClass ?>"><div <?php echo $kp_modulos_add->icon->cellAttributes() ?>>
<span id="el_kp_modulos_icon">
<input type="text" data-table="kp_modulos" data-field="x_icon" name="x_icon" id="x_icon" size="30" maxlength="110" placeholder="<?php echo HtmlEncode($kp_modulos_add->icon->getPlaceHolder()) ?>" value="<?php echo $kp_modulos_add->icon->EditValue ?>"<?php echo $kp_modulos_add->icon->editAttributes() ?>>
</span>
<?php echo $kp_modulos_add->icon->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_modulos_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_modulos_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_modulos_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_modulos_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_modulos_add->terminate();
?>