<?php
namespace PHPMaker2020\recetarios_2021;

// Autoload
include_once "autoload.php";

// Session
if (session_status() !== PHP_SESSION_ACTIVE)
	\Delight\Cookie\Session::start(Config("COOKIE_SAMESITE")); // Init session data

// Output buffering
ob_start();
?>
<?php

// Write header
WriteHeader(FALSE);

// Create page object
$afiliadosr_add = new afiliadosr_add();

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

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

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

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

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

	// Validate form
	fafiliadosradd.validate = function() {
		if (!this.validateRequired)
			return true; // Ignore validation
		var $ = jQuery, fobj = this.getForm(), $fobj = $(fobj);
		if ($fobj.find("#confirm").val() == "confirm")
			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 ($afiliadosr_add->Apellido->Required) { ?>
				elm = this.getElements("x" + infix + "_Apellido");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $afiliadosr_add->Apellido->caption(), $afiliadosr_add->Apellido->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($afiliadosr_add->Nombres->Required) { ?>
				elm = this.getElements("x" + infix + "_Nombres");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $afiliadosr_add->Nombres->caption(), $afiliadosr_add->Nombres->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($afiliadosr_add->Nro_Afiliado->Required) { ?>
				elm = this.getElements("x" + infix + "_Nro_Afiliado");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $afiliadosr_add->Nro_Afiliado->caption(), $afiliadosr_add->Nro_Afiliado->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
	fafiliadosradd.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
	fafiliadosradd.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $afiliadosr_add->showPageHeader(); ?>
<?php
$afiliadosr_add->showMessage();
?>
<form name="fafiliadosradd" id="fafiliadosradd" class="<?php echo $afiliadosr_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="afiliadosr">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?php echo (int)$afiliadosr_add->IsModal ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($afiliadosr_add->Apellido->Visible) { // Apellido ?>
	<div id="r_Apellido" class="form-group row">
		<label id="elh_afiliadosr_Apellido" for="x_Apellido" class="<?php echo $afiliadosr_add->LeftColumnClass ?>"><?php echo $afiliadosr_add->Apellido->caption() ?><?php echo $afiliadosr_add->Apellido->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $afiliadosr_add->RightColumnClass ?>"><div <?php echo $afiliadosr_add->Apellido->cellAttributes() ?>>
<span id="el_afiliadosr_Apellido">
<input type="text" data-table="afiliadosr" data-field="x_Apellido" name="x_Apellido" id="x_Apellido" size="30" maxlength="25" placeholder="<?php echo HtmlEncode($afiliadosr_add->Apellido->getPlaceHolder()) ?>" value="<?php echo $afiliadosr_add->Apellido->EditValue ?>"<?php echo $afiliadosr_add->Apellido->editAttributes() ?>>
</span>
<?php echo $afiliadosr_add->Apellido->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($afiliadosr_add->Nombres->Visible) { // Nombres ?>
	<div id="r_Nombres" class="form-group row">
		<label id="elh_afiliadosr_Nombres" for="x_Nombres" class="<?php echo $afiliadosr_add->LeftColumnClass ?>"><?php echo $afiliadosr_add->Nombres->caption() ?><?php echo $afiliadosr_add->Nombres->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $afiliadosr_add->RightColumnClass ?>"><div <?php echo $afiliadosr_add->Nombres->cellAttributes() ?>>
<span id="el_afiliadosr_Nombres">
<input type="text" data-table="afiliadosr" data-field="x_Nombres" name="x_Nombres" id="x_Nombres" size="30" maxlength="25" placeholder="<?php echo HtmlEncode($afiliadosr_add->Nombres->getPlaceHolder()) ?>" value="<?php echo $afiliadosr_add->Nombres->EditValue ?>"<?php echo $afiliadosr_add->Nombres->editAttributes() ?>>
</span>
<?php echo $afiliadosr_add->Nombres->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($afiliadosr_add->Nro_Afiliado->Visible) { // Nro_Afiliado ?>
	<div id="r_Nro_Afiliado" class="form-group row">
		<label id="elh_afiliadosr_Nro_Afiliado" for="x_Nro_Afiliado" class="<?php echo $afiliadosr_add->LeftColumnClass ?>"><?php echo $afiliadosr_add->Nro_Afiliado->caption() ?><?php echo $afiliadosr_add->Nro_Afiliado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $afiliadosr_add->RightColumnClass ?>"><div <?php echo $afiliadosr_add->Nro_Afiliado->cellAttributes() ?>>
<span id="el_afiliadosr_Nro_Afiliado">
<input type="text" data-table="afiliadosr" data-field="x_Nro_Afiliado" name="x_Nro_Afiliado" id="x_Nro_Afiliado" size="30" maxlength="10" placeholder="<?php echo HtmlEncode($afiliadosr_add->Nro_Afiliado->getPlaceHolder()) ?>" value="<?php echo $afiliadosr_add->Nro_Afiliado->EditValue ?>"<?php echo $afiliadosr_add->Nro_Afiliado->editAttributes() ?>>
</span>
<?php echo $afiliadosr_add->Nro_Afiliado->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
<?php if (!$afiliadosr_add->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $afiliadosr_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 $afiliadosr_add->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$afiliadosr_add->showPageFooter();
if (Config("DEBUG"))
	echo GetDebugMessage();
?>
<script>
loadjs.ready("load", function() {

	// Startup script
	$("#x_Nro_Afiliado").mask("999999/99");
});
</script>
<?php include_once "footer.php"; ?>
<?php
$afiliadosr_add->terminate();
?>