Heray-Was-Here
Server : Apache
System : Linux hybrid3195.ca.ns.planethoster.net 3.10.0-1160.119.1.el7.tuxcare.els19.x86_64 #1 SMP Mon Mar 31 17:29:00 UTC 2025 x86_64
User : alliancerealtynb ( 1004)
PHP Version : 7.4.33
Disable Function : noop
Directory :  /home/alliancerealtynb/public_html/adminAR/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alliancerealtynb/public_html/adminAR/classes/crm_view.php
<?php namespace PHPMaker2020\Alliance; ?>
<?php

/**
 * Table class for crm_view
 */
class crm_view 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 $last_name;
	public $first_name;
	public $email1;
	public $tel;
	public $mobile;
	public $owner;
	public $type;
	public $field_3091;
	public $field_3090;
	public $field_3088;
	public $field_3187;
	public $field_3188;
	public $field_3183;
	public $field_3184;
	public $archive;
	public $Note;

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

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

		// Update Table
		$this->UpdateTable = "`crm_view`";
		$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('crm_view', 'crm_view', '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;

		// last_name
		$this->last_name = new DbField('crm_view', 'crm_view', 'x_last_name', 'last_name', '`last_name`', '`last_name`', 200, 100, -1, FALSE, '`last_name`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->last_name->Sortable = TRUE; // Allow sort
		$this->fields['last_name'] = &$this->last_name;

		// first_name
		$this->first_name = new DbField('crm_view', 'crm_view', 'x_first_name', 'first_name', '`first_name`', '`first_name`', 200, 100, -1, FALSE, '`first_name`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->first_name->Sortable = TRUE; // Allow sort
		$this->fields['first_name'] = &$this->first_name;

		// email1
		$this->email1 = new DbField('crm_view', 'crm_view', 'x_email1', 'email1', '`email1`', '`email1`', 200, 100, -1, FALSE, '`email1`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->email1->Sortable = TRUE; // Allow sort
		$this->fields['email1'] = &$this->email1;

		// tel
		$this->tel = new DbField('crm_view', 'crm_view', 'x_tel', 'tel', '`tel`', '`tel`', 200, 100, -1, FALSE, '`tel`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->tel->Sortable = TRUE; // Allow sort
		$this->fields['tel'] = &$this->tel;

		// mobile
		$this->mobile = new DbField('crm_view', 'crm_view', 'x_mobile', 'mobile', '`mobile`', '`mobile`', 200, 100, -1, FALSE, '`mobile`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->mobile->Sortable = TRUE; // Allow sort
		$this->fields['mobile'] = &$this->mobile;

		// owner
		$this->owner = new DbField('crm_view', 'crm_view', 'x_owner', 'owner', '`owner`', '`owner`', 3, 11, -1, FALSE, '`owner`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'SELECT');
		$this->owner->Nullable = FALSE; // NOT NULL field
		$this->owner->Sortable = TRUE; // Allow sort
		$this->owner->UsePleaseSelect = TRUE; // Use PleaseSelect by default
		$this->owner->PleaseSelectText = $Language->phrase("PleaseSelect"); // "PleaseSelect" text
		$this->owner->Lookup = new Lookup('owner', 'crm_view', FALSE, '', ["","","",""], [], [], [], [], [], [], '', '');
		$this->owner->OptionCount = 3;
		$this->owner->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
		$this->fields['owner'] = &$this->owner;

		// type
		$this->type = new DbField('crm_view', 'crm_view', 'x_type', 'type', '`type`', '`type`', 201, 65535, -1, FALSE, '`type`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'SELECT');
		$this->type->Sortable = TRUE; // Allow sort
		$this->type->UsePleaseSelect = TRUE; // Use PleaseSelect by default
		$this->type->PleaseSelectText = $Language->phrase("PleaseSelect"); // "PleaseSelect" text
		$this->type->Lookup = new Lookup('type', 'crm_view', FALSE, '', ["","","",""], [], [], [], [], [], [], '', '');
		$this->type->OptionCount = 4;
		$this->fields['type'] = &$this->type;

		// field_3091
		$this->field_3091 = new DbField('crm_view', 'crm_view', 'x_field_3091', 'field_3091', '`field_3091`', '`field_3091`', 200, 50, -1, FALSE, '`field_3091`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3091->Sortable = TRUE; // Allow sort
		$this->fields['field_3091'] = &$this->field_3091;

		// field_3090
		$this->field_3090 = new DbField('crm_view', 'crm_view', 'x_field_3090', 'field_3090', '`field_3090`', '`field_3090`', 200, 50, -1, FALSE, '`field_3090`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3090->Sortable = TRUE; // Allow sort
		$this->fields['field_3090'] = &$this->field_3090;

		// field_3088
		$this->field_3088 = new DbField('crm_view', 'crm_view', 'x_field_3088', 'field_3088', '`field_3088`', '`field_3088`', 200, 50, -1, FALSE, '`field_3088`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3088->Sortable = TRUE; // Allow sort
		$this->fields['field_3088'] = &$this->field_3088;

		// field_3187
		$this->field_3187 = new DbField('crm_view', 'crm_view', 'x_field_3187', 'field_3187', '`field_3187`', '`field_3187`', 200, 50, -1, FALSE, '`field_3187`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3187->Sortable = TRUE; // Allow sort
		$this->fields['field_3187'] = &$this->field_3187;

		// field_3188
		$this->field_3188 = new DbField('crm_view', 'crm_view', 'x_field_3188', 'field_3188', '`field_3188`', '`field_3188`', 200, 50, -1, FALSE, '`field_3188`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3188->Sortable = TRUE; // Allow sort
		$this->fields['field_3188'] = &$this->field_3188;

		// field_3183
		$this->field_3183 = new DbField('crm_view', 'crm_view', 'x_field_3183', 'field_3183', '`field_3183`', '`field_3183`', 200, 50, -1, FALSE, '`field_3183`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3183->Sortable = TRUE; // Allow sort
		$this->fields['field_3183'] = &$this->field_3183;

		// field_3184
		$this->field_3184 = new DbField('crm_view', 'crm_view', 'x_field_3184', 'field_3184', '`field_3184`', '`field_3184`', 200, 50, -1, FALSE, '`field_3184`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'TEXT');
		$this->field_3184->Sortable = TRUE; // Allow sort
		$this->fields['field_3184'] = &$this->field_3184;

		// archive
		$this->archive = new DbField('crm_view', 'crm_view', 'x_archive', 'archive', '`archive`', '`archive`', 16, 1, -1, FALSE, '`archive`', FALSE, FALSE, FALSE, 'FORMATTED TEXT', 'RADIO');
		$this->archive->Nullable = FALSE; // NOT NULL field
		$this->archive->Sortable = TRUE; // Allow sort
		$this->archive->Lookup = new Lookup('archive', 'crm_view', FALSE, '', ["","","",""], [], [], [], [], [], [], '', '');
		$this->archive->OptionCount = 2;
		$this->archive->DefaultErrorMessage = $Language->phrase("IncorrectField");
		$this->archive->AdvancedSearch->SearchValueDefault = 0;
		$this->archive->AdvancedSearch->SearchOperatorDefault = "=";
		$this->archive->AdvancedSearch->SearchOperatorDefault2 = "";
		$this->archive->AdvancedSearch->SearchConditionDefault = "AND";
		$this->fields['archive'] = &$this->archive;

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

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

	// Multiple column sort
	public function updateSort(&$fld, $ctrl)
	{
		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);
			if ($ctrl) {
				$orderBy = $this->getSessionOrderBy();
				if (ContainsString($orderBy, $sortField . " " . $lastSort)) {
					$orderBy = str_replace($sortField . " " . $lastSort, $sortField . " " . $thisSort, $orderBy);
				} else {
					if ($orderBy != "")
						$orderBy .= ", ";
					$orderBy .= $sortField . " " . $thisSort;
				}
				$this->setSessionOrderBy($orderBy); // Save to Session
			} else {
				$this->setSessionOrderBy($sortField . " " . $thisSort); // Save to Session
			}
		} else {
			if (!$ctrl)
				$fld->setSort("");
		}
	}

	// Table level SQL
	public function getSqlFrom() // From
	{
		return ($this->SqlFrom != "") ? $this->SqlFrom : "`crm_view`";
	}
	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->last_name->DbValue = $row['last_name'];
		$this->first_name->DbValue = $row['first_name'];
		$this->email1->DbValue = $row['email1'];
		$this->tel->DbValue = $row['tel'];
		$this->mobile->DbValue = $row['mobile'];
		$this->owner->DbValue = $row['owner'];
		$this->type->DbValue = $row['type'];
		$this->field_3091->DbValue = $row['field_3091'];
		$this->field_3090->DbValue = $row['field_3090'];
		$this->field_3088->DbValue = $row['field_3088'];
		$this->field_3187->DbValue = $row['field_3187'];
		$this->field_3188->DbValue = $row['field_3188'];
		$this->field_3183->DbValue = $row['field_3183'];
		$this->field_3184->DbValue = $row['field_3184'];
		$this->archive->DbValue = $row['archive'];
		$this->Note->DbValue = $row['Note'];
	}

	// 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 "crm_viewlist.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 == "crm_viewview.php")
			return $Language->phrase("View");
		elseif ($pageName == "crm_viewedit.php")
			return $Language->phrase("Edit");
		elseif ($pageName == "crm_viewadd.php")
			return $Language->phrase("Add");
		else
			return "";
	}

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

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

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

	// Edit URL
	public function getEditUrl($parm = "")
	{
		$url = $this->keyUrl("crm_viewedit.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("crm_viewadd.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("crm_viewdelete.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->last_name->setDbValue($rs->fields('last_name'));
		$this->first_name->setDbValue($rs->fields('first_name'));
		$this->email1->setDbValue($rs->fields('email1'));
		$this->tel->setDbValue($rs->fields('tel'));
		$this->mobile->setDbValue($rs->fields('mobile'));
		$this->owner->setDbValue($rs->fields('owner'));
		$this->type->setDbValue($rs->fields('type'));
		$this->field_3091->setDbValue($rs->fields('field_3091'));
		$this->field_3090->setDbValue($rs->fields('field_3090'));
		$this->field_3088->setDbValue($rs->fields('field_3088'));
		$this->field_3187->setDbValue($rs->fields('field_3187'));
		$this->field_3188->setDbValue($rs->fields('field_3188'));
		$this->field_3183->setDbValue($rs->fields('field_3183'));
		$this->field_3184->setDbValue($rs->fields('field_3184'));
		$this->archive->setDbValue($rs->fields('archive'));
		$this->Note->setDbValue($rs->fields('Note'));
	}

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

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

		// Common render codes
		// id
		// last_name
		// first_name
		// email1
		// tel
		// mobile
		// owner
		// type
		// field_3091
		// field_3090
		// field_3088
		// field_3187
		// field_3188
		// field_3183
		// field_3184
		// archive
		// Note
		// id

		$this->id->ViewValue = $this->id->CurrentValue;
		$this->id->ViewCustomAttributes = "";

		// last_name
		$this->last_name->ViewValue = $this->last_name->CurrentValue;
		$this->last_name->ViewCustomAttributes = "";

		// first_name
		$this->first_name->ViewValue = $this->first_name->CurrentValue;
		$this->first_name->ViewCustomAttributes = "";

		// email1
		$this->email1->ViewValue = $this->email1->CurrentValue;
		$this->email1->ViewCustomAttributes = "";

		// tel
		$this->tel->ViewValue = $this->tel->CurrentValue;
		$this->tel->ViewCustomAttributes = "";

		// mobile
		$this->mobile->ViewValue = $this->mobile->CurrentValue;
		$this->mobile->ViewCustomAttributes = "";

		// owner
		if (strval($this->owner->CurrentValue) != "") {
			$this->owner->ViewValue = $this->owner->optionCaption($this->owner->CurrentValue);
		} else {
			$this->owner->ViewValue = NULL;
		}
		$this->owner->CellCssStyle .= "text-align: center;";
		$this->owner->ViewCustomAttributes = "";

		// type
		if (strval($this->type->CurrentValue) != "") {
			$this->type->ViewValue = $this->type->optionCaption($this->type->CurrentValue);
		} else {
			$this->type->ViewValue = NULL;
		}
		$this->type->ViewCustomAttributes = "";

		// field_3091
		$this->field_3091->ViewValue = $this->field_3091->CurrentValue;
		$this->field_3091->ViewCustomAttributes = "";

		// field_3090
		$this->field_3090->ViewValue = $this->field_3090->CurrentValue;
		$this->field_3090->ViewCustomAttributes = "";

		// field_3088
		$this->field_3088->ViewValue = $this->field_3088->CurrentValue;
		$this->field_3088->ViewCustomAttributes = "";

		// field_3187
		$this->field_3187->ViewValue = $this->field_3187->CurrentValue;
		$this->field_3187->ViewCustomAttributes = "";

		// field_3188
		$this->field_3188->ViewValue = $this->field_3188->CurrentValue;
		$this->field_3188->ViewCustomAttributes = "";

		// field_3183
		$this->field_3183->ViewValue = $this->field_3183->CurrentValue;
		$this->field_3183->ViewCustomAttributes = "";

		// field_3184
		$this->field_3184->ViewValue = $this->field_3184->CurrentValue;
		$this->field_3184->ViewCustomAttributes = "";

		// archive
		if (strval($this->archive->CurrentValue) != "") {
			$this->archive->ViewValue = $this->archive->optionCaption($this->archive->CurrentValue);
		} else {
			$this->archive->ViewValue = NULL;
		}
		$this->archive->CellCssStyle .= "text-align: center;";
		$this->archive->ViewCustomAttributes = "";

		// Note
		$this->Note->ViewValue = $this->Note->CurrentValue;
		$this->Note->ViewValue = FormatNumber($this->Note->ViewValue, 0, -2, -2, -2);
		$this->Note->CellCssStyle .= "text-align: center;";
		$this->Note->ViewCustomAttributes = "";

		// id
		$this->id->LinkCustomAttributes = "";
		$this->id->HrefValue = "";
		$this->id->TooltipValue = "";

		// last_name
		$this->last_name->LinkCustomAttributes = "";
		$this->last_name->HrefValue = "";
		$this->last_name->TooltipValue = "";

		// first_name
		$this->first_name->LinkCustomAttributes = "";
		$this->first_name->HrefValue = "";
		$this->first_name->TooltipValue = "";

		// email1
		$this->email1->LinkCustomAttributes = "";
		$this->email1->HrefValue = "";
		$this->email1->TooltipValue = "";

		// tel
		$this->tel->LinkCustomAttributes = "";
		$this->tel->HrefValue = "";
		$this->tel->TooltipValue = "";

		// mobile
		$this->mobile->LinkCustomAttributes = "";
		$this->mobile->HrefValue = "";
		$this->mobile->TooltipValue = "";

		// owner
		$this->owner->LinkCustomAttributes = "";
		$this->owner->HrefValue = "";
		$this->owner->TooltipValue = "";

		// type
		$this->type->LinkCustomAttributes = "";
		$this->type->HrefValue = "";
		$this->type->TooltipValue = "";

		// field_3091
		$this->field_3091->LinkCustomAttributes = "";
		$this->field_3091->HrefValue = "";
		$this->field_3091->TooltipValue = "";

		// field_3090
		$this->field_3090->LinkCustomAttributes = "";
		$this->field_3090->HrefValue = "";
		$this->field_3090->TooltipValue = "";

		// field_3088
		$this->field_3088->LinkCustomAttributes = "";
		$this->field_3088->HrefValue = "";
		$this->field_3088->TooltipValue = "";

		// field_3187
		$this->field_3187->LinkCustomAttributes = "";
		$this->field_3187->HrefValue = "";
		$this->field_3187->TooltipValue = "";

		// field_3188
		$this->field_3188->LinkCustomAttributes = "";
		$this->field_3188->HrefValue = "";
		$this->field_3188->TooltipValue = "";

		// field_3183
		$this->field_3183->LinkCustomAttributes = "";
		$this->field_3183->HrefValue = "";
		$this->field_3183->TooltipValue = "";

		// field_3184
		$this->field_3184->LinkCustomAttributes = "";
		$this->field_3184->HrefValue = "";
		$this->field_3184->TooltipValue = "";

		// archive
		$this->archive->LinkCustomAttributes = "";
		$this->archive->HrefValue = "";
		$this->archive->TooltipValue = "";

		// Note
		$this->Note->LinkCustomAttributes = "";
		$this->Note->HrefValue = "";
		$this->Note->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 = "";

		// last_name
		$this->last_name->EditAttrs["class"] = "form-control";
		$this->last_name->EditCustomAttributes = "";
		if (!$this->last_name->Raw)
			$this->last_name->CurrentValue = HtmlDecode($this->last_name->CurrentValue);
		$this->last_name->EditValue = $this->last_name->CurrentValue;
		$this->last_name->PlaceHolder = RemoveHtml($this->last_name->caption());

		// first_name
		$this->first_name->EditAttrs["class"] = "form-control";
		$this->first_name->EditCustomAttributes = "";
		if (!$this->first_name->Raw)
			$this->first_name->CurrentValue = HtmlDecode($this->first_name->CurrentValue);
		$this->first_name->EditValue = $this->first_name->CurrentValue;
		$this->first_name->PlaceHolder = RemoveHtml($this->first_name->caption());

		// email1
		$this->email1->EditAttrs["class"] = "form-control";
		$this->email1->EditCustomAttributes = "";
		if (!$this->email1->Raw)
			$this->email1->CurrentValue = HtmlDecode($this->email1->CurrentValue);
		$this->email1->EditValue = $this->email1->CurrentValue;
		$this->email1->PlaceHolder = RemoveHtml($this->email1->caption());

		// tel
		$this->tel->EditAttrs["class"] = "form-control";
		$this->tel->EditCustomAttributes = "";
		if (!$this->tel->Raw)
			$this->tel->CurrentValue = HtmlDecode($this->tel->CurrentValue);
		$this->tel->EditValue = $this->tel->CurrentValue;
		$this->tel->PlaceHolder = RemoveHtml($this->tel->caption());

		// mobile
		$this->mobile->EditAttrs["class"] = "form-control";
		$this->mobile->EditCustomAttributes = "";
		if (!$this->mobile->Raw)
			$this->mobile->CurrentValue = HtmlDecode($this->mobile->CurrentValue);
		$this->mobile->EditValue = $this->mobile->CurrentValue;
		$this->mobile->PlaceHolder = RemoveHtml($this->mobile->caption());

		// owner
		$this->owner->EditAttrs["class"] = "form-control";
		$this->owner->EditCustomAttributes = "";
		$this->owner->EditValue = $this->owner->options(TRUE);

		// type
		$this->type->EditAttrs["class"] = "form-control";
		$this->type->EditCustomAttributes = "";
		$this->type->EditValue = $this->type->options(TRUE);

		// field_3091
		$this->field_3091->EditAttrs["class"] = "form-control";
		$this->field_3091->EditCustomAttributes = "";
		if (!$this->field_3091->Raw)
			$this->field_3091->CurrentValue = HtmlDecode($this->field_3091->CurrentValue);
		$this->field_3091->EditValue = $this->field_3091->CurrentValue;
		$this->field_3091->PlaceHolder = RemoveHtml($this->field_3091->caption());

		// field_3090
		$this->field_3090->EditAttrs["class"] = "form-control";
		$this->field_3090->EditCustomAttributes = "";
		if (!$this->field_3090->Raw)
			$this->field_3090->CurrentValue = HtmlDecode($this->field_3090->CurrentValue);
		$this->field_3090->EditValue = $this->field_3090->CurrentValue;
		$this->field_3090->PlaceHolder = RemoveHtml($this->field_3090->caption());

		// field_3088
		$this->field_3088->EditAttrs["class"] = "form-control";
		$this->field_3088->EditCustomAttributes = "";
		if (!$this->field_3088->Raw)
			$this->field_3088->CurrentValue = HtmlDecode($this->field_3088->CurrentValue);
		$this->field_3088->EditValue = $this->field_3088->CurrentValue;
		$this->field_3088->PlaceHolder = RemoveHtml($this->field_3088->caption());

		// field_3187
		$this->field_3187->EditAttrs["class"] = "form-control";
		$this->field_3187->EditCustomAttributes = "";
		if (!$this->field_3187->Raw)
			$this->field_3187->CurrentValue = HtmlDecode($this->field_3187->CurrentValue);
		$this->field_3187->EditValue = $this->field_3187->CurrentValue;
		$this->field_3187->PlaceHolder = RemoveHtml($this->field_3187->caption());

		// field_3188
		$this->field_3188->EditAttrs["class"] = "form-control";
		$this->field_3188->EditCustomAttributes = "";
		if (!$this->field_3188->Raw)
			$this->field_3188->CurrentValue = HtmlDecode($this->field_3188->CurrentValue);
		$this->field_3188->EditValue = $this->field_3188->CurrentValue;
		$this->field_3188->PlaceHolder = RemoveHtml($this->field_3188->caption());

		// field_3183
		$this->field_3183->EditAttrs["class"] = "form-control";
		$this->field_3183->EditCustomAttributes = "";
		if (!$this->field_3183->Raw)
			$this->field_3183->CurrentValue = HtmlDecode($this->field_3183->CurrentValue);
		$this->field_3183->EditValue = $this->field_3183->CurrentValue;
		$this->field_3183->PlaceHolder = RemoveHtml($this->field_3183->caption());

		// field_3184
		$this->field_3184->EditAttrs["class"] = "form-control";
		$this->field_3184->EditCustomAttributes = "";
		if (!$this->field_3184->Raw)
			$this->field_3184->CurrentValue = HtmlDecode($this->field_3184->CurrentValue);
		$this->field_3184->EditValue = $this->field_3184->CurrentValue;
		$this->field_3184->PlaceHolder = RemoveHtml($this->field_3184->caption());

		// archive
		$this->archive->EditCustomAttributes = "";
		$this->archive->EditValue = $this->archive->options(FALSE);

		// Note
		$this->Note->EditAttrs["class"] = "form-control";
		$this->Note->EditCustomAttributes = "";
		$this->Note->EditValue = $this->Note->CurrentValue;
		$this->Note->PlaceHolder = RemoveHtml($this->Note->caption());

		// 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->last_name);
					$doc->exportCaption($this->first_name);
					$doc->exportCaption($this->email1);
					$doc->exportCaption($this->tel);
					$doc->exportCaption($this->mobile);
					$doc->exportCaption($this->owner);
					$doc->exportCaption($this->type);
					$doc->exportCaption($this->field_3091);
					$doc->exportCaption($this->field_3090);
					$doc->exportCaption($this->field_3088);
					$doc->exportCaption($this->field_3187);
					$doc->exportCaption($this->field_3188);
					$doc->exportCaption($this->field_3183);
					$doc->exportCaption($this->field_3184);
					$doc->exportCaption($this->archive);
				} else {
					$doc->exportCaption($this->id);
					$doc->exportCaption($this->last_name);
					$doc->exportCaption($this->first_name);
					$doc->exportCaption($this->email1);
					$doc->exportCaption($this->tel);
					$doc->exportCaption($this->mobile);
					$doc->exportCaption($this->owner);
					$doc->exportCaption($this->type);
					$doc->exportCaption($this->field_3091);
					$doc->exportCaption($this->field_3090);
					$doc->exportCaption($this->field_3088);
					$doc->exportCaption($this->field_3187);
					$doc->exportCaption($this->field_3188);
					$doc->exportCaption($this->field_3183);
					$doc->exportCaption($this->field_3184);
					$doc->exportCaption($this->archive);
					$doc->exportCaption($this->Note);
				}
				$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->last_name);
						$doc->exportField($this->first_name);
						$doc->exportField($this->email1);
						$doc->exportField($this->tel);
						$doc->exportField($this->mobile);
						$doc->exportField($this->owner);
						$doc->exportField($this->type);
						$doc->exportField($this->field_3091);
						$doc->exportField($this->field_3090);
						$doc->exportField($this->field_3088);
						$doc->exportField($this->field_3187);
						$doc->exportField($this->field_3188);
						$doc->exportField($this->field_3183);
						$doc->exportField($this->field_3184);
						$doc->exportField($this->archive);
					} else {
						$doc->exportField($this->id);
						$doc->exportField($this->last_name);
						$doc->exportField($this->first_name);
						$doc->exportField($this->email1);
						$doc->exportField($this->tel);
						$doc->exportField($this->mobile);
						$doc->exportField($this->owner);
						$doc->exportField($this->type);
						$doc->exportField($this->field_3091);
						$doc->exportField($this->field_3090);
						$doc->exportField($this->field_3088);
						$doc->exportField($this->field_3187);
						$doc->exportField($this->field_3188);
						$doc->exportField($this->field_3183);
						$doc->exportField($this->field_3184);
						$doc->exportField($this->archive);
						$doc->exportField($this->Note);
					}
					$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>);

		$id= $this->id->CurrentValue;
		$tel=$this->tel->CurrentValue;
		$mobile=$this->mobile->CurrentValue;
		$email1=$this->email1->CurrentValue;
		$tel2=$this->field_3187->CurrentValue;
		$mobile2=$this->field_3188->CurrentValue;
		$email2=$this->field_3088->CurrentValue;

		//$this->last_name->ViewValue = "<a href='contact_listinglist.php?id=".$id."' target='_blank'>".$this->last_name->ViewValue."</a>";
		$this->tel->ViewValue = "<a href='tel:".$tel."'>".$tel."</a>";
		$this->mobile->ViewValue = "<a href='tel:".$mobile."'>".$mobile."</a>";
		$this->email1->ViewValue = "<a href='".$email1."'>".$email1."</a>";
		$this->field_3187->ViewValue = "<a href='tel:".$tel2."'>".$tel2."</a>";
		$this->field_3188->ViewValue = "<a href='tel:".$mobile2."'>".$mobile2."</a>";
		$this->field_3088->ViewValue = "<a href='mailto:".$email2."'>".$email2."</a>";
		$this->Note->ViewValue = "<a href='wp_property_notesadd.php?showdetail=&PropertyID=".$id."'>Note</a>";	
	}

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

		// Enter your code here
	}
}
?>

Hry