setDBO(VoxelCareDB::getDatabase()); }//function function SetId($id) { $this->_id = (int)$id; $this->_item = null; } function deletePrice($id, $part) { if (!(int)$id) return; $column = ''; switch($part) { case 'pp': $column = 'patient_price'; break; case 'cp':$column = 'company_price'; break; case 'cf':$column = 'franchise_to_company_fee'; break; case 'ff':$column = 'voxelcare_to_franchise_fee'; break; default: return; } $sql = "UPDATE #__vxc_pricing SET $column = NULL WHERE id = ".$id; $this->_db->execute($sql); } function store(&$data) { $table =& $this->getTable('pricing'); $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 p.id id, p.attvalue attvalue, p.franchise franchise, p.user user, p.company_price company_price , p.patient_price patient_price , p.franchise_to_company_fee franchise_to_company_fee, p.voxelcare_to_franchise_fee voxelcare_to_franchise_fee FROM #__vxc_pricing p WHERE p.id = ".$this->_id; $db->setQuery($sql); $row = $db->loadObject(); if (!$row) { $row = new stdClass(); $row->id = 0; } $this->_item = $row; } return $this->_item; } function getDataByInfoFCI($franchiseId,$companyId,$atvalueId) { if (!(int) $franchiseId ) return null; if (empty($this->_item)) { $db =& $this->_db; $where = array(); $where[] = " p.franchise = ". $franchiseId; if ((int)$companyId) $where[] = " p.user = ". $companyId; else $where[] = " p.user IS NULL"; if ((int)$atvalueId) $where[] = " p.attvalue = ". $atvalueId; else $where[] = " p.attvalue IS NULL"; $sql = "SELECT p.id id, p.attvalue attvalue, p.franchise franchise, p.user user, p.company_price company_price , p.patient_price patient_price , p.franchise_to_company_fee franchise_to_company_fee, p.voxelcare_to_franchise_fee voxelcare_to_franchise_fee FROM #__vxc_pricing p WHERE " . implode(' AND ', $where); $db->setQuery($sql); $row = $db->loadObject(); if (!$row) { $row = new stdClass(); $row->id = 0; } $this->_item = $row; } return $this->_item; } function getDataByInfoFC($franchiseId,$companyId) { if (!(int) $franchiseId ) return null; $db =& $this->_db; $where = array(); $where[] = " p.franchise = ". $franchiseId; if ((int)$companyId) $where[] = " p.user = ". $companyId; else $where[] = " p.user IS NULL"; $sql = "SELECT p.id id, p.attvalue attvalue, p.franchise franchise, p.user user, p.company_price company_price , p.patient_price patient_price , p.franchise_to_company_fee franchise_to_company_fee, p.voxelcare_to_franchise_fee voxelcare_to_franchise_fee , atv.name atvname, at.name atname FROM #__vxc_pricing p LEFT JOIN #__vxc_attributetypevalue atv ON atv.id = p.attvalue LEFT JOIN #__vxc_attributetype at ON at.id = atv.attributetype WHERE " . implode(' AND ', $where); $db->setQuery($sql); return $db->loadObjectList(); } }// class