<?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_ordenes_edit = new kp_ordenes_edit();

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

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

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

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

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

	// Validate form
	fkp_ordenesedit.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_ordenes_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_ordenes_edit->id_reg->caption(), $kp_ordenes_edit->id_reg->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_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_ordenes_edit->idempresa->caption(), $kp_ordenes_edit->idempresa->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_edit->numcompra->Required) { ?>
				elm = this.getElements("x" + infix + "_numcompra");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_ordenes_edit->numcompra->caption(), $kp_ordenes_edit->numcompra->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_edit->fecha->Required) { ?>
				elm = this.getElements("x" + infix + "_fecha");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_ordenes_edit->fecha->caption(), $kp_ordenes_edit->fecha->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_fecha");
				if (elm && !ew.checkDateDef(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_ordenes_edit->fecha->errorMessage()) ?>");
			<?php if ($kp_ordenes_edit->tipocompra->Required) { ?>
				elm = this.getElements("x" + infix + "_tipocompra");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_ordenes_edit->tipocompra->caption(), $kp_ordenes_edit->tipocompra->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_edit->cita->Required) { ?>
				elm = this.getElements("x" + infix + "_cita");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $kp_ordenes_edit->cita->caption(), $kp_ordenes_edit->cita->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_cita");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_ordenes_edit->cita->errorMessage()) ?>");
			<?php if ($kp_ordenes_edit->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_ordenes_edit->estado->caption(), $kp_ordenes_edit->estado->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_ordenes_edit->estado->errorMessage()) ?>");

				// 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_ordenesedit.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_ordenesedit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $kp_ordenes_edit->showPageHeader(); ?>
<?php
$kp_ordenes_edit->showMessage();
?>
<form name="fkp_ordenesedit" id="fkp_ordenesedit" class="<?php echo $kp_ordenes_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_ordenes">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$kp_ordenes_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($kp_ordenes_edit->id_reg->Visible) { // id_reg ?>
	<div id="r_id_reg" class="form-group row">
		<label id="elh_kp_ordenes_id_reg" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->id_reg->caption() ?><?php echo $kp_ordenes_edit->id_reg->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->id_reg->cellAttributes() ?>>
<span id="el_kp_ordenes_id_reg">
<span<?php echo $kp_ordenes_edit->id_reg->viewAttributes() ?>><input type="text" readonly class="form-control-plaintext" value="<?php echo HtmlEncode(RemoveHtml($kp_ordenes_edit->id_reg->EditValue)) ?>"></span>
</span>
<input type="hidden" data-table="kp_ordenes" data-field="x_id_reg" name="x_id_reg" id="x_id_reg" value="<?php echo HtmlEncode($kp_ordenes_edit->id_reg->CurrentValue) ?>">
<?php echo $kp_ordenes_edit->id_reg->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_edit->idempresa->Visible) { // idempresa ?>
	<div id="r_idempresa" class="form-group row">
		<label id="elh_kp_ordenes_idempresa" for="x_idempresa" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->idempresa->caption() ?><?php echo $kp_ordenes_edit->idempresa->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->idempresa->cellAttributes() ?>>
<span id="el_kp_ordenes_idempresa">
<input type="text" data-table="kp_ordenes" data-field="x_idempresa" name="x_idempresa" id="x_idempresa" size="30" maxlength="20" placeholder="<?php echo HtmlEncode($kp_ordenes_edit->idempresa->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_edit->idempresa->EditValue ?>"<?php echo $kp_ordenes_edit->idempresa->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_edit->idempresa->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_edit->numcompra->Visible) { // numcompra ?>
	<div id="r_numcompra" class="form-group row">
		<label id="elh_kp_ordenes_numcompra" for="x_numcompra" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->numcompra->caption() ?><?php echo $kp_ordenes_edit->numcompra->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->numcompra->cellAttributes() ?>>
<span id="el_kp_ordenes_numcompra">
<input type="text" data-table="kp_ordenes" data-field="x_numcompra" name="x_numcompra" id="x_numcompra" size="30" maxlength="20" placeholder="<?php echo HtmlEncode($kp_ordenes_edit->numcompra->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_edit->numcompra->EditValue ?>"<?php echo $kp_ordenes_edit->numcompra->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_edit->numcompra->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_edit->fecha->Visible) { // fecha ?>
	<div id="r_fecha" class="form-group row">
		<label id="elh_kp_ordenes_fecha" for="x_fecha" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->fecha->caption() ?><?php echo $kp_ordenes_edit->fecha->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->fecha->cellAttributes() ?>>
<span id="el_kp_ordenes_fecha">
<input type="text" data-table="kp_ordenes" data-field="x_fecha" name="x_fecha" id="x_fecha" maxlength="19" placeholder="<?php echo HtmlEncode($kp_ordenes_edit->fecha->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_edit->fecha->EditValue ?>"<?php echo $kp_ordenes_edit->fecha->editAttributes() ?>>
<?php if (!$kp_ordenes_edit->fecha->ReadOnly && !$kp_ordenes_edit->fecha->Disabled && !isset($kp_ordenes_edit->fecha->EditAttrs["readonly"]) && !isset($kp_ordenes_edit->fecha->EditAttrs["disabled"])) { ?>
<script>
loadjs.ready(["fkp_ordenesedit", "datetimepicker"], function() {
	ew.createDateTimePicker("fkp_ordenesedit", "x_fecha", {"ignoreReadonly":true,"useCurrent":false,"format":0});
});
</script>
<?php } ?>
</span>
<?php echo $kp_ordenes_edit->fecha->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_edit->tipocompra->Visible) { // tipocompra ?>
	<div id="r_tipocompra" class="form-group row">
		<label id="elh_kp_ordenes_tipocompra" for="x_tipocompra" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->tipocompra->caption() ?><?php echo $kp_ordenes_edit->tipocompra->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->tipocompra->cellAttributes() ?>>
<span id="el_kp_ordenes_tipocompra">
<input type="text" data-table="kp_ordenes" data-field="x_tipocompra" name="x_tipocompra" id="x_tipocompra" size="30" maxlength="10" placeholder="<?php echo HtmlEncode($kp_ordenes_edit->tipocompra->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_edit->tipocompra->EditValue ?>"<?php echo $kp_ordenes_edit->tipocompra->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_edit->tipocompra->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_edit->cita->Visible) { // cita ?>
	<div id="r_cita" class="form-group row">
		<label id="elh_kp_ordenes_cita" for="x_cita" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->cita->caption() ?><?php echo $kp_ordenes_edit->cita->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->cita->cellAttributes() ?>>
<span id="el_kp_ordenes_cita">
<input type="text" data-table="kp_ordenes" data-field="x_cita" name="x_cita" id="x_cita" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_ordenes_edit->cita->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_edit->cita->EditValue ?>"<?php echo $kp_ordenes_edit->cita->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_edit->cita->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_edit->estado->Visible) { // estado ?>
	<div id="r_estado" class="form-group row">
		<label id="elh_kp_ordenes_estado" for="x_estado" class="<?php echo $kp_ordenes_edit->LeftColumnClass ?>"><?php echo $kp_ordenes_edit->estado->caption() ?><?php echo $kp_ordenes_edit->estado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_edit->RightColumnClass ?>"><div <?php echo $kp_ordenes_edit->estado->cellAttributes() ?>>
<span id="el_kp_ordenes_estado">
<input type="text" data-table="kp_ordenes" data-field="x_estado" name="x_estado" id="x_estado" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($kp_ordenes_edit->estado->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_edit->estado->EditValue ?>"<?php echo $kp_ordenes_edit->estado->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_edit->estado->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_ordenes_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_ordenes_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_ordenes_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_ordenes_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_ordenes_edit->terminate();
?>