function applyFilters($q, $au)
{
//DB_DataObject::debugLevel(1);
-
- $tn = $this->tableName();
- //$this->selectAdd(" i18n_translate('c' , 'CN', 'en') as country_name");
- $p = DB_DataObject::factory('Person');
- $p->whereAdd("office_id > 0");
- $p->selectAdd();
- $p->selectAdd("DISTINCT(office_id) as office_id");
- $officeIds = $p->fetchAll('office_id');
- $this->whereAddIn("$tn.id", $officeIds, 'INT');
- $this->joinAddCountry();
- //$this->selectAdd("DISTINCT(id)");
-
-// $this->whereAdd("
-// {$tn}.id = (SELECT DISTINCT(office_id) FROM Person WHERE Person.office_id > 0)
-// ");
-
-// $this->selectAdd("
-// SELECT DISTINCT(office_id) FROM Person WHERE Person.office_id > 0
-// ");
+ $tn = $this->tableName();
+ $this->selectAdd(" i18n_translate('c' , {$tn}.country, 'en') as office_id_country_name");
}
- function joinAddCountry()
- {
- $this->_join .= "
- LEFT JOIN
- i18n AS join_country
- ON
- (join_country.lkey = Office.country)
- WHERE
- join_country.inlang = 'en'
- ";
- $item = DB_DataObject::Factory('I18n');
- $this->selectAs($item, 'country_id_%s', 'join_country');
- }
+
function toEventString() {
return $this->name;
}
function checkPerm($lvl, $au)
{
return $au->hasPerm("Core.Offices", $lvl);
- }
+ }
+
+ function company()
+ {
+ $c = DB_DataObject::Factory('Companies');
+ $c->get($this->company_id);
+ return $c;
+
+ }
}
\ No newline at end of file