protected function setDefaultDbRowObjectValues(Gpf_DbEngine_RowBase $dbRow) { $dbRow->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); $actualDate = Gpf_Common_DateUtils::getDateTime(time()); $dbRow->setDateInserted($actualDate); $dbRow->setDateApproved($actualDate); $dbRow->setStatus(Gpf_Db_User::APPROVED); }
public function process(Pap_Common_TransactionCompoundContext $context) { $transaction = $context->getTransaction(); $context->getContext()->debug("SubaffiliateFirstSaleBonus started"); if($transaction->getTier() != 2) { $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Not 2. tier"); return; } $row = $this->getChildAffiliateInfo($transaction); $date = new Gpf_DateTime(time()); $date->addDay(-Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::VALIDITY_DAYS)); if(Gpf_Common_DateUtils::getDateTime($date->toTimeStamp()) > $row->get(Pap_Db_Table_Users::DATEINSERTED)) { $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Date Inserted is older than defined days."); return; } if($this->getChildAffiliateTransactionsCount($row->get(Pap_Db_Table_Transactions::USER_ID)) > 1) { $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Not user's first transaction."); return; } if(Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::BONUS_TYPE) == '%') { $transaction->setCommission($transaction->getCommission()+(Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::BONUS_AMOUNT)/100)*$transaction->getTotalCost()); } else{ $transaction->setCommission(Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::BONUS_AMOUNT)+$transaction->getCommission()); } $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Success."); return; }
protected function setTimeVariableValues($timeOffset = 0) { parent::setTimeVariableValues($timeOffset); $firstClickTime = Gpf_Common_DateUtils::getTimestamp($this->transaction->get(Pap_Db_Table_Transactions::FIRST_CLICK_TIME)); $lastClickTime = Gpf_Common_DateUtils::getTimestamp($this->transaction->get(Pap_Db_Table_Transactions::LAST_CLICK_TIME)); $this->setVariable('firstclicktime', Gpf_Common_DateUtils::getDateTime($firstClickTime + $timeOffset)); $this->setVariable('lastclicktime', Gpf_Common_DateUtils::getDateTime($lastClickTime + $timeOffset)); }
private function addUserInCommissionGroup($commissionGroupId, $userId, $status) { $userInCommissionGroup = new Pap_Db_UserInCommissionGroup(); $userInCommissionGroup->setCommissionGroupId($commissionGroupId); $userInCommissionGroup->setUserId($userId); $userInCommissionGroup->setStatus($status); $userInCommissionGroup->setDateAdded(Gpf_Common_DateUtils::getDateTime(time())); $userInCommissionGroup->save(); }
public function initSettings($context) { $context->addDbSetting(BusinessCatalyst_Config::LOGIN, ''); $context->addDbSetting(BusinessCatalyst_Config::PASSWORD, ''); $context->addDbSetting(BusinessCatalyst_Config::SITE_ID, ''); $context->addDbSetting(BusinessCatalyst_Config::PAP_CUSTOM_FIELD_NAME, ''); $context->addDbSetting(BusinessCatalyst_Config::BC_DOMAIN_NAME, ''); $context->addDbSetting(BusinessCatalyst_Config::BC_LAST_CHECK, Gpf_Common_DateUtils::getDateTime(1)); $context->addDbSetting(BusinessCatalyst_Config::BC_LAST_ENTITY_ID, '0'); }
/** * @param Pap_Contexts_Tracking $context * @return boolean */ private function isInCookieLifetimeLimit(Pap_Contexts_Tracking $context) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add(Pap_Db_Table_Transactions::DATE_INSERTED); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::DATA1, '=', $this->getIdentifier($context)); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', Pap_Db_Transaction::TYPE_SALE); $select->orderBy->add(Pap_Db_Table_Transactions::DATE_INSERTED); $select->limit->set(0, 1); try { $firstSale = $select->getOneRow()->get(Pap_Db_Table_Transactions::DATE_INSERTED); $cookieLifeTime = Pap_Tracking_Cookie::getCookieLifeTimeInDays($context); if (Gpf_Common_DateUtils::getDifference($firstSale, Gpf_Common_DateUtils::getDateTime(time()), 'day') > $cookieLifeTime) { $context->debug(' Transaction is not in cookie limit. Date of first transaction: ' . $firstSale . ' is not in cookie limit: ' . $cookieLifeTime . ' days.'); return false; } } catch (Gpf_DbEngine_NoRowException $e) { } return true; }
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); }
protected function getHeader() { return "/**\n". " * @copyright Copyright (c) 2008-2009 Quality Unit s.r.o.\n". " * @author Quality Unit\n". " * @package PapApi\n". " * @since Version 1.0.0\n". " * \n". " * Licensed under the Quality Unit, s.r.o. Dual License Agreement,\n". " * Version 1.0 (the \"License\"); you may not use this file except in compliance\n". " * with the License. You may obtain a copy of the License at\n". " * http://www.qualityunit.com/licenses/gpf\n". " * Generated on: " . Gpf_Common_DateUtils::getDateTime(time()) . "\n" . " * PAP version: " . Pap_Application::getInstance()->getVersion() . ", GPF version: " . Gpf::GPF_VERSION . "\n" . " * \n". " */\n\n". "@ini_set('session.gc_maxlifetime', 28800);\n". "@ini_set('session.cookie_path', '/');\n". "@ini_set('session.use_cookies', true);\n". "@ini_set('magic_quotes_runtime', false);\n". "@ini_set('session.use_trans_sid', false);\n". "@ini_set('zend.ze1_compatibility_mode', false);\n"; }
protected function execute() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_RecurringCommissions::getInstance()); $select->from->add(Pap_Db_Table_RecurringCommissions::getName()); foreach ($select->getAllRowsIterator() as $row) { $recurringCommission = new Pap_Features_RecurringCommissions_RecurringCommission(); $recurringCommission->fillFromRecord($row); $recurringCommission->setPersistent(true); if ($this->isDone($recurringCommission->getId())) { continue; } $recurrencePreset = $recurringCommission->getRecurrencePreset(); $lastCommissionDate = $recurringCommission->getLastCommissionDate(); if ($lastCommissionDate == null) { $lastCommissionDate = $recurringCommission->getTransaction()->getDateInserted(); } $nextTimestamp = $recurrencePreset->getNextDate(Gpf_Common_DateUtils::mysqlDateTime2Timestamp($lastCommissionDate)); if ($nextTimestamp == null || $nextTimestamp > time()) { continue; } $recurringCommission->setLastCommissionDate(Gpf_Common_DateUtils::getDateTime($nextTimestamp)); if ($recurringCommission->getStatus() == Pap_Common_Constants::STATUS_APPROVED) { try { $recurringCommission->createCommissions(); } catch (Gpf_Exception $e) { Gpf_Log::critical('Recurring commissions - error create commissions: ' . $e->getMessage()); $this->setDone(); } } $recurringCommission->save(); $this->setDone(); } }
/** * @param timestamp $lastTimestamp * @return next date timestamp or null if there is no other date */ public function getNextDate($lastTimestamp) { if ($this->getStartDate() != null && $this->getStartDate() > Gpf_Common_DateUtils::getDateTime(time())) { return null; } if ($this->getEndDate() != null && $this->getEndDate() < Gpf_Common_DateUtils::getDateTime(time())) { return null; } $recurrenceSetting = new Gpf_Db_RecurrenceSetting(); $recurrenceSetting->setRecurrencePresetId($this->getId()); $nextDate = 0; foreach ($recurrenceSetting->loadCollection() as $recurrenceSetting) { $setting = Gpf_Recurrence_Setting_Factory::getRecurrenceSetting($recurrenceSetting); $settingNextDate = $setting->getNextDate($lastTimestamp); if ($nextDate < $settingNextDate) { $nextDate = $settingNextDate; } } if ($nextDate == 0) { return null; } return $nextDate; }
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(); } } }
/** * * @service user_in_commission_group add * @param $fields * @return Gpf_Rpc_Form */ public function add(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $dbRow = $this->createDbRowObject(); $this->setDefaultDbRowObjectValues($dbRow); $form->fill($dbRow); $dbRow->setDateAdded(Gpf_Common_DateUtils::getDateTime(time())); $dbRow->removeUserFromCampaignGroups($form->getFieldValue('campaignid')); try { $dbRow->save(); } catch (Exception $e) { $form->setErrorMessage($e->getMessage()); return $form; } $form->load($dbRow); $form->setField("Id", $dbRow->getPrimaryKeyValue()); $form->setInfoMessage($this->_("%s was successfully added", $this->getDbRowObjectName())); return $form; }
/** * @return datetime string in system format */ public function toDateTime() { return Gpf_Common_DateUtils::getDateTime($this->timestamp); }
private function createMasterMerchantUser() { $filters = new Pap_Merchants_Filters(); $filters->addDefaultFilters(); $merchantUser = new Pap_Merchants_User(); $merchantUser->setId(Gpf_Settings::get(Pap_Settings::DEFAULT_MERCHANT_ID)); $merchantUser->setRefId("merchant"); $merchantUser->setPassword($this->account->getPassword()); $merchantUser->setUserName($this->account->getEmail()); $merchantUser->setFirstName($this->account->getFirstname()); $merchantUser->setLastName($this->account->getLastname()); $merchantUser->setAccountId($this->account->getId()); $merchantUser->setStatus(Gpf_Db_User::APPROVED); $merchantUser->setNote(Gpf_Lang::_runtime("Hello and welcome to our affiliate program.<br/>I'm your affiliate manager, and I'm here for you if you have ANY questions or problems related to our affiliate program.<br/><br/>I wish you all success in promoting our products, and profitable partnership for both you and us.")); $merchantUser->setPhoto($this->copyToFileUploads('affiliate-manager.gif')); $merchantUser->setData('1', '12345678'); $merchantUser->setData('6', $this->account->getEmail()); $merchantUser->setDateInserted(Gpf_Common_DateUtils::getDateTime(time())); $merchantUser->save(); $this->setMerchantNotificationMail($this->account->getEmail()); $this->setQuickLaunchSettings($merchantUser->getAccountUserId(), 'showDesktop,Campaigns-Manager,Banner-Manager,Affiliate-Manager,Transaction-Manager,Pay-Affiliates,Reports,Quick-Report,Trends-Report,Clicks-List,Configuration-Manager,Logs-History'); // set wallpaper to tiled $attribute = new Gpf_Db_UserAttribute(); $attribute->setName('wallpaperPosition'); $attribute->set(Gpf_Db_Table_UserAttributes::VALUE, 'T'); $attribute->setAccountUserId($merchantUser->getAccountUserId()); $attribute->save(); Gpf_Settings::set(Pap_Settings::DEFAULT_MERCHANT_PANEL_THEME, Pap_Branding::DEFAULT_MERCHANT_PANEL_THEME); }
/** * @return Gpf_Rpc_Params */ private function getParams($limit) { $params = new Gpf_Rpc_Params(); $params->add('sort_col', 'dateinserted'); $params->add('sort_asc', false); $params->add('offset', 0); $params->add('limit', $limit); $params->add('columns', array(array("id"),array("id"),array("id"),array("commission"),array("totalcost"),array("orderid"),array("productid"),array("dateinserted"),array("name"),array("rtype"),array("tier"),array("commissionTypeName"),array("rstatus"),array("payoutstatus"),array("userid"),array("username"),array("firstname"),array("lastname"),array("channel"))); $filters = array(); if ($this->statsparams->isDateFromDefined()) { $filters[] = array('dateinserted', 'D>=', Gpf_Common_DateUtils::getDateTime($this->statsparams->getDateFrom()->toTimeStamp() + $this->timeOffset)); } if ($this->statsparams->isDateToDefined()) { $filters[] = array('dateinserted', 'D<=', Gpf_Common_DateUtils::getDateTime($this->statsparams->getDateTo()->toTimeStamp() + $this->timeOffset)); } if ($this->statsparams->isTypeDefined()) { $filters[] = array('rtype', 'IN', $this->statsparams->getType()); } if ($this->statsparams->isAffiliateIdDefined()) { $filters[] = array('userid', 'E', $this->statsparams->getAffiliateId()); } if ($this->statsparams->isAccountIdDefined()) { $filters[] = array('accountid', 'E', $this->statsparams->getAccountId()); } if (count($filters) > 0) { $params->add('filters', $filters); } return $params; }
public function loadTransactionsFromTime($session, $fromTime, $from , $to){ $this->loginFromSession($session); $select = $this->createTransactionsSelect($from,$to); $select->where->add("t.".Pap_Db_Table_Transactions::DATE_INSERTED, '>=', Gpf_Common_DateUtils::getDateTime($fromTime)); return $this->createTransactionResponse($select); }
protected function getDateVisit(Pap_Tracking_Cookie_ClickData $clickCookie) { if ($clickCookie->getTimestamp() != null) { return Gpf_Common_DateUtils::getDateTime($clickCookie->getTimestamp()); } if ($this->lastClickCookie->getTimestamp() != null) { return Gpf_Common_DateUtils::getDateTime($this->lastClickCookie->getTimestamp()); } return Gpf_Common_DateUtils::now(); }
/** * * @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)); }
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'); }
/** * @return string datetime in standard format */ public function getVisitDateTime() { if (strlen($timeStamp = $this->getCustomTimeStampFromRequest())) { return Gpf_Common_DateUtils::getDateTime($timeStamp); } return parent::getVisitDateTime(); }
public function addUserToGroup($campaignId, $userId, $commissionGroupId, $status) { $userInCommGroup = $this->createUserInCommGroup($userId, $commissionGroupId, $status); $userInCommGroup->setDateAdded(Gpf_Common_DateUtils::getDateTime(time())); $userInCommGroup->removeUserFromCampaignGroups($campaignId); $userInCommGroup->insert(); }
public static function addDateUnitToTimestamp($timestamp, $units, $unitType, $returnDate = true) { $d = $timestamp; switch ($unitType) { case Gpf_Common_DateUtils::DAY: if (self::belowMinTimestamp($timestamp + Gpf_DateTime::daysToSeconds($units))) { $time = Gpf_DateTime::MIN_TIMESTAMP; break; } if (self::overMaxTimestamp($timestamp + Gpf_DateTime::daysToSeconds($units))) { $time = Gpf_DateTime::MAX_TIMESTAMP; break; } $time = mktime(0, 0, 0, date("m", $d), date("d", $d) + $units, date("Y", $d)); break; case Gpf_Common_DateUtils::WEEK: if (self::belowMinTimestamp($timestamp + Gpf_DateTime::weeksToSeconds($units))) { $time = Gpf_DateTime::MIN_TIMESTAMP; break; } if (self::overMaxTimestamp($timestamp + Gpf_DateTime::weeksToSeconds($units))) { $time = Gpf_DateTime::MAX_TIMESTAMP; break; } $time = mktime(0, 0, 0, date("m", $d), date("d", $d) + 7 * $units, date("Y", $d)); break; case Gpf_Common_DateUtils::MONTH: if (self::belowMinTimestamp($timestamp + Gpf_DateTime::monthsToSeconds($units))) { $time = Gpf_DateTime::MIN_TIMESTAMP; break; } if (self::overMaxTimestamp($timestamp + Gpf_DateTime::monthsToSeconds($units))) { $time = Gpf_DateTime::MAX_TIMESTAMP; break; } $month = date("m", $d) + $units; $day = self::daysInMonth($month, date("d", $d), date("Y", $d)); $time = mktime(0, 0, 0, $month, $day, date("Y", $d)); break; case Gpf_Common_DateUtils::YEAR: if (self::belowMinTimestamp($timestamp + Gpf_DateTime::yearsToSeconds($units))) { $time = Gpf_DateTime::MIN_TIMESTAMP; break; } if (self::overMaxTimestamp($timestamp + Gpf_DateTime::yearsToSeconds($units))) { $time = Gpf_DateTime::MAX_TIMESTAMP; break; } $time = mktime(0, 0, 0, date("m", $d), date("d", $d), date("Y", $d) + $units); break; } if ($returnDate) { return Gpf_Common_DateUtils::getDate($time); } return Gpf_Common_DateUtils::getDateTime($time); }