<?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_tablaweb_add = new kp_tablaweb_add();

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

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

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

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

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

	// Validate form
	fkp_tablawebadd.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_tablaweb_add->nomwebta->Required) { ?>
				elm = this.getElements("x" + infix + "_nomwebta");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_tablaweb_add->nomwebta->caption(), $kp_tablaweb_add->nomwebta->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_tablaweb_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_tablaweb_add->estado->caption(), $kp_tablaweb_add->estado->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_tablaweb_add->estado->errorMessage()) ?>");
			<?php if ($kp_tablaweb_add->ordenar->Required) { ?>
				elm = this.getElements("x" + infix + "_ordenar");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_tablaweb_add->ordenar->caption(), $kp_tablaweb_add->ordenar->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_ordenar");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_tablaweb_add->ordenar->errorMessage()) ?>");
			<?php if ($kp_tablaweb_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_tablaweb_add->icon->caption(), $kp_tablaweb_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_tablawebadd.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_tablawebadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $kp_tablaweb_add->showPageHeader(); ?>
<?php
$kp_tablaweb_add->showMessage();
?>
<form name="fkp_tablawebadd" id="fkp_tablawebadd" class="<?php echo $kp_tablaweb_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_tablaweb">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$kp_tablaweb_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($kp_tablaweb_add->nomwebta->Visible) { // nomwebta ?>
	<div id="r_nomwebta" class="form-group row">
		<label id="elh_kp_tablaweb_nomwebta" for="x_nomwebta" class="<?php echo $kp_tablaweb_add->LeftColumnClass ?>"><?php echo $kp_tablaweb_add->nomwebta->caption() ?><?php echo $kp_tablaweb_add->nomwebta->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_tablaweb_add->RightColumnClass ?>"><div <?php echo $kp_tablaweb_add->nomwebta->cellAttributes() ?>>
<span id="el_kp_tablaweb_nomwebta">
<input type="text" data-table="kp_tablaweb" data-field="x_nomwebta" name="x_nomwebta" id="x_nomwebta" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($kp_tablaweb_add->nomwebta->getPlaceHolder()) ?>" value="<?php echo $kp_tablaweb_add->nomwebta->EditValue ?>"<?php echo $kp_tablaweb_add->nomwebta->editAttributes() ?>>
</span>
<?php echo $kp_tablaweb_add->nomwebta->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_tablaweb_add->estado->Visible) { // estado ?>
	<div id="r_estado" class="form-group row">
		<label id="elh_kp_tablaweb_estado" for="x_estado" class="<?php echo $kp_tablaweb_add->LeftColumnClass ?>"><?php echo $kp_tablaweb_add->estado->caption() ?><?php echo $kp_tablaweb_add->estado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_tablaweb_add->RightColumnClass ?>"><div <?php echo $kp_tablaweb_add->estado->cellAttributes() ?>>
<span id="el_kp_tablaweb_estado">
<input type="text" data-table="kp_tablaweb" data-field="x_estado" name="x_estado" id="x_estado" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_tablaweb_add->estado->getPlaceHolder()) ?>" value="<?php echo $kp_tablaweb_add->estado->EditValue ?>"<?php echo $kp_tablaweb_add->estado->editAttributes() ?>>
</span>
<?php echo $kp_tablaweb_add->estado->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_tablaweb_add->ordenar->Visible) { // ordenar ?>
	<div id="r_ordenar" class="form-group row">
		<label id="elh_kp_tablaweb_ordenar" for="x_ordenar" class="<?php echo $kp_tablaweb_add->LeftColumnClass ?>"><?php echo $kp_tablaweb_add->ordenar->caption() ?><?php echo $kp_tablaweb_add->ordenar->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_tablaweb_add->RightColumnClass ?>"><div <?php echo $kp_tablaweb_add->ordenar->cellAttributes() ?>>
<span id="el_kp_tablaweb_ordenar">
<input type="text" data-table="kp_tablaweb" data-field="x_ordenar" name="x_ordenar" id="x_ordenar" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_tablaweb_add->ordenar->getPlaceHolder()) ?>" value="<?php echo $kp_tablaweb_add->ordenar->EditValue ?>"<?php echo $kp_tablaweb_add->ordenar->editAttributes() ?>>
</span>
<?php echo $kp_tablaweb_add->ordenar->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_tablaweb_add->icon->Visible) { // icon ?>
	<div id="r_icon" class="form-group row">
		<label id="elh_kp_tablaweb_icon" for="x_icon" class="<?php echo $kp_tablaweb_add->LeftColumnClass ?>"><?php echo $kp_tablaweb_add->icon->caption() ?><?php echo $kp_tablaweb_add->icon->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_tablaweb_add->RightColumnClass ?>"><div <?php echo $kp_tablaweb_add->icon->cellAttributes() ?>>
<span id="el_kp_tablaweb_icon">
<input type="text" data-table="kp_tablaweb" data-field="x_icon" name="x_icon" id="x_icon" size="30" maxlength="110" placeholder="<?php echo HtmlEncode($kp_tablaweb_add->icon->getPlaceHolder()) ?>" value="<?php echo $kp_tablaweb_add->icon->EditValue ?>"<?php echo $kp_tablaweb_add->icon->editAttributes() ?>>
</span>
<?php echo $kp_tablaweb_add->icon->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_tablaweb_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_tablaweb_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_tablaweb_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_tablaweb_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_tablaweb_add->terminate();
?>