private function setData(Gpf_Data_RecordSet $recordSet, $totalCount = null) { $this->cachedData = $recordSet; if ($totalCount == null) { $this->size = $this->cachedData->getSize(); return; } $this->size = $totalCount; }
public function getNumberOfSubaffiliates($userid = null) { $result = new Gpf_Data_RecordSet(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('COUNT(u.userid)', 'amount'); $selectBuilder->from->add(Pap_Db_Table_Users::getName(), "u"); $selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "u.accountuserid = gu.accountuserid"); $selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid"); $selectBuilder->where->add('u.deleted', '=', Gpf::NO); if ($userid === null) { $selectBuilder->where->add('u.parentuserid', '=', Gpf_Session::getAuthUser()->getPapUserId()); } else { $selectBuilder->where->add('u.parentuserid', '=', $userid); } $selectBuilder->where->add('gu.rstatus', '<>', 'D'); if ($this->params->isDateFromDefined()) { $selectBuilder->where->add('u.' . Pap_Stats_Table::DATEINSERTED, '>=', $this->params->getDateFrom()->toDateTime()); } if ($this->params->isDateToDefined()) { $selectBuilder->where->add('u.' . Pap_Stats_Table::DATEINSERTED, '<=', $this->params->getDateTo()->toDateTime()); } $selectBuilder->limit->set(0, 1); $result->load($selectBuilder); if($result->getSize() == 0) { return 0; } foreach($result as $record) { return $record->get('amount'); } }
/** * returns text description about campaign commissions * * @param string $campaignId * @param Gpf_Data_RecordSet $rsCommissions * @return string */ private function getCommissionsDescription($campaignId, Gpf_Data_RecordSet $rsCommissions) { if($rsCommissions->getSize() == 0) { return $this->_('none active'); } $commissions = array(); $maxTiers = 1; foreach($rsCommissions as $record) { if($campaignId != $record->get("campaignid")) { continue; } $rType = $record->get('rtype'); $tier = $record->get('tier'); if($tier > $maxTiers) { $maxTiers = $tier; } $commissions[$rType][$tier]['commtype'] = $record->get(Pap_Db_Table_Commissions::TYPE); $commissions[$rType][$tier]['value'] = $record->get(Pap_Db_Table_Commissions::VALUE); } $description = ''; for($i=1; $i<=$maxTiers; $i++) { if(isset($commissions[Pap_Common_Constants::TYPE_CPM][$i])) { $description .= ($description != '' ? ', ' : ''); $description .= $this->_('CPM').': '.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commissions[Pap_Common_Constants::TYPE_CPM][$i]['value']); } if(isset($commissions[Pap_Common_Constants::TYPE_CLICK][$i])) { $description .= ($description != '' ? ', ' : ''); $description .= $this->_('per click').': '.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commissions[Pap_Common_Constants::TYPE_CLICK][$i]['value']); } if(isset($commissions[Pap_Common_Constants::TYPE_SALE][$i])) { $description .= ($description != '' ? ', ' : ''); $description .= $this->_('per sale').': '. Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commissions[Pap_Common_Constants::TYPE_SALE][$i]['value'], $commissions[Pap_Common_Constants::TYPE_SALE][$i]['commtype']); } } if($description == '') { $description = $this->_('none active'); } return $description; }
public function checkUserApprovedDirectLinks($userId) { $result = new Gpf_Data_RecordSet(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('COUNT('.Pap_Db_Table_DirectLinkUrls::ID.')', 'count'); $selectBuilder->from->add(Pap_Db_Table_DirectLinkUrls::getName()); $selectBuilder->where->add(Pap_Db_Table_DirectLinkUrls::USER_ID, '=', $userId); $selectBuilder->where->add(Pap_Db_Table_DirectLinkUrls::STATUS, '=', Pap_Common_Constants::STATUS_APPROVED); $result->load($selectBuilder); if($result->getSize() == 0) { return false; } foreach($result as $record) { if($record->get('count') > 0) { return true; } break; } return false; }
public function fill(Gpf_Data_RecordSet $data) { $this->rows = $data; $this->from = 0; $this->to = $this->count = $data->getSize(); }
/** * returns default currency or an exception * * @return Gpf_Db_Currency */ public static function getDefaultCurrency() { $result = new Gpf_Data_RecordSet(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Gpf_Db_Table_Currencies::ID, 'currencyid'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::NAME, 'name'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::SYMBOL, 'symbol'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::PRECISION, 'cprecision'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::IS_DEFAULT, 'isdefault'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::WHEREDISPLAY, 'wheredisplay'); $selectBuilder->select->add(Gpf_Db_Table_Currencies::EXCHANGERATE, 'exchrate'); $selectBuilder->from->add(Gpf_Db_Table_Currencies::getName()); $selectBuilder->where->add('isdefault', '=', 1); $selectBuilder->limit->set(0, 1); $result->load($selectBuilder); if ($result->getSize() == 0) { throw new Gpf_DbEngine_NoRowException($selectBuilder); } foreach ($result as $record) { $currency = new Gpf_Db_Currency(); $currency->fillFromRecord($record); return $currency; } throw new Gpf_DbEngine_NoRowException($selectBuilder); }
/** * checks if user is in campaign, if yes, it will return valid commissionGroupID, * otherwise it returns false * * @param string $userId * @return string or false */ public function checkUserIsInCampaign($userId) { $result = new Gpf_Data_RecordSet(); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('u.usercommgroupid', 'usercommgroupid'); $selectBuilder->select->add('u.commissiongroupid', 'commissiongroupid'); $selectBuilder->select->add('u.rstatus', 'rstatus'); $selectBuilder->from->add('qu_pap_userincommissiongroup', 'u'); $selectBuilder->from->addInnerJoin('qu_pap_commissiongroups', 'g', 'u.commissiongroupid=g.commissiongroupid'); $selectBuilder->where->add('g.campaignid', '=', $this->getId()); $selectBuilder->where->add('u.userid', '=', $userId); $selectBuilder->limit->set(0, 1); $result->load($selectBuilder); if($result->getSize() == 0) { return false; } foreach($result as $record) { if($this->isUserCommissionGroupStatusAllowed($record->get('rstatus'))) { return $record->get('commissiongroupid'); } break; } return false; }
/** * returns text description about campaign commissions * * @param string $campaignId * @param Gpf_Data_RecordSet $rsCommissions * @return string */ public function getCommissionsDescription($campaignId, Gpf_Data_RecordSet $rsCommissions, $commissionGroupId = null, $extendedFormatting = false) { if ($rsCommissions->getSize() == 0) { return $this->_('none active !'); } if ($commissionGroupId == null) { try { $commissionGroupId = $this->getDefaultCommissionGroup($campaignId); } catch (Gpf_Exception $e) { return $this->_('none active'); } } $commissions = array(); foreach ($rsCommissions as $record) { if ($campaignId != $record->get("campaignid") || ($commissionGroupId != '' && $commissionGroupId != $record->get("commissiongroupid"))) { continue; } $rType = $record->get('rtype'); $commissions[$rType]['commtype'] = $record->get(Pap_Db_Table_Commissions::TYPE); $commissions[$rType]['value'] = $record->get(Pap_Db_Table_Commissions::VALUE); switch ($rType) { case Pap_Common_Constants::TYPE_CPM: $commissionTypeName = $this->_('CPM'); break; case Pap_Common_Constants::TYPE_CLICK: $commissionTypeName = $this->_('per click'); break; case Pap_Common_Constants::TYPE_SALE: $commissionTypeName = $this->_('per sale / lead'); break; default: $commissionTypeName = $record->get('commissionTypeName'); break; } $commissions[$rType]['name'] = $commissionTypeName; } $description = ''; if ($extendedFormatting) { foreach ($commissions as $rtype => $commission) { $description .= ($description != '' ? '<br>' : ''); $description .= $commission['name'].': <strong>'.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commission['value'], $commission['commtype']).'</strong>'; } } else { foreach ($commissions as $rtype => $commission) { $description .= ($description != '' ? ', ' : ''); $description .= $commission['name'].': '.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commission['value'], $commission['commtype']); } } if($description == '') { $description = $this->_('none active'); } return $description; }
private function getCachedRecordSet(Gpf_Data_RecordSet $recordSet) { $from = $this->params->get(Gpf_Ui_RichListBox::FROM); $rowsPerPage = $this->params->get(Gpf_Ui_RichListBox::ROWS_PER_PAGE); $this->count = $recordSet->getSize(); if ($this->count > $this->params->get(Gpf_Ui_RichListBox::MAX_CACHED_COUNT)) { $cachedRecordSet = $recordSet->toShalowRecordSet(); if ($from + $rowsPerPage > $this->count) { $to = $this->count; } else { $to = $from + $rowsPerPage; } for ($from; $from < $to; $from++) { $cachedRecordSet->add($recordSet->getRecord($from)); } return $cachedRecordSet; } return $recordSet; }