<?php namespace PHPMaker2020\recetarios_2021; ?>
<?php

/**
 * Table class for boletas
 */
class boletas extends DbTable
{
	protected $SqlFrom = "";
	protected $SqlSelect = "";
	protected $SqlSelectList = "";
	protected $SqlWhere = "";
	protected $SqlGroupBy = "";
	protected $SqlHaving = "";
	protected $SqlOrderBy = "";
	public $UseSessionForListSql = TRUE;

	// Column CSS classes
	public $LeftColumnClass = "col-sm-2 col-form-label ew-label";
	public $RightColumnClass = "col-sm-10";
	public $OffsetColumnClass = "col-sm-10 offset-sm-2";
	public $TableLeftColumnClass = "w-col-2";

	// Export
	public $ExportDoc;

	// Fields
	public $id;
	public $id_empresa;
	public $CUIT_Empresa;
	public $Codigo_Empresa;
	public $Domicilio;
	public $Localidad;
	public $Mes_Liquidado;
	public $Anio;
	public $Cuota_Sindical_Destino_Seccional;
	public $APORTE_No_REm_SINDICAL;
	public $APORTE_BENEFICIO_SOCIAL_NO_Rem;
	public $OTROS;
	public $Fecha;
	public $ip;
	public $Lugar;
	public $Codigo_Convenio;
	public $Total;

