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

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

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

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

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

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

	// Validate form
	fcomentarioadd.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 ($comentario_add->id_detallecuota->Required) { ?>
				elm = this.getElements("x" + infix + "_id_detallecuota");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $comentario_add->id_detallecuota->caption(), $comentario_add->id_detallecuota->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_id_detallecuota");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($comentario_add->id_detallecuota->errorMessage()) ?>");
			<?php if ($comentario_add->descripcion->Required) { ?>
				elm = this.getElements("x" + infix + "_descripcion");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $comentario_add->descripcion->caption(), $comentario_add->descripcion->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($comentario_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", $comentario_add->estado->caption(), $comentario_add->estado->RequiredErrorMessage)) ?>");
			<?php } ?>
				elm = this.getElements("x" + infix + "_estado");
				if (elm && !ew.checkInteger(elm.value))
					return this.onError(elm, "<?php echo JsEncode($comentario_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
	fcomentarioadd.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
	fcomentarioadd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $comentario_add->showPageHeader(); ?>
<?php
$comentario_add->showMessage();
?>
<form name="fcomentarioadd" id="fcomentarioadd" class="<?php echo $comentario_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="comentario">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$comentario_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($comentario_add->id_detallecuota->Visible) { // id_detallecuota ?>
	<div id="r_id_detallecuota" class="form-group row">
		<label id="elh_comentario_id_detallecuota" for="x_id_detallecuota" class="<?php echo $comentario_add->LeftColumnClass ?>"><?php echo $comentario_add->id_detallecuota->caption() ?><?php echo $comentario_add->id_detallecuota->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $comentario_add->RightColumnClass ?>"><div <?php echo $comentario_add->id_detallecuota->cellAttributes() ?>>
<span id="el_comentario_id_detallecuota">
<input type="text" data-table="comentario" data-field="x_id_detallecuota" name="x_id_detallecuota" id="x_id_detallecuota" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($comentario_add->id_detallecuota->getPlaceHolder()) ?>" value="<?php echo $comentario_add->id_detallecuota->EditValue ?>"<?php echo $comentario_add->id_detallecuota->editAttributes() ?>>
</span>
<?php echo $comentario_add->id_detallecuota->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($comentario_add->descripcion->Visible) { // descripcion ?>
	<div id="r_descripcion" class="form-group row">
		<label id="elh_comentario_descripcion" for="x_descripcion" class="<?php echo $comentario_add->LeftColumnClass ?>"><?php echo $comentario_add->descripcion->caption() ?><?php echo $comentario_add->descripcion->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $comentario_add->RightColumnClass ?>"><div <?php echo $comentario_add->descripcion->cellAttributes() ?>>
<span id="el_comentario_descripcion">
<textarea data-table="comentario" data-field="x_descripcion" name="x_descripcion" id="x_descripcion" cols="35" rows="4" placeholder="<?php echo HtmlEncode($comentario_add->descripcion->getPlaceHolder()) ?>"<?php echo $comentario_add->descripcion->editAttributes() ?>><?php echo $comentario_add->descripcion->EditValue ?></textarea>
</span>
<?php echo $comentario_add->descripcion->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($comentario_add->estado->Visible) { // estado ?>
	<div id="r_estado" class="form-group row">
		<label id="elh_comentario_estado" for="x_estado" class="<?php echo $comentario_add->LeftColumnClass ?>"><?php echo $comentario_add->estado->caption() ?><?php echo $comentario_add->estado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $comentario_add->RightColumnClass ?>"><div <?php echo $comentario_add->estado->cellAttributes() ?>>
<span id="el_comentario_estado">
<input type="text" data-table="comentario" data-field="x_estado" name="x_estado" id="x_estado" size="30" maxlength="11" placeholder="<?php echo HtmlEncode($comentario_add->estado->getPlaceHolder()) ?>" value="<?php echo $comentario_add->estado->EditValue ?>"<?php echo $comentario_add->estado->editAttributes() ?>>
</span>
<?php echo $comentario_add->estado->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$comentario_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $comentario_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 $comentario_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$comentario_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
$comentario_add->terminate();
?>