public function firstTimeApproved(Pap_Affiliates_User $user){ $userInCommision = new Pap_Db_UserInCommissionGroup(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_Campaigns::getInstance(), 'ca'); $selectBuilder->from->add('qu_pap_commissiongroups', 'c'); $selectBuilder->from->addInnerJoin('qu_pap_userincommissiongroup', 'u', 'u.commissiongroupid=c.commissiongroupid'); $selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'ca', 'ca.'.Pap_Db_Table_Campaigns::ID.'=c.campaignid'); $selectBuilder->where->add('u.userid','=',$user->getId()); foreach ($selectBuilder->getAllRowsIterator() as $row){ $campaign = new Pap_Common_Campaign(); $campaign->fillFromRecord($row); $userInCommision->sendInviteMail($campaign,$user->getId()); } }
protected function createDefaultCommissionTypes() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_Campaigns::getInstance()); $selectBuilder->from->add(Pap_Db_Table_Campaigns::getName()); $result = $selectBuilder->getAllRows(); foreach($result as $record) { $campaign = new Pap_Common_Campaign(); $campaign->setId($record->get(Pap_Db_Table_Campaigns::ID)); $campaign->load(); try { $campaign->getCommissionTypeObject(Pap_Common_Constants::TYPE_CLICK); } catch (Pap_Tracking_Exception $e) { $campaign->insertCommissionType(Pap_Common_Constants::TYPE_CLICK); } try { $campaign->getCommissionTypeObject(Pap_Common_Constants::TYPE_SALE); } catch (Pap_Tracking_Exception $e) { $campaign->insertCommissionType(Pap_Common_Constants::TYPE_SALE); } } }
/** * * @return Pap_Db_UserInCommissionGroup */ public function getUserCommissionGroup($userId, $campaignId) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_UserInCommissionGroup::getInstance(), 'ucg'); $selectBuilder->from->add(Pap_Db_Table_UserInCommissionGroup::getName(), 'ucg'); $selectBuilder->from->addInnerJoin(Pap_Db_Table_CommissionGroups::getName(), 'cg', 'ucg.'.Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID .'='. 'cg.'.Pap_Db_Table_CommissionGroups::ID); $selectBuilder->where->add('ucg.'.Pap_Db_Table_UserInCommissionGroup::USER_ID, '=', $userId); $selectBuilder->where->add('cg.'.Pap_Db_Table_CommissionGroups::CAMPAIGN_ID, '=', $campaignId); $userInGroup = new Pap_Db_UserInCommissionGroup(); $userInGroup->setStatus(Pap_Features_PerformanceRewards_Condition::STATUS_APPROVED); try { $record = $selectBuilder->getOneRow(); $userInGroup->fillFromRecord($record); $userInGroup->setPersistent(true); } catch (Gpf_DbEngine_NoRowException $e) { $userInGroup->setUserId($userId); $userInGroup->setCommissionGroupId(Pap_Db_Table_Campaigns::getInstance()->getDefaultCommissionGroup($campaignId)->getId()); } return $userInGroup; }
/** * returns ID of default commission group for this campaign * * @return string */ public function getDefaultCommissionGroup() { return Pap_Db_Table_Campaigns::getInstance()->getDefaultCommissionGroup($this->getId())->getId(); }
function init() { $this->setTable(Pap_Db_Table_Campaigns::getInstance()); parent::init(); }
/** * @return Gpf_Data_RecordSet */ private function getCampaigns() { $campaigns = new Gpf_SqlBuilder_SelectBuilder(); $campaigns->select->addAll(Pap_Db_Table_Campaigns::getInstance()); $campaigns->from->add(Pap_Db_Table_Campaigns::getName()); return $campaigns->getAllRows(); }