<?php
namespace PHPMaker2020\recetarios_2021;

/**
 * Page class
 */
class boletas_edit extends boletas
{

	// Page ID
	public $PageID = "edit";

	// Project ID
	public $ProjectID = "{2A7E3B79-A2EC-4C74-B4A2-FA2DA14712FE}";

	// Table name
	public $TableName = 'boletas';

	// Page object name
	public $PageObjName = "boletas_edit";

	// Page headings
	public $Heading = "";
	public $Subheading = "";
	public $PageHeader;
	public $PageFooter;

	// Token
	public $Token = "";
	public $TokenTimeout = 0;
	public $CheckToken;

	// Page heading
	public function pageHeading()
	{
		global $Language;
		if ($this->Heading != "")
			return $this->Heading;
		if (method_exists($this, "tableCaption"))
			return $this->tableCaption();
		return "";
	}

	// Page subheading
	public function pageSubheading()
	{
		global $Language;
		if ($this->Subheading != "")
			return $this->Subheading;
		if ($this->TableName)
			return $Language->phrase($this->PageID);
		return "";
	}

	// Page name
	public function pageName()
	{
		return CurrentPageName();
	}

	// Page URL
	public function pageUrl()
	{
		$url = CurrentPageName() . "?";
		if ($this->UseTokenInUrl)
			$url .= "t=" . $this->TableVar . "&"; // Add page token
		return $url;
	}

	// Messages
	private $_message = "";
	private $_failureMessage = "";
	private $_successMessage = "";
	private $_warningMessage = "";

	// Get message
	public function getMessage()
	{
		return isset($_SESSION[SESSION_MESSAGE]) ? $_SESSION[SESSION_MESSAGE] : $this->_message;
	}

	// Set message
	public function setMessage($v)
	{
		AddMessage($this->_message, $v);
		$_SESSION[SESSION_MESSAGE] = $this->_message;
	}

	// Get failure message
	public function getFailureMessage()
	{
		return isset($_SESSION[SESSION_FAILURE_MESSAGE]) ? $_SESSION[SESSION_FAILURE_MESSAGE] : $this->_failureMessage;
	}

	// Set failure message
	public function setFailureMessage($v)
	{
		AddMessage($this->_failureMessage, $v);
		$_SESSION[SESSION_FAILURE_MESSAGE] = $this->_failureMessage;
	}

	// Get success message
	public function getSuccessMessage()
	{
		return isset($_SESSION[SESSION_SUCCESS_MESSAGE]) ? $_SESSION[SESSION_SUCCESS_MESSAGE] : $this->_successMessage;
	}

	// Set success message
	public function setSuccessMessage($v)
	{
		AddMessage($this->_successMessage, $v);
		$_SESSION[SESSION_SUCCESS_MESSAGE] = $this->_successMessage;
	}

	// Get warning message
	public function getWarningMessage()
	{
		return isset($_SESSION[SESSION_WARNING_MESSAGE]) ? $_SESSION[SESSION_WARNING_MESSAGE] : $this->_warningMessage;
	}

	// Set warning message
	public function setWarningMessage($v)
	{
		AddMessage($this->_warningMessage, $v);
		$_SESSION[SESSION_WARNING_MESSAGE] = $this->_warningMessage;
	}

	// Clear message
	public function clearMessage()
	{
		$this->_message = "";
		$_SESSION[SESSION_MESSAGE] = "";
	}

	// Clear failure message
	public function clearFailureMessage()
	{
		$this->_failureMessage = "";
		$_SESSION[SESSION_FAILURE_MESSAGE] = "";
	}

	// Clear success message
	public function clearSuccessMessage()
	{
		$this->_successMessage = "";
		$_SESSION[SESSION_SUCCESS_MESSAGE] = "";
	}

	// Clear warning message
	public function clearWarningMessage()
	{
		$this->_warningMessage = "";
		$_SESSION[SESSION_WARNING_MESSAGE] = "";
	}

	// Clear messages
	public function clearMessages()
	{
		$this->clearMessage();
		$this->clearFailureMessage();
		$this->clearSuccessMessage();
		$this->clearWarningMessage();
	}

