<?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_add = new kp_ordenes_add();

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

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

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

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

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

	// Validate form
	fkp_ordenesadd.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_add->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_add->idempresa->caption(), $kp_ordenes_add->idempresa->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_add->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_add->numcompra->caption(), $kp_ordenes_add->numcompra->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_add->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_add->fecha->caption(), $kp_ordenes_add->fecha->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_fecha");
				if (elm && !ew.checkDateDef(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_ordenes_add->fecha->errorMessage()) ?>");
			<?php if ($kp_ordenes_add->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_add->tipocompra->caption(), $kp_ordenes_add->tipocompra->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($kp_ordenes_add->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_add->cita->caption(), $kp_ordenes_add->cita->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_cita");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_ordenes_add->cita->errorMessage()) ?>");
			<?php if ($kp_ordenes_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_ordenes_add->estado->caption(), $kp_ordenes_add->estado->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($kp_ordenes_add->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_ordenesadd.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_ordenesadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $kp_ordenes_add->showPageHeader(); ?>
<?php
$kp_ordenes_add->showMessage();
?>
<form name="fkp_ordenesadd" id="fkp_ordenesadd" class="<?php echo $kp_ordenes_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_ordenes">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$kp_ordenes_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($kp_ordenes_add->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_add->LeftColumnClass ?>"><?php echo $kp_ordenes_add->idempresa->caption() ?><?php echo $kp_ordenes_add->idempresa->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_add->RightColumnClass ?>"><div <?php echo $kp_ordenes_add->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_add->idempresa->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_add->idempresa->EditValue ?>"<?php echo $kp_ordenes_add->idempresa->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_add->idempresa->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_add->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_add->LeftColumnClass ?>"><?php echo $kp_ordenes_add->numcompra->caption() ?><?php echo $kp_ordenes_add->numcompra->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_add->RightColumnClass ?>"><div <?php echo $kp_ordenes_add->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_add->numcompra->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_add->numcompra->EditValue ?>"<?php echo $kp_ordenes_add->numcompra->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_add->numcompra->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_add->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_add->LeftColumnClass ?>"><?php echo $kp_ordenes_add->fecha->caption() ?><?php echo $kp_ordenes_add->fecha->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_add->RightColumnClass ?>"><div <?php echo $kp_ordenes_add->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_add->fecha->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_add->fecha->EditValue ?>"<?php echo $kp_ordenes_add->fecha->editAttributes() ?>>
<?php if (!$kp_ordenes_add->fecha->ReadOnly && !$kp_ordenes_add->fecha->Disabled && !isset($kp_ordenes_add->fecha->EditAttrs["readonly"]) && !isset($kp_ordenes_add->fecha->EditAttrs["disabled"])) { ?>
<script>
loadjs.ready(["fkp_ordenesadd", "datetimepicker"], function() {
	ew.createDateTimePicker("fkp_ordenesadd", "x_fecha", {"ignoreReadonly":true,"useCurrent":false,"format":0});
});
</script>
<?php } ?>
</span>
<?php echo $kp_ordenes_add->fecha->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_add->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_add->LeftColumnClass ?>"><?php echo $kp_ordenes_add->tipocompra->caption() ?><?php echo $kp_ordenes_add->tipocompra->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_add->RightColumnClass ?>"><div <?php echo $kp_ordenes_add->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_add->tipocompra->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_add->tipocompra->EditValue ?>"<?php echo $kp_ordenes_add->tipocompra->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_add->tipocompra->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_add->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_add->LeftColumnClass ?>"><?php echo $kp_ordenes_add->cita->caption() ?><?php echo $kp_ordenes_add->cita->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_add->RightColumnClass ?>"><div <?php echo $kp_ordenes_add->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_add->cita->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_add->cita->EditValue ?>"<?php echo $kp_ordenes_add->cita->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_add->cita->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($kp_ordenes_add->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_add->LeftColumnClass ?>"><?php echo $kp_ordenes_add->estado->caption() ?><?php echo $kp_ordenes_add->estado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $kp_ordenes_add->RightColumnClass ?>"><div <?php echo $kp_ordenes_add->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_add->estado->getPlaceHolder()) ?>" value="<?php echo $kp_ordenes_add->estado->EditValue ?>"<?php echo $kp_ordenes_add->estado->editAttributes() ?>>
</span>
<?php echo $kp_ordenes_add->estado->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$kp_ordenes_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $kp_ordenes_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_ordenes_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$kp_ordenes_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_ordenes_add->terminate();
?>