private function getFixedCost($commTypeId) { $commType = new Pap_Db_CommissionType(); $commType->setId($commTypeId); $commType->load(); if (($commType->getFixedcostValue()==0) || ($commType->getFixedcostValue()=='null')) { return ""; } return $commType->getFixedcostType().$commType->getFixedcostValue(); }
public function loadCommissionType(Pap_Db_CommissionType $commissionType) { $this->setField("Id", $commissionType->getId()); $this->setField(Pap_Db_Table_CommissionTypes::TYPE, $commissionType->getType()); $this->setField(Pap_Db_Table_CommissionTypes::NAME, $commissionType->getName()); $this->setField(Pap_Db_Table_CommissionTypes::CODE, $commissionType->getCode()); $this->setField(Pap_Db_Table_CommissionTypes::STATUS, $commissionType->getStatus()); $this->setField(Pap_Db_Table_CommissionTypes::APPROVAL, $commissionType->getApproval()); $this->setField(Pap_Db_Table_CommissionTypes::RECURRENCEPRESETID, $commissionType->getRecurrencePresetId()); $this->setField(Pap_Db_Table_CommissionTypes::ZEROORDERSCOMMISSION, $commissionType->getZeroOrdersCommissions()); $this->setField(Pap_Db_Table_CommissionTypes::SAVEZEROCOMMISSION, $commissionType->getSaveZeroCommissions()); $this->setField(Pap_Db_Table_CommissionTypes::FIXEDCOSTTYPE, $commissionType->getFixedcostType()); $this->setField(Pap_Db_Table_CommissionTypes::FIXEDCOSTVALUE, $commissionType->getFixedcostValue()); }
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); }