<?php

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

//
// Table class for Urgencias
//
class crUrgencias extends crTableBase {

//	var $SelectLimit = TRUE;
	var $Numero_Factura;
	var $Codigo_prestador;
	var $Tipo_identificacion_us;
	var $Numero_identificacion_us;
	var $Fecha_ingreso;
	var $Hora_ingreso;
	var $Numero_Autorizacion;
	var $Causa_externa;
	var $Diagnostico_salida;
	var $Diagnostico_rel1;
	var $Diagnostico_rel2;
	var $Diagnostico_rel3;
	var $Destino_usuario;
	var $Estado_salida;
	var $Causa_basica_muerte;
	var $Fecha_salida_usuar;
	var $Hora_salida;

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

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

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

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

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

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

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

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

		// Causa_externa
		$this->Causa_externa = new crField('Urgencias', 'Urgencias', 'x_Causa_externa', 'Causa_externa', '`Causa_externa`', 3, 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 = "";

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

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

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

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

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

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

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

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

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

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