<?php

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

//
// Table class for consulta_final_2018
//
class crconsulta_final_2018 extends crTableBase {

//	var $SelectLimit = TRUE;
	var $Codigo_prestador;
	var $Tipo_id_usuario;
	var $Numero_id_usuario;
	var $Fecha_consulta;
	var $Codigo_consulta;
	var $Finalidad_consulta;
	var $Causa_externa;
	var $Codigo_diagnostico;
	var $Tipo_diagnostico_principal;
	var $Edad;
	var $Unidad_edad;
	var $Sexo;
	var $Zona_residencia;
	var $Tipo_Usuario;
	var $Codigo_eps;
	var $Causa_Completa;
	var $Id;
	var $Letra;
	var $Numero;
	var $Codigo_tres;
	var $Titulo_codigo_tres;

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

		// Codigo_prestador
		$this->Codigo_prestador = new crField('consulta_final_2018', 'consulta_final_2018', 'x_Codigo_prestador', 'Codigo_prestador', '`Codigo_prestador`', 20, EWR_DATATYPE_NUMBER, -1);
		$this->Codigo_prestador->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Codigo_prestador'] = &$this->Codigo_prestador;
		$this->Codigo_prestador->DateFilter = "";
		$this->Codigo_prestador->SqlSelect = "";
		$this->Codigo_prestador->SqlOrderBy = "";

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

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

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

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

		// Finalidad_consulta
		$this->Finalidad_consulta = new crField('consulta_final_2018', 'consulta_final_2018', 'x_Finalidad_consulta', 'Finalidad_consulta', '`Finalidad_consulta`', 16, EWR_DATATYPE_NUMBER, -1);
		$this->Finalidad_consulta->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Finalidad_consulta'] = &$this->Finalidad_consulta;
		$this->Finalidad_consulta->DateFilter = "";
		$this->Finalidad_consulta->SqlSelect = "";
		$this->Finalidad_consulta->SqlOrderBy = "";

		// Causa_externa
		$this->Causa_externa = new crField('consulta_final_2018', 'consulta_final_2018', 'x_Causa_externa', 'Causa_externa', '`Causa_externa`', 16, EWR_DATATYPE_NUMBER, -1);
		$this->Causa_externa->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Causa_externa'] = &$this->Causa_externa;
		$this->Causa_externa->DateFilter = "";
		$this->Causa_externa->SqlSelect = "";
		$this->Causa_externa->SqlOrderBy = "";

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

		// Tipo_diagnostico_principal
		$this->Tipo_diagnostico_principal = new crField('consulta_final_2018', 'consulta_final_2018', 'x_Tipo_diagnostico_principal', 'Tipo_diagnostico_principal', '`Tipo_diagnostico_principal`', 16, EWR_DATATYPE_NUMBER, -1);
		$this->Tipo_diagnostico_principal->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Tipo_diagnostico_principal'] = &$this->Tipo_diagnostico_principal;
		$this->Tipo_diagnostico_principal->DateFilter = "";
		$this->Tipo_diagnostico_principal->SqlSelect = "";
		$this->Tipo_diagnostico_principal->SqlOrderBy = "";

		// Edad
		$this->Edad = new crField('consulta_final_2018', 'consulta_final_2018', '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('consulta_final_2018', 'consulta_final_2018', 'x_Unidad_edad', 'Unidad_edad', '`Unidad_edad`', 16, 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('consulta_final_2018', 'consulta_final_2018', 'x_Sexo', 'Sexo', '`Sexo`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Sexo'] = &$this->Sexo;
		$this->Sexo->DateFilter = "";
		$this->Sexo->SqlSelect = "";
		$this->Sexo->SqlOrderBy = "";

		// Zona_residencia
		$this->Zona_residencia = new crField('consulta_final_2018', 'consulta_final_2018', '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 = "";

		// Tipo_Usuario
		$this->Tipo_Usuario = new crField('consulta_final_2018', 'consulta_final_2018', 'x_Tipo_Usuario', 'Tipo_Usuario', '`Tipo_Usuario`', 16, 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 = "";

		// Codigo_eps
		$this->Codigo_eps = new crField('consulta_final_2018', 'consulta_final_2018', '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 = "";

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

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

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

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

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

		// Titulo_codigo_tres
		$this->Titulo_codigo_tres = new crField('consulta_final_2018', 'consulta_final_2018', 'x_Titulo_codigo_tres', 'Titulo_codigo_tres', '`Titulo_codigo_tres`', 200, EWR_DATATYPE_STRING, -1);
		$this->fields['Titulo_codigo_tres'] = &$this->Titulo_codigo_tres;
		$this->Titulo_codigo_tres->DateFilter = "";
		$this->Titulo_codigo_tres->SqlSelect = "";
		$this->Titulo_codigo_tres->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 : "`consulta_final_2018`";
	}

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