<?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_edit = new afiliadosr_edit();

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

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

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

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

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

	// Validate form
	fafiliadosredit.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_edit->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_edit->Apellido->caption(), $afiliadosr_edit->Apellido->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($afiliadosr_edit->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_edit->Nombres->caption(), $afiliadosr_edit->Nombres->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($afiliadosr_edit->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_edit->Nro_Afiliado->caption(), $afiliadosr_edit->Nro_Afiliado->RequiredErrorMessage)) ?>");
			<?php } ?>
			<?php if ($afiliadosr_edit->Fecha_Insercion->Required) { ?>
				elm = this.getElements("x" + infix + "_Fecha_Insercion");
				if (elm && !ew.isHidden(elm) && !ew.hasValue(elm))
					return this.onError(elm, "<?php echo JsEncode(str_replace("%s", $afiliadosr_edit->Fecha_Insercion->caption(), $afiliadosr_edit->Fecha_Insercion->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
	fafiliadosredit.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
	fafiliadosredit.validateRequired = <?php echo Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

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

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

});
</script>
<?php $afiliadosr_edit->showPageHeader(); ?>
<?php
$afiliadosr_edit->showMessage();
?>
<form name="fafiliadosredit" id="fafiliadosredit" class="<?php echo $afiliadosr_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="afiliadosr">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?php echo (int)$afiliadosr_edit->IsModal ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($afiliadosr_edit->Apellido->Visible) { // Apellido ?>
	<div id="r_Apellido" class="form-group row">
		<label id="elh_afiliadosr_Apellido" for="x_Apellido" class="<?php echo $afiliadosr_edit->LeftColumnClass ?>"><?php echo $afiliadosr_edit->Apellido->caption() ?><?php echo $afiliadosr_edit->Apellido->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $afiliadosr_edit->RightColumnClass ?>"><div <?php echo $afiliadosr_edit->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_edit->Apellido->getPlaceHolder()) ?>" value="<?php echo $afiliadosr_edit->Apellido->EditValue ?>"<?php echo $afiliadosr_edit->Apellido->editAttributes() ?>>
</span>
<?php echo $afiliadosr_edit->Apellido->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($afiliadosr_edit->Nombres->Visible) { // Nombres ?>
	<div id="r_Nombres" class="form-group row">
		<label id="elh_afiliadosr_Nombres" for="x_Nombres" class="<?php echo $afiliadosr_edit->LeftColumnClass ?>"><?php echo $afiliadosr_edit->Nombres->caption() ?><?php echo $afiliadosr_edit->Nombres->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $afiliadosr_edit->RightColumnClass ?>"><div <?php echo $afiliadosr_edit->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_edit->Nombres->getPlaceHolder()) ?>" value="<?php echo $afiliadosr_edit->Nombres->EditValue ?>"<?php echo $afiliadosr_edit->Nombres->editAttributes() ?>>
</span>
<?php echo $afiliadosr_edit->Nombres->CustomMsg ?></div></div>
	</div>
<?php } ?>
<?php if ($afiliadosr_edit->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_edit->LeftColumnClass ?>"><?php echo $afiliadosr_edit->Nro_Afiliado->caption() ?><?php echo $afiliadosr_edit->Nro_Afiliado->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
		<div class="<?php echo $afiliadosr_edit->RightColumnClass ?>"><div <?php echo $afiliadosr_edit->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_edit->Nro_Afiliado->getPlaceHolder()) ?>" value="<?php echo $afiliadosr_edit->Nro_Afiliado->EditValue ?>"<?php echo $afiliadosr_edit->Nro_Afiliado->editAttributes() ?>>
</span>
<?php echo $afiliadosr_edit->Nro_Afiliado->CustomMsg ?></div></div>
	</div>
<?php } ?>
</div><!-- /page* -->
	<input type="hidden" data-table="afiliadosr" data-field="x_id" name="x_id" id="x_id" value="<?php echo HtmlEncode($afiliadosr_edit->id->CurrentValue) ?>">
<?php if (!$afiliadosr_edit->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
	<div class="<?php echo $afiliadosr_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 $afiliadosr_edit->getReturnUrl() ?>"><?php echo $Language->phrase("CancelBtn") ?></button>
	</div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$afiliadosr_edit->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_edit->terminate();
?>