<?php

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

//
// Table class for causas_generales_2020
//
class crcausas_generales_2020 extends crTableBase {

//	var $SelectLimit = TRUE;
	var $Count28consulta_final_2020_Codigo_diagnostico29;
	var $Causa_Completa;
	var $Codigo_diagnostico;
	var $Codigo_tres;
	var $Contador;

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

		// Count(consulta_final_2020.Codigo_diagnostico)
		$this->Count28consulta_final_2020_Codigo_diagnostico29 = new crField('causas_generales_2020', 'causas_generales_2020', 'x_Count28consulta_final_2020_Codigo_diagnostico29', 'Count(consulta_final_2020.Codigo_diagnostico)', '`Count(consulta_final_2020.Codigo_diagnostico)`', 20, EWR_DATATYPE_NUMBER, -1);
		$this->Count28consulta_final_2020_Codigo_diagnostico29->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Count28consulta_final_2020_Codigo_diagnostico29'] = &$this->Count28consulta_final_2020_Codigo_diagnostico29;
		$this->Count28consulta_final_2020_Codigo_diagnostico29->DateFilter = "";
		$this->Count28consulta_final_2020_Codigo_diagnostico29->SqlSelect = "";
		$this->Count28consulta_final_2020_Codigo_diagnostico29->SqlOrderBy = "";

		// Causa_Completa
		$this->Causa_Completa = new crField('causas_generales_2020', 'causas_generales_2020', 'x_Causa_Completa', 'Causa_Completa', 'consulta_final_2020.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 = "";

		// Codigo_diagnostico
		$this->Codigo_diagnostico = new crField('causas_generales_2020', 'causas_generales_2020', 'x_Codigo_diagnostico', 'Codigo_diagnostico', 'consulta_final_2020.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 = "";

		// Codigo_tres
		$this->Codigo_tres = new crField('causas_generales_2020', 'causas_generales_2020', 'x_Codigo_tres', 'Codigo_tres', 'consulta_final_2020.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 = "";

		// Contador
		$this->Contador = new crField('causas_generales_2020', 'causas_generales_2020', 'x_Contador', 'Contador', 'consulta_final_2020.Contador', 3, EWR_DATATYPE_NUMBER, -1);
		$this->Contador->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
		$this->fields['Contador'] = &$this->Contador;
		$this->Contador->DateFilter = "";
		$this->Contador->SqlSelect = "";
		$this->Contador->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_2020";
	}

	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 Count(consulta_final_2020.Codigo_diagnostico) As `Count(consulta_final_2020.Codigo_diagnostico)`, consulta_final_2020.Causa_Completa As Causa_Completa, consulta_final_2020.Codigo_diagnostico As Codigo_diagnostico, consulta_final_2020.Codigo_tres As Codigo_tres, consulta_final_2020.Contador 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 : "consulta_final_2020.Codigo_tres";
	}

	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 : "`Count(consulta_final_2020.Codigo_diagnostico)` Desc";
	}

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