protected function buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_UserInCommissionGroup::getName(), "uicg"); $onCondition = "uicg.".Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID." = cg.".Pap_Db_Table_CommissionGroups::ID; $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_CommissionGroups::getName(), "cg", $onCondition); $onCondition = "cg.".Pap_Db_Table_CommissionGroups::CAMPAIGN_ID. " = c." .Pap_Db_Table_Campaigns::ID; $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), "c", $onCondition); }
protected function onBannerSelectBuilderCreated(Gpf_SqlBuilder_SelectBuilder $builder){ $builder->select->add('b.'.Pap_Db_Table_Banners::SIZE, 'size'); $builder->select->add('c.'.Pap_Db_Table_Campaigns::NAME, 'campaignName'); $builder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'b.'.Pap_Db_Table_Banners::CAMPAIGN_ID.'=c.'.Pap_Db_Table_Campaigns::ID); $builder->where->add('b.'.Pap_Db_Table_Banners::TYPE , '!=' , 'R'); }
public function run() { $time1 = microtime(); Pap3Compatibility_Migration_OutputWriter::logOnce("Deleting migrated data from existing PAP4 tables<br/>"); try { $this->deleteTable(Pap_Db_Table_Campaigns::getName()); $this->deleteTable(Pap_Db_Table_CommissionGroups::getName()); $this->deleteTable(Pap_Db_Table_CommissionTypes::getName()); $this->deleteTable(Pap_Db_Table_Commissions::getName()); $this->deleteTable(Pap_Db_Table_UserInCommissionGroup::getName()); $this->deleteTable(Gpf_Db_Table_FormFields::getName()); $this->deleteTable(Gpf_Db_Table_FieldGroups::getName()); $this->deleteTable(Pap_Db_Table_Transactions::getName()); $this->deleteTable(Pap_Db_Table_Clicks::getName()); $this->deleteTable(Pap_Db_Table_RawClicks::getName()); $this->deleteTable(Pap_Db_Table_Impressions::getName()); $this->deleteTable(Pap_Db_Table_Banners::getName()); $this->deleteTable(Gpf_Db_Table_FieldGroups::getName()); $this->deleteTable(Pap_Db_Table_PayoutsHistory::getName()); $this->deleteTable(Pap_Db_Table_Payouts::getName()); $this->deleteTable(Gpf_Db_Table_Currencies::getName()); $this->deleteTable(Gpf_Db_Table_MailAccounts::getName()); } catch(Exception $e) { Pap3Compatibility_Migration_OutputWriter::log(" Errror: ".$e->getMessage()."<br/>"); } $time2 = microtime(); Pap3Compatibility_Migration_OutputWriter::logDone($time1, $time2); }
private function getDefaultCampaignId() { if($this->defaultCampaignId == '') { $this->defaultCampaignId = Pap_Db_Table_Campaigns::getDefaultCampaignId(); } return $this->defaultCampaignId; }
protected function buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_Rules::getName(), 'r'); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'c.'.Pap_Db_Table_Campaigns::ID.'=r.'.Pap_Db_Table_Rules::CAMPAIGN_ID); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_CommissionGroups::getName(), 'cg', 'r.'.Pap_Db_Table_Rules::COMMISSION_GROUP_ID.'=cg.'.Pap_Db_Table_CommissionGroups::ID); }
protected function buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_AffiliateTrackingCodes::getName(), 'atc'); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_CommissionTypes::getName(), 'com', 'com.commtypeid=atc.commtypeid'); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'cam', 'cam.campaignid=com.campaignid'); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'u', 'u.userid=atc.userid'); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'u.accountuserid=gu.accountuserid'); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'au.authid=gu.authid'); }
protected function buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_DirectLinkUrls::getName(), "l"); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "l.userid = pu.userid"); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid"); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Channels::getName(), "ch", "ch.channelid = l.channelid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), "b", "b.bannerid = l.bannerid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), "c", "c.campaignid = l.campaignid"); }
private function removeCommissionGroups() { $delete = new Gpf_SqlBuilder_DeleteBuilder(); $delete->delete->add('cg'); $delete->from->add(Pap_Db_Table_UserInCommissionGroup::getName(), 'ucg'); $delete->from->addRightJoin(Pap_Db_Table_CommissionGroups::getName(), 'cg', 'ucg.'.Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID.'=cg.'.Pap_Db_Table_CommissionGroups::ID); $delete->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'cg.'.Pap_Db_Table_CommissionGroups::CAMPAIGN_ID.'=c.'.Pap_Db_Table_Campaigns::ID); $delete->where->add('cg.'.Pap_Db_Table_CommissionGroups::IS_DEFAULT, '=', Gpf::NO); $delete->delete(); }
protected function buildFrom() { $this->_selectBuilder->from->addSubselect($this->rawClicksSelect, "rc"); $onCondition = "rc.".Pap_Db_Table_RawClicks::CAMPAIGNID." = c.".Pap_Db_Table_Campaigns::ID; $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', $onCondition); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', "rc.bannerid = b.bannerid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'pb', "rc.parentbannerid = pb.bannerid"); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "rc.userid = pu.userid"); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid"); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Channels::getName(), 'ch', 'ch.channelid=rc.channel'); }
/** * @return Gpf_SqlBuilder_SelectBuilder */ protected function createSelectBuilder() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('c.'.Pap_Db_Table_Campaigns::ID, self::ID); $selectBuilder->select->add('c.'.Pap_Db_Table_Campaigns::NAME, self::VALUE); $selectBuilder->from->add(Pap_Db_Table_Campaigns::getName(), 'c'); if(Gpf_Session::getAuthUser()->getRoleTypeId() == Pap_Application::ROLETYPE_AFFILIATE) { $selectBuilder->where->add('c.' . Pap_Db_Table_Campaigns::STATUS, '!=', 'S'); } Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Campaigns.getCampaignsSelect', $selectBuilder); return $selectBuilder; }
/** * @return Gpf_Data_RecordSet */ protected function getMatchingCampaignsRecordSet($productId) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Pap_Db_Table_Campaigns::ID); $selectBuilder->select->add(Pap_Db_Table_Campaigns::PRODUCT_ID); $selectBuilder->from->add(Pap_Db_Table_Campaigns::getName()); $selectBuilder->where->add(Pap_Db_Table_Campaigns::PRODUCT_ID, 'REGEXP', '[,[:space:]]'.$productId.'[,[:space:]]', 'OR'); $selectBuilder->where->add(Pap_Db_Table_Campaigns::PRODUCT_ID, 'REGEXP', '^'.$productId.'$', 'OR'); $selectBuilder->where->add(Pap_Db_Table_Campaigns::PRODUCT_ID, 'REGEXP', '^'.$productId.'[,[:space:]]', 'OR'); $selectBuilder->where->add(Pap_Db_Table_Campaigns::PRODUCT_ID, 'REGEXP', '[,[:space:]]'.$productId.'$', 'OR'); return $selectBuilder->getAllRows(); }
private function updateNullValidTo() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('campaignid'); $select->select->add('cookielifetime'); $select->from->add(Pap_Db_Table_Campaigns::getName()); $recordSet = $select->getAllRows(); foreach ($recordSet as $record) { $campaign = new Pap_Common_Campaign(); $campaign->setId($record->get('campaignid')); $campaign->setCookieLifetime($record->get('cookielifetime')); $this->updateValidityFor($campaign); } }
public function getPendingDirectLinksCount() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('l.'.Pap_Db_Table_DirectLinkUrls::ID); $select->from->add(Pap_Db_Table_DirectLinkUrls::getName(), 'l'); $select->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', 'b.'.Pap_Db_Table_Banners::ID.' = l.'.Pap_Db_Table_DirectLinkUrls::BANNER_ID); $select->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'c.'.Pap_Db_Table_Campaigns::ID.' = l.'.Pap_Db_Table_DirectLinkUrls::CAMPAIGN_ID); $select->where->add('l.'.Pap_Db_Table_DirectLinkUrls::STATUS, "=", self::PENDING); Gpf_Plugins_Engine::extensionPoint('AffiliateNetwork.directLinksModifyWhere', $select); $result = $select->getAllRows(); return $result->getSize(); }
private function initActionCampaignNames() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('c.'.Pap_Db_Table_Campaigns::NAME); $select->select->add('ct.'.Pap_Db_Table_CommissionTypes::ID); $select->from->add(Pap_Db_Table_Campaigns::getName(), 'c'); $select->from->addInnerJoin(Pap_Db_Table_CommissionTypes::getName(), 'ct', 'ct.'.Pap_Db_Table_CommissionTypes::CAMPAIGNID.'='.'c.'.Pap_Db_Table_Campaigns::ID); $select->where->add('ct.'.Pap_Db_Table_CommissionTypes::NAME, '!=', ''); $select->where->add('ct.'.Pap_Db_Table_CommissionTypes::NAME, '!=', null); $this->campaignNamesCache = array(); foreach ($select->getAllRows() as $row) { $this->campaignNamesCache[$row->get(Pap_Db_Table_CommissionTypes::ID)] = $row->get(Pap_Db_Table_Campaigns::NAME); } }
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()); } }
private function loadCampaigns() { $result = new Gpf_Data_RecordSet('id'); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Pap_Db_Table_Campaigns::ID, 'id'); $selectBuilder->select->add(Pap_Db_Table_Campaigns::NAME, 'name'); $selectBuilder->select->add(Pap_Db_Table_Campaigns::STATUS, 'status'); $selectBuilder->select->add(Pap_Db_Table_Campaigns::DESCRIPTION, 'description'); $selectBuilder->select->add(Pap_Db_Table_Campaigns::LOGO_URL, 'logourl'); $selectBuilder->from->add(Pap_Db_Table_Campaigns::getName()); $selectBuilder->where->add(Pap_Db_Table_Campaigns::STATUS, 'IN', Pap_Affiliates_Promo_Campaigns::getCampaignAllowedStatuses()); $selectBuilder->orderBy->add(Pap_Db_Table_Campaigns::ORDER); $result->load($selectBuilder); return $result; }
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 Gpf_SqlBuilder_SelectBuilder */ protected function createSelectBuilder() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('b.'.Pap_Db_Table_Banners::ID, self::ID); $selectBuilder->select->add('b.'.Pap_Db_Table_Banners::NAME, self::VALUE); $selectBuilder->from->add(Pap_Db_Table_Banners::getName(), 'b'); $selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'camp', 'b.'.Pap_Db_Table_Banners::CAMPAIGN_ID.'=camp.'.Pap_Db_Table_Campaigns::ID); $cond = new Gpf_SqlBuilder_CompoundWhereCondition(); $cond->add('b.'.Pap_Db_Table_Banners::STATUS, '=', 'A'); $cond->add('b.'.Pap_Db_Table_Banners::STATUS, '=', 'H','OR'); $selectBuilder->where->addCondition($cond,'AND'); $selectBuilder->where->add('camp.'.Pap_Db_Table_Campaigns::STATUS, 'IN', array(Pap_Db_Campaign::CAMPAIGN_STATUS_ACTIVE, Pap_Db_Campaign::CAMPAIGN_STATUS_STOPPED)); if ($this->params->get('campaignid') != '') { $selectBuilder->where->add('b.'.Pap_Db_Table_Banners::CAMPAIGN_ID, '=', $this->params->get('campaignid')); } Gpf_Plugins_Engine::extensionPoint('PostAffiliate.BannerListbox.getBannerSelect', $selectBuilder); $this->onBannerSelectBuilderCreated($selectBuilder); return $selectBuilder; }
/** * @throws Gpf_DbEngine_TooManyRowsException * @throws Gpf_DbEngine_NoRowException * @param string $transId * @return Gpf_Data_Record */ private function getTransactionData($transId) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Pap_Db_Table_Transactions::TRANSACTION_ID, Pap_Db_Table_Transactions::TRANSACTION_ID, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::USER_ID, Pap_Db_Table_Transactions::USER_ID, 't'); $selectBuilder->select->add(Gpf_Db_Table_AuthUsers::USERNAME, Gpf_Db_Table_AuthUsers::USERNAME, 'au'); $selectBuilder->select->add(Gpf_Db_Table_AuthUsers::FIRSTNAME, Gpf_Db_Table_AuthUsers::FIRSTNAME, 'au'); $selectBuilder->select->add(Gpf_Db_Table_AuthUsers::LASTNAME, Gpf_Db_Table_AuthUsers::LASTNAME, 'au'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::SYMBOL, Gpf_Db_Table_Currencies::SYMBOL, "c"); $selectBuilder->select->add(Gpf_Db_Table_Currencies::WHEREDISPLAY, Gpf_Db_Table_Currencies::WHEREDISPLAY, "c"); $selectBuilder->select->add(Pap_Db_Table_Campaigns::NAME, "campaignname", "ca"); $selectBuilder->select->add(Pap_Db_Table_Transactions::R_STATUS, Pap_Db_Table_Transactions::R_STATUS, "t"); $selectBuilder->select->add(Pap_Db_Table_Transactions::R_TYPE, Pap_Db_Table_Transactions::R_TYPE, "t"); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATE_INSERTED, Pap_Db_Table_Transactions::DATE_INSERTED, "t"); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATE_APPROVED, Pap_Db_Table_Transactions::DATE_APPROVED, "t"); $selectBuilder->select->add(Pap_Db_Table_Transactions::PAYOUT_STATUS, Pap_Db_Table_Transactions::PAYOUT_STATUS, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::REFERER_URL, Pap_Db_Table_Transactions::REFERER_URL, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::IP, Pap_Db_Table_Transactions::IP, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::COMMISSION, Pap_Db_Table_Transactions::COMMISSION, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::TIER, Pap_Db_Table_Transactions::TIER, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::ORDER_ID, Pap_Db_Table_Transactions::ORDER_ID, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::PRODUCT_ID, Pap_Db_Table_Transactions::PRODUCT_ID, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::TOTAL_COST, Pap_Db_Table_Transactions::TOTAL_COST, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::TRACK_METHOD, Pap_Db_Table_Transactions::TRACK_METHOD, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::FIRST_CLICK_TIME, Pap_Db_Table_Transactions::FIRST_CLICK_TIME, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::FIRST_CLICK_REFERER, Pap_Db_Table_Transactions::FIRST_CLICK_REFERER, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::FIRST_CLICK_IP, Pap_Db_Table_Transactions::FIRST_CLICK_IP, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::FIRST_CLICK_DATA1, Pap_Db_Table_Transactions::FIRST_CLICK_DATA1, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::FIRST_CLICK_DATA2, Pap_Db_Table_Transactions::FIRST_CLICK_DATA2, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::LAST_CLICK_TIME, Pap_Db_Table_Transactions::LAST_CLICK_TIME, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::LAST_CLICK_REFERER, Pap_Db_Table_Transactions::LAST_CLICK_REFERER, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::LAST_CLICK_IP, Pap_Db_Table_Transactions::LAST_CLICK_IP, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::LAST_CLICK_DATA1, Pap_Db_Table_Transactions::LAST_CLICK_DATA1, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::LAST_CLICK_DATA2, Pap_Db_Table_Transactions::LAST_CLICK_DATA2, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATA1, Pap_Db_Table_Transactions::DATA1, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATA2, Pap_Db_Table_Transactions::DATA2, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATA3, Pap_Db_Table_Transactions::DATA3, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATA4, Pap_Db_Table_Transactions::DATA4, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::DATA5, Pap_Db_Table_Transactions::DATA5, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::ORIGINAL_CURRENCY_VALUE, Pap_Db_Table_Transactions::ORIGINAL_CURRENCY_VALUE, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::MERCHANTNOTE, Pap_Db_Table_Transactions::MERCHANTNOTE, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::SYSTEMNOTE, Pap_Db_Table_Transactions::SYSTEMNOTE, 't'); $selectBuilder->select->add(Pap_Db_Table_Transactions::VISITOR_ID, Pap_Db_Table_Transactions::VISITOR_ID, 't'); $selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), "t"); $selectBuilder->from->addLeftJoin(Pap_Db_Table_Users::getName(), "pu", "t.".Pap_Db_Table_Transactions::USER_ID." = pu.".Pap_Db_Table_Users::ID); $selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.".Pap_Db_Table_Users::ACCOUNTUSERID." = gu.".Gpf_Db_Table_Users::ID); $selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.".Gpf_Db_Table_Users::AUTHID." = au.".Gpf_Db_Table_AuthUsers::ID); $selectBuilder->from->addLeftJoin(Gpf_Db_Table_Currencies::getName(), "c", "t.".Pap_Db_Table_Transactions::ORIGINAL_CURRENCY_ID." = c.".Gpf_Db_Table_Currencies::ID); $selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), "ca", "t.".Pap_Db_Table_Transactions::CAMPAIGN_ID." = ca.".Pap_Db_Table_Campaigns::ID); $selectBuilder->where->add(Pap_Db_Table_Transactions::TRANSACTION_ID, '=', $transId); $row = $selectBuilder->getOneRow(); return $row; }
private function processCampaignsToPublic() { $update = new Gpf_SqlBuilder_UpdateBuilder(); $update->from->add(Pap_Db_Table_Campaigns::getName()); $update->set->add(Pap_Db_Table_Campaigns::TYPE, Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC); $update->execute(); }
protected function buildFrom() { parent::buildFrom(); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'c.'.Pap_Db_Table_Campaigns::ID.'=r.'.Pap_Db_Table_Transactions::CAMPAIGN_ID); }
/** * 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 buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), "t"); $onCondition = "t.".Pap_Db_Table_Transactions::CAMPAIGN_ID." = c.".Pap_Db_Table_Campaigns::ID; $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), 'c', $onCondition); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "t.userid = pu.userid"); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid"); $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Channels::getName(), "ch", "t.channel = ch.channelid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_CommissionTypes::getName(), "ct", "t.commtypeid = ct.commtypeid"); $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Currencies::getName(), 'cs', 't.originalcurrencyid = cs.currencyid'); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', 'b.bannerid = t.bannerid'); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_PayoutsHistory::getName(), 'ph', 'ph.'.Pap_Db_Table_PayoutsHistory::ID.' = t.'.Pap_Db_Table_Transactions::PAYOUTHISTORY_ID); }
/** * * Pap alert application handle, do not modify this source! * * @param String $dateFrom * @param String $dateTo * @param String $userId * @return Gpf_Data_RecordSet */ public static function getTransactions(Pap_Stats_Params $statsParams) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('tr.'.Pap_Db_Table_Transactions::USER_ID, 'userid'); $select->select->add('au.'.Gpf_Db_Table_AuthUsers::FIRSTNAME, 'name'); $select->select->add('au.'.Gpf_Db_Table_AuthUsers::LASTNAME, 'surname'); $select->select->add('au.'.Gpf_Db_Table_AuthUsers::USERNAME, 'username'); $select->select->add('pu.data1', 'weburl'); $select->select->add('tr.'.Pap_Db_Table_Transactions::TRANSACTION_ID, 'transid'); $select->select->add('tr.'.Pap_Db_Table_Transactions::TOTAL_COST, 'totalcost'); $select->select->add('tr.'.Pap_Db_Table_Transactions::FIXED_COST, 'fixedcost'); $select->select->add('tr.'.Pap_Db_Table_Transactions::ORDER_ID, 'orderid'); $select->select->add('tr.'.Pap_Db_Table_Transactions::PRODUCT_ID, 'productid'); $select->select->add('tr.'.Pap_Db_Table_Transactions::DATE_INSERTED, 'dateinserted'); $select->select->add('tr.'.Pap_Db_Table_Transactions::R_STATUS, 'rstatus'); $select->select->add('tr.'.Pap_Db_Table_Transactions::R_TYPE, 'transtype'); $select->select->add('tr.'.Pap_Db_Table_Transactions::PARRENT_TRANSACTION_ID, 'transkind'); $select->select->add('tr.'.Pap_Db_Table_Transactions::PAYOUT_STATUS, 'payoutstatus'); $select->select->add('tr.'.Pap_Db_Table_Transactions::DATE_APPROVED, 'dateapproved'); $select->select->add('tr.'.Pap_Db_Table_Transactions::COMMISSION, 'commission'); $select->select->add('tr.'.Pap_Db_Table_Transactions::REFERER_URL, 'refererurl'); $select->select->add('c.'.Pap_Db_Table_Campaigns::ID, 'campcategoryid'); $select->select->add('c.'.Pap_Db_Table_Campaigns::NAME, 'campaign'); $select->select->add('tr.data1', 'data1'); $select->select->add('tr.data2', 'data2'); $select->select->add('tr.data3', 'data3'); $select->select->add('tr.'.Pap_Db_Table_Transactions::COUNTRY_CODE, 'countrycode'); $select->from->add(Pap_Db_Table_Transactions::getName(), 'tr'); $select->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'tr.'.Pap_Db_Table_Transactions::CAMPAIGN_ID.'=c.'.Pap_Db_Table_Campaigns::ID); $select->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'pu', 'tr.'.Pap_Db_Table_Transactions::USER_ID.'=pu.'.Pap_Db_Table_Users::ID); $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'gu.'.Gpf_Db_Table_Users::ID.'=pu.'.Pap_Db_Table_Users::ACCOUNTUSERID); $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'gu.'.Gpf_Db_Table_Users::AUTHID.'=au.'.Gpf_Db_Table_AuthUsers::ID); if ($statsParams->isDateFromDefined()) { $select->where->add('tr.'.Pap_Db_Table_Transactions::DATE_INSERTED, '>=', $statsParams->getDateFrom()->toDateTime()); } if ($statsParams->isDateToDefined()) { $select->where->add('tr.'.Pap_Db_Table_Transactions::DATE_INSERTED, '<=', $statsParams->getDateTo()->toDateTime()); } if ($statsParams->getAffiliateId() != '') { $select->where->add('tr.'.Pap_Db_Table_Transactions::USER_ID, '=', $statsParams->getAffiliateId()); } return $select->getAllRows(); }
private function createCampaign() { $campaign = Pap_Db_Table_Campaigns::createDefaultCampaign($this->account->getId(), 'First campaign', '11111111'); $this->createSampleBanners($campaign->getId()); $this->createSampleChannel(); $this->createSampleDirectLinkUrl(); }
/** * * @param $campaignId * @param $commissionType * @param $affiliateId * @return Gpf_Data_RecordSet */ public function getAllUserCommissionTypes($campaignId = null, $commissionType = null, $affiliateId = null) { $selectBuilder = $this->getAllCommissionTypesSelect($campaignId, $commissionType); $selectBuilder->select->add(Pap_Db_Table_Campaigns::NAME, 'campaignname', 'c'); $selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', 'ct.'.self::CAMPAIGNID.'=c.'.Pap_Db_Table_Campaigns::ID); if (Gpf_Session::getAuthUser()->getAccountId() != Gpf_Db_Account::DEFAULT_ACCOUNT_ID) { $selectBuilder->where->add(Pap_Db_Table_Campaigns::ACCOUNTID, '=', Gpf_Session::getAuthUser()->getAccountId()); } if ($affiliateId !== null && $affiliateId !== '') { $selectBuilder->from->addLeftJoin(Pap_Db_Table_CommissionGroups::getName(), 'cg', 'ct.'.self::CAMPAIGNID.'=cg.'.Pap_Db_Table_CommissionGroups::CAMPAIGN_ID); $selectBuilder->from->addLeftJoin(Pap_Db_Table_UserInCommissionGroup::getName(), 'uicg', 'cg.'.Pap_Db_Table_CommissionGroups::ID.'=uicg.'.Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID); $condition = new Gpf_SqlBuilder_CompoundWhereCondition(); $subCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); $subCondition->add('uicg.'.Pap_Db_Table_UserInCommissionGroup::USER_ID, '=', $affiliateId); $subCondition->add('uicg.'.Pap_Db_Table_UserInCommissionGroup::STATUS, '=', 'A'); $condition->addCondition($subCondition, 'OR'); $condition->add('c.'.Pap_Db_Table_Campaigns::TYPE, '=', 'P', 'OR'); $selectBuilder->where->addCondition($condition); $selectBuilder->groupBy->add('ct.'.self::ID); } return $selectBuilder->getAllRows(); }
/** * * @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; }
/** * @throws Gpf_Exception */ public function setCampaignDefault($campaignId) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add(Pap_Db_Table_Campaigns::ACCOUNTID); $select->from->add(Pap_Db_Table_Campaigns::getName()); $select->where->add(Pap_Db_Table_Campaigns::ID, '=', $campaignId); $campaign = $select->getOneRow(); $oldCampaignSelect = new Gpf_SqlBuilder_SelectBuilder(); $oldCampaignSelect->select->add(Pap_Db_Table_Campaigns::ID); $oldCampaignSelect->from->add(Pap_Db_Table_Campaigns::getName()); $oldCampaignSelect->where->add(Pap_Db_Table_Campaigns::ACCOUNTID, '=', $campaign->get(Pap_Db_Table_Campaigns::ACCOUNTID)); $oldCampaignSelect->where->add(Pap_Db_Table_Campaigns::IS_DEFAULT, '=', Gpf::YES); $oldCampaignId = $oldCampaignSelect->getOneRow()->get(Pap_Db_Table_Campaigns::ID); if ($oldCampaignId == $campaignId) { return; } $oldCampaignUpdate = new Gpf_SqlBuilder_UpdateBuilder(); $oldCampaignUpdate->from->add(Pap_Db_Table_Campaigns::getName()); $oldCampaignUpdate->set->add(Pap_Db_Table_Campaigns::IS_DEFAULT, Gpf::NO); $oldCampaignUpdate->where->add(Pap_Db_Table_Campaigns::ID, '=', $oldCampaignId); $oldCampaignUpdate->executeOne(); $update = new Gpf_SqlBuilder_UpdateBuilder(); $update->from->add(Pap_Db_Table_Campaigns::getName()); $update->set->add(Pap_Db_Table_Campaigns::IS_DEFAULT, Gpf::YES); $update->where->add(Pap_Db_Table_Campaigns::ID, '=', $campaignId); $update->executeOne(); }
/** * @return Pap_Db_Table_Campaigns */ public static function getInstance() { if(self::$instance === null) { self::$instance = new self; } return self::$instance; }
function init() { $this->setTable(Pap_Db_Table_Campaigns::getInstance()); parent::init(); }