	// Show message
	public function showMessage()
	{
		$hidden = TRUE;
		$html = "";

		// Message
		$message = $this->getMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($message, "");
		if ($message != "") { // Message in Session, display
			if (!$hidden)
				$message = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $message;
			$html .= '<div class="alert alert-info alert-dismissible ew-info"><i class="icon fas fa-info"></i>' . $message . '</div>';
			$_SESSION[SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$warningMessage = $this->getWarningMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($warningMessage, "warning");
		if ($warningMessage != "") { // Message in Session, display
			if (!$hidden)
				$warningMessage = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $warningMessage;
			$html .= '<div class="alert alert-warning alert-dismissible ew-warning"><i class="icon fas fa-exclamation"></i>' . $warningMessage . '</div>';
			$_SESSION[SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$successMessage = $this->getSuccessMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($successMessage, "success");
		if ($successMessage != "") { // Message in Session, display
			if (!$hidden)
				$successMessage = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $successMessage;
			$html .= '<div class="alert alert-success alert-dismissible ew-success"><i class="icon fas fa-check"></i>' . $successMessage . '</div>';
			$_SESSION[SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$errorMessage = $this->getFailureMessage();
		if (method_exists($this, "Message_Showing"))
			$this->Message_Showing($errorMessage, "failure");
		if ($errorMessage != "") { // Message in Session, display
			if (!$hidden)
				$errorMessage = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . $errorMessage;
			$html .= '<div class="alert alert-danger alert-dismissible ew-error"><i class="icon fas fa-ban"></i>' . $errorMessage . '</div>';
			$_SESSION[SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		echo '<div class="ew-message-dialog' . (($hidden) ? ' d-none' : "") . '">' . $html . '</div>';
	}

	// Get message as array
	public function getMessages()
	{
		$ar = [];

		// Message
		$message = $this->getMessage();

		//if (method_exists($this, "Message_Showing"))
		//	$this->Message_Showing($message, "");

		if ($message != "") { // Message in Session, display
			$ar["message"] = $message;
			$_SESSION[SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$warningMessage = $this->getWarningMessage();

		//if (method_exists($this, "Message_Showing"))
		//	$this->Message_Showing($warningMessage, "warning");

		if ($warningMessage != "") { // Message in Session, display
			$ar["warningMessage"] = $warningMessage;
			$_SESSION[SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$successMessage = $this->getSuccessMessage();

		//if (method_exists($this, "Message_Showing"))
		//	$this->Message_Showing($successMessage, "success");

		if ($successMessage != "") { // Message in Session, display
			$ar["successMessage"] = $successMessage;
			$_SESSION[SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$failureMessage = $this->getFailureMessage();

		//if (method_exists($this, "Message_Showing"))
		//	$this->Message_Showing($failureMessage, "failure");

		if ($failureMessage != "") { // Message in Session, display
			$ar["failureMessage"] = $failureMessage;
			$_SESSION[SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		return $ar;
	}

	// Show Page Header
	public function showPageHeader()
	{
		$header = $this->PageHeader;
		$this->Page_DataRendering($header);
		if ($header != "") { // Header exists, display
			echo '<p id="ew-page-header">' . $header . '</p>';
		}
	}

	// Show Page Footer
	public function showPageFooter()
	{
		$footer = $this->PageFooter;
		$this->Page_DataRendered($footer);
		if ($footer != "") { // Footer exists, display
			echo '<p id="ew-page-footer">' . $footer . '</p>';
		}
	}

	// Validate page request
	protected function isPageRequest()
	{
		global $CurrentForm;
		if ($this->UseTokenInUrl) {
			if ($CurrentForm)
				return ($this->TableVar == $CurrentForm->getValue("t"));
			if (Get("t") !== NULL)
				return ($this->TableVar == Get("t"));
		}
		return TRUE;
	}

	// Valid Post
	protected function validPost()
	{
		if (!$this->CheckToken || !IsPost() || IsApi())
			return TRUE;
		if (Post(Config("TOKEN_NAME")) === NULL)
			return FALSE;
		$fn = Config("CHECK_TOKEN_FUNC");
		if (is_callable($fn))
			return $fn(Post(Config("TOKEN_NAME")), $this->TokenTimeout);
		return FALSE;
	}

	// Create Token
	public function createToken()
	{
		global $CurrentToken;
		$fn = Config("CREATE_TOKEN_FUNC"); // Always create token, required by API file/lookup request
		if ($this->Token == "" && is_callable($fn)) // Create token
			$this->Token = $fn();
		$CurrentToken = $this->Token; // Save to global variable
	}

	// Constructor
	public function __construct()
	{
		global $Language, $DashboardReport;
		global $UserTable;

		// Check token
		$this->CheckToken = Config("CHECK_TOKEN");

		// Initialize
		$GLOBALS["Page"] = &$this;
		$this->TokenTimeout = SessionTimeoutTime();

		// Language object
		if (!isset($Language))
			$Language = new Language();

		// Parent constuctor
		parent::__construct();

		// Table object (boletas)
		if (!isset($GLOBALS["boletas"]) || get_class($GLOBALS["boletas"]) == PROJECT_NAMESPACE . "boletas") {
			$GLOBALS["boletas"] = &$this;
			$GLOBALS["Table"] = &$GLOBALS["boletas"];
		}

		// Table object (usuarios)
		if (!isset($GLOBALS['usuarios']))
			$GLOBALS['usuarios'] = new usuarios();

		// Page ID (for backward compatibility only)
		if (!defined(PROJECT_NAMESPACE . "PAGE_ID"))
			define(PROJECT_NAMESPACE . "PAGE_ID", 'edit');

		// Table name (for backward compatibility only)
		if (!defined(PROJECT_NAMESPACE . "TABLE_NAME"))
			define(PROJECT_NAMESPACE . "TABLE_NAME", 'boletas');

		// Start timer
		if (!isset($GLOBALS["DebugTimer"]))
			$GLOBALS["DebugTimer"] = new Timer();

		// Debug message
		LoadDebugMessage();

		// Open connection
		if (!isset($GLOBALS["Conn"]))
			$GLOBALS["Conn"] = $this->getConnection();

		// User table object (usuarios)
		$UserTable = $UserTable ?: new usuarios();
	}

	// Terminate page
	public function terminate($url = "")
	{
		global $ExportFileName, $TempImages, $DashboardReport;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		// Export
		global $boletas;
		if ($this->CustomExport && $this->CustomExport == $this->Export && array_key_exists($this->CustomExport, Config("EXPORT_CLASSES"))) {
				$content = ob_get_contents();
			if ($ExportFileName == "")
				$ExportFileName = $this->TableVar;
			$class = PROJECT_NAMESPACE . Config("EXPORT_CLASSES." . $this->CustomExport);
			if (class_exists($class)) {
				$doc = new $class($boletas);
				$doc->Text = @$content;
				if ($this->isExport("email"))
					echo $this->exportEmail($doc->Text);
				else
					$doc->export();
				DeleteTempImages(); // Delete temp images
				exit();
			}
		}
		if (!IsApi())
			$this->Page_Redirecting($url);

		// Close connection
		CloseConnections();

		// Return for API
		if (IsApi()) {
			$res = $url === TRUE;
			if (!$res) // Show error
				WriteJson(array_merge(["success" => FALSE], $this->getMessages()));
			return;
		}

		// Go to URL if specified
		if ($url != "") {
			if (!Config("DEBUG") && ob_get_length())
				ob_end_clean();

			// Handle modal response
			if ($this->IsModal) { // Show as modal
				$row = ["url" => $url, "modal" => "1"];
				$pageName = GetPageName($url);
				if ($pageName != $this->getListUrl()) { // Not List page
					$row["caption"] = $this->getModalCaption($pageName);
					if ($pageName == "boletasview.php")
						$row["view"] = "1";
				} else { // List page should not be shown as modal => error
					$row["error"] = $this->getFailureMessage();
					$this->clearFailureMessage();
				}
				WriteJson($row);
			} else {
				SaveDebugMessage();
				AddHeader("Location", $url);
			}
		}
		exit();
	}

	// Get records from recordset
	protected function getRecordsFromRecordset($rs, $current = FALSE)
	{
		$rows = [];
		if (is_object($rs)) { // Recordset
			while ($rs && !$rs->EOF) {
				$this->loadRowValues($rs); // Set up DbValue/CurrentValue
				$row = $this->getRecordFromArray($rs->fields);
				if ($current)
					return $row;
				else
					$rows[] = $row;
				$rs->moveNext();
			}
		} elseif (is_array($rs)) {
			foreach ($rs as $ar) {
				$row = $this->getRecordFromArray($ar);
				if ($current)
					return $row;
				else
					$rows[] = $row;
			}
		}
		return $rows;
	}

	// Get record from array
	protected function getRecordFromArray($ar)
	{
		$row = [];
		if (is_array($ar)) {
			foreach ($ar as $fldname => $val) {
				if (array_key_exists($fldname, $this->fields) && ($this->fields[$fldname]->Visible || $this->fields[$fldname]->IsPrimaryKey)) { // Primary key or Visible
					$fld = &$this->fields[$fldname];
					if ($fld->HtmlTag == "FILE") { // Upload field
						if (EmptyValue($val)) {
							$row[$fldname] = NULL;
						} else {
							if ($fld->DataType == DATATYPE_BLOB) {
								$url = FullUrl(GetApiUrl(Config("API_FILE_ACTION"),
									Config("API_OBJECT_NAME") . "=" . $fld->TableVar . "&" .
									Config("API_FIELD_NAME") . "=" . $fld->Param . "&" .
									Config("API_KEY_NAME") . "=" . rawurlencode($this->getRecordKeyValue($ar)))); //*** need to add this? API may not be in the same folder
								$row[$fldname] = ["type" => ContentType($val), "url" => $url, "name" => $fld->Param . ContentExtension($val)];
							} elseif (!$fld->UploadMultiple || !ContainsString($val, Config("MULTIPLE_UPLOAD_SEPARATOR"))) { // Single file
								$url = FullUrl(GetApiUrl(Config("API_FILE_ACTION"),
									Config("API_OBJECT_NAME") . "=" . $fld->TableVar . "&" .
									"fn=" . Encrypt($fld->physicalUploadPath() . $val)));
								$row[$fldname] = ["type" => MimeContentType($val), "url" => $url, "name" => $val];
							} else { // Multiple files
								$files = explode(Config("MULTIPLE_UPLOAD_SEPARATOR"), $val);
								$ar = [];
								foreach ($files as $file) {
									$url = FullUrl(GetApiUrl(Config("API_FILE_ACTION"),
										Config("API_OBJECT_NAME") . "=" . $fld->TableVar . "&" .
										"fn=" . Encrypt($fld->physicalUploadPath() . $file)));
									if (!EmptyValue($file))
										$ar[] = ["type" => MimeContentType($file), "url" => $url, "name" => $file];
								}
								$row[$fldname] = $ar;
							}
						}
					} else {
						$row[$fldname] = $val;
					}
				}
			}
		}
		return $row;
	}

	// Get record key value from array
	protected function getRecordKeyValue($ar)
	{
		$key = "";
		if (is_array($ar)) {
			$key .= @$ar['id'];
		}
		return $key;
	}

	/**
	 * Hide fields for add/edit
	 *
	 * @return void
	 */
	protected function hideFieldsForAddEdit()
	{
		if ($this->isAdd() || $this->isCopy() || $this->isGridAdd())
			$this->id->Visible = FALSE;
	}

	// Lookup data
	public function lookup()
	{
		global $Language, $Security;
		if (!isset($Language))
			$Language = new Language(Config("LANGUAGE_FOLDER"), Post("language", ""));

		// Set up API request
		if (!ValidApiRequest())
			return FALSE;
		$this->setupApiSecurity();

		// Get lookup object
		$fieldName = Post("field");
		if (!array_key_exists($fieldName, $this->fields))
			return FALSE;
		$lookupField = $this->fields[$fieldName];
		$lookup = $lookupField->Lookup;
		if ($lookup === NULL)
			return FALSE;
		$tbl = $lookup->getTable();
		if (!$Security->allowLookup(Config("PROJECT_ID") . $tbl->TableName)) // Lookup permission
			return FALSE;

		// Get lookup parameters
		$lookupType = Post("ajax", "unknown");
		$pageSize = -1;
		$offset = -1;
		$searchValue = "";
		if (SameText($lookupType, "modal")) {
			$searchValue = Post("sv", "");
			$pageSize = Post("recperpage", 10);
			$offset = Post("start", 0);
		} elseif (SameText($lookupType, "autosuggest")) {
			$searchValue = Param("q", "");
			$pageSize = Param("n", -1);
			$pageSize = is_numeric($pageSize) ? (int)$pageSize : -1;
			if ($pageSize <= 0)
				$pageSize = Config("AUTO_SUGGEST_MAX_ENTRIES");
			$start = Param("start", -1);
			$start = is_numeric($start) ? (int)$start : -1;
			$page = Param("page", -1);
			$page = is_numeric($page) ? (int)$page : -1;
			$offset = $start >= 0 ? $start : ($page > 0 && $pageSize > 0 ? ($page - 1) * $pageSize : 0);
		}
		$userSelect = Decrypt(Post("s", ""));
		$userFilter = Decrypt(Post("f", ""));
		$userOrderBy = Decrypt(Post("o", ""));
		$keys = Post("keys");
		$lookup->LookupType = $lookupType; // Lookup type
		if ($keys !== NULL) { // Selected records from modal
			if (is_array($keys))
				$keys = implode(Config("MULTIPLE_OPTION_SEPARATOR"), $keys);
			$lookup->FilterFields = []; // Skip parent fields if any
			$lookup->FilterValues[] = $keys; // Lookup values
			$pageSize = -1; // Show all records
		} else { // Lookup values
			$lookup->FilterValues[] = Post("v0", Post("lookupValue", ""));
		}
		$cnt = is_array($lookup->FilterFields) ? count($lookup->FilterFields) : 0;
		for ($i = 1; $i <= $cnt; $i++)
			$lookup->FilterValues[] = Post("v" . $i, "");
		$lookup->SearchValue = $searchValue;
		$lookup->PageSize = $pageSize;
		$lookup->Offset = $offset;
		if ($userSelect != "")
			$lookup->UserSelect = $userSelect;
		if ($userFilter != "")
			$lookup->UserFilter = $userFilter;
		if ($userOrderBy != "")
			$lookup->UserOrderBy = $userOrderBy;
		$lookup->toJson($this); // Use settings from current page
	}

	// Set up API security
	public function setupApiSecurity()
	{
		global $Security;

		// Setup security for API request
		if ($Security->isLoggedIn()) $Security->TablePermission_Loading();
		$Security->loadCurrentUserLevel(Config("PROJECT_ID") . $this->TableName);
		if ($Security->isLoggedIn()) $Security->TablePermission_Loaded();
		$Security->UserID_Loading();
		$Security->loadUserID();
		$Security->UserID_Loaded();
	}
	public $FormClassName = "ew-horizontal ew-form ew-edit-form";
	public $IsModal = FALSE;
	public $IsMobileOrModal = FALSE;
	public $DbMasterFilter;
	public $DbDetailFilter;

	//
	// Page run
	//

	public function run()
	{
		global $ExportType, $CustomExportType, $ExportFileName, $UserProfile, $Language, $Security, $CurrentForm,
			$FormError, $SkipHeaderFooter;

		// Is modal
		$this->IsModal = (Param("modal") == "1");

		// User profile
		$UserProfile = new UserProfile();

		// Security
		if (ValidApiRequest()) { // API request
			$this->setupApiSecurity(); // Set up API Security
			if (!$Security->canEdit()) {
				SetStatus(401); // Unauthorized
				return;
			}
		} else {
			$Security = new AdvancedSecurity();
			if (!$Security->isLoggedIn())
				$Security->autoLogin();
			if ($Security->isLoggedIn())
				$Security->TablePermission_Loading();
			$Security->loadCurrentUserLevel($this->ProjectID . $this->TableName);
			if ($Security->isLoggedIn())
				$Security->TablePermission_Loaded();
			if (!$Security->canEdit()) {
				$Security->saveLastUrl();
				$this->setFailureMessage(DeniedMessage()); // Set no permission
				if ($Security->canList())
					$this->terminate(GetUrl("boletaslist.php"));
				else
					$this->terminate(GetUrl("login.php"));
				return;
			}
			if ($Security->isLoggedIn()) {
				$Security->UserID_Loading();
				$Security->loadUserID();
				$Security->UserID_Loaded();
			}
		}

		// Create form object
		$CurrentForm = new HttpForm();
		$this->CurrentAction = Param("action"); // Set up current action
		$this->id->setVisibility();
		$this->id_empresa->setVisibility();
		$this->CUIT_Empresa->setVisibility();
		$this->Codigo_Empresa->setVisibility();
		$this->Domicilio->setVisibility();
		$this->Localidad->setVisibility();
		$this->Mes_Liquidado->setVisibility();
		$this->Anio->setVisibility();
		$this->Cuota_Sindical_Destino_Seccional->setVisibility();
		$this->APORTE_No_REm_SINDICAL->setVisibility();
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->setVisibility();
		$this->OTROS->setVisibility();
		$this->Fecha->setVisibility();
		$this->ip->setVisibility();
		$this->Lugar->setVisibility();
		$this->Codigo_Convenio->setVisibility();
		$this->Total->setVisibility();
		$this->hideFieldsForAddEdit();

		// Do not use lookup cache
		$this->setUseLookupCache(FALSE);

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();

		// Check token
		if (!$this->validPost()) {
			Write($Language->phrase("InvalidPostRequest"));
			$this->terminate();
		}

		// Create Token
		$this->createToken();

		// Set up lookup cache
		// Check permission

		if (!$Security->canEdit()) {
			$this->setFailureMessage(DeniedMessage()); // No permission
			$this->terminate("boletaslist.php");
			return;
		}

		// Check modal
		if ($this->IsModal)
			$SkipHeaderFooter = TRUE;
		$this->IsMobileOrModal = IsMobile() || $this->IsModal;
		$this->FormClassName = "ew-form ew-edit-form ew-horizontal";
		$loaded = FALSE;
		$postBack = FALSE;

		// Set up current action and primary key
		if (IsApi()) {

			// Load key values
			$loaded = TRUE;
			if (Get("id") !== NULL) {
				$this->id->setQueryStringValue(Get("id"));
				$this->id->setOldValue($this->id->QueryStringValue);
			} elseif (Key(0) !== NULL) {
				$this->id->setQueryStringValue(Key(0));
				$this->id->setOldValue($this->id->QueryStringValue);
			} elseif (Post("id") !== NULL) {
				$this->id->setFormValue(Post("id"));
				$this->id->setOldValue($this->id->FormValue);
			} elseif (Route(2) !== NULL) {
				$this->id->setQueryStringValue(Route(2));
				$this->id->setOldValue($this->id->QueryStringValue);
			} else {
				$loaded = FALSE; // Unable to load key
			}

			// Load record
			if ($loaded)
				$loaded = $this->loadRow();
			if (!$loaded) {
				$this->setFailureMessage($Language->phrase("NoRecord")); // Set no record message
				$this->terminate();
				return;
			}
			$this->CurrentAction = "update"; // Update record directly
			$postBack = TRUE;
		} else {
			if (Post("action") !== NULL) {
				$this->CurrentAction = Post("action"); // Get action code
				if (!$this->isShow()) // Not reload record, handle as postback
					$postBack = TRUE;

				// Load key from Form
				if ($CurrentForm->hasValue("x_id")) {
					$this->id->setFormValue($CurrentForm->getValue("x_id"));
				}
			} else {
				$this->CurrentAction = "show"; // Default action is display

				// Load key from QueryString / Route
				$loadByQuery = FALSE;
				if (Get("id") !== NULL) {
					$this->id->setQueryStringValue(Get("id"));
					$loadByQuery = TRUE;
				} elseif (Route(2) !== NULL) {
					$this->id->setQueryStringValue(Route(2));
					$loadByQuery = TRUE;
				} else {
					$this->id->CurrentValue = NULL;
				}
			}

			// Load current record
			$loaded = $this->loadRow();
		}

		// Process form if post back
		if ($postBack) {
			$this->loadFormValues(); // Get form values
		}

		// Validate form if post back
		if ($postBack) {
			if (!$this->validateForm()) {
				$this->setFailureMessage($FormError);
				$this->EventCancelled = TRUE; // Event cancelled
				$this->restoreFormValues();
				if (IsApi()) {
					$this->terminate();
					return;
				} else {
					$this->CurrentAction = ""; // Form error, reset action
				}
			}
		}

		// Perform current action
		switch ($this->CurrentAction) {
			case "show": // Get a record to display
				if (!$loaded) { // Load record based on key
					if ($this->getFailureMessage() == "")
						$this->setFailureMessage($Language->phrase("NoRecord")); // No record found
					$this->terminate("boletaslist.php"); // No matching record, return to list
				}
				break;
			case "update": // Update
				$returnUrl = $this->getReturnUrl();
				if (GetPageName($returnUrl) == "boletaslist.php")
					$returnUrl = $this->addMasterUrl($returnUrl); // List page, return to List page with correct master key if necessary
				$this->SendEmail = TRUE; // Send email on update success
				if ($this->editRow()) { // Update record based on key
					if ($this->getSuccessMessage() == "")
						$this->setSuccessMessage($Language->phrase("UpdateSuccess")); // Update success
					if (IsApi()) {
						$this->terminate(TRUE);
						return;
					} else {
						$this->terminate($returnUrl); // Return to caller
					}
				} elseif (IsApi()) { // API request, return
					$this->terminate();
					return;
				} elseif ($this->getFailureMessage() == $Language->phrase("NoRecord")) {
					$this->terminate($returnUrl); // Return to caller
				} else {
					$this->EventCancelled = TRUE; // Event cancelled
					$this->restoreFormValues(); // Restore form values if update failed
				}
		}

		// Set up Breadcrumb
		$this->setupBreadcrumb();

		// Render the record
		$this->RowType = ROWTYPE_EDIT; // Render as Edit
		$this->resetAttributes();
		$this->renderRow();
	}

	// Get upload files
	protected function getUploadFiles()
	{
		global $CurrentForm, $Language;
	}

	// Load form values
	protected function loadFormValues()
	{

		// Load from form
		global $CurrentForm;

		// Check field name 'id' first before field var 'x_id'
		$val = $CurrentForm->hasValue("id") ? $CurrentForm->getValue("id") : $CurrentForm->getValue("x_id");
		if (!$this->id->IsDetailKey)
			$this->id->setFormValue($val);

		// Check field name 'id_empresa' first before field var 'x_id_empresa'
		$val = $CurrentForm->hasValue("id_empresa") ? $CurrentForm->getValue("id_empresa") : $CurrentForm->getValue("x_id_empresa");
		if (!$this->id_empresa->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->id_empresa->Visible = FALSE; // Disable update for API request
			else
				$this->id_empresa->setFormValue($val);
		}

		// Check field name 'CUIT_Empresa' first before field var 'x_CUIT_Empresa'
		$val = $CurrentForm->hasValue("CUIT_Empresa") ? $CurrentForm->getValue("CUIT_Empresa") : $CurrentForm->getValue("x_CUIT_Empresa");
		if (!$this->CUIT_Empresa->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->CUIT_Empresa->Visible = FALSE; // Disable update for API request
			else
				$this->CUIT_Empresa->setFormValue($val);
		}

		// Check field name 'Codigo_Empresa' first before field var 'x_Codigo_Empresa'
		$val = $CurrentForm->hasValue("Codigo_Empresa") ? $CurrentForm->getValue("Codigo_Empresa") : $CurrentForm->getValue("x_Codigo_Empresa");
		if (!$this->Codigo_Empresa->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Codigo_Empresa->Visible = FALSE; // Disable update for API request
			else
				$this->Codigo_Empresa->setFormValue($val);
		}

		// Check field name 'Domicilio' first before field var 'x_Domicilio'
		$val = $CurrentForm->hasValue("Domicilio") ? $CurrentForm->getValue("Domicilio") : $CurrentForm->getValue("x_Domicilio");
		if (!$this->Domicilio->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Domicilio->Visible = FALSE; // Disable update for API request
			else
				$this->Domicilio->setFormValue($val);
		}

		// Check field name 'Localidad' first before field var 'x_Localidad'
		$val = $CurrentForm->hasValue("Localidad") ? $CurrentForm->getValue("Localidad") : $CurrentForm->getValue("x_Localidad");
		if (!$this->Localidad->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Localidad->Visible = FALSE; // Disable update for API request
			else
				$this->Localidad->setFormValue($val);
		}

		// Check field name 'Mes_Liquidado' first before field var 'x_Mes_Liquidado'
		$val = $CurrentForm->hasValue("Mes_Liquidado") ? $CurrentForm->getValue("Mes_Liquidado") : $CurrentForm->getValue("x_Mes_Liquidado");
		if (!$this->Mes_Liquidado->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Mes_Liquidado->Visible = FALSE; // Disable update for API request
			else
				$this->Mes_Liquidado->setFormValue($val);
		}

		// Check field name 'Anio' first before field var 'x_Anio'
		$val = $CurrentForm->hasValue("Anio") ? $CurrentForm->getValue("Anio") : $CurrentForm->getValue("x_Anio");
		if (!$this->Anio->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Anio->Visible = FALSE; // Disable update for API request
			else
				$this->Anio->setFormValue($val);
		}

		// Check field name 'Cuota_Sindical_Destino_Seccional' first before field var 'x_Cuota_Sindical_Destino_Seccional'
		$val = $CurrentForm->hasValue("Cuota_Sindical_Destino_Seccional") ? $CurrentForm->getValue("Cuota_Sindical_Destino_Seccional") : $CurrentForm->getValue("x_Cuota_Sindical_Destino_Seccional");
		if (!$this->Cuota_Sindical_Destino_Seccional->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Cuota_Sindical_Destino_Seccional->Visible = FALSE; // Disable update for API request
			else
				$this->Cuota_Sindical_Destino_Seccional->setFormValue($val);
		}

		// Check field name 'APORTE_No_REm_SINDICAL' first before field var 'x_APORTE_No_REm_SINDICAL'
		$val = $CurrentForm->hasValue("APORTE_No_REm_SINDICAL") ? $CurrentForm->getValue("APORTE_No_REm_SINDICAL") : $CurrentForm->getValue("x_APORTE_No_REm_SINDICAL");
		if (!$this->APORTE_No_REm_SINDICAL->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->APORTE_No_REm_SINDICAL->Visible = FALSE; // Disable update for API request
			else
				$this->APORTE_No_REm_SINDICAL->setFormValue($val);
		}

		// Check field name 'APORTE_BENEFICIO_SOCIAL_NO_Rem' first before field var 'x_APORTE_BENEFICIO_SOCIAL_NO_Rem'
		$val = $CurrentForm->hasValue("APORTE_BENEFICIO_SOCIAL_NO_Rem") ? $CurrentForm->getValue("APORTE_BENEFICIO_SOCIAL_NO_Rem") : $CurrentForm->getValue("x_APORTE_BENEFICIO_SOCIAL_NO_Rem");
		if (!$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->Visible = FALSE; // Disable update for API request
			else
				$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->setFormValue($val);
		}

		// Check field name 'OTROS' first before field var 'x_OTROS'
		$val = $CurrentForm->hasValue("OTROS") ? $CurrentForm->getValue("OTROS") : $CurrentForm->getValue("x_OTROS");
		if (!$this->OTROS->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->OTROS->Visible = FALSE; // Disable update for API request
			else
				$this->OTROS->setFormValue($val);
		}

		// Check field name 'Fecha' first before field var 'x_Fecha'
		$val = $CurrentForm->hasValue("Fecha") ? $CurrentForm->getValue("Fecha") : $CurrentForm->getValue("x_Fecha");
		if (!$this->Fecha->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Fecha->Visible = FALSE; // Disable update for API request
			else
				$this->Fecha->setFormValue($val);
			$this->Fecha->CurrentValue = UnFormatDateTime($this->Fecha->CurrentValue, 0);
		}

		// Check field name 'ip' first before field var 'x_ip'
		$val = $CurrentForm->hasValue("ip") ? $CurrentForm->getValue("ip") : $CurrentForm->getValue("x_ip");
		if (!$this->ip->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->ip->Visible = FALSE; // Disable update for API request
			else
				$this->ip->setFormValue($val);
		}

		// Check field name 'Lugar' first before field var 'x_Lugar'
		$val = $CurrentForm->hasValue("Lugar") ? $CurrentForm->getValue("Lugar") : $CurrentForm->getValue("x_Lugar");
		if (!$this->Lugar->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Lugar->Visible = FALSE; // Disable update for API request
			else
				$this->Lugar->setFormValue($val);
		}

		// Check field name 'Codigo_Convenio' first before field var 'x_Codigo_Convenio'
		$val = $CurrentForm->hasValue("Codigo_Convenio") ? $CurrentForm->getValue("Codigo_Convenio") : $CurrentForm->getValue("x_Codigo_Convenio");
		if (!$this->Codigo_Convenio->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Codigo_Convenio->Visible = FALSE; // Disable update for API request
			else
				$this->Codigo_Convenio->setFormValue($val);
		}

		// Check field name 'Total' first before field var 'x_Total'
		$val = $CurrentForm->hasValue("Total") ? $CurrentForm->getValue("Total") : $CurrentForm->getValue("x_Total");
		if (!$this->Total->IsDetailKey) {
			if (IsApi() && $val == NULL)
				$this->Total->Visible = FALSE; // Disable update for API request
			else
				$this->Total->setFormValue($val);
		}
	}

	// Restore form values
	public function restoreFormValues()
	{
		global $CurrentForm;
		$this->id->CurrentValue = $this->id->FormValue;
		$this->id_empresa->CurrentValue = $this->id_empresa->FormValue;
		$this->CUIT_Empresa->CurrentValue = $this->CUIT_Empresa->FormValue;
		$this->Codigo_Empresa->CurrentValue = $this->Codigo_Empresa->FormValue;
		$this->Domicilio->CurrentValue = $this->Domicilio->FormValue;
		$this->Localidad->CurrentValue = $this->Localidad->FormValue;
		$this->Mes_Liquidado->CurrentValue = $this->Mes_Liquidado->FormValue;
		$this->Anio->CurrentValue = $this->Anio->FormValue;
		$this->Cuota_Sindical_Destino_Seccional->CurrentValue = $this->Cuota_Sindical_Destino_Seccional->FormValue;
		$this->APORTE_No_REm_SINDICAL->CurrentValue = $this->APORTE_No_REm_SINDICAL->FormValue;
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue = $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->FormValue;
		$this->OTROS->CurrentValue = $this->OTROS->FormValue;
		$this->Fecha->CurrentValue = $this->Fecha->FormValue;
		$this->Fecha->CurrentValue = UnFormatDateTime($this->Fecha->CurrentValue, 0);
		$this->ip->CurrentValue = $this->ip->FormValue;
		$this->Lugar->CurrentValue = $this->Lugar->FormValue;
		$this->Codigo_Convenio->CurrentValue = $this->Codigo_Convenio->FormValue;
		$this->Total->CurrentValue = $this->Total->FormValue;
	}

	// Load row based on key values
	public function loadRow()
	{
		global $Security, $Language;
		$filter = $this->getRecordFilter();

		// Call Row Selecting event
		$this->Row_Selecting($filter);

		// Load SQL based on filter
		$this->CurrentFilter = $filter;
		$sql = $this->getCurrentSql();
		$conn = $this->getConnection();
		$res = FALSE;
		$rs = LoadRecordset($sql, $conn);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->loadRowValues($rs); // Load row values
			$rs->close();
		}
		return $res;
	}

	// Load row values from recordset
	public function loadRowValues($rs = NULL)
	{
		if ($rs && !$rs->EOF)
			$row = $rs->fields;
		else
			$row = $this->newRow();

		// Call Row Selected event
		$this->Row_Selected($row);
		if (!$rs || $rs->EOF)
			return;
		$this->id->setDbValue($row['id']);
		$this->id_empresa->setDbValue($row['id_empresa']);
		$this->CUIT_Empresa->setDbValue($row['CUIT_Empresa']);
		$this->Codigo_Empresa->setDbValue($row['Codigo_Empresa']);
		$this->Domicilio->setDbValue($row['Domicilio']);
		$this->Localidad->setDbValue($row['Localidad']);
		$this->Mes_Liquidado->setDbValue($row['Mes_Liquidado']);
		$this->Anio->setDbValue($row['Anio']);
		$this->Cuota_Sindical_Destino_Seccional->setDbValue($row['Cuota_Sindical_Destino_Seccional']);
		$this->APORTE_No_REm_SINDICAL->setDbValue($row['APORTE_No_REm_SINDICAL']);
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->setDbValue($row['APORTE_BENEFICIO_SOCIAL_NO_Rem']);
		$this->OTROS->setDbValue($row['OTROS']);
		$this->Fecha->setDbValue($row['Fecha']);
		$this->ip->setDbValue($row['ip']);
		$this->Lugar->setDbValue($row['Lugar']);
		$this->Codigo_Convenio->setDbValue($row['Codigo_Convenio']);
		$this->Total->setDbValue($row['Total']);
	}

	// Return a row with default values
	protected function newRow()
	{
		$row = [];
		$row['id'] = NULL;
		$row['id_empresa'] = NULL;
		$row['CUIT_Empresa'] = NULL;
		$row['Codigo_Empresa'] = NULL;
		$row['Domicilio'] = NULL;
		$row['Localidad'] = NULL;
		$row['Mes_Liquidado'] = NULL;
		$row['Anio'] = NULL;
		$row['Cuota_Sindical_Destino_Seccional'] = NULL;
		$row['APORTE_No_REm_SINDICAL'] = NULL;
		$row['APORTE_BENEFICIO_SOCIAL_NO_Rem'] = NULL;
		$row['OTROS'] = NULL;
		$row['Fecha'] = NULL;
		$row['ip'] = NULL;
		$row['Lugar'] = NULL;
		$row['Codigo_Convenio'] = NULL;
		$row['Total'] = NULL;
		return $row;
	}

	// Load old record
	protected function loadOldRecord()
	{

		// Load key values from Session
		$validKey = TRUE;
		if (strval($this->getKey("id")) != "")
			$this->id->OldValue = $this->getKey("id"); // id
		else
			$validKey = FALSE;

		// Load old record
		$this->OldRecordset = NULL;
		if ($validKey) {
			$this->CurrentFilter = $this->getRecordFilter();
			$sql = $this->getCurrentSql();
			$conn = $this->getConnection();
			$this->OldRecordset = LoadRecordset($sql, $conn);
		}
		$this->loadRowValues($this->OldRecordset); // Load row values
		return $validKey;
	}

	// Render row values based on field settings
	public function renderRow()
	{
		global $Security, $Language, $CurrentLanguage;

		// Initialize URLs
		// Convert decimal values if posted back

		if ($this->Cuota_Sindical_Destino_Seccional->FormValue == $this->Cuota_Sindical_Destino_Seccional->CurrentValue && is_numeric(ConvertToFloatString($this->Cuota_Sindical_Destino_Seccional->CurrentValue)))
			$this->Cuota_Sindical_Destino_Seccional->CurrentValue = ConvertToFloatString($this->Cuota_Sindical_Destino_Seccional->CurrentValue);

		// Convert decimal values if posted back
		if ($this->APORTE_No_REm_SINDICAL->FormValue == $this->APORTE_No_REm_SINDICAL->CurrentValue && is_numeric(ConvertToFloatString($this->APORTE_No_REm_SINDICAL->CurrentValue)))
			$this->APORTE_No_REm_SINDICAL->CurrentValue = ConvertToFloatString($this->APORTE_No_REm_SINDICAL->CurrentValue);

		// Convert decimal values if posted back
		if ($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->FormValue == $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue && is_numeric(ConvertToFloatString($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue)))
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue = ConvertToFloatString($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue);

		// Convert decimal values if posted back
		if ($this->OTROS->FormValue == $this->OTROS->CurrentValue && is_numeric(ConvertToFloatString($this->OTROS->CurrentValue)))
			$this->OTROS->CurrentValue = ConvertToFloatString($this->OTROS->CurrentValue);

		// Convert decimal values if posted back
		if ($this->Total->FormValue == $this->Total->CurrentValue && is_numeric(ConvertToFloatString($this->Total->CurrentValue)))
			$this->Total->CurrentValue = ConvertToFloatString($this->Total->CurrentValue);

		// Call Row_Rendering event
		$this->Row_Rendering();

		// Common render codes for all row types
		// id
		// id_empresa
		// CUIT_Empresa
		// Codigo_Empresa
		// Domicilio
		// Localidad
		// Mes_Liquidado
		// Anio
		// Cuota_Sindical_Destino_Seccional
		// APORTE_No_REm_SINDICAL
		// APORTE_BENEFICIO_SOCIAL_NO_Rem
		// OTROS
		// Fecha
		// ip
		// Lugar
		// Codigo_Convenio
		// Total

		if ($this->RowType == ROWTYPE_VIEW) { // View row

			// id
			$this->id->ViewValue = $this->id->CurrentValue;
			$this->id->ViewCustomAttributes = "";

			// id_empresa
			$this->id_empresa->ViewValue = $this->id_empresa->CurrentValue;
			$this->id_empresa->ViewValue = FormatNumber($this->id_empresa->ViewValue, 0, -2, -2, -2);
			$this->id_empresa->ViewCustomAttributes = "";

			// CUIT_Empresa
			$this->CUIT_Empresa->ViewValue = $this->CUIT_Empresa->CurrentValue;
			$this->CUIT_Empresa->ViewCustomAttributes = "";

			// Codigo_Empresa
			$this->Codigo_Empresa->ViewValue = $this->Codigo_Empresa->CurrentValue;
			$this->Codigo_Empresa->ViewCustomAttributes = "";

			// Domicilio
			$this->Domicilio->ViewValue = $this->Domicilio->CurrentValue;
			$this->Domicilio->ViewCustomAttributes = "";

			// Localidad
			$this->Localidad->ViewValue = $this->Localidad->CurrentValue;
			$this->Localidad->ViewCustomAttributes = "";

			// Mes_Liquidado
			$this->Mes_Liquidado->ViewValue = $this->Mes_Liquidado->CurrentValue;
			$this->Mes_Liquidado->ViewValue = FormatNumber($this->Mes_Liquidado->ViewValue, 0, -2, -2, -2);
			$this->Mes_Liquidado->ViewCustomAttributes = "";

			// Anio
			$this->Anio->ViewValue = $this->Anio->CurrentValue;
			$this->Anio->ViewValue = FormatNumber($this->Anio->ViewValue, 0, -2, -2, -2);
			$this->Anio->ViewCustomAttributes = "";

			// Cuota_Sindical_Destino_Seccional
			$this->Cuota_Sindical_Destino_Seccional->ViewValue = $this->Cuota_Sindical_Destino_Seccional->CurrentValue;
			$this->Cuota_Sindical_Destino_Seccional->ViewValue = FormatNumber($this->Cuota_Sindical_Destino_Seccional->ViewValue, 2, -2, -2, -2);
			$this->Cuota_Sindical_Destino_Seccional->ViewCustomAttributes = "";

			// APORTE_No_REm_SINDICAL
			$this->APORTE_No_REm_SINDICAL->ViewValue = $this->APORTE_No_REm_SINDICAL->CurrentValue;
			$this->APORTE_No_REm_SINDICAL->ViewValue = FormatNumber($this->APORTE_No_REm_SINDICAL->ViewValue, 2, -2, -2, -2);
			$this->APORTE_No_REm_SINDICAL->ViewCustomAttributes = "";

			// APORTE_BENEFICIO_SOCIAL_NO_Rem
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->ViewValue = $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue;
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->ViewValue = FormatNumber($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->ViewValue, 2, -2, -2, -2);
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->ViewCustomAttributes = "";

			// OTROS
			$this->OTROS->ViewValue = $this->OTROS->CurrentValue;
			$this->OTROS->ViewValue = FormatNumber($this->OTROS->ViewValue, 2, -2, -2, -2);
			$this->OTROS->ViewCustomAttributes = "";

			// Fecha
			$this->Fecha->ViewValue = $this->Fecha->CurrentValue;
			$this->Fecha->ViewValue = FormatDateTime($this->Fecha->ViewValue, 0);
			$this->Fecha->ViewCustomAttributes = "";

			// ip
			$this->ip->ViewValue = $this->ip->CurrentValue;
			$this->ip->ViewCustomAttributes = "";

			// Lugar
			$this->Lugar->ViewValue = $this->Lugar->CurrentValue;
			$this->Lugar->ViewCustomAttributes = "";

			// Codigo_Convenio
			$this->Codigo_Convenio->ViewValue = $this->Codigo_Convenio->CurrentValue;
			$this->Codigo_Convenio->ViewCustomAttributes = "";

			// Total
			$this->Total->ViewValue = $this->Total->CurrentValue;
			$this->Total->ViewValue = FormatNumber($this->Total->ViewValue, 2, -2, -2, -2);
			$this->Total->ViewCustomAttributes = "";

			// id
			$this->id->LinkCustomAttributes = "";
			$this->id->HrefValue = "";
			$this->id->TooltipValue = "";

			// id_empresa
			$this->id_empresa->LinkCustomAttributes = "";
			$this->id_empresa->HrefValue = "";
			$this->id_empresa->TooltipValue = "";

			// CUIT_Empresa
			$this->CUIT_Empresa->LinkCustomAttributes = "";
			$this->CUIT_Empresa->HrefValue = "";
			$this->CUIT_Empresa->TooltipValue = "";

			// Codigo_Empresa
			$this->Codigo_Empresa->LinkCustomAttributes = "";
			$this->Codigo_Empresa->HrefValue = "";
			$this->Codigo_Empresa->TooltipValue = "";

			// Domicilio
			$this->Domicilio->LinkCustomAttributes = "";
			$this->Domicilio->HrefValue = "";
			$this->Domicilio->TooltipValue = "";

			// Localidad
			$this->Localidad->LinkCustomAttributes = "";
			$this->Localidad->HrefValue = "";
			$this->Localidad->TooltipValue = "";

			// Mes_Liquidado
			$this->Mes_Liquidado->LinkCustomAttributes = "";
			$this->Mes_Liquidado->HrefValue = "";
			$this->Mes_Liquidado->TooltipValue = "";

			// Anio
			$this->Anio->LinkCustomAttributes = "";
			$this->Anio->HrefValue = "";
			$this->Anio->TooltipValue = "";

			// Cuota_Sindical_Destino_Seccional
			$this->Cuota_Sindical_Destino_Seccional->LinkCustomAttributes = "";
			$this->Cuota_Sindical_Destino_Seccional->HrefValue = "";
			$this->Cuota_Sindical_Destino_Seccional->TooltipValue = "";

			// APORTE_No_REm_SINDICAL
			$this->APORTE_No_REm_SINDICAL->LinkCustomAttributes = "";
			$this->APORTE_No_REm_SINDICAL->HrefValue = "";
			$this->APORTE_No_REm_SINDICAL->TooltipValue = "";

			// APORTE_BENEFICIO_SOCIAL_NO_Rem
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->LinkCustomAttributes = "";
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->HrefValue = "";
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->TooltipValue = "";

			// OTROS
			$this->OTROS->LinkCustomAttributes = "";
			$this->OTROS->HrefValue = "";
			$this->OTROS->TooltipValue = "";

			// Fecha
			$this->Fecha->LinkCustomAttributes = "";
			$this->Fecha->HrefValue = "";
			$this->Fecha->TooltipValue = "";

			// ip
			$this->ip->LinkCustomAttributes = "";
			$this->ip->HrefValue = "";
			$this->ip->TooltipValue = "";

			// Lugar
			$this->Lugar->LinkCustomAttributes = "";
			$this->Lugar->HrefValue = "";
			$this->Lugar->TooltipValue = "";

			// Codigo_Convenio
			$this->Codigo_Convenio->LinkCustomAttributes = "";
			$this->Codigo_Convenio->HrefValue = "";
			$this->Codigo_Convenio->TooltipValue = "";

			// Total
			$this->Total->LinkCustomAttributes = "";
			$this->Total->HrefValue = "";
			$this->Total->TooltipValue = "";
		} elseif ($this->RowType == ROWTYPE_EDIT) { // Edit row

			// id
			$this->id->EditAttrs["class"] = "form-control";
			$this->id->EditCustomAttributes = "";
			$this->id->EditValue = $this->id->CurrentValue;
			$this->id->ViewCustomAttributes = "";

			// id_empresa
			$this->id_empresa->EditAttrs["class"] = "form-control";
			$this->id_empresa->EditCustomAttributes = "";
			$this->id_empresa->EditValue = HtmlEncode($this->id_empresa->CurrentValue);
			$this->id_empresa->PlaceHolder = RemoveHtml($this->id_empresa->caption());

			// CUIT_Empresa
			$this->CUIT_Empresa->EditAttrs["class"] = "form-control";
			$this->CUIT_Empresa->EditCustomAttributes = "";
			if (!$this->CUIT_Empresa->Raw)
				$this->CUIT_Empresa->CurrentValue = HtmlDecode($this->CUIT_Empresa->CurrentValue);
			$this->CUIT_Empresa->EditValue = HtmlEncode($this->CUIT_Empresa->CurrentValue);
			$this->CUIT_Empresa->PlaceHolder = RemoveHtml($this->CUIT_Empresa->caption());

			// Codigo_Empresa
			$this->Codigo_Empresa->EditAttrs["class"] = "form-control";
			$this->Codigo_Empresa->EditCustomAttributes = "";
			if (!$this->Codigo_Empresa->Raw)
				$this->Codigo_Empresa->CurrentValue = HtmlDecode($this->Codigo_Empresa->CurrentValue);
			$this->Codigo_Empresa->EditValue = HtmlEncode($this->Codigo_Empresa->CurrentValue);
			$this->Codigo_Empresa->PlaceHolder = RemoveHtml($this->Codigo_Empresa->caption());

			// Domicilio
			$this->Domicilio->EditAttrs["class"] = "form-control";
			$this->Domicilio->EditCustomAttributes = "";
			if (!$this->Domicilio->Raw)
				$this->Domicilio->CurrentValue = HtmlDecode($this->Domicilio->CurrentValue);
			$this->Domicilio->EditValue = HtmlEncode($this->Domicilio->CurrentValue);
			$this->Domicilio->PlaceHolder = RemoveHtml($this->Domicilio->caption());

			// Localidad
			$this->Localidad->EditAttrs["class"] = "form-control";
			$this->Localidad->EditCustomAttributes = "";
			if (!$this->Localidad->Raw)
				$this->Localidad->CurrentValue = HtmlDecode($this->Localidad->CurrentValue);
			$this->Localidad->EditValue = HtmlEncode($this->Localidad->CurrentValue);
			$this->Localidad->PlaceHolder = RemoveHtml($this->Localidad->caption());

			// Mes_Liquidado
			$this->Mes_Liquidado->EditAttrs["class"] = "form-control";
			$this->Mes_Liquidado->EditCustomAttributes = "";
			$this->Mes_Liquidado->EditValue = HtmlEncode($this->Mes_Liquidado->CurrentValue);
			$this->Mes_Liquidado->PlaceHolder = RemoveHtml($this->Mes_Liquidado->caption());

			// Anio
			$this->Anio->EditAttrs["class"] = "form-control";
			$this->Anio->EditCustomAttributes = "";
			$this->Anio->EditValue = HtmlEncode($this->Anio->CurrentValue);
			$this->Anio->PlaceHolder = RemoveHtml($this->Anio->caption());

			// Cuota_Sindical_Destino_Seccional
			$this->Cuota_Sindical_Destino_Seccional->EditAttrs["class"] = "form-control";
			$this->Cuota_Sindical_Destino_Seccional->EditCustomAttributes = "";
			$this->Cuota_Sindical_Destino_Seccional->EditValue = HtmlEncode($this->Cuota_Sindical_Destino_Seccional->CurrentValue);
			$this->Cuota_Sindical_Destino_Seccional->PlaceHolder = RemoveHtml($this->Cuota_Sindical_Destino_Seccional->caption());
			if (strval($this->Cuota_Sindical_Destino_Seccional->EditValue) != "" && is_numeric($this->Cuota_Sindical_Destino_Seccional->EditValue))
				$this->Cuota_Sindical_Destino_Seccional->EditValue = FormatNumber($this->Cuota_Sindical_Destino_Seccional->EditValue, -2, -2, -2, -2);
			

			// APORTE_No_REm_SINDICAL
			$this->APORTE_No_REm_SINDICAL->EditAttrs["class"] = "form-control";
			$this->APORTE_No_REm_SINDICAL->EditCustomAttributes = "";
			$this->APORTE_No_REm_SINDICAL->EditValue = HtmlEncode($this->APORTE_No_REm_SINDICAL->CurrentValue);
			$this->APORTE_No_REm_SINDICAL->PlaceHolder = RemoveHtml($this->APORTE_No_REm_SINDICAL->caption());
			if (strval($this->APORTE_No_REm_SINDICAL->EditValue) != "" && is_numeric($this->APORTE_No_REm_SINDICAL->EditValue))
				$this->APORTE_No_REm_SINDICAL->EditValue = FormatNumber($this->APORTE_No_REm_SINDICAL->EditValue, -2, -2, -2, -2);
			

			// APORTE_BENEFICIO_SOCIAL_NO_Rem
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditAttrs["class"] = "form-control";
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditCustomAttributes = "";
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditValue = HtmlEncode($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue);
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->PlaceHolder = RemoveHtml($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->caption());
			if (strval($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditValue) != "" && is_numeric($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditValue))
				$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditValue = FormatNumber($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->EditValue, -2, -2, -2, -2);
			

			// OTROS
			$this->OTROS->EditAttrs["class"] = "form-control";
			$this->OTROS->EditCustomAttributes = "";
			$this->OTROS->EditValue = HtmlEncode($this->OTROS->CurrentValue);
			$this->OTROS->PlaceHolder = RemoveHtml($this->OTROS->caption());
			if (strval($this->OTROS->EditValue) != "" && is_numeric($this->OTROS->EditValue))
				$this->OTROS->EditValue = FormatNumber($this->OTROS->EditValue, -2, -2, -2, -2);
			

			// Fecha
			$this->Fecha->EditAttrs["class"] = "form-control";
			$this->Fecha->EditCustomAttributes = "";
			$this->Fecha->EditValue = HtmlEncode(FormatDateTime($this->Fecha->CurrentValue, 8));
			$this->Fecha->PlaceHolder = RemoveHtml($this->Fecha->caption());

			// ip
			$this->ip->EditAttrs["class"] = "form-control";
			$this->ip->EditCustomAttributes = "";
			if (!$this->ip->Raw)
				$this->ip->CurrentValue = HtmlDecode($this->ip->CurrentValue);
			$this->ip->EditValue = HtmlEncode($this->ip->CurrentValue);
			$this->ip->PlaceHolder = RemoveHtml($this->ip->caption());

			// Lugar
			$this->Lugar->EditAttrs["class"] = "form-control";
			$this->Lugar->EditCustomAttributes = "";
			if (!$this->Lugar->Raw)
				$this->Lugar->CurrentValue = HtmlDecode($this->Lugar->CurrentValue);
			$this->Lugar->EditValue = HtmlEncode($this->Lugar->CurrentValue);
			$this->Lugar->PlaceHolder = RemoveHtml($this->Lugar->caption());

			// Codigo_Convenio
			$this->Codigo_Convenio->EditAttrs["class"] = "form-control";
			$this->Codigo_Convenio->EditCustomAttributes = "";
			if (!$this->Codigo_Convenio->Raw)
				$this->Codigo_Convenio->CurrentValue = HtmlDecode($this->Codigo_Convenio->CurrentValue);
			$this->Codigo_Convenio->EditValue = HtmlEncode($this->Codigo_Convenio->CurrentValue);
			$this->Codigo_Convenio->PlaceHolder = RemoveHtml($this->Codigo_Convenio->caption());

			// Total
			$this->Total->EditAttrs["class"] = "form-control";
			$this->Total->EditCustomAttributes = "";
			$this->Total->EditValue = HtmlEncode($this->Total->CurrentValue);
			$this->Total->PlaceHolder = RemoveHtml($this->Total->caption());
			if (strval($this->Total->EditValue) != "" && is_numeric($this->Total->EditValue))
				$this->Total->EditValue = FormatNumber($this->Total->EditValue, -2, -2, -2, -2);
			

			// Edit refer script
			// id

			$this->id->LinkCustomAttributes = "";
			$this->id->HrefValue = "";

			// id_empresa
			$this->id_empresa->LinkCustomAttributes = "";
			$this->id_empresa->HrefValue = "";

			// CUIT_Empresa
			$this->CUIT_Empresa->LinkCustomAttributes = "";
			$this->CUIT_Empresa->HrefValue = "";

			// Codigo_Empresa
			$this->Codigo_Empresa->LinkCustomAttributes = "";
			$this->Codigo_Empresa->HrefValue = "";

			// Domicilio
			$this->Domicilio->LinkCustomAttributes = "";
			$this->Domicilio->HrefValue = "";

			// Localidad
			$this->Localidad->LinkCustomAttributes = "";
			$this->Localidad->HrefValue = "";

			// Mes_Liquidado
			$this->Mes_Liquidado->LinkCustomAttributes = "";
			$this->Mes_Liquidado->HrefValue = "";

			// Anio
			$this->Anio->LinkCustomAttributes = "";
			$this->Anio->HrefValue = "";

			// Cuota_Sindical_Destino_Seccional
			$this->Cuota_Sindical_Destino_Seccional->LinkCustomAttributes = "";
			$this->Cuota_Sindical_Destino_Seccional->HrefValue = "";

			// APORTE_No_REm_SINDICAL
			$this->APORTE_No_REm_SINDICAL->LinkCustomAttributes = "";
			$this->APORTE_No_REm_SINDICAL->HrefValue = "";

			// APORTE_BENEFICIO_SOCIAL_NO_Rem
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->LinkCustomAttributes = "";
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->HrefValue = "";

			// OTROS
			$this->OTROS->LinkCustomAttributes = "";
			$this->OTROS->HrefValue = "";

			// Fecha
			$this->Fecha->LinkCustomAttributes = "";
			$this->Fecha->HrefValue = "";

			// ip
			$this->ip->LinkCustomAttributes = "";
			$this->ip->HrefValue = "";

			// Lugar
			$this->Lugar->LinkCustomAttributes = "";
			$this->Lugar->HrefValue = "";

			// Codigo_Convenio
			$this->Codigo_Convenio->LinkCustomAttributes = "";
			$this->Codigo_Convenio->HrefValue = "";

			// Total
			$this->Total->LinkCustomAttributes = "";
			$this->Total->HrefValue = "";
		}
		if ($this->RowType == ROWTYPE_ADD || $this->RowType == ROWTYPE_EDIT || $this->RowType == ROWTYPE_SEARCH) // Add/Edit/Search row
			$this->setupFieldTitles();

		// Call Row Rendered event
		if ($this->RowType != ROWTYPE_AGGREGATEINIT)
			$this->Row_Rendered();
	}

	// Validate form
	protected function validateForm()
	{
		global $Language, $FormError;

		// Initialize form error message
		$FormError = "";

		// Check if validation required
		if (!Config("SERVER_VALIDATE"))
			return ($FormError == "");
		if ($this->id->Required) {
			if (!$this->id->IsDetailKey && $this->id->FormValue != NULL && $this->id->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->id->caption(), $this->id->RequiredErrorMessage));
			}
		}
		if ($this->id_empresa->Required) {
			if (!$this->id_empresa->IsDetailKey && $this->id_empresa->FormValue != NULL && $this->id_empresa->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->id_empresa->caption(), $this->id_empresa->RequiredErrorMessage));
			}
		}
		if (!CheckInteger($this->id_empresa->FormValue)) {
			AddMessage($FormError, $this->id_empresa->errorMessage());
		}
		if ($this->CUIT_Empresa->Required) {
			if (!$this->CUIT_Empresa->IsDetailKey && $this->CUIT_Empresa->FormValue != NULL && $this->CUIT_Empresa->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->CUIT_Empresa->caption(), $this->CUIT_Empresa->RequiredErrorMessage));
			}
		}
		if ($this->Codigo_Empresa->Required) {
			if (!$this->Codigo_Empresa->IsDetailKey && $this->Codigo_Empresa->FormValue != NULL && $this->Codigo_Empresa->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Codigo_Empresa->caption(), $this->Codigo_Empresa->RequiredErrorMessage));
			}
		}
		if ($this->Domicilio->Required) {
			if (!$this->Domicilio->IsDetailKey && $this->Domicilio->FormValue != NULL && $this->Domicilio->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Domicilio->caption(), $this->Domicilio->RequiredErrorMessage));
			}
		}
		if ($this->Localidad->Required) {
			if (!$this->Localidad->IsDetailKey && $this->Localidad->FormValue != NULL && $this->Localidad->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Localidad->caption(), $this->Localidad->RequiredErrorMessage));
			}
		}
		if ($this->Mes_Liquidado->Required) {
			if (!$this->Mes_Liquidado->IsDetailKey && $this->Mes_Liquidado->FormValue != NULL && $this->Mes_Liquidado->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Mes_Liquidado->caption(), $this->Mes_Liquidado->RequiredErrorMessage));
			}
		}
		if (!CheckInteger($this->Mes_Liquidado->FormValue)) {
			AddMessage($FormError, $this->Mes_Liquidado->errorMessage());
		}
		if ($this->Anio->Required) {
			if (!$this->Anio->IsDetailKey && $this->Anio->FormValue != NULL && $this->Anio->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Anio->caption(), $this->Anio->RequiredErrorMessage));
			}
		}
		if (!CheckInteger($this->Anio->FormValue)) {
			AddMessage($FormError, $this->Anio->errorMessage());
		}
		if ($this->Cuota_Sindical_Destino_Seccional->Required) {
			if (!$this->Cuota_Sindical_Destino_Seccional->IsDetailKey && $this->Cuota_Sindical_Destino_Seccional->FormValue != NULL && $this->Cuota_Sindical_Destino_Seccional->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Cuota_Sindical_Destino_Seccional->caption(), $this->Cuota_Sindical_Destino_Seccional->RequiredErrorMessage));
			}
		}
		if (!CheckNumber($this->Cuota_Sindical_Destino_Seccional->FormValue)) {
			AddMessage($FormError, $this->Cuota_Sindical_Destino_Seccional->errorMessage());
		}
		if ($this->APORTE_No_REm_SINDICAL->Required) {
			if (!$this->APORTE_No_REm_SINDICAL->IsDetailKey && $this->APORTE_No_REm_SINDICAL->FormValue != NULL && $this->APORTE_No_REm_SINDICAL->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->APORTE_No_REm_SINDICAL->caption(), $this->APORTE_No_REm_SINDICAL->RequiredErrorMessage));
			}
		}
		if (!CheckNumber($this->APORTE_No_REm_SINDICAL->FormValue)) {
			AddMessage($FormError, $this->APORTE_No_REm_SINDICAL->errorMessage());
		}
		if ($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->Required) {
			if (!$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->IsDetailKey && $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->FormValue != NULL && $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->caption(), $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->RequiredErrorMessage));
			}
		}
		if (!CheckNumber($this->APORTE_BENEFICIO_SOCIAL_NO_Rem->FormValue)) {
			AddMessage($FormError, $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->errorMessage());
		}
		if ($this->OTROS->Required) {
			if (!$this->OTROS->IsDetailKey && $this->OTROS->FormValue != NULL && $this->OTROS->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->OTROS->caption(), $this->OTROS->RequiredErrorMessage));
			}
		}
		if (!CheckNumber($this->OTROS->FormValue)) {
			AddMessage($FormError, $this->OTROS->errorMessage());
		}
		if ($this->Fecha->Required) {
			if (!$this->Fecha->IsDetailKey && $this->Fecha->FormValue != NULL && $this->Fecha->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Fecha->caption(), $this->Fecha->RequiredErrorMessage));
			}
		}
		if (!CheckDate($this->Fecha->FormValue)) {
			AddMessage($FormError, $this->Fecha->errorMessage());
		}
		if ($this->ip->Required) {
			if (!$this->ip->IsDetailKey && $this->ip->FormValue != NULL && $this->ip->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->ip->caption(), $this->ip->RequiredErrorMessage));
			}
		}
		if ($this->Lugar->Required) {
			if (!$this->Lugar->IsDetailKey && $this->Lugar->FormValue != NULL && $this->Lugar->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Lugar->caption(), $this->Lugar->RequiredErrorMessage));
			}
		}
		if ($this->Codigo_Convenio->Required) {
			if (!$this->Codigo_Convenio->IsDetailKey && $this->Codigo_Convenio->FormValue != NULL && $this->Codigo_Convenio->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Codigo_Convenio->caption(), $this->Codigo_Convenio->RequiredErrorMessage));
			}
		}
		if ($this->Total->Required) {
			if (!$this->Total->IsDetailKey && $this->Total->FormValue != NULL && $this->Total->FormValue == "") {
				AddMessage($FormError, str_replace("%s", $this->Total->caption(), $this->Total->RequiredErrorMessage));
			}
		}
		if (!CheckNumber($this->Total->FormValue)) {
			AddMessage($FormError, $this->Total->errorMessage());
		}

		// Return validate result
		$validateForm = ($FormError == "");

		// Call Form_CustomValidate event
		$formCustomError = "";
		$validateForm = $validateForm && $this->Form_CustomValidate($formCustomError);
		if ($formCustomError != "") {
			AddMessage($FormError, $formCustomError);
		}
		return $validateForm;
	}

	// Update record based on key values
	protected function editRow()
	{
		global $Security, $Language;
		$oldKeyFilter = $this->getRecordFilter();
		$filter = $this->applyUserIDFilters($oldKeyFilter);
		$conn = $this->getConnection();
		$this->CurrentFilter = $filter;
		$sql = $this->getCurrentSql();
		$conn->raiseErrorFn = Config("ERROR_FUNC");
		$rs = $conn->execute($sql);
		$conn->raiseErrorFn = "";
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$this->setFailureMessage($Language->phrase("NoRecord")); // Set no record message
			$editRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold = &$rs->fields;
			$this->loadDbValues($rsold);
			$rsnew = [];

			// id_empresa
			$this->id_empresa->setDbValueDef($rsnew, $this->id_empresa->CurrentValue, 0, $this->id_empresa->ReadOnly);

			// CUIT_Empresa
			$this->CUIT_Empresa->setDbValueDef($rsnew, $this->CUIT_Empresa->CurrentValue, "", $this->CUIT_Empresa->ReadOnly);

			// Codigo_Empresa
			$this->Codigo_Empresa->setDbValueDef($rsnew, $this->Codigo_Empresa->CurrentValue, "", $this->Codigo_Empresa->ReadOnly);

			// Domicilio
			$this->Domicilio->setDbValueDef($rsnew, $this->Domicilio->CurrentValue, NULL, $this->Domicilio->ReadOnly);

			// Localidad
			$this->Localidad->setDbValueDef($rsnew, $this->Localidad->CurrentValue, NULL, $this->Localidad->ReadOnly);

			// Mes_Liquidado
			$this->Mes_Liquidado->setDbValueDef($rsnew, $this->Mes_Liquidado->CurrentValue, 0, $this->Mes_Liquidado->ReadOnly);

			// Anio
			$this->Anio->setDbValueDef($rsnew, $this->Anio->CurrentValue, 0, $this->Anio->ReadOnly);

			// Cuota_Sindical_Destino_Seccional
			$this->Cuota_Sindical_Destino_Seccional->setDbValueDef($rsnew, $this->Cuota_Sindical_Destino_Seccional->CurrentValue, NULL, $this->Cuota_Sindical_Destino_Seccional->ReadOnly);

			// APORTE_No_REm_SINDICAL
			$this->APORTE_No_REm_SINDICAL->setDbValueDef($rsnew, $this->APORTE_No_REm_SINDICAL->CurrentValue, NULL, $this->APORTE_No_REm_SINDICAL->ReadOnly);

			// APORTE_BENEFICIO_SOCIAL_NO_Rem
			$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->setDbValueDef($rsnew, $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->CurrentValue, NULL, $this->APORTE_BENEFICIO_SOCIAL_NO_Rem->ReadOnly);

			// OTROS
			$this->OTROS->setDbValueDef($rsnew, $this->OTROS->CurrentValue, NULL, $this->OTROS->ReadOnly);

			// Fecha
			$this->Fecha->setDbValueDef($rsnew, UnFormatDateTime($this->Fecha->CurrentValue, 0), CurrentDate(), $this->Fecha->ReadOnly);

			// ip
			$this->ip->setDbValueDef($rsnew, $this->ip->CurrentValue, NULL, $this->ip->ReadOnly);

			// Lugar
			$this->Lugar->setDbValueDef($rsnew, $this->Lugar->CurrentValue, NULL, $this->Lugar->ReadOnly);

			// Codigo_Convenio
			$this->Codigo_Convenio->setDbValueDef($rsnew, $this->Codigo_Convenio->CurrentValue, "", $this->Codigo_Convenio->ReadOnly);

			// Total
			$this->Total->setDbValueDef($rsnew, $this->Total->CurrentValue, NULL, $this->Total->ReadOnly);

			// Call Row Updating event
			$updateRow = $this->Row_Updating($rsold, $rsnew);

			// Check for duplicate key when key changed
			if ($updateRow) {
				$newKeyFilter = $this->getRecordFilter($rsnew);
				if ($newKeyFilter != $oldKeyFilter) {
					$rsChk = $this->loadRs($newKeyFilter);
					if ($rsChk && !$rsChk->EOF) {
						$keyErrMsg = str_replace("%f", $newKeyFilter, $Language->phrase("DupKey"));
						$this->setFailureMessage($keyErrMsg);
						$rsChk->close();
						$updateRow = FALSE;
					}
				}
			}
			if ($updateRow) {
				$conn->raiseErrorFn = Config("ERROR_FUNC");
				if (count($rsnew) > 0)
					$editRow = $this->update($rsnew, "", $rsold);
				else
					$editRow = TRUE; // No field to update
				$conn->raiseErrorFn = "";
				if ($editRow) {
				}
			} else {
				if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {

					// Use the message, do nothing
				} elseif ($this->CancelMessage != "") {
					$this->setFailureMessage($this->CancelMessage);
					$this->CancelMessage = "";
				} else {
					$this->setFailureMessage($Language->phrase("UpdateCancelled"));
				}
				$editRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($editRow)
			$this->Row_Updated($rsold, $rsnew);
		$rs->close();

		// Clean upload path if any
		if ($editRow) {
		}

		// Write JSON for API request
		if (IsApi() && $editRow) {
			$row = $this->getRecordsFromRecordset([$rsnew], TRUE);
			WriteJson(["success" => TRUE, $this->TableVar => $row]);
		}
		return $editRow;
	}

	// Set up Breadcrumb
	protected function setupBreadcrumb()
	{
		global $Breadcrumb, $Language;
		$Breadcrumb = new Breadcrumb();
		$url = substr(CurrentUrl(), strrpos(CurrentUrl(), "/")+1);
		$Breadcrumb->add("list", $this->TableVar, $this->addMasterUrl("boletaslist.php"), "", $this->TableVar, TRUE);
		$pageId = "edit";
		$Breadcrumb->add("edit", $pageId, $url);
	}

	// Setup lookup options
	public function setupLookupOptions($fld)
	{
		if ($fld->Lookup !== NULL && $fld->Lookup->Options === NULL) {

			// Get default connection and filter
			$conn = $this->getConnection();
			$lookupFilter = "";

			// No need to check any more
			$fld->Lookup->Options = [];

			// Set up lookup SQL and connection
			switch ($fld->FieldVar) {
				default:
					$lookupFilter = "";
					break;
			}

			// Always call to Lookup->getSql so that user can setup Lookup->Options in Lookup_Selecting server event
			$sql = $fld->Lookup->getSql(FALSE, "", $lookupFilter, $this);

			// Set up lookup cache
			if ($fld->UseLookupCache && $sql != "" && count($fld->Lookup->Options) == 0) {
				$totalCnt = $this->getRecordCount($sql, $conn);
				if ($totalCnt > $fld->LookupCacheCount) // Total count > cache count, do not cache
					return;
				$rs = $conn->execute($sql);
				$ar = [];
				while ($rs && !$rs->EOF) {
					$row = &$rs->fields;

					// Format the field values
					switch ($fld->FieldVar) {
					}
					$ar[strval($row[0])] = $row;
					$rs->moveNext();
				}
				if ($rs)
					$rs->close();
				$fld->Lookup->Options = $ar;
			}
		}
	}

	// Set up starting record parameters
	public function setupStartRecord()
	{
		if ($this->DisplayRecords == 0)
			return;
		if ($this->isPageRequest()) { // Validate request
			$startRec = Get(Config("TABLE_START_REC"));
			$pageNo = Get(Config("TABLE_PAGE_NO"));
			if ($pageNo !== NULL) { // Check for "pageno" parameter first
				if (is_numeric($pageNo)) {
					$this->StartRecord = ($pageNo - 1) * $this->DisplayRecords + 1;
					if ($this->StartRecord <= 0) {
						$this->StartRecord = 1;
					} elseif ($this->StartRecord >= (int)(($this->TotalRecords - 1)/$this->DisplayRecords) * $this->DisplayRecords + 1) {
						$this->StartRecord = (int)(($this->TotalRecords - 1)/$this->DisplayRecords) * $this->DisplayRecords + 1;
					}
					$this->setStartRecordNumber($this->StartRecord);
				}
			} elseif ($startRec !== NULL) { // Check for "start" parameter
				$this->StartRecord = $startRec;
				$this->setStartRecordNumber($this->StartRecord);
			}
		}
		$this->StartRecord = $this->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->StartRecord) || $this->StartRecord == "") { // Avoid invalid start record counter
			$this->StartRecord = 1; // Reset start record counter
			$this->setStartRecordNumber($this->StartRecord);
		} elseif ($this->StartRecord > $this->TotalRecords) { // Avoid starting record > total records
			$this->StartRecord = (int)(($this->TotalRecords - 1)/$this->DisplayRecords) * $this->DisplayRecords + 1; // Point to last page first record
			$this->setStartRecordNumber($this->StartRecord);
		} elseif (($this->StartRecord - 1) % $this->DisplayRecords != 0) {
			$this->StartRecord = (int)(($this->StartRecord - 1)/$this->DisplayRecords) * $this->DisplayRecords + 1; // Point to page boundary
			$this->setStartRecordNumber($this->StartRecord);
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'|'warning'
	function Message_Showing(&$msg, $type) {
		if ($type == 'success') {

			//$msg = "your success message";
		} elseif ($type == 'failure') {

			//$msg = "your failure message";
		} elseif ($type == 'warning') {

			//$msg = "your warning message";
		} else {

			//$msg = "your message";
		}
	}

	// Page Render event
	function Page_Render() {

		//echo "Page Render";
	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$customError) {

		// Return error message in CustomError
		return TRUE;
	}
} // End class
?>