<?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_codbarras_edit = new kp_codbarras_edit();

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

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

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

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

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

	// Validate form
	fkp_codbarrasedit.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_codbarras_edit->id_reg->Required) { ?>
				elm = this.getElements("x" + infix + "_id_reg");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_codbarras_edit->id_reg->caption(), $kp_codbarras_edit->id_reg->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_codbarras_edit->idempresa->Required) { ?>
				elm = this.getElements("x" + infix + "_idempresa");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_codbarras_edit->idempresa->caption(), $kp_codbarras_edit->idempresa->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_idempresa");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_codbarras_edit->idempresa->errorMessage()) ?>");
			<?php if ($kp_codbarras_edit->idarticulo->Required) { ?>
				elm = this.getElements("x" + infix + "_idarticulo");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_codbarras_edit->idarticulo->caption(), $kp_codbarras_edit->idarticulo->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_codbarras_edit->codbarra->Required) { ?>
				elm = this.getElements("x" + infix + "_codbarra");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_codbarras_edit->codbarra->caption(), $kp_codbarras_edit->codbarra->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_codbarrasedit.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_codbarrasedit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $kp_codbarras_edit->showPageHeader(); ?>
<?php
$kp_codbarras_edit->showMessage();
?>
<form name="fkp_codbarrasedit" id="fkp_codbarrasedit" class="<?php echo $kp_codbarras_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_codbarras">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$kp_codbarras_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($kp_codbarras_edit->id_reg->Visible) { // id_reg ?>
	<div id="r_id_reg" class="form-group row">
		<label id="elh_kp_codbarras_id_reg" class="<?php echo $kp_codbarras_edit->LeftColumnClass ?>"><?php echo $kp_codbarras_edit->id_reg->caption() ?><?php echo $kp_codbarras_edit->id_reg->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_codbarras_edit->RightColumnClass ?>"><div <?php echo $kp_codbarras_edit->id_reg->cellAttributes() ?>>
<span id="el_kp_codbarras_id_reg">
<span<?php echo $kp_codbarras_edit->id_reg->viewAttributes() ?>><input type="text" readonly class="form-control-plaintext" value="<?php echo HtmlEncode(RemoveHtml($kp_codbarras_edit->id_reg->EditValue)) ?>"></span>
</span>
<input type="hidden" data-table="kp_codbarras" data-field="x_id_reg" name="x_id_reg" id="x_id_reg" value="<?php echo HtmlEncode($kp_codbarras_edit->id_reg->CurrentValue) ?>">
<?php echo $kp_codbarras_edit->id_reg->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_codbarras_edit->idempresa->Visible) { // idempresa ?>
	<div id="r_idempresa" class="form-group row">
		<label id="elh_kp_codbarras_idempresa" for="x_idempresa" class="<?php echo $kp_codbarras_edit->LeftColumnClass ?>"><?php echo $kp_codbarras_edit->idempresa->caption() ?><?php echo $kp_codbarras_edit->idempresa->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_codbarras_edit->RightColumnClass ?>"><div <?php echo $kp_codbarras_edit->idempresa->cellAttributes() ?>>
<span id="el_kp_codbarras_idempresa">
<input type="text" data-table="kp_codbarras" data-field="x_idempresa" name="x_idempresa" id="x_idempresa" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_codbarras_edit->idempresa->getPlaceHolder()) ?>" value="<?php echo $kp_codbarras_edit->idempresa->EditValue ?>"<?php echo $kp_codbarras_edit->idempresa->editAttributes() ?>>
</span>
<?php echo $kp_codbarras_edit->idempresa->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_codbarras_edit->idarticulo->Visible) { // idarticulo ?>
	<div id="r_idarticulo" class="form-group row">
		<label id="elh_kp_codbarras_idarticulo" for="x_idarticulo" class="<?php echo $kp_codbarras_edit->LeftColumnClass ?>"><?php echo $kp_codbarras_edit->idarticulo->caption() ?><?php echo $kp_codbarras_edit->idarticulo->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_codbarras_edit->RightColumnClass ?>"><div <?php echo $kp_codbarras_edit->idarticulo->cellAttributes() ?>>
<span id="el_kp_codbarras_idarticulo">
<input type="text" data-table="kp_codbarras" data-field="x_idarticulo" name="x_idarticulo" id="x_idarticulo" size="30" maxlength="20" placeholder="<?php echo HtmlEncode($kp_codbarras_edit->idarticulo->getPlaceHolder()) ?>" value="<?php echo $kp_codbarras_edit->idarticulo->EditValue ?>"<?php echo $kp_codbarras_edit->idarticulo->editAttributes() ?>>
</span>
<?php echo $kp_codbarras_edit->idarticulo->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_codbarras_edit->codbarra->Visible) { // codbarra ?>
	<div id="r_codbarra" class="form-group row">
		<label id="elh_kp_codbarras_codbarra" for="x_codbarra" class="<?php echo $kp_codbarras_edit->LeftColumnClass ?>"><?php echo $kp_codbarras_edit->codbarra->caption() ?><?php echo $kp_codbarras_edit->codbarra->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_codbarras_edit->RightColumnClass ?>"><div <?php echo $kp_codbarras_edit->codbarra->cellAttributes() ?>>
<span id="el_kp_codbarras_codbarra">
<input type="text" data-table="kp_codbarras" data-field="x_codbarra" name="x_codbarra" id="x_codbarra" size="30" maxlength="50" placeholder="<?php echo HtmlEncode($kp_codbarras_edit->codbarra->getPlaceHolder()) ?>" value="<?php echo $kp_codbarras_edit->codbarra->EditValue ?>"<?php echo $kp_codbarras_edit->codbarra->editAttributes() ?>>
</span>
<?php echo $kp_codbarras_edit->codbarra->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_codbarras_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_codbarras_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_codbarras_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_codbarras_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_codbarras_edit->terminate();
?>