function preProcess() { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE); if ($oid) { $this->_id = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE); } else { $this->assign('hide_contact', TRUE); $this->_id = $cid; } if (!CRM_Utils_Rule::positiveInteger($this->_id)) { CRM_Core_Error::fatal('We need a valid discount ID for view'); } $this->assign('id', $this->_id); $defaults = array(); $params = array('id' => $this->_id); require_once 'CRM/CiviDiscount/BAO/Item.php'; CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults); require_once 'CRM/CiviDiscount/BAO/Track.php'; if ($cid) { $rows = CRM_CiviDiscount_BAO_Track::getUsageByContact($this->_id); } else { $rows = CRM_CiviDiscount_BAO_Track::getUsageByOrg($this->_id); } $this->assign('rows', $rows); $this->assign('code_details', $defaults); $this->ajaxResponse['tabCount'] = count($rows); if (!empty($defaults['code'])) { CRM_Utils_System::setTitle($defaults['code']); } }