private function updateNullDateVisits() { $update = new Gpf_SqlBuilder_UpdateBuilder(); $update->from->add(Pap_Db_Table_VisitorAffiliates::getName()); $update->set->add(Pap_Db_Table_VisitorAffiliates::DATEVISIT, Gpf_Common_DateUtils::now()); $update->where->add(Pap_Db_Table_VisitorAffiliates::DATEVISIT, 'is', 'NULL', 'AND', false); $update->update(); }
function __construct(){ parent::__construct(); $this->setAccountId(Gpf_Db_Account::DEFAULT_ACCOUNT_ID); $this->setDateInserted(Gpf_Common_DateUtils::now()); $this->setChannel(''); $this->setSplit(1); $this->setTier(1); }
private function deleteVisitorAffiliates() { $delete = new Gpf_SqlBuilder_DeleteBuilder(); $delete->from->add(Pap_Db_Table_VisitorAffiliates::getName()); $delete->where->add(Pap_Db_Table_VisitorAffiliates::VALIDTO,'<',Gpf_Common_DateUtils::now()); $delete->where->add(Pap_Db_Table_VisitorAffiliates::VALIDTO,'!=',null); $delete->limit->set('',$this->deleteLimit); $statement = $delete->delete(); return $statement->affectedRows()>0; }
protected function addFillBonus(Pap_Common_User $user, $fillCount, $commission) { $transaction = new Pap_Common_Transaction(); $transaction->setCommission($commission); $transaction->setType(Pap_Db_Transaction::TYPE_EXTRA_BONUS); $transaction->setDateInserted(Gpf_Common_DateUtils::now()); $transaction->setStatus(Pap_Common_Constants::STATUS_APPROVED); $transaction->setPayoutStatus(Pap_Common_Constants::PSTATUS_UNPAID); $transaction->setUserId($user->getId()); $transaction->setSystemNote($this->_('Matrix %sx fill bonus', $fillCount)); $transaction->insert(); }
public function addForcedAffiliateToVisitorAffiliates(Pap_Common_VisitorAffiliateCacheCompoundContext $visitorAffiliatesCacheCompoundContext) { $context = $visitorAffiliatesCacheCompoundContext->getContext(); if ($context->getTrackingMethod() != Pap_Common_Transaction::TRACKING_METHOD_FORCED_PARAMETER && $context->getTrackingMethod() != Pap_Common_Transaction::TRACKING_METHOD_COUPON) { $context->debug('SplitCommissions - not forced affiliate'); return; } $context->debug('SplitCommissions - forced affiliate'); $context->setDateCreated(Gpf_Common_DateUtils::now()); $this->splitCommissionsSaveVisitorAffiliate($visitorAffiliatesCacheCompoundContext); }
protected function insertBonusTransaction($commissionValue) { $transaction = new Pap_Common_Transaction(); $transaction->setCommission($commissionValue); $transaction->setType(Pap_Db_Transaction::TYPE_EXTRA_BONUS); $transaction->setDateInserted(Gpf_Common_DateUtils::now()); $transaction->setStatus('A'); $transaction->setPayoutStatus('U'); $transaction->setUserId($this->getCurrentUserId()); $transaction->setCampaignId($this->transaction->getCampaignId()); $transaction->setSystemNote('Commission of rule: ' . $this->rule->getString()); $transaction->setData1($this->rule->getId()); $transaction->setData2($this->getToDateRange()); $transaction->insert(); }
public function createCommissions() { $comissionEntry = new Pap_Db_RecurringCommissionEntry(); $comissionEntry->setRecurringCommissionId($this->getId()); try { $parentTransaction = $this->getTransaction(); } catch (Gpf_Exception $e) { $parentTransaction = null; } foreach ($comissionEntry->loadCollection() as $comissionEntry) { if (!$this->isExistsUser($comissionEntry->getUserId())) { Gpf_log::error('Recurring commissions - createCommissions: user does not exist: ' . $comissionEntry->getUserId()); if ($comissionEntry->getTier() == '1') { return; } else { continue; } } $transaction = new Pap_Common_Transaction(); $transaction->setDateInserted(Gpf_Common_DateUtils::now()); $transaction->setType(Pap_Common_Constants::TYPE_RECURRING); $transaction->setTier($comissionEntry->getTier()); $transaction->setUserId($comissionEntry->getUserId()); $transaction->setCommissionTypeId($this->getCommissionTypeId()); $transaction->setParentTransactionId($this->getTransactionId()); $transaction->setCommission($comissionEntry->getCommission()); $transaction->setPayoutStatus(Pap_Common_Transaction::PAYOUT_UNPAID); $transaction->setStatus(Pap_Common_Constants::STATUS_APPROVED); $transaction->setOrderId($this->getOrderId()); if ($parentTransaction != null) { if ($transaction->getOrderId() == '') { $transaction->setOrderId($parentTransaction->getOrderId()); } $transaction->setProductId($parentTransaction->getProductId()); $transaction->setTotalCost($parentTransaction->getTotalCost()); $transaction->setCampaignId($parentTransaction->getCampaignId()); $transaction->setBannerId($parentTransaction->getBannerId()); $transaction->setParentBannerId($parentTransaction->getParentBannerId()); $transaction->setCountryCode($parentTransaction->getCountryCode()); $transaction->setData1($parentTransaction->getData1()); $transaction->setData2($parentTransaction->getData2()); $transaction->setData3($parentTransaction->getData3()); $transaction->setData4($parentTransaction->getData4()); $transaction->setData5($parentTransaction->getData5()); } $transaction->save(); } }
private function saveReportsSendTask() { $task = new Gpf_Db_PlannedTask(); $task->setClassName(Pap_Merchants_Config_EmailNotificationsFormBase::REPORTS_SEND_CLASS); $task->setRecurrencePresetId('A'); $task->setParams(serialize(array('lastdate' => Gpf_Common_DateUtils::now()))); $task->setAccountId(Gpf_Application::getInstance()->getAccountId()); try { $task->loadFromData(array( Gpf_Db_Table_PlannedTasks::CLASSNAME, Gpf_Db_Table_PlannedTasks::RECURRENCEPRESETID, Gpf_Db_Table_PlannedTasks::ACCOUNTID)); } catch (Gpf_DbEngine_NoRowException $e) { $task->insert(); } catch (Gpf_DbEngine_TooManyRowsException $e) { } }
protected function execute() { try { $fromtime = $this->getFromTime(); if ($fromtime) { $select = $this->createSellNotificationSelect(Gpf_Common_DateUtils::getDateTime($fromtime)); foreach ($select->getAllRows() as $saleRow) { $this->createNotificationsForSale($saleRow); } if (!empty($this->androidNotifications)) $this->sendGoogleNotifications(); } $fromtime = (string) Gpf_Common_DateUtils::getTimestamp(Gpf_Common_DateUtils::now()); $this->saveFromTime($fromtime); $this->cleanupOldRegistrations(); } catch (Exception $e) { throw new Gpf_Exception('Pap_Mobile_NotificationTask failed ' . $e->getMessage()); } $this->interrupt(10 * 60); }
/** * * @service mail_outbox write * @param $ids * @return Gpf_Rpc_Action */ public function restartSendingMail(Gpf_Rpc_Params $params) { $action = new Gpf_Rpc_Action($params); $action->setErrorMessage($this->_('Failed to restart %s row(s)')); $action->setInfoMessage($this->_('%s row(s) successfully restarted')); foreach ($action->getIds() as $id) { try { $update = new Gpf_SqlBuilder_UpdateBuilder(); $update->from->add(Gpf_Db_Table_MailOutbox::getName()); $update->set->add(Gpf_Db_Table_MailOutbox::ERROR_MSG, self::RESTART_ERROR_MSG); $update->set->add(Gpf_Db_Table_MailOutbox::RETRY_NR, self::RESTART_RETRY_NR); $update->set->add(Gpf_Db_Table_MailOutbox::SCHNEDULET_AT, Gpf_Common_DateUtils::now()); $update->where->add(Gpf_Db_Table_MailOutbox::ID, '=', $id, 'AND'); $update->where->add(Gpf_Db_Table_MailOutbox::STATUS, '=', self::STATUS_PENDING); $update->executeOne(); $action->addOk(); } catch (Exception $e) { $action->addError(); } } return $action; }
/** * * @service user_comm_group add * @param $fields */ public function add(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $dbRow = $this->createDbRowObject(); $this->setDefaultDbRowObjectValues($dbRow); $form->fill($dbRow); $dbRow->set(Pap_Db_Table_UserInCommissionGroup::STATUS, self::DEFAULT_STATUS); $dbRow->set(Pap_Db_Table_UserInCommissionGroup::NOTE, self::DEFAULT_NOTE); $dbRow->set(Pap_Db_Table_UserInCommissionGroup::DATE_ADDED, Gpf_Common_DateUtils::now()); try { $dbRow->save(); } catch (Exception $e) { $form->setErrorMessage($e->getMessage()); return $form; } $form->load($dbRow); $form->setField("Id", $dbRow->getPrimaryKeyValue()); $form->setInfoMessage($this->getDbRowObjectName().$this->_(" added")); return $form; }
public function scheduleTasks($inclusion_type, $inclusion_tasks) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Gpf_Db_Table_PlannedTasks::getInstance()); $select->from->add(Gpf_Db_Table_PlannedTasks::getName()); $condition = new Gpf_SqlBuilder_CompoundWhereCondition(); $condition->add(Gpf_Db_Table_PlannedTasks::LASTPLANDATE, '<', Gpf_Common_DateUtils::now(), 'OR'); $condition->add(Gpf_Db_Table_PlannedTasks::LASTPLANDATE, 'is', 'NULL', 'OR', false); $select->where->addCondition($condition); if ($inclusion_type == Gpf_Tasks_Runner::INCLUDE_TASKS) { $select->where->add(Gpf_Db_Table_PlannedTasks::CLASSNAME, 'IN', $inclusion_tasks); } else { if ($inclusion_type == Gpf_Tasks_Runner::EXCLUDE_TASKS) { $select->where->add(Gpf_Db_Table_PlannedTasks::CLASSNAME, 'NOT IN', $inclusion_tasks); } } foreach ($select->getAllRows() as $plannedTaskRow) { $plannedTask = new Gpf_Db_PlannedTask(); $plannedTask->fillFromRecord($plannedTaskRow); if ($plannedTask->getLastPlanDate() == null) { $plannedTask->setLastPlanDate(Gpf_Common_DateUtils::now()); } $task = new Gpf_Db_Task(); $task->setClassName($plannedTask->getClassName()); $task->setParams($plannedTask->getParams()); $task->setAccountId($plannedTask->getAccountId()); $task->save(); $preset = new Gpf_Recurrence_Preset(); $preset->setId($plannedTask->getRecurrencePresetId()); $preset->load(); $nextDate = $preset->getNextDate(Gpf_Common_DateUtils::mysqlDateTime2Timestamp($plannedTask->getLastPlanDate())); if ($nextDate != null && $nextDate > 0) { $plannedTask->setLastPlanDate(Gpf_Common_DateUtils::getDateTime($nextDate)); $plannedTask->update(); } } }
public function save() { if ($this->isFirstChangeStatus()) { $this->setDateApproved(Gpf_Common_DateUtils::now()); } try { $authUser = new Gpf_Db_AuthUser(); $authUser->setPrimaryKeyValue($this->authUser->getPrimaryKeyValue()); $authUser->load(); $this->accountUser->setAuthId($authUser->getId()); } catch (Gpf_Exception $e) { try { $this->authUser->loadFromUsername(); $this->accountUser->setAuthId($this->authUser->getId()); } catch (Exception $e) { } } $this->inserting = !$this->user->rowExists(); $this->checkConstraints(); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.User.beforeSave', $this); $this->authUser->save(); $this->accountUser->setAuthId($this->authUser->getId()); try { $this->accountUser->save(); } catch (Gpf_Exception $e) { $this->authUser->delete(); throw new Gpf_Exception($e->getMessage()); } $this->user->set('accountuserid', $this->accountUser->get('accountuserid')); $this->initRefid($this->accountUser->getId()); $this->initMinimupPayout(); try { $this->user->save(); } catch (Gpf_Exception $e) { $this->authUser->delete(); $this->accountUser->delete(); throw new Gpf_Exception($e->getMessage()); } if ($this->inserting) { $this->afterInsert(); } else { Pap_Db_Table_CachedBanners::deleteCachedBannersForUser($this->user->getId(), $this->user->getRefId()); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.User.afterSave', $this); } }
/** * @param $ip * @return Pap_Db_VisitorAffiliate */ protected function getLatestVisitorAffiliateFromDbByIp($ip, $accountId) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->from->add(Pap_Db_Table_VisitorAffiliates::getName()); $selectBuilder->select->addAll(Pap_Db_Table_VisitorAffiliates::getInstance()); $selectBuilder->where->add(Pap_Db_Table_VisitorAffiliates::IP, '=', $ip); $selectBuilder->where->add(Pap_Db_Table_VisitorAffiliates::ACCOUNTID, '=', $accountId); $selectBuilder->where->add(Pap_Db_Table_VisitorAffiliates::VALIDTO, '>=', Gpf_Common_DateUtils::now()); $selectBuilder->orderBy->add(Pap_Db_Table_VisitorAffiliates::DATEVISIT, false); $selectBuilder->limit->set(0, 1); try { $visitorAffiliate = new Pap_Db_VisitorAffiliate(); $visitorAffiliate->fillFromRecord($selectBuilder->getOneRow()); } catch (Gpf_Exception $e) { return null; } return $visitorAffiliate; }
private function getLastDateParams() { $params = array('lastdate' => Gpf_Common_DateUtils::now()); return serialize($params); }
protected function migrateBanners() { Pap3Compatibility_Migration_OutputWriter::log(" Migrating banners....."); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('*'); $selectBuilder->from->add('wd_pa_banners', 'b'); $selectBuilder->where->add('b.deleted', '=', '0' ); $result = $selectBuilder->getAllRows(); $count = 0; foreach($result as $record) { $obj = new Pap_Common_Banner(); $obj->setId($record->get('bannerid')); $obj->setCampaignId($record->get('campaignid')); $obj->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID); if($record->get('destinationurl') != '') { $obj->setDestinationUrl($record->get('destinationurl')); } else { $obj->setDestinationUrl(' '); } $obj->setName($record->get('name')); if($record->get('dateinserted') != '') { $obj->set('dateinserted', $record->get('dateinserted')); } else { $obj->set('dateinserted', Gpf_Common_DateUtils::now()); } $obj->setStatus(($record->get('hidden') == 1 ? 'H' : 'A')); $bannerType = Pap3Compatibility_Migration_Pap3Constants::translateBannerType($record->get('bannertype')); switch($bannerType) { case Pap_Common_Banner_Factory::BannerTypeText: $obj->setData1($record->get('sourceurl')); $obj->setData2($this->replaceVariables($record->get('description'))); break; case Pap_Common_Banner_Factory::BannerTypeImage: $obj->setData1($record->get('sourceurl')); break; case Pap_Common_Banner_Factory::BannerTypeHtml: $obj->setData1('N'); $obj->setData2($this->replaceVariables($record->get('description'))); break; case Pap_Common_Banner_Factory::BannerTypePopup: case Pap_Common_Banner_Factory::BannerTypePopunder: // these banners are not yet supported in PAP4 continue; case Pap_Common_Banner_Factory::BannerTypePromoEmail: $obj->setData1($record->get('sourceurl')); $obj->setData2($this->replaceVariables($record->get('description'))); break; } $obj->setBannerType($bannerType); try { $obj->save(); } catch (Gpf_Exception $e) { Pap3Compatibility_Migration_OutputWriter::log( sprintf(' Warning: banner %s not migrated. Reason: %s', $obj->getId(), $e->getMessage())); } $count++; } Pap3Compatibility_Migration_OutputWriter::log(" ($count) ..... DONE<br/>"); }
private function createTestAffiliateUser() { $affiliateUser = new Pap_Affiliates_User(); $affiliateUser->setId('11111111'); $affiliateUser->setDateInserted(Gpf_Common_DateUtils::now()); $affiliateUser->setRefId("testaff"); $affiliateUser->setPassword($this->account->getPassword()); $affiliateUser->setUserName(Pap_Branding::DEMO_AFFILIATE_USERNAME); $affiliateUser->setFirstName("Test"); $affiliateUser->setLastName("Affiliate"); $affiliateUser->setAccountId($this->account->getId()); $affiliateUser->setStatus(Gpf_Db_User::APPROVED); $affiliateUser->set('dateapproved', Gpf_Common_DateUtils::Now()); $affiliateUser->save(); $this->setQuickLaunchSettings($affiliateUser->getAccountUserId(), 'showDesktop'); Gpf_Settings::set(Pap_Settings::DEFAULT_AFFILIATE_PANEL_THEME, Pap_Branding::DEFAULT_AFFILIATE_PANEL_THEME); }
public function finish() { $this->setIsExecuting(false); $this->setProgressMessage(''); $this->set(Gpf_Db_Table_Tasks::DATEFINISHED, Gpf_Common_DateUtils::now()); $this->save(); }
public function isValid() { return $this->getValidTo() >= Gpf_Common_DateUtils::now(); }
public function createSampleBanners($campaignId) { $banner = new Pap_Common_Banner(); $banner->setId('11110001'); $banner->setName('Sample image banner 1'); $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeImage); $banner->setCampaignId($campaignId); $banner->setStatus('A'); $banner->setDestinationUrl("http://www.qualityunit.com"); $banner->setSize("P468x60"); $banner->setData1($this->copyToBannerUploads('sample_image_banner.gif')); $banner->setAccountId($this->account->getId()); $banner->set("dateinserted", Gpf_Common_DateUtils::now()); $banner->setWrapperId('plain'); $banner->save(); $banner = new Pap_Common_Banner(); $banner->setId('11110002'); $banner->setName('Sample text link 1'); $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeText); $banner->setCampaignId($campaignId); $banner->setStatus('A'); $banner->setDestinationUrl("http://www.qualityunit.com"); $banner->setSize("U"); $banner->setData1("Click here"); $banner->setData2("to find out more about this link"); $banner->set("dateinserted", Gpf_Common_DateUtils::now()); $banner->setAccountId($this->account->getId()); $banner->setWrapperId('plain'); $banner->save(); $banner = new Pap_Common_Banner(); $banner->setId('11110003'); $banner->setName('Sample Flash banner'); $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeFlash); $banner->setCampaignId($campaignId); $banner->setStatus('A'); $banner->setDestinationUrl("http://www.qualityunit.com"); $banner->setSize("P468x60"); $banner->setData1($this->copyToBannerUploads("sample_flash_banner.swf")); $banner->setData2("Opaque"); $banner->set("dateinserted", Gpf_Common_DateUtils::now()); $banner->setAccountId($this->account->getId()); $banner->setWrapperId('plain'); $banner->save(); $banner = new Pap_Common_Banner(); $banner->setId('11110004'); $banner->setName('Sample HTML banner 1'); $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypeHtml); $banner->setCampaignId($campaignId); $banner->setStatus('A'); $banner->setDestinationUrl("http://www.qualityunit.com"); $banner->setSize("U"); $banner->setData1('N'); $banner->setData2('<table width="100%" border="0" cellpadding="3"> <tr> <td align="left" valign="top"><img src="' . $this->copyToBannerUploads('sample_html_banner_image.gif') . '" alt=""/></td> <td></td> <td align="left" valign="top"> <b>Post Affiliate Pro</b><br/> - a powerful affiliate management system that allows you to:<br/> - easy set up and maintain your own affiliate program <br/> - pay your affiliates per lead per click per sale or %commission.<br/> - multi-tier commissions: up to 10 tiers<br/> - get more traffic for you website without additional costs<br/> - increase sales<br/> - already used by more than thousand merchants worldwide <br/> </td> </tr> <tr> <td colspan="3" align="left"> Post Affiliate Pro offers you a vast spectrum of features and PRICE / FEATURES RATIO IS THE BEST you can find. <br/>You also get FREE INSTALLATION, lifetime upgrades and fast and helpful support.<br/><br/> <b>Post Affiliate Pro</b> is compatible with nearly all merchant accounts, payment gateways, shopping carts and membership systems. <br/> <a style="color:red;" href="{$targeturl}">Click here to learn more</a> </td> </tr> </table>'); $banner->set("dateinserted", Gpf_Common_DateUtils::now()); $banner->setAccountId($this->account->getId()); $banner->setWrapperId('plain'); $banner->save(); $banner = new Pap_Common_Banner(); $banner->setId('11110005'); $banner->setName('Sample promotional email'); $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypePromoEmail); $banner->setCampaignId($campaignId); $banner->setStatus('A'); $banner->setDestinationUrl("http://www.qualityunit.com"); $banner->setSize("U"); $banner->setData1("New generation affiliate software"); $banner->setData2('Dear friend,<br><br>I would like to let you know about an affiliate software I recently found.<br>It is called Post Affiliate Pro.<br><br>Go to the link below learn more:<br><a href=\"{$targeturl}\">Post Affiliate Pro</a><br><br>best regards,<br><br>{$firstname} {$lastname}'); $banner->set("dateinserted", Gpf_Common_DateUtils::now()); $banner->setAccountId($this->account->getId()); $banner->setWrapperId('plain'); $banner->save(); $banner = new Pap_Common_Banner(); $banner->setId('11110006'); $banner->setName('Sample Simple PDF book 1'); $banner->setBannerType(Pap_Common_Banner_Factory::BannerTypePdf); $banner->setCampaignId($campaignId); $banner->setStatus('A'); $banner->setDestinationUrl("http://www.qualityunit.com"); $banner->setSize("U"); $banner->setData1("book1.pdf"); $banner->setData2('<span style="font-weight: bold;">Example Simple PDF book</span><br><br><img src="http://www.qualityunit.com/themes/site_themes/qu/pap/post_affiliate_pro_logo.gif"><br><br>Dear {$firstname} {$lastname},<br><br>let me present you this book.<br><br><ol><li>list 1</li><li>list 2</li><li>list 3</li></ol>To find out more, click <a href="{$targeturl}">here</a>.<br>'); $banner->setData3('Sample SimplePDF book'); $banner->set("dateinserted", Gpf_Common_DateUtils::now()); $banner->setAccountId($this->account->getId()); $banner->setWrapperId('plain'); $banner->save(); }
protected function processRecurringCommission(Pap_Features_RecurringCommissions_RecurringCommission $recurringCommission) { $recurringCommission->createCommissions(); $recurringCommission->setLastCommissionDate(Gpf_Common_DateUtils::now()); $recurringCommission->save(); }
public function insert() { $this->setVersion(); $this->set(Gpf_Db_Table_InstalledTemplates::CHANGED, Gpf_Common_DateUtils::now()); parent::insert(); }
/** * @return string datetime in standard format */ public function getVisitDateTime() { if (($visit = $this->getVisit()) != null) { return $visit->getDateVisit(); } if (!is_null($this->getDateCreated()) && $this->getDateCreated() !== '') { return $this->getDateCreated(); } return Gpf_Common_DateUtils::now(); }
protected function checkBeforeSave(Pap_Common_Campaign $row, Gpf_Rpc_Form $form, $operationType) { /** $this->checkCampaignValidity($row, $form, $operationType); */ if($row->getIsDefault() && $row->get('rstatus') <> Pap_Db_Campaign::CAMPAIGN_STATUS_ACTIVE) { throw new Gpf_Exception($this->_("Error, you cannot deactivate Default campaign")); } if($row->get('rstatus') == "") { throw new Gpf_Exception($this->_("You have to specify status of campaign (rstatus field)")); } /* if ($row->getIsDefault() || $row->getCampaignType() == null) { if ($form->existsField('rtype') && $form->getFieldValue('rtype') != Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC) { throw new Gpf_Exception($this->_("Type of default campaign must be public")); } } */ if ($row->getDateInserted() == null || $row->getDateInserted() == '') { $row->setDateInserted(Gpf_Common_DateUtils::now()); } if (!$form->existsField('accountid') || $form->getFieldValue('accountid') == '') { $row->set("accountid", Gpf_Session::getAuthUser()->getAccountId()); } return true; }
protected function insertTransaction($affiliateId, $type, $commissionValue, $status, Gpf_Data_Record $commission = null) { if ($affiliateId == null) { return; } $transaction = new Pap_Common_Transaction(); $transaction->setUserId($affiliateId); $transaction->setType($type); if ($commission != null) { $transaction->setTier($commission->get(Pap_Db_Table_Commissions::TIER)); } else { $transaction->setTier('1'); } $transaction->setStatus($status); $transaction->setPayoutStatus('U'); $transaction->setDateInserted(Gpf_Common_DateUtils::now()); $transaction->setCommission($commissionValue); $transaction->setData5($this->user->getId()); $transaction->setIp(Gpf_Http::getRemoteIp()); $transaction->insert(); }
protected function getNumberOfAllTransactionPerClickCommission($userId, $commissionTypeId, $timePeriod = -1) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('SUM('.Pap_Db_Table_Transactions::CLICK_COUNT.')', 'numberOfAll'); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::USER_ID, '=', $userId); $select->where->add(Pap_Db_Table_Transactions::COMMISSIONTYPEID, '=', $commissionTypeId); if ($timePeriod > 0) { $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, '>', Gpf_Common_DateUtils::getDateTime(Gpf_Common_DateUtils::getTimestamp(Gpf_Common_DateUtils::now())-$timePeriod)); } return $select->getOneRow()->get('numberOfAll'); }
protected function migrateUsersInCampaigns() { Pap3Compatibility_Migration_OutputWriter::log(" Migrating users in campaigns....."); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('*'); $selectBuilder->from->add('wd_pa_affiliatescampaigns'); $count = 0; foreach($selectBuilder->getAllRowsIterator() as $record) { if($record->get('affiliateid') == '' || $record->get('campcategoryid') == '') { continue; } $count++; try { $obj = new Pap_Db_UserInCommissionGroup(); $obj->setUserId($record->get('affiliateid')); $obj->setCommissionGroupId($record->get('campcategoryid')); $obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus'))); $obj->setDateAdded(Gpf_Common_DateUtils::now()); $obj->save(); } catch(Gpf_Exception $e) { // non important error, don't display it } } Pap3Compatibility_Migration_OutputWriter::log(" ($count) ..... DONE<br/>"); }
/** * parameter ts should contain client time in format * YYYY-MM-DD_HH:MM:SS * */ public function computeTimeOffset() { if(!isset($_REQUEST['ts']) || $_REQUEST['ts'] == '') { return; } $serverTime = Gpf_Common_DateUtils::now(); $serverTimestamp = strtotime($serverTime); $this->clientDate = str_replace('_', ' ', $_REQUEST['ts']); $clientTimestamp = strtotime($this->clientDate); $offset = $clientTimestamp - $serverTimestamp; $part = ((int)($offset / 900) * 900); if ($offset - $part > 450) { $part = $part + 900; } Gpf_Session::getInstance()->setTimeOffset($part); }
/** * @return Pap_Common_Campaign */ public static function createDefaultCampaign($accountId, $campaignName, $campaignId = null, $type = Pap_Common_Campaign::CAMPAIGN_TYPE_PUBLIC) { $campaign = new Pap_Common_Campaign(); if ($campaignId != null) { $campaign->setId($campaignId); } $campaign->setName($campaignName); $campaign->setDateInserted(Gpf_Common_DateUtils::now()); $campaign->setCampaignStatus(Pap_Common_Campaign::CAMPAIGN_STATUS_ACTIVE); $campaign->setCampaignType($type); $campaign->setCookieLifetime(0); $campaign->resetOverwriteCookieToDefault(); $campaign->setAccountId($accountId); $campaign->setIsDefault(); $campaign->save(); self::createDefaultCommissionSettings($campaign); return $campaign; }
/** * * @return Gpf_Db_Task */ protected function getPendingTask($lastRunTaskId, $inclusion_type, $inclusion_tasks) { $sql = new Gpf_SqlBuilder_SelectBuilder(); $sql->select->addAll(Gpf_Db_Table_Tasks::getInstance()); $sql->from->add(Gpf_Db_Table_Tasks::getName()); $sql->where->add(Gpf_Db_Table_Tasks::DATEFINISHED, '=', null); $sql->where->add(Gpf_Db_Table_Tasks::TYPE, '=', Gpf_Db_Task::TYPE_CRON); if ($inclusion_type == self::INCLUDE_TASKS) { $sql->where->add(Gpf_Db_Table_Tasks::CLASSNAME, 'IN', $inclusion_tasks); } else { if ($inclusion_type == self::EXCLUDE_TASKS) { $sql->where->add(Gpf_Db_Table_Tasks::CLASSNAME, 'NOT IN', $inclusion_tasks); } } $andCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); $andCondition->add(Gpf_Db_Table_Tasks::IS_EXECUTING, '<>', Gpf::YES, 'OR'); $orCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); $orCondition->add(Gpf_Db_Table_Tasks::IS_EXECUTING, '=', Gpf::YES); $orCondition->add(Gpf_Db_Table_Tasks::DATECHANGED, '<', Gpf_Common_DateUtils::getDateTime(time() - self::MAX_TASK_RUN_TIME_WITHOUT_UPDATE)); $andCondition->addCondition($orCondition, 'OR'); $sql->where->addCondition($andCondition); $sleepCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); $sleepCondition->add(Gpf_Db_Table_Tasks::SLEEP_UNTIL, '=', null, 'OR'); $sleepCondition->add(Gpf_Db_Table_Tasks::SLEEP_UNTIL, '<=', Gpf_Common_DateUtils::now(), 'OR'); $sql->where->addCondition($sleepCondition); $sql->orderBy->add(Gpf_Db_Table_Tasks::WORKING_AREA_TO . '-' . Gpf_Db_Table_Tasks::WORKING_AREA_FROM, false); $sql->orderBy->add(Gpf_Db_Table_Tasks::DATECHANGED); $recordset = $sql->getAllRows(); if ($recordset->getSize() == 0) { return false; } if ($lastRunTaskId == null) { return $this->getTask($recordset->get(0)); } $recordId = $this->findLastRunTaskRecordsetPosition($recordset, $lastRunTaskId); if ($recordId === null) { return $this->getTask($recordset->get(0)); } if ($recordId == $recordset->getSize() - 1) { return false; } if ($recordset->get($recordId + 1) == null) { return false; } return $this->getTask($recordset->get($recordId + 1)); }