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

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

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

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

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

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

	// Validate form
	fcuotaadd.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 ($cuota_add->id_producto->Required) { ?>
				elm = this.getElements("x" + infix + "_id_producto");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $cuota_add->id_producto->caption(), $cuota_add->id_producto->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_id_producto");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($cuota_add->id_producto->errorMessage()) ?>");
			<?php if ($cuota_add->interes->Required) { ?>
				elm = this.getElements("x" + infix + "_interes");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $cuota_add->interes->caption(), $cuota_add->interes->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($cuota_add->plazo_meses->Required) { ?>
				elm = this.getElements("x" + infix + "_plazo_meses");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $cuota_add->plazo_meses->caption(), $cuota_add->plazo_meses->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_plazo_meses");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($cuota_add->plazo_meses->errorMessage()) ?>");
			<?php if ($cuota_add->monto->Required) { ?>
				elm = this.getElements("x" + infix + "_monto");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $cuota_add->monto->caption(), $cuota_add->monto->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_monto");
				if (elm && !ew.checkNumber(elm.value))
					return this.onError(elm, "<?php echo JsEncode($cuota_add->monto->errorMessage()) ?>");
			<?php if ($cuota_add->pagar_mensual->Required) { ?>
				elm = this.getElements("x" + infix + "_pagar_mensual");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $cuota_add->pagar_mensual->caption(), $cuota_add->pagar_mensual->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_pagar_mensual");
				if (elm && !ew.checkNumber(elm.value))
					return this.onError(elm, "<?php echo JsEncode($cuota_add->pagar_mensual->errorMessage()) ?>");
			<?php if ($cuota_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", $cuota_add->estado->caption(), $cuota_add->estado->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($cuota_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
	fcuotaadd.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
	fcuotaadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $cuota_add->showPageHeader(); ?>
<?php
$cuota_add->showMessage();
?>
<form name="fcuotaadd" id="fcuotaadd" class="<?php echo $cuota_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="cuota">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$cuota_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($cuota_add->id_producto->Visible) { // id_producto ?>
	<div id="r_id_producto" class="form-group row">
		<label id="elh_cuota_id_producto" for="x_id_producto" class="<?php echo $cuota_add->LeftColumnClass ?>"><?php echo $cuota_add->id_producto->caption() ?><?php echo $cuota_add->id_producto->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $cuota_add->RightColumnClass ?>"><div <?php echo $cuota_add->id_producto->cellAttributes() ?>>
<span id="el_cuota_id_producto">
<input type="text" data-table="cuota" data-field="x_id_producto" name="x_id_producto" id="x_id_producto" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($cuota_add->id_producto->getPlaceHolder()) ?>" value="<?php echo $cuota_add->id_producto->EditValue ?>"<?php echo $cuota_add->id_producto->editAttributes() ?>>
</span>
<?php echo $cuota_add->id_producto->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($cuota_add->interes->Visible) { // interes ?>
	<div id="r_interes" class="form-group row">
		<label id="elh_cuota_interes" for="x_interes" class="<?php echo $cuota_add->LeftColumnClass ?>"><?php echo $cuota_add->interes->caption() ?><?php echo $cuota_add->interes->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $cuota_add->RightColumnClass ?>"><div <?php echo $cuota_add->interes->cellAttributes() ?>>
<span id="el_cuota_interes">
<input type="text" data-table="cuota" data-field="x_interes" name="x_interes" id="x_interes" size="30" maxlength="10" placeholder="<?php echo HtmlEncode($cuota_add->interes->getPlaceHolder()) ?>" value="<?php echo $cuota_add->interes->EditValue ?>"<?php echo $cuota_add->interes->editAttributes() ?>>
</span>
<?php echo $cuota_add->interes->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($cuota_add->plazo_meses->Visible) { // plazo_meses ?>
	<div id="r_plazo_meses" class="form-group row">
		<label id="elh_cuota_plazo_meses" for="x_plazo_meses" class="<?php echo $cuota_add->LeftColumnClass ?>"><?php echo $cuota_add->plazo_meses->caption() ?><?php echo $cuota_add->plazo_meses->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $cuota_add->RightColumnClass ?>"><div <?php echo $cuota_add->plazo_meses->cellAttributes() ?>>
<span id="el_cuota_plazo_meses">
<input type="text" data-table="cuota" data-field="x_plazo_meses" name="x_plazo_meses" id="x_plazo_meses" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($cuota_add->plazo_meses->getPlaceHolder()) ?>" value="<?php echo $cuota_add->plazo_meses->EditValue ?>"<?php echo $cuota_add->plazo_meses->editAttributes() ?>>
</span>
<?php echo $cuota_add->plazo_meses->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($cuota_add->monto->Visible) { // monto ?>
	<div id="r_monto" class="form-group row">
		<label id="elh_cuota_monto" for="x_monto" class="<?php echo $cuota_add->LeftColumnClass ?>"><?php echo $cuota_add->monto->caption() ?><?php echo $cuota_add->monto->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $cuota_add->RightColumnClass ?>"><div <?php echo $cuota_add->monto->cellAttributes() ?>>
<span id="el_cuota_monto">
<input type="text" data-table="cuota" data-field="x_monto" name="x_monto" id="x_monto" size="30" maxlength="12" placeholder="<?php echo HtmlEncode($cuota_add->monto->getPlaceHolder()) ?>" value="<?php echo $cuota_add->monto->EditValue ?>"<?php echo $cuota_add->monto->editAttributes() ?>>
</span>
<?php echo $cuota_add->monto->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($cuota_add->pagar_mensual->Visible) { // pagar_mensual ?>
	<div id="r_pagar_mensual" class="form-group row">
		<label id="elh_cuota_pagar_mensual" for="x_pagar_mensual" class="<?php echo $cuota_add->LeftColumnClass ?>"><?php echo $cuota_add->pagar_mensual->caption() ?><?php echo $cuota_add->pagar_mensual->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $cuota_add->RightColumnClass ?>"><div <?php echo $cuota_add->pagar_mensual->cellAttributes() ?>>
<span id="el_cuota_pagar_mensual">
<input type="text" data-table="cuota" data-field="x_pagar_mensual" name="x_pagar_mensual" id="x_pagar_mensual" size="30" maxlength="12" placeholder="<?php echo HtmlEncode($cuota_add->pagar_mensual->getPlaceHolder()) ?>" value="<?php echo $cuota_add->pagar_mensual->EditValue ?>"<?php echo $cuota_add->pagar_mensual->editAttributes() ?>>
</span>
<?php echo $cuota_add->pagar_mensual->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($cuota_add->estado->Visible) { // estado ?>
	<div id="r_estado" class="form-group row">
		<label id="elh_cuota_estado" for="x_estado" class="<?php echo $cuota_add->LeftColumnClass ?>"><?php echo $cuota_add->estado->caption() ?><?php echo $cuota_add->estado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $cuota_add->RightColumnClass ?>"><div <?php echo $cuota_add->estado->cellAttributes() ?>>
<span id="el_cuota_estado">
<input type="text" data-table="cuota" data-field="x_estado" name="x_estado" id="x_estado" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($cuota_add->estado->getPlaceHolder()) ?>" value="<?php echo $cuota_add->estado->EditValue ?>"<?php echo $cuota_add->estado->editAttributes() ?>>
</span>
<?php echo $cuota_add->estado->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$cuota_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $cuota_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 $cuota_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$cuota_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
$cuota_add->terminate();
?>