setDBO(VoxelCareDB::getDatabase()); $userId = LegacyHelper::getUserId(); if ($userId) { $this->_db->setQuery("SELECT uf.franchise id FROM #__vxc_userfranchise uf WHERE uf.userid = ".$userId); $this->_id = $this->_db->loadResult(); } }//function function SetId($id) { $this->_id = (int)$id; $this->_item = null; } function store(&$data) { $table =& $this->getTable('franchise'); $db =& $this->_db; $table->reset(); $id = (int)$data['id']; $table->load($id); if (!$table->bind($data)) return false; if (!$table->check()) return false; if (!$table->store(true)) return false; $this->SetId($table->id); $data['id'] = $this->_id; return true; } function getData() { if (empty($this->_item)) { $db =& $this->_db; $sql = "SELECT f.id id , f.name name, f.address address, f.address2 address2, f.email email, f.telephone telephone, f.mobile mobile, f.fax fax, f.vat_number vat_number, f.country country, f.vat_percent vat_percent, f.company_number company_number, f.acct_number acct_number, f.website website FROM #__vxc_franchise f WHERE f.id = ".$this->_id; $db->setQuery($sql); $row = $db->loadObject(); if (!$row) { $row = new stdClass(); $row->id = 0; $row->name = null; } $this->_item = $row; } return $this->_item; } function getAgencies() { $sql = "SELECT a.id id, a.name name, fa.id faid, fa.description description, fa.price price, fa.default_off default_off FROM #__vxc_agency a LEFT JOIN #__vxc_franchiseagency fa ON fa.agency = a.id AND fa.franchise = ".$this->_id." ORDER BY a.sorting"; $this->_db->setQuery($sql); return $this->_db->loadObjectList(); } }// class