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

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

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

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

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

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

	// Validate form
	fubigeo_peru_provincesadd.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 ($ubigeo_peru_provinces_add->id->Required) { ?>
				elm = this.getElements("x" + infix + "_id");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $ubigeo_peru_provinces_add->id->caption(), $ubigeo_peru_provinces_add->id->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($ubigeo_peru_provinces_add->name->Required) { ?>
				elm = this.getElements("x" + infix + "_name");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $ubigeo_peru_provinces_add->name->caption(), $ubigeo_peru_provinces_add->name->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($ubigeo_peru_provinces_add->department_id->Required) { ?>
				elm = this.getElements("x" + infix + "_department_id");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $ubigeo_peru_provinces_add->department_id->caption(), $ubigeo_peru_provinces_add->department_id->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
	fubigeo_peru_provincesadd.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
	fubigeo_peru_provincesadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $ubigeo_peru_provinces_add->showPageHeader(); ?>
<?php
$ubigeo_peru_provinces_add->showMessage();
?>
<form name="fubigeo_peru_provincesadd" id="fubigeo_peru_provincesadd" class="<?php echo $ubigeo_peru_provinces_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="ubigeo_peru_provinces">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$ubigeo_peru_provinces_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($ubigeo_peru_provinces_add->id->Visible) { // id ?>
	<div id="r_id" class="form-group row">
		<label id="elh_ubigeo_peru_provinces_id" for="x_id" class="<?php echo $ubigeo_peru_provinces_add->LeftColumnClass ?>"><?php echo $ubigeo_peru_provinces_add->id->caption() ?><?php echo $ubigeo_peru_provinces_add->id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $ubigeo_peru_provinces_add->RightColumnClass ?>"><div <?php echo $ubigeo_peru_provinces_add->id->cellAttributes() ?>>
<span id="el_ubigeo_peru_provinces_id">
<input type="text" data-table="ubigeo_peru_provinces" data-field="x_id" name="x_id" id="x_id" size="30" maxlength="4" placeholder="<?php echo HtmlEncode($ubigeo_peru_provinces_add->id->getPlaceHolder()) ?>" value="<?php echo $ubigeo_peru_provinces_add->id->EditValue ?>"<?php echo $ubigeo_peru_provinces_add->id->editAttributes() ?>>
</span>
<?php echo $ubigeo_peru_provinces_add->id->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($ubigeo_peru_provinces_add->name->Visible) { // name ?>
	<div id="r_name" class="form-group row">
		<label id="elh_ubigeo_peru_provinces_name" for="x_name" class="<?php echo $ubigeo_peru_provinces_add->LeftColumnClass ?>"><?php echo $ubigeo_peru_provinces_add->name->caption() ?><?php echo $ubigeo_peru_provinces_add->name->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $ubigeo_peru_provinces_add->RightColumnClass ?>"><div <?php echo $ubigeo_peru_provinces_add->name->cellAttributes() ?>>
<span id="el_ubigeo_peru_provinces_name">
<input type="text" data-table="ubigeo_peru_provinces" data-field="x_name" name="x_name" id="x_name" size="30" maxlength="45" placeholder="<?php echo HtmlEncode($ubigeo_peru_provinces_add->name->getPlaceHolder()) ?>" value="<?php echo $ubigeo_peru_provinces_add->name->EditValue ?>"<?php echo $ubigeo_peru_provinces_add->name->editAttributes() ?>>
</span>
<?php echo $ubigeo_peru_provinces_add->name->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($ubigeo_peru_provinces_add->department_id->Visible) { // department_id ?>
	<div id="r_department_id" class="form-group row">
		<label id="elh_ubigeo_peru_provinces_department_id" for="x_department_id" class="<?php echo $ubigeo_peru_provinces_add->LeftColumnClass ?>"><?php echo $ubigeo_peru_provinces_add->department_id->caption() ?><?php echo $ubigeo_peru_provinces_add->department_id->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $ubigeo_peru_provinces_add->RightColumnClass ?>"><div <?php echo $ubigeo_peru_provinces_add->department_id->cellAttributes() ?>>
<span id="el_ubigeo_peru_provinces_department_id">
<input type="text" data-table="ubigeo_peru_provinces" data-field="x_department_id" name="x_department_id" id="x_department_id" size="30" maxlength="2" placeholder="<?php echo HtmlEncode($ubigeo_peru_provinces_add->department_id->getPlaceHolder()) ?>" value="<?php echo $ubigeo_peru_provinces_add->department_id->EditValue ?>"<?php echo $ubigeo_peru_provinces_add->department_id->editAttributes() ?>>
</span>
<?php echo $ubigeo_peru_provinces_add->department_id->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$ubigeo_peru_provinces_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $ubigeo_peru_provinces_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 $ubigeo_peru_provinces_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$ubigeo_peru_provinces_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
$ubigeo_peru_provinces_add->terminate();
?>