private function getCommissionTypeAndValue($campaignId, $userId, $commissionTypeId, $tier = null) { if (is_null($tier) || $tier == '') { $tier = 1; } // getting user if($userId == '') { $this->errorMsg = $this->_("User is not valid!"); return false; } $user = new Pap_Common_User(); $user->setPrimaryKeyValue($userId); try { $user->load(); } catch (Gpf_DbEngine_NoRowException $e) { $this->errorMsg = $this->_("User is not valid!"); return false; } // getting campaign $campaign = new Pap_Common_Campaign(); $campaign->setId($campaignId); try { $campaign->load(); } catch (Gpf_DbEngine_NoRowException $e) { $this->errorMsg = $this->_("Campaign is not valid!"); return false; } // getting commission type try { $commissionType = new Pap_Db_CommissionType(); $commissionType->setId($commissionTypeId); $commissionType->setStatus(Pap_Db_CommissionType::STATUS_ENABLED); $commissionType->loadFromData(); } catch (Gpf_DbEngine_NoRowException $e) { $this->errorMsg = $this->_("Transaction type is not valid or doesn't exist in this campaign!"); return false; } $fixedcostType = $commissionType->getFixedcostType(); $fixedcostValue = $commissionType->getFixedcostValue(); // getting commission group $commGroupId = $campaign->getCommissionGroupForUser($userId); if($commGroupId == false) { $this->errorMsg = $this->_("Cannot recognize commission group for this user in campaign!"); return false; } $rsCommissions = $campaign->getCommissionsCollection($commGroupId, $commissionType->getId()); $commType = null; $commValue = null; foreach($rsCommissions as $record) { if($record->get('tier') == $tier && $record->get('subtype') == 'N') { $commType = $record->get('commissiontype'); $commValue = $record->get('commissionvalue'); break; } } if($commType == null) { $this->errorMsg = $this->_("Error getting commission settings!"); return false; } return array('type' => $commType, 'value' => $commValue, 'fixedcostValue' => $fixedcostValue, 'fixedcostType' => $fixedcostType); }