<?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_ubigeos_edit = new kp_ubigeos_edit();

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

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

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

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

	// Form object
	currentPageID = ew.PAGE_ID = "edit";
	fkp_ubigeosedit = currentForm = new ew.Form("fkp_ubigeosedit", "edit");

	// Validate form
	fkp_ubigeosedit.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_ubigeos_edit->codubigeo->Required) { ?>
				elm = this.getElements("x" + infix + "_codubigeo");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_ubigeos_edit->codubigeo->caption(), $kp_ubigeos_edit->codubigeo->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ubigeos_edit->codruta->Required) { ?>
				elm = this.getElements("x" + infix + "_codruta");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_ubigeos_edit->codruta->caption(), $kp_ubigeos_edit->codruta->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_ubigeosedit.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_ubigeosedit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $kp_ubigeos_edit->showPageHeader(); ?>
<?php
$kp_ubigeos_edit->showMessage();
?>
<form name="fkp_ubigeosedit" id="fkp_ubigeosedit" class="<?php echo $kp_ubigeos_edit->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_ubigeos">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$kp_ubigeos_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($kp_ubigeos_edit->codubigeo->Visible) { // codubigeo ?>
	<div id="r_codubigeo" class="form-group row">
		<label id="elh_kp_ubigeos_codubigeo" for="x_codubigeo" class="<?php echo $kp_ubigeos_edit->LeftColumnClass ?>"><?php echo $kp_ubigeos_edit->codubigeo->caption() ?><?php echo $kp_ubigeos_edit->codubigeo->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ubigeos_edit->RightColumnClass ?>"><div <?php echo $kp_ubigeos_edit->codubigeo->cellAttributes() ?>>
<input type="text" data-table="kp_ubigeos" data-field="x_codubigeo" name="x_codubigeo" id="x_codubigeo" size="30" maxlength="20" placeholder="<?php echo HtmlEncode($kp_ubigeos_edit->codubigeo->getPlaceHolder()) ?>" value="<?php echo $kp_ubigeos_edit->codubigeo->EditValue ?>"<?php echo $kp_ubigeos_edit->codubigeo->editAttributes() ?>>
<input type="hidden" data-table="kp_ubigeos" data-field="x_codubigeo" name="o_codubigeo" id="o_codubigeo" value="<?php echo HtmlEncode($kp_ubigeos_edit->codubigeo->CurrentValue) ?>">
<?php echo $kp_ubigeos_edit->codubigeo->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ubigeos_edit->codruta->Visible) { // codruta ?>
	<div id="r_codruta" class="form-group row">
		<label id="elh_kp_ubigeos_codruta" for="x_codruta" class="<?php echo $kp_ubigeos_edit->LeftColumnClass ?>"><?php echo $kp_ubigeos_edit->codruta->caption() ?><?php echo $kp_ubigeos_edit->codruta->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ubigeos_edit->RightColumnClass ?>"><div <?php echo $kp_ubigeos_edit->codruta->cellAttributes() ?>>
<span id="el_kp_ubigeos_codruta">
<input type="text" data-table="kp_ubigeos" data-field="x_codruta" name="x_codruta" id="x_codruta" size="30" maxlength="5" placeholder="<?php echo HtmlEncode($kp_ubigeos_edit->codruta->getPlaceHolder()) ?>" value="<?php echo $kp_ubigeos_edit->codruta->EditValue ?>"<?php echo $kp_ubigeos_edit->codruta->editAttributes() ?>>
</span>
<?php echo $kp_ubigeos_edit->codruta->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_ubigeos_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_ubigeos_edit->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit"><?php echo $Language->phrase("SaveBtn") ?></button>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" data-href="<?php echo $kp_ubigeos_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_ubigeos_edit->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_ubigeos_edit->terminate();
?>