<?php

// Global variable for table object
$Usuario = NULL;

//
// Table class for Usuario
//
class crUsuario extends crTableBase {

//	var $SelectLimit = TRUE;
	var $Tipo_doc;
	var $Documento;
	var $Codigo_eps;
	var $Tipo_Usuario;
	var $Primer_ap;
	var $Segundo_ap;
	var $Primer_nom;
	var $Segundo_nom;
	var $Edad;
	var $Unidad_edad;
	var $Sexo;
	var $Codigo_dpto;
	var $Cod_municipio;
	var $Zona_residencia;

	//
	// Table class constructor
	//
	function __construct() {
		global $ReportLanguage;
		$this->TableVar = 'Usuario';
		$this->TableName = 'Usuario';
		$this->TableType = 'TABLE';
		$this->ExportAll = TRUE;
		$this->ExportPageBreakCount = 0;

		// Tipo_doc
		$this->Tipo_doc = new crField('Usuario', 'Usuario', 'x_Tipo_doc', 'Tipo_doc', '`Tipo_doc`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Tipo_doc'] = &$this->Tipo_doc;
		$this->Tipo_doc->DateFilter = "";
		$this->Tipo_doc->SqlSelect = "";
		$this->Tipo_doc->SqlOrderBy = "";

		// Documento
		$this->Documento = new crField('Usuario', 'Usuario', 'x_Documento', 'Documento', '`Documento`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Documento'] = &$this->Documento;
		$this->Documento->DateFilter = "";
		$this->Documento->SqlSelect = "";
		$this->Documento->SqlOrderBy = "";

		// Codigo_eps
		$this->Codigo_eps = new crField('Usuario', 'Usuario', 'x_Codigo_eps', 'Codigo_eps', '`Codigo_eps`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Codigo_eps'] = &$this->Codigo_eps;
		$this->Codigo_eps->DateFilter = "";
		$this->Codigo_eps->SqlSelect = "";
		$this->Codigo_eps->SqlOrderBy = "";

		// Tipo_Usuario
		$this->Tipo_Usuario = new crField('Usuario', 'Usuario', 'x_Tipo_Usuario', 'Tipo_Usuario', '`Tipo_Usuario`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Tipo_Usuario->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Tipo_Usuario'] = &$this->Tipo_Usuario;
		$this->Tipo_Usuario->DateFilter = "";
		$this->Tipo_Usuario->SqlSelect = "";
		$this->Tipo_Usuario->SqlOrderBy = "";

		// Primer_ap
		$this->Primer_ap = new crField('Usuario', 'Usuario', 'x_Primer_ap', 'Primer_ap', '`Primer_ap`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Primer_ap'] = &$this->Primer_ap;
		$this->Primer_ap->DateFilter = "";
		$this->Primer_ap->SqlSelect = "";
		$this->Primer_ap->SqlOrderBy = "";

		// Segundo_ap
		$this->Segundo_ap = new crField('Usuario', 'Usuario', 'x_Segundo_ap', 'Segundo_ap', '`Segundo_ap`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Segundo_ap'] = &$this->Segundo_ap;
		$this->Segundo_ap->DateFilter = "";
		$this->Segundo_ap->SqlSelect = "";
		$this->Segundo_ap->SqlOrderBy = "";

		// Primer_nom
		$this->Primer_nom = new crField('Usuario', 'Usuario', 'x_Primer_nom', 'Primer_nom', '`Primer_nom`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Primer_nom'] = &$this->Primer_nom;
		$this->Primer_nom->DateFilter = "";
		$this->Primer_nom->SqlSelect = "";
		$this->Primer_nom->SqlOrderBy = "";

		// Segundo_nom
		$this->Segundo_nom = new crField('Usuario', 'Usuario', 'x_Segundo_nom', 'Segundo_nom', '`Segundo_nom`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Segundo_nom'] = &$this->Segundo_nom;
		$this->Segundo_nom->DateFilter = "";
		$this->Segundo_nom->SqlSelect = "";
		$this->Segundo_nom->SqlOrderBy = "";

		// Edad
		$this->Edad = new crField('Usuario', 'Usuario', 'x_Edad', 'Edad', '`Edad`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Edad->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Edad'] = &$this->Edad;
		$this->Edad->DateFilter = "";
		$this->Edad->SqlSelect = "";
		$this->Edad->SqlOrderBy = "";

		// Unidad_edad
		$this->Unidad_edad = new crField('Usuario', 'Usuario', 'x_Unidad_edad', 'Unidad_edad', '`Unidad_edad`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Unidad_edad->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Unidad_edad'] = &$this->Unidad_edad;
		$this->Unidad_edad->DateFilter = "";
		$this->Unidad_edad->SqlSelect = "";
		$this->Unidad_edad->SqlOrderBy = "";

		// Sexo
		$this->Sexo = new crField('Usuario', 'Usuario', 'x_Sexo', 'Sexo', '`Sexo`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Sexo'] = &$this->Sexo;
		$this->Sexo->DateFilter = "";
		$this->Sexo->SqlSelect = "";
		$this->Sexo->SqlOrderBy = "";

		// Codigo_dpto
		$this->Codigo_dpto = new crField('Usuario', 'Usuario', 'x_Codigo_dpto', 'Codigo_dpto', '`Codigo_dpto`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Codigo_dpto->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Codigo_dpto'] = &$this->Codigo_dpto;
		$this->Codigo_dpto->DateFilter = "";
		$this->Codigo_dpto->SqlSelect = "";
		$this->Codigo_dpto->SqlOrderBy = "";

		// Cod_municipio
		$this->Cod_municipio = new crField('Usuario', 'Usuario', 'x_Cod_municipio', 'Cod_municipio', '`Cod_municipio`', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Cod_municipio->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Cod_municipio'] = &$this->Cod_municipio;
		$this->Cod_municipio->DateFilter = "";
		$this->Cod_municipio->SqlSelect = "";
		$this->Cod_municipio->SqlOrderBy = "";

		// Zona_residencia
		$this->Zona_residencia = new crField('Usuario', 'Usuario', 'x_Zona_residencia', 'Zona_residencia', '`Zona_residencia`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Zona_residencia'] = &$this->Zona_residencia;
		$this->Zona_residencia->DateFilter = "";
		$this->Zona_residencia->SqlSelect = "";
		$this->Zona_residencia->SqlOrderBy = "";
	}

	// Single column sort
	function UpdateSort(&$ofld) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
		} else {
			if ($ofld->GroupingFieldId == 0) $ofld->setSort("");
		}
	}

	// Get Sort SQL
	function SortSql() {
		$sDtlSortSql = "";
		$argrps = array();
		foreach ($this->fields as $fld) {
			if ($fld->getSort() <> "") {
				if ($fld->GroupingFieldId > 0) {
					if ($fld->FldGroupSql <> "")
						$argrps[$fld->GroupingFieldId] = str_replace("%s", $fld->FldExpression, $fld->FldGroupSql) . " " . $fld->getSort();
					else
						$argrps[$fld->GroupingFieldId] = $fld->FldExpression . " " . $fld->getSort();
				} else {
					if ($sDtlSortSql <> "") $sDtlSortSql .= ", ";
					$sDtlSortSql .= $fld->FldExpression . " " . $fld->getSort();
				}
			}
		}
		$sSortSql = "";
		foreach ($argrps as $grp) {
			if ($sSortSql <> "") $sSortSql .= ", ";
			$sSortSql .= $grp;
		}
		if ($sDtlSortSql <> "") {
			if ($sSortSql <> "") $sSortSql .= ",";
			$sSortSql .= $sDtlSortSql;
		}
		return $sSortSql;
	}

	// Table level SQL
	// From

	var $_SqlFrom = "";

	function getSqlFrom() {
		return ($this->_SqlFrom <> "") ? $this->_SqlFrom : "`Usuario`";
	}

	function SqlFrom() { // For backward compatibility
		return $this->getSqlFrom();
	}

	function setSqlFrom($v) {
		$this->_SqlFrom = $v;
	}

	// Select
	var $_SqlSelect = "";

	function getSqlSelect() {
		return ($this->_SqlSelect <> "") ? $this->_SqlSelect : "SELECT * FROM " . $this->getSqlFrom();
	}

	function SqlSelect() { // For backward compatibility
		return $this->getSqlSelect();
	}

	function setSqlSelect($v) {
		$this->_SqlSelect = $v;
	}

	// Where
	var $_SqlWhere = "";

	function getSqlWhere() {
		$sWhere = ($this->_SqlWhere <> "") ? $this->_SqlWhere : "";
		return $sWhere;
	}

	function SqlWhere() { // For backward compatibility
		return $this->getSqlWhere();
	}

	function setSqlWhere($v) {
		$this->_SqlWhere = $v;
	}

	// Group By
	var $_SqlGroupBy = "";

	function getSqlGroupBy() {
		return ($this->_SqlGroupBy <> "") ? $this->_SqlGroupBy : "";
	}

	function SqlGroupBy() { // For backward compatibility
		return $this->getSqlGroupBy();
	}

	function setSqlGroupBy($v) {
		$this->_SqlGroupBy = $v;
	}

	// Having
	var $_SqlHaving = "";

	function getSqlHaving() {
		return ($this->_SqlHaving <> "") ? $this->_SqlHaving : "";
	}

	function SqlHaving() { // For backward compatibility
		return $this->getSqlHaving();
	}

	function setSqlHaving($v) {
		$this->_SqlHaving = $v;
	}

	// Order By
	var $_SqlOrderBy = "";

	function getSqlOrderBy() {
		return ($this->_SqlOrderBy <> "") ? $this->_SqlOrderBy : "";
	}

	function SqlOrderBy() { // For backward compatibility
		return $this->getSqlOrderBy();
	}

	function setSqlOrderBy($v) {
		$this->_SqlOrderBy = $v;
	}

	// Select Aggregate
	var $_SqlSelectAgg = "";

	function getSqlSelectAgg() {
		return ($this->_SqlSelectAgg <> "") ? $this->_SqlSelectAgg : "SELECT * FROM " . $this->getSqlFrom();
	}

	function SqlSelectAgg() { // For backward compatibility
		return $this->getSqlSelectAgg();
	}

	function setSqlSelectAgg($v) {
		$this->_SqlSelectAgg = $v;
	}

	// Aggregate Prefix
	var $_SqlAggPfx = "";

	function getSqlAggPfx() {
		return ($this->_SqlAggPfx <> "") ? $this->_SqlAggPfx : "";
	}

	function SqlAggPfx() { // For backward compatibility
		return $this->getSqlAggPfx();
	}

	function setSqlAggPfx($v) {
		$this->_SqlAggPfx = $v;
	}

	// Aggregate Suffix
	var $_SqlAggSfx = "";

	function getSqlAggSfx() {
		return ($this->_SqlAggSfx <> "") ? $this->_SqlAggSfx : "";
	}

	function SqlAggSfx() { // For backward compatibility
		return $this->getSqlAggSfx();
	}

	function setSqlAggSfx($v) {
		$this->_SqlAggSfx = $v;
	}

	// Select Count
	var $_SqlSelectCount = "";

	function getSqlSelectCount() {
		return ($this->_SqlSelectCount <> "") ? $this->_SqlSelectCount : "SELECT COUNT(*) FROM " . $this->getSqlFrom();
	}

	function SqlSelectCount() { // For backward compatibility
		return $this->getSqlSelectCount();
	}

	function setSqlSelectCount($v) {
		$this->_SqlSelectCount = $v;
	}

	// Sort URL
	function SortUrl(&$fld) {
		return "";
	}

	// Table level events
	// Page Selecting event
	function Page_Selecting(&$filter) {

		// Enter your code here	
	}

	// Page Breaking event
	function Page_Breaking(&$break, &$content) {

		// Example:
		//$break = FALSE; // Skip page break, or
		//$content = "<div style=\"page-break-after:always;\">&nbsp;</div>"; // Modify page break content

	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here	
	}

	// Cell Rendered event
	function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue, &$LinkAttrs) {

		//$ViewValue = "xxx";
		//$ViewAttrs["style"] = "xxx";

	}

	// 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
	}

	// Load Filters event
	function Page_FilterLoad() {

		// Enter your code here
		// Example: Register/Unregister Custom Extended Filter
		//ewr_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter'); // With function, or
		//ewr_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A'); // No function, use Page_Filtering event
		//ewr_UnregisterFilter($this-><Field>, 'StartsWithA');

	}

	// Page Filter Validated event
	function Page_FilterValidated() {

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

	}

	// Page Filtering event
	function Page_Filtering(&$fld, &$filter, $typ, $opr = "", $val = "", $cond = "", $opr2 = "", $val2 = "") {

		// Note: ALWAYS CHECK THE FILTER TYPE ($typ)! Example:
		// if ($typ == "dropdown" && $fld->FldName == "MyField") // Dropdown filter
		//     $filter = "..."; // Modify the filter
		// if ($typ == "extended" && $fld->FldName == "MyField") // Extended filter
		//     $filter = "..."; // Modify the filter
		// if ($typ == "popup" && $fld->FldName == "MyField") // Popup filter
		//     $filter = "..."; // Modify the filter
		// if ($typ == "custom" && $opr == "..." && $fld->FldName == "MyField") // Custom filter, $opr is the custom filter ID
		//     $filter = "..."; // Modify the filter

	}

	// 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) {

		// Enter your code here
	}
}
?>