	// Constructor
	public function __construct()
	{
		global $Language, $CurrentLanguage;
		parent::__construct();

		// Language object
		if (!isset($Language))
			$Language = new Language();
		$this->TableVar = 'boletas';
		$this->TableName = 'boletas';
		$this->TableType = 'TABLE';

		// Update Table
		$this->UpdateTable = "`boletas`";
		$this->Dbid = 'DB';
		$this->ExportAll = TRUE;
		$this->ExportPageBreakCount = 0; // Page break per every n record (PDF only)
		$this->ExportPageOrientation = "portrait"; // Page orientation (PDF only)
		$this->ExportPageSize = "a4"; // Page size (PDF only)
		$this->ExportExcelPageOrientation = ""; // Page orientation (PhpSpreadsheet only)
		$this->ExportExcelPageSize = ""; // Page size (PhpSpreadsheet only)
		$this->ExportWordPageOrientation = "portrait"; // Page orientation (PHPWord only)
		$this->ExportWordColumnWidth = NULL; // Cell width (PHPWord only)
		$this->DetailAdd = FALSE; // Allow detail add
		$this->DetailEdit = FALSE; // Allow detail edit
		$this->DetailView = FALSE; // Allow detail view
		$this->ShowMultipleDetails = FALSE; // Show multiple details
		$this->GridAddRowCount = 5;
		$this->AllowAddDeleteRow = TRUE; // Allow add/delete row
		$this->UserIDAllowSecurity = Config("DEFAULT_USER_ID_ALLOW_SECURITY"); // Default User ID allowed permissions
		$this->BasicSearch = new BasicSearch($this->TableVar);

		// id
		$this->id = new DbField('boletas', 'boletas', 'x_id', 'id', '`id`', '`id`', 3, 11, -1, FALSE, '`id`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'NO');
		$this->id->IsAutoIncrement = TRUE; // Autoincrement field
		$this->id->IsPrimaryKey = TRUE; // Primary key field
		$this->id->Sortable = TRUE; // Allow sort
		$this->id->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
		$this->fields['id'] = &$this->id;

		// id_empresa
		$this->id_empresa = new DbField('boletas', 'boletas', 'x_id_empresa', 'id_empresa', '`id_empresa`', '`id_empresa`', 3, 11, -1, FALSE, '`id_empresa`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->id_empresa->Nullable = FALSE; // NOT NULL field
		$this->id_empresa->Required = TRUE; // Required field
		$this->id_empresa->Sortable = TRUE; // Allow sort
		$this->id_empresa->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
		$this->fields['id_empresa'] = &$this->id_empresa;

		// CUIT_Empresa
		$this->CUIT_Empresa = new DbField('boletas', 'boletas', 'x_CUIT_Empresa', 'CUIT_Empresa', '`CUIT_Empresa`', '`CUIT_Empresa`', 200, 11, -1, FALSE, '`CUIT_Empresa`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->CUIT_Empresa->Nullable = FALSE; // NOT NULL field
		$this->CUIT_Empresa->Required = TRUE; // Required field
		$this->CUIT_Empresa->Sortable = TRUE; // Allow sort
		$this->fields['CUIT_Empresa'] = &$this->CUIT_Empresa;

		// Codigo_Empresa
		$this->Codigo_Empresa = new DbField('boletas', 'boletas', 'x_Codigo_Empresa', 'Codigo_Empresa', '`Codigo_Empresa`', '`Codigo_Empresa`', 200, 4, -1, FALSE, '`Codigo_Empresa`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Codigo_Empresa->Nullable = FALSE; // NOT NULL field
		$this->Codigo_Empresa->Required = TRUE; // Required field
		$this->Codigo_Empresa->Sortable = TRUE; // Allow sort
		$this->fields['Codigo_Empresa'] = &$this->Codigo_Empresa;

		// Domicilio
		$this->Domicilio = new DbField('boletas', 'boletas', 'x_Domicilio', 'Domicilio', '`Domicilio`', '`Domicilio`', 200, 150, -1, FALSE, '`Domicilio`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Domicilio->Sortable = TRUE; // Allow sort
		$this->fields['Domicilio'] = &$this->Domicilio;

		// Localidad
		$this->Localidad = new DbField('boletas', 'boletas', 'x_Localidad', 'Localidad', '`Localidad`', '`Localidad`', 200, 150, -1, FALSE, '`Localidad`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Localidad->Sortable = TRUE; // Allow sort
		$this->fields['Localidad'] = &$this->Localidad;

		// Mes_Liquidado
		$this->Mes_Liquidado = new DbField('boletas', 'boletas', 'x_Mes_Liquidado', 'Mes_Liquidado', '`Mes_Liquidado`', '`Mes_Liquidado`', 3, 11, -1, FALSE, '`Mes_Liquidado`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Mes_Liquidado->Nullable = FALSE; // NOT NULL field
		$this->Mes_Liquidado->Required = TRUE; // Required field
		$this->Mes_Liquidado->Sortable = TRUE; // Allow sort
		$this->Mes_Liquidado->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
		$this->fields['Mes_Liquidado'] = &$this->Mes_Liquidado;

		// Anio
		$this->Anio = new DbField('boletas', 'boletas', 'x_Anio', 'Anio', '`Anio`', '`Anio`', 3, 11, -1, FALSE, '`Anio`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Anio->Nullable = FALSE; // NOT NULL field
		$this->Anio->Required = TRUE; // Required field
		$this->Anio->Sortable = TRUE; // Allow sort
		$this->Anio->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
		$this->fields['Anio'] = &$this->Anio;

		// Cuota_Sindical_Destino_Seccional
		$this->Cuota_Sindical_Destino_Seccional = new DbField('boletas', 'boletas', 'x_Cuota_Sindical_Destino_Seccional', 'Cuota_Sindical_Destino_Seccional', '`Cuota_Sindical_Destino_Seccional`', '`Cuota_Sindical_Destino_Seccional`', 5, 22, -1, FALSE, '`Cuota_Sindical_Destino_Seccional`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Cuota_Sindical_Destino_Seccional->Sortable = TRUE; // Allow sort
		$this->Cuota_Sindical_Destino_Seccional->DefaultErrorMessage = $Language->phrase("IncorrectFloat");
		$this->fields['Cuota_Sindical_Destino_Seccional'] = &$this->Cuota_Sindical_Destino_Seccional;

		// APORTE_No_REm_SINDICAL
		$this->APORTE_No_REm_SINDICAL = new DbField('boletas', 'boletas', 'x_APORTE_No_REm_SINDICAL', 'APORTE_No_REm_SINDICAL', '`APORTE_No_REm_SINDICAL`', '`APORTE_No_REm_SINDICAL`', 5, 22, -1, FALSE, '`APORTE_No_REm_SINDICAL`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->APORTE_No_REm_SINDICAL->Sortable = TRUE; // Allow sort
		$this->APORTE_No_REm_SINDICAL->DefaultErrorMessage = $Language->phrase("IncorrectFloat");
		$this->fields['APORTE_No_REm_SINDICAL'] = &$this->APORTE_No_REm_SINDICAL;

		// APORTE_BENEFICIO_SOCIAL_NO_Rem
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem = new DbField('boletas', 'boletas', 'x_APORTE_BENEFICIO_SOCIAL_NO_Rem', 'APORTE_BENEFICIO_SOCIAL_NO_Rem', '`APORTE_BENEFICIO_SOCIAL_NO_Rem`', '`APORTE_BENEFICIO_SOCIAL_NO_Rem`', 5, 22, -1, FALSE, '`APORTE_BENEFICIO_SOCIAL_NO_Rem`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->Sortable = TRUE; // Allow sort
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->DefaultErrorMessage = $Language->phrase("IncorrectFloat");
		$this->fields['APORTE_BENEFICIO_SOCIAL_NO_Rem'] = &$this->APORTE_BENEFICIO_SOCIAL_NO_Rem;

		// OTROS
		$this->OTROS = new DbField('boletas', 'boletas', 'x_OTROS', 'OTROS', '`OTROS`', '`OTROS`', 5, 22, -1, FALSE, '`OTROS`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->OTROS->Sortable = TRUE; // Allow sort
		$this->OTROS->DefaultErrorMessage = $Language->phrase("IncorrectFloat");
		$this->fields['OTROS'] = &$this->OTROS;

		// Fecha
		$this->Fecha = new DbField('boletas', 'boletas', 'x_Fecha', 'Fecha', '`Fecha`', CastDateFieldForLike("`Fecha`", 0, "DB"), 133, 10, 0, FALSE, '`Fecha`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Fecha->Nullable = FALSE; // NOT NULL field
		$this->Fecha->Required = TRUE; // Required field
		$this->Fecha->Sortable = TRUE; // Allow sort
		$this->Fecha->DefaultErrorMessage = str_replace("%s", $GLOBALS["DATE_FORMAT"], $Language->phrase("IncorrectDate"));
		$this->fields['Fecha'] = &$this->Fecha;

		// ip
		$this->ip = new DbField('boletas', 'boletas', 'x_ip', 'ip', '`ip`', '`ip`', 200, 16, -1, FALSE, '`ip`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->ip->Sortable = TRUE; // Allow sort
		$this->fields['ip'] = &$this->ip;

		// Lugar
		$this->Lugar = new DbField('boletas', 'boletas', 'x_Lugar', 'Lugar', '`Lugar`', '`Lugar`', 200, 250, -1, FALSE, '`Lugar`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Lugar->Sortable = TRUE; // Allow sort
		$this->fields['Lugar'] = &$this->Lugar;

		// Codigo_Convenio
		$this->Codigo_Convenio = new DbField('boletas', 'boletas', 'x_Codigo_Convenio', 'Codigo_Convenio', '`Codigo_Convenio`', '`Codigo_Convenio`', 200, 4, -1, FALSE, '`Codigo_Convenio`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Codigo_Convenio->Nullable = FALSE; // NOT NULL field
		$this->Codigo_Convenio->Required = TRUE; // Required field
		$this->Codigo_Convenio->Sortable = TRUE; // Allow sort
		$this->fields['Codigo_Convenio'] = &$this->Codigo_Convenio;

		// Total
		$this->Total = new DbField('boletas', 'boletas', 'x_Total', 'Total', '`Total`', '`Total`', 5, 22, -1, FALSE, '`Total`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->Total->Sortable = TRUE; // Allow sort
		$this->Total->DefaultErrorMessage = $Language->phrase("IncorrectFloat");
		$this->fields['Total'] = &$this->Total;
	}

	// Field Visibility
	public function getFieldVisibility($fldParm)
	{
		global $Security;
		return $this->$fldParm->Visible; // Returns original value
	}

	// Set left column class (must be predefined col-*-* classes of Bootstrap grid system)
	function setLeftColumnClass($class)
	{
		if (preg_match('/^col\-(\w+)\-(\d+)$/', $class, $match)) {
			$this->LeftColumnClass = $class . " col-form-label ew-label";
			$this->RightColumnClass = "col-" . $match[1] . "-" . strval(12 - (int)$match[2]);
			$this->OffsetColumnClass = $this->RightColumnClass . " " . str_replace("col-", "offset-", $class);
			$this->TableLeftColumnClass = preg_replace('/^col-\w+-(\d+)$/', "w-col-$1", $class); // Change to w-col-*
		}
	}

	// Single column sort
	public function updateSort(&$fld)
	{
		if ($this->CurrentOrder == $fld->Name) {
			$sortField = $fld->Expression;
			$lastSort = $fld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$thisSort = $this->CurrentOrderType;
			} else {
				$thisSort = ($lastSort == "ASC") ? "DESC" : "ASC";
			}
			$fld->setSort($thisSort);
			$this->setSessionOrderBy($sortField . " " . $thisSort); // Save to Session
		} else {
			$fld->setSort("");
		}
	}

	// Table level SQL
	public function getSqlFrom() // From
	{
		return ($this->SqlFrom != "") ? $this->SqlFrom : "`boletas`";
	}
	public function sqlFrom() // For backward compatibility
	{
		return $this->getSqlFrom();
	}
	public function setSqlFrom($v)
	{
		$this->SqlFrom = $v;
	}
	public function getSqlSelect() // Select
	{
		return ($this->SqlSelect != "") ? $this->SqlSelect : "SELECT * FROM " . $this->getSqlFrom();
	}
	public function sqlSelect() // For backward compatibility
	{
		return $this->getSqlSelect();
	}
	public function setSqlSelect($v)
	{
		$this->SqlSelect = $v;
	}
	public function getSqlWhere() // Where
	{
		$where = ($this->SqlWhere != "") ? $this->SqlWhere : "";
		$this->TableFilter = "";
		AddFilter($where, $this->TableFilter);
		return $where;
	}
	public function sqlWhere() // For backward compatibility
	{
		return $this->getSqlWhere();
	}
	public function setSqlWhere($v)
	{
		$this->SqlWhere = $v;
	}
	public function getSqlGroupBy() // Group By
	{
		return ($this->SqlGroupBy != "") ? $this->SqlGroupBy : "";
	}
	public function sqlGroupBy() // For backward compatibility
	{
		return $this->getSqlGroupBy();
	}
	public function setSqlGroupBy($v)
	{
		$this->SqlGroupBy = $v;
	}
	public function getSqlHaving() // Having
	{
		return ($this->SqlHaving != "") ? $this->SqlHaving : "";
	}
	public function sqlHaving() // For backward compatibility
	{
		return $this->getSqlHaving();
	}
	public function setSqlHaving($v)
	{
		$this->SqlHaving = $v;
	}
	public function getSqlOrderBy() // Order By
	{
		return ($this->SqlOrderBy != "") ? $this->SqlOrderBy : "";
	}
	public function sqlOrderBy() // For backward compatibility
	{
		return $this->getSqlOrderBy();
	}
	public function setSqlOrderBy($v)
	{
		$this->SqlOrderBy = $v;
	}

	// Apply User ID filters
	public function applyUserIDFilters($filter, $id = "")
	{
		return $filter;
	}

	// Check if User ID security allows view all
	public function userIDAllow($id = "")
	{
		$allow = $this->UserIDAllowSecurity;
		switch ($id) {
			case "add":
			case "copy":
			case "gridadd":
			case "register":
			case "addopt":
				return (($allow & 1) == 1);
			case "edit":
			case "gridedit":
			case "update":
			case "changepwd":
			case "forgotpwd":
				return (($allow & 4) == 4);
			case "delete":
				return (($allow & 2) == 2);
			case "view":
				return (($allow & 32) == 32);
			case "search":
				return (($allow & 64) == 64);
			case "lookup":
				return (($allow & 256) == 256);
			default:
				return (($allow & 8) == 8);
		}
	}

	// Get recordset
	public function getRecordset($sql, $rowcnt = -1, $offset = -1)
	{
		$conn = $this->getConnection();
		$conn->raiseErrorFn = Config("ERROR_FUNC");
		$rs = $conn->selectLimit($sql, $rowcnt, $offset);
		$conn->raiseErrorFn = "";
		return $rs;
	}

	// Get record count
	public function getRecordCount($sql, $c = NULL)
	{
		$cnt = -1;
		$rs = NULL;
		$sql = preg_replace('/\/\*BeginOrderBy\*\/[\s\S]+\/\*EndOrderBy\*\//', "", $sql); // Remove ORDER BY clause (MSSQL)
		$pattern = '/^SELECT\s([\s\S]+)\sFROM\s/i';

		// Skip Custom View / SubQuery / SELECT DISTINCT / ORDER BY
		if (($this->TableType == 'TABLE' || $this->TableType == 'VIEW' || $this->TableType == 'LINKTABLE') &&
			preg_match($pattern, $sql) && !preg_match('/\(\s*(SELECT[^)]+)\)/i', $sql) &&
			!preg_match('/^\s*select\s+distinct\s+/i', $sql) && !preg_match('/\s+order\s+by\s+/i', $sql)) {
			$sqlwrk = "SELECT COUNT(*) FROM " . preg_replace($pattern, "", $sql);
		} else {
			$sqlwrk = "SELECT COUNT(*) FROM (" . $sql . ") COUNT_TABLE";
		}
		$conn = $c ?: $this->getConnection();
		if ($rs = $conn->execute($sqlwrk)) {
			if (!$rs->EOF && $rs->FieldCount() > 0) {
				$cnt = $rs->fields[0];
				$rs->close();
			}
			return (int)$cnt;
		}

		// Unable to get count, get record count directly
		if ($rs = $conn->execute($sql)) {
			$cnt = $rs->RecordCount();
			$rs->close();
			return (int)$cnt;
		}
		return $cnt;
	}

	// Get SQL
	public function getSql($where, $orderBy = "")
	{
		return BuildSelectSql($this->getSqlSelect(), $this->getSqlWhere(),
			$this->getSqlGroupBy(), $this->getSqlHaving(), $this->getSqlOrderBy(),
			$where, $orderBy);
	}

	// Table SQL
	public function getCurrentSql()
	{
		$filter = $this->CurrentFilter;
		$filter = $this->applyUserIDFilters($filter);
		$sort = $this->getSessionOrderBy();
		return $this->getSql($filter, $sort);
	}

	// Table SQL with List page filter
	public function getListSql()
	{
		$filter = $this->UseSessionForListSql ? $this->getSessionWhere() : "";
		AddFilter($filter, $this->CurrentFilter);
		$filter = $this->applyUserIDFilters($filter);
		$this->Recordset_Selecting($filter);
		$select = $this->getSqlSelect();
		$sort = $this->UseSessionForListSql ? $this->getSessionOrderBy() : "";
		return BuildSelectSql($select, $this->getSqlWhere(), $this->getSqlGroupBy(),
			$this->getSqlHaving(), $this->getSqlOrderBy(), $filter, $sort);
	}

	// Get ORDER BY clause
	public function getOrderBy()
	{
		$sort = $this->getSessionOrderBy();
		return BuildSelectSql("", "", "", "", $this->getSqlOrderBy(), "", $sort);
	}

	// Get record count based on filter (for detail record count in master table pages)
	public function loadRecordCount($filter)
	{
		$origFilter = $this->CurrentFilter;
		$this->CurrentFilter = $filter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$select = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlSelect() : "SELECT * FROM " . $this->getSqlFrom();
		$groupBy = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlGroupBy() : "";
		$having = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlHaving() : "";
		$sql = BuildSelectSql($select, $this->getSqlWhere(), $groupBy, $having, "", $this->CurrentFilter, "");
		$cnt = $this->getRecordCount($sql);
		$this->CurrentFilter = $origFilter;
		return $cnt;
	}

	// Get record count (for current List page)
	public function listRecordCount()
	{
		$filter = $this->getSessionWhere();
		AddFilter($filter, $this->CurrentFilter);
		$filter = $this->applyUserIDFilters($filter);
		$this->Recordset_Selecting($filter);
		$select = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlSelect() : "SELECT * FROM " . $this->getSqlFrom();
		$groupBy = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlGroupBy() : "";
		$having = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlHaving() : "";
		$sql = BuildSelectSql($select, $this->getSqlWhere(), $groupBy, $having, "", $filter, "");
		$cnt = $this->getRecordCount($sql);
		return $cnt;
	}

	// INSERT statement
	protected function insertSql(&$rs)
	{
		$names = "";
		$values = "";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]) || $this->fields[$name]->IsCustom)
				continue;
			$names .= $this->fields[$name]->Expression . ",";
			$values .= QuotedValue($value, $this->fields[$name]->DataType, $this->Dbid) . ",";
		}
		$names = preg_replace('/,+$/', "", $names);
		$values = preg_replace('/,+$/', "", $values);
		return "INSERT INTO " . $this->UpdateTable . " (" . $names . ") VALUES (" . $values . ")";
	}

	// Insert
	public function insert(&$rs)
	{
		$conn = $this->getConnection();
		$success = $conn->execute($this->insertSql($rs));
		if ($success) {

			// Get insert id if necessary
			$this->id->setDbValue($conn->insert_ID());
			$rs['id'] = $this->id->DbValue;
		}
		return $success;
	}

	// UPDATE statement
	protected function updateSql(&$rs, $where = "", $curfilter = TRUE)
	{
		$sql = "UPDATE " . $this->UpdateTable . " SET ";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]) || $this->fields[$name]->IsCustom || $this->fields[$name]->IsAutoIncrement)
				continue;
			$sql .= $this->fields[$name]->Expression . "=";
			$sql .= QuotedValue($value, $this->fields[$name]->DataType, $this->Dbid) . ",";
		}
		$sql = preg_replace('/,+$/', "", $sql);
		$filter = ($curfilter) ? $this->CurrentFilter : "";
		if (is_array($where))
			$where = $this->arrayToFilter($where);
		AddFilter($filter, $where);
		if ($filter != "")
			$sql .= " WHERE " . $filter;
		return $sql;
	}

	// Update
	public function update(&$rs, $where = "", $rsold = NULL, $curfilter = TRUE)
	{
		$conn = $this->getConnection();
		$success = $conn->execute($this->updateSql($rs, $where, $curfilter));
		return $success;
	}

	// DELETE statement
	protected function deleteSql(&$rs, $where = "", $curfilter = TRUE)
	{
		$sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
		if (is_array($where))
			$where = $this->arrayToFilter($where);
		if ($rs) {
			if (array_key_exists('id', $rs))
				AddFilter($where, QuotedName('id', $this->Dbid) . '=' . QuotedValue($rs['id'], $this->id->DataType, $this->Dbid));
		}
		$filter = ($curfilter) ? $this->CurrentFilter : "";
		AddFilter($filter, $where);
		if ($filter != "")
			$sql .= $filter;
		else
			$sql .= "0=1"; // Avoid delete
		return $sql;
	}

	// Delete
	public function delete(&$rs, $where = "", $curfilter = FALSE)
	{
		$success = TRUE;
		$conn = $this->getConnection();
		if ($success)
			$success = $conn->execute($this->deleteSql($rs, $where, $curfilter));
		return $success;
	}

	// Load DbValue from recordset or array
	protected function loadDbValues(&$rs)
	{
		if (!$rs || !is_array($rs) && $rs->EOF)
			return;
		$row = is_array($rs) ? $rs : $rs->fields;
		$this->id->DbValue = $row['id'];
		$this->id_empresa->DbValue = $row['id_empresa'];
		$this->CUIT_Empresa->DbValue = $row['CUIT_Empresa'];
		$this->Codigo_Empresa->DbValue = $row['Codigo_Empresa'];
		$this->Domicilio->DbValue = $row['Domicilio'];
		$this->Localidad->DbValue = $row['Localidad'];
		$this->Mes_Liquidado->DbValue = $row['Mes_Liquidado'];
		$this->Anio->DbValue = $row['Anio'];
		$this->Cuota_Sindical_Destino_Seccional->DbValue = $row['Cuota_Sindical_Destino_Seccional'];
		$this->APORTE_No_REm_SINDICAL->DbValue = $row['APORTE_No_REm_SINDICAL'];
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->DbValue = $row['APORTE_BENEFICIO_SOCIAL_NO_Rem'];
		$this->OTROS->DbValue = $row['OTROS'];
		$this->Fecha->DbValue = $row['Fecha'];
		$this->ip->DbValue = $row['ip'];
		$this->Lugar->DbValue = $row['Lugar'];
		$this->Codigo_Convenio->DbValue = $row['Codigo_Convenio'];
		$this->Total->DbValue = $row['Total'];
	}

	// Delete uploaded files
	public function deleteUploadedFiles($row)
	{
		$this->loadDbValues($row);
	}

	// Record filter WHERE clause
	protected function sqlKeyFilter()
	{
		return "`id` = @id@";
	}

	// Get record filter
	public function getRecordFilter($row = NULL)
	{
		$keyFilter = $this->sqlKeyFilter();
		if (is_array($row))
			$val = array_key_exists('id', $row) ? $row['id'] : NULL;
		else
			$val = $this->id->OldValue !== NULL ? $this->id->OldValue : $this->id->CurrentValue;
		if (!is_numeric($val))
			return "0=1"; // Invalid key
		if ($val == NULL)
			return "0=1"; // Invalid key
		else
			$keyFilter = str_replace("@id@", AdjustSql($val, $this->Dbid), $keyFilter); // Replace key value
		return $keyFilter;
	}

	// Return page URL
	public function getReturnUrl()
	{
		$name = PROJECT_NAME . "_" . $this->TableVar . "_" . Config("TABLE_RETURN_URL");

		// Get referer URL automatically
		if (ServerVar("HTTP_REFERER") != "" && ReferPageName() != CurrentPageName() && ReferPageName() != "login.php") // Referer not same page or login page
			$_SESSION[$name] = ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] != "") {
			return $_SESSION[$name];
		} else {
			return "boletaslist.php";
		}
	}
	public function setReturnUrl($v)
	{
		$_SESSION[PROJECT_NAME . "_" . $this->TableVar . "_" . Config("TABLE_RETURN_URL")] = $v;
	}

	// Get modal caption
	public function getModalCaption($pageName)
	{
		global $Language;
		if ($pageName == "boletasview.php")
			return $Language->phrase("View");
		elseif ($pageName == "boletasedit.php")
			return $Language->phrase("Edit");
		elseif ($pageName == "boletasadd.php")
			return $Language->phrase("Add");
		else
			return "";
	}

	// List URL
	public function getListUrl()
	{
		return "boletaslist.php";
	}

	// View URL
	public function getViewUrl($parm = "")
	{
		if ($parm != "")
			$url = $this->keyUrl("boletasview.php", $this->getUrlParm($parm));
		else
			$url = $this->keyUrl("boletasview.php", $this->getUrlParm(Config("TABLE_SHOW_DETAIL") . "="));
		return $this->addMasterUrl($url);
	}

	// Add URL
	public function getAddUrl($parm = "")
	{
		if ($parm != "")
			$url = "boletasadd.php?" . $this->getUrlParm($parm);
		else
			$url = "boletasadd.php";
		return $this->addMasterUrl($url);
	}

	// Edit URL
	public function getEditUrl($parm = "")
	{
		$url = $this->keyUrl("boletasedit.php", $this->getUrlParm($parm));
		return $this->addMasterUrl($url);
	}

	// Inline edit URL
	public function getInlineEditUrl()
	{
		$url = $this->keyUrl(CurrentPageName(), $this->getUrlParm("action=edit"));
		return $this->addMasterUrl($url);
	}

	// Copy URL
	public function getCopyUrl($parm = "")
	{
		$url = $this->keyUrl("boletasadd.php", $this->getUrlParm($parm));
		return $this->addMasterUrl($url);
	}

	// Inline copy URL
	public function getInlineCopyUrl()
	{
		$url = $this->keyUrl(CurrentPageName(), $this->getUrlParm("action=copy"));
		return $this->addMasterUrl($url);
	}

	// Delete URL
	public function getDeleteUrl()
	{
		return $this->keyUrl("boletasdelete.php", $this->getUrlParm());
	}

	// Add master url
	public function addMasterUrl($url)
	{
		return $url;
	}
	public function keyToJson($htmlEncode = FALSE)
	{
		$json = "";
		$json .= "id:" . JsonEncode($this->id->CurrentValue, "number");
		$json = "{" . $json . "}";
		if ($htmlEncode)
			$json = HtmlEncode($json);
		return $json;
	}

	// Add key value to URL
	public function keyUrl($url, $parm = "")
	{
		$url = $url . "?";
		if ($parm != "")
			$url .= $parm . "&";
		if ($this->id->CurrentValue != NULL) {
			$url .= "id=" . urlencode($this->id->CurrentValue);
		} else {
			return "javascript:ew.alert(ew.language.phrase('InvalidRecord'));";
		}
		return $url;
	}

	// Sort URL
	public function sortUrl(&$fld)
	{
		if ($this->CurrentAction || $this->isExport() ||
			in_array($fld->Type, [128, 204, 205])) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$urlParm = $this->getUrlParm("order=" . urlencode($fld->Name) . "&amp;ordertype=" . $fld->reverseSort());
			return $this->addMasterUrl(CurrentPageName() . "?" . $urlParm);
		} else {
			return "";
		}
	}

	// Get record keys from Post/Get/Session
	public function getRecordKeys()
	{
		$arKeys = [];
		$arKey = [];
		if (Param("key_m") !== NULL) {
			$arKeys = Param("key_m");
			$cnt = count($arKeys);
		} else {
			if (Param("id") !== NULL)
				$arKeys[] = Param("id");
			elseif (IsApi() && Key(0) !== NULL)
				$arKeys[] = Key(0);
			elseif (IsApi() && Route(2) !== NULL)
				$arKeys[] = Route(2);
			else
				$arKeys = NULL; // Do not setup

			//return $arKeys; // Do not return yet, so the values will also be checked by the following code
		}

		// Check keys
		$ar = [];
		if (is_array($arKeys)) {
			foreach ($arKeys as $key) {
				if (!is_numeric($key))
					continue;
				$ar[] = $key;
			}
		}
		return $ar;
	}

	// Get filter from record keys
	public function getFilterFromRecordKeys($setCurrent = TRUE)
	{
		$arKeys = $this->getRecordKeys();
		$keyFilter = "";
		foreach ($arKeys as $key) {
			if ($keyFilter != "") $keyFilter .= " OR ";
			if ($setCurrent)
				$this->id->CurrentValue = $key;
			else
				$this->id->OldValue = $key;
			$keyFilter .= "(" . $this->getRecordFilter() . ")";
		}
		return $keyFilter;
	}

	// Load rows based on filter
	public function &loadRs($filter)
	{

		// Set up filter (WHERE Clause)
		$sql = $this->getSql($filter);
		$conn = $this->getConnection();
		$rs = $conn->execute($sql);
		return $rs;
	}

	// Load row values from recordset
	public function loadListRowValues(&$rs)
	{
		$this->id->setDbValue($rs->fields('id'));
		$this->id_empresa->setDbValue($rs->fields('id_empresa'));
		$this->CUIT_Empresa->setDbValue($rs->fields('CUIT_Empresa'));
		$this->Codigo_Empresa->setDbValue($rs->fields('Codigo_Empresa'));
		$this->Domicilio->setDbValue($rs->fields('Domicilio'));
		$this->Localidad->setDbValue($rs->fields('Localidad'));
		$this->Mes_Liquidado->setDbValue($rs->fields('Mes_Liquidado'));
		$this->Anio->setDbValue($rs->fields('Anio'));
		$this->Cuota_Sindical_Destino_Seccional->setDbValue($rs->fields('Cuota_Sindical_Destino_Seccional'));
		$this->APORTE_No_REm_SINDICAL->setDbValue($rs->fields('APORTE_No_REm_SINDICAL'));
		$this->APORTE_BENEFICIO_SOCIAL_NO_Rem->setDbValue($rs->fields('APORTE_BENEFICIO_SOCIAL_NO_Rem'));
		$this->OTROS->setDbValue($rs->fields('OTROS'));
		$this->Fecha->setDbValue($rs->fields('Fecha'));
		$this->ip->setDbValue($rs->fields('ip'));
		$this->Lugar->setDbValue($rs->fields('Lugar'));
		$this->Codigo_Convenio->setDbValue($rs->fields('Codigo_Convenio'));
		$this->Total->setDbValue($rs->fields('Total'));
	}

	// Render list row values
	public function renderListRow()
	{
		global $Security, $CurrentLanguage, $Language;

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

		// Common render codes
		// 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
		// 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 = "";

		// Call Row Rendered event
		$this->Row_Rendered();

		// Save data for Custom Template
		$this->Rows[] = $this->customTemplateFieldValues();
	}

	// Render edit row values
	public function renderEditRow()
	{
		global $Security, $CurrentLanguage, $Language;

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

		// 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 = $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 = $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 = $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 = $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 = $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 = $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 = $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 = $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 = $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 = $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 = $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 = 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 = $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 = $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 = $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 = $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);
		

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// Aggregate list row values
	public function aggregateListRowValues()
	{
	}

	// Aggregate list row (for rendering)
	public function aggregateListRow()
	{

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// Export data in HTML/CSV/Word/Excel/Email/PDF format
	public function exportDocument($doc, $recordset, $startRec = 1, $stopRec = 1, $exportPageType = "")
	{
		if (!$recordset || !$doc)
			return;
		if (!$doc->ExportCustom) {

			// Write header
			$doc->exportTableHeader();
			if ($doc->Horizontal) { // Horizontal format, write header
				$doc->beginExportRow();
				if ($exportPageType == "view") {
					$doc->exportCaption($this->id);
					$doc->exportCaption($this->id_empresa);
					$doc->exportCaption($this->CUIT_Empresa);
					$doc->exportCaption($this->Codigo_Empresa);
					$doc->exportCaption($this->Domicilio);
					$doc->exportCaption($this->Localidad);
					$doc->exportCaption($this->Mes_Liquidado);
					$doc->exportCaption($this->Anio);
					$doc->exportCaption($this->Cuota_Sindical_Destino_Seccional);
					$doc->exportCaption($this->APORTE_No_REm_SINDICAL);
					$doc->exportCaption($this->APORTE_BENEFICIO_SOCIAL_NO_Rem);
					$doc->exportCaption($this->OTROS);
					$doc->exportCaption($this->Fecha);
					$doc->exportCaption($this->ip);
					$doc->exportCaption($this->Lugar);
					$doc->exportCaption($this->Codigo_Convenio);
					$doc->exportCaption($this->Total);
				} else {
					$doc->exportCaption($this->id);
					$doc->exportCaption($this->id_empresa);
					$doc->exportCaption($this->CUIT_Empresa);
					$doc->exportCaption($this->Codigo_Empresa);
					$doc->exportCaption($this->Domicilio);
					$doc->exportCaption($this->Localidad);
					$doc->exportCaption($this->Mes_Liquidado);
					$doc->exportCaption($this->Anio);
					$doc->exportCaption($this->Cuota_Sindical_Destino_Seccional);
					$doc->exportCaption($this->APORTE_No_REm_SINDICAL);
					$doc->exportCaption($this->APORTE_BENEFICIO_SOCIAL_NO_Rem);
					$doc->exportCaption($this->OTROS);
					$doc->exportCaption($this->Fecha);
					$doc->exportCaption($this->ip);
					$doc->exportCaption($this->Lugar);
					$doc->exportCaption($this->Codigo_Convenio);
					$doc->exportCaption($this->Total);
				}
				$doc->endExportRow();
			}
		}

		// Move to first record
		$recCnt = $startRec - 1;
		if (!$recordset->EOF) {
			$recordset->moveFirst();
			if ($startRec > 1)
				$recordset->move($startRec - 1);
		}
		while (!$recordset->EOF && $recCnt < $stopRec) {
			$recCnt++;
			if ($recCnt >= $startRec) {
				$rowCnt = $recCnt - $startRec + 1;

				// Page break
				if ($this->ExportPageBreakCount > 0) {
					if ($rowCnt > 1 && ($rowCnt - 1) % $this->ExportPageBreakCount == 0)
						$doc->exportPageBreak();
				}
				$this->loadListRowValues($recordset);

				// Render row
				$this->RowType = ROWTYPE_VIEW; // Render view
				$this->resetAttributes();
				$this->renderListRow();
				if (!$doc->ExportCustom) {
					$doc->beginExportRow($rowCnt); // Allow CSS styles if enabled
					if ($exportPageType == "view") {
						$doc->exportField($this->id);
						$doc->exportField($this->id_empresa);
						$doc->exportField($this->CUIT_Empresa);
						$doc->exportField($this->Codigo_Empresa);
						$doc->exportField($this->Domicilio);
						$doc->exportField($this->Localidad);
						$doc->exportField($this->Mes_Liquidado);
						$doc->exportField($this->Anio);
						$doc->exportField($this->Cuota_Sindical_Destino_Seccional);
						$doc->exportField($this->APORTE_No_REm_SINDICAL);
						$doc->exportField($this->APORTE_BENEFICIO_SOCIAL_NO_Rem);
						$doc->exportField($this->OTROS);
						$doc->exportField($this->Fecha);
						$doc->exportField($this->ip);
						$doc->exportField($this->Lugar);
						$doc->exportField($this->Codigo_Convenio);
						$doc->exportField($this->Total);
					} else {
						$doc->exportField($this->id);
						$doc->exportField($this->id_empresa);
						$doc->exportField($this->CUIT_Empresa);
						$doc->exportField($this->Codigo_Empresa);
						$doc->exportField($this->Domicilio);
						$doc->exportField($this->Localidad);
						$doc->exportField($this->Mes_Liquidado);
						$doc->exportField($this->Anio);
						$doc->exportField($this->Cuota_Sindical_Destino_Seccional);
						$doc->exportField($this->APORTE_No_REm_SINDICAL);
						$doc->exportField($this->APORTE_BENEFICIO_SOCIAL_NO_Rem);
						$doc->exportField($this->OTROS);
						$doc->exportField($this->Fecha);
						$doc->exportField($this->ip);
						$doc->exportField($this->Lugar);
						$doc->exportField($this->Codigo_Convenio);
						$doc->exportField($this->Total);
					}
					$doc->endExportRow($rowCnt);
				}
			}

			// Call Row Export server event
			if ($doc->ExportCustom)
				$this->Row_Export($recordset->fields);
			$recordset->moveNext();
		}
		if (!$doc->ExportCustom) {
			$doc->exportTableFooter();
		}
	}

	// Get file data
	public function getFileData($fldparm, $key, $resize, $width = 0, $height = 0)
	{

		// No binary fields
		return FALSE;
	}

	// Table level events
	// Recordset Selecting event
	function Recordset_Selecting(&$filter) {

		// Enter your code here
	}

	// Recordset Selected event
	function Recordset_Selected(&$rs) {

		//echo "Recordset Selected";
	}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

		// Example:
		//$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value

	}

	// Recordset Searching event
	function Recordset_Searching(&$filter) {

		// Enter your code here
	}

	// Row_Selecting event
	function Row_Selecting(&$filter) {

		// Enter your code here
	}

	// Row Selected event
	function Row_Selected(&$rs) {

		//echo "Row Selected";
	}

	// Row Inserting event
	function Row_Inserting($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Inserted event
	function Row_Inserted($rsold, &$rsnew) {

		//echo "Row Inserted"
	}

	// Row Updating event
	function Row_Updating($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Updated event
	function Row_Updated($rsold, &$rsnew) {

		//echo "Row Updated";
	}

	// Row Update Conflict event
	function Row_UpdateConflict($rsold, &$rsnew) {

		// Enter your code here
		// To ignore conflict, set return value to FALSE

		return TRUE;
	}

	// Grid Inserting event
	function Grid_Inserting() {

		// Enter your code here
		// To reject grid insert, set return value to FALSE

		return TRUE;
	}

	// Grid Inserted event
	function Grid_Inserted($rsnew) {

		//echo "Grid Inserted";
	}

	// Grid Updating event
	function Grid_Updating($rsold) {

		// Enter your code here
		// To reject grid update, set return value to FALSE

		return TRUE;
	}

	// Grid Updated event
	function Grid_Updated($rsold, $rsnew) {

		//echo "Grid Updated";
	}

	// Row Deleting event
	function Row_Deleting(&$rs) {

		// Enter your code here
		// To cancel, set return value to False

		return TRUE;
	}

	// Row Deleted event
	function Row_Deleted(&$rs) {

		//echo "Row Deleted";
	}

	// Email Sending event
	function Email_Sending($email, &$args) {

		//var_dump($email); var_dump($args); exit();
		return TRUE;
	}

	// Lookup Selecting event
	function Lookup_Selecting($fld, &$filter) {

		//var_dump($fld->Name, $fld->Lookup, $filter); // Uncomment to view the filter
		// Enter your code here

	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here
	}

	// Row Rendered event
	function Row_Rendered() {

		// To view properties of field class, use:
		//var_dump($this-><FieldName>);

	}

	// User ID Filtering event
	function UserID_Filtering(&$filter) {

		// Enter your code here
	}
}
?>