Example #1
0
    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;
    }
Example #2
0
 function __construct()
 {
     parent::__construct();
     $this->setApplication(Gpf_Application::getInstance()->getCode());
     $date = new Gpf_DateTime();
     $this->setDateinserted($date->toDateTime());
 }
 public function __construct($type)
 {
     parent::__construct();
     $date = new Gpf_DateTime();
     $this->setDateInserted($date->toDateTime());
     $this->setType($type);
 }
Example #4
0
    public function save(Pap_Contexts_Impression $context) {
        $context->debug('  Saving impression started');

        $impression = $this->createRowImpression();
        $impression->setAccountId($context->getAccountId());
        $impression->setUserId($context->getUserObject()->getId());
        $impression->setBannerId($context->getBannerId());
        $impression->setParentBannerId($context->getParentBannerId());
        $impression->setCampaignId($context->getCampaignId());
        $impression->setChannel($context->getChannelId());
        $impression->setCountryCode('');
        if (!$this->isGeoIpImpressionsDisabled()) {
            $impression->setCountryCode($context->getCountryCode());
        }
        $impression->setData1($context->getClickData1());
        $impression->setData2($context->getClickData2());
        $time = new Gpf_DateTime($context->getDate());
        $impression->setTime($time->getHourStart()->toDateTime());

        try {
        	$this->saveAndIncrementImpressionCount($context, $impression);
        } catch (Gpf_Exception $e) {
        	$context->debug($this->_('Saving impression interrupted: %s', $e->getMessage()));
        }

        $context->debug('  Saving impression ended');
    }
	public function cleanupOldRegistrations() {
		$notificationRegistrationRow = new Gpf_Db_NotificationRegistration();
		$rowCollection = $notificationRegistrationRow->loadCollection();

		foreach ($rowCollection as $notificationRegistrationRow) {
			$notificationRegistrationTime = new Gpf_DateTime($notificationRegistrationRow->getRegistrationTime());
			if ($notificationRegistrationTime->toTimeStamp() < time() - self::MONTH * 3) {
				$notificationRegistrationRow->delete();
			}
		}
	}
	/**
	 * @return boolean
	 */
	private function isRecurrenceMonth() {
		if ($this->plannedTask->isPrimaryKeyEmpty()) {
			return false;
		}
		$lastSendDate = $this->plannedTask->getParams();
		if (is_null($lastSendDate) || $lastSendDate == '') {
			return true;
		}
		$dateTime = new Gpf_DateTime();
		if (Gpf_Common_DateUtils::getDifference($lastSendDate, $dateTime->toDateTime(), Gpf_Common_DateUtils::MONTH) > $this->accountSettings->get(Pap_Settings::NOTIFICATION_PAY_DAY_REMINDER_RECURRENCE_MONTH)) {
			return true;			
		}
		return false;
	}
Example #7
0
 public function __construct(Gpf_DateTime $from, Gpf_DateTime $to, $timeGroupBy)
 {
     $dateCurrent = clone $from->getClientTime();
     if ($timeGroupBy == Gpf_Common_DateUtils::DAY) {
         $this->makeDayLabels($dateCurrent, $to->getClientTime());
         return;
     } else {
         if ($timeGroupBy == Gpf_Common_DateUtils::MONTH) {
             $this->makeMonthLabels($dateCurrent, $to->getClientTime());
             return;
         }
     }
     $this->makeWeekLabels($dateCurrent, $to->getClientTime());
 }
 /**
  * @param $request
  * @param $groupId
  * @param $validTo
  * @return string
  */
 public function __construct(Gpf_Rpc_Request $request, Gpf_DateTime $validTo = null)
 {
     parent::__construct();
     $json = new Gpf_Rpc_Json();
     if ($validTo === null) {
         $validTo = new Gpf_DateTime();
         $validTo->addDay(30);
     }
     $this->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());
     $this->setGroupId('');
     $this->setRequest($json->encode($request->toObject()));
     $this->setValidTo($validTo->toDateTime());
     $this->insert();
     return $this;
 }
Example #9
0
 private function deleteNewEntries($tableName, Gpf_DateTime $fromDate) {
     $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder();
     for ($i = $fromDate->getDay(); $i<=31; $i++) {
         $updateBuilder->set->add("raw_$i", 0);
         $updateBuilder->set->add("unique_$i", 0);
         if (strstr($tableName, 'click')) {
             $updateBuilder->set->add("declined_$i", 0);
         }
     }
     $updateBuilder->from->add($tableName);
     $updateBuilder->where->add('month', '=', $fromDate->getMonthStart()->toDate());
     $updateBuilder->execute();
     
     $delete = new Gpf_SqlBuilder_DeleteBuilder();
     $delete->from->add($tableName);
     $delete->where->add('month', '>', $fromDate->toDate());
     $delete->execute();
 }
Example #10
0
 public function execute() {
     $update = new Gpf_SqlBuilder_UpdateBuilder();
     $update->from->add(Pap_Db_Table_Transactions::getName());
     $dateTime = Gpf_DateTime::min();
     $update->set->add(Pap_Db_Table_Transactions::DATA2, $dateTime->toDateTime());
     $compoundCondition = new Gpf_SqlBuilder_CompoundWhereCondition();
     $compoundCondition->add(Pap_Db_Table_Transactions::DATA2,'=' ,'AT');
     $compoundCondition->add(Pap_Db_Table_Transactions::DATA2,'=' , 'AUC', 'OR');
     $update->where->addCondition($compoundCondition);
     $update->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', Pap_Db_Transaction::TYPE_EXTRA_BONUS);
 }
    public function recognize(Pap_Contexts_Action $context) {
        if ($context->isVisitorAffiliateRecognized()) {
            return;
        }
        
        if(Gpf_Settings::get(Pap_Settings::TRACK_BY_IP_SETTING_NAME) != Gpf::YES) {
            return;
        }
        
        $ip = $context->getIp();
        $context->debug('Trying to get visitor affiliate from IP address '. $ip);

        $visitorAffiliate = $this->visitorAffiliateCache->getLatestVisitorAffiliateFromIp($ip, $context->getAccountId());
        if ($visitorAffiliate == null) {
            $context->debug("No visitor affiliate from IP '$ip'");
            return;
        }
        
        try {
            $periodInSeconds = $this->getValidityInSeconds();
        } catch (Gpf_Exception $e) {
            $context->debug($e->getMessage());
            return;
        }
        
        
        $dateFrom = new Gpf_DateTime($context->getVisitDateTime());
        $dateFrom->addSecond(-1*$periodInSeconds);
        $dateVisit = new Gpf_DateTime($visitorAffiliate->getDateVisit());

        if ($dateFrom->compare($dateVisit) > 0) {
            $context->debug("    No click from IP '$ip' found within ip validity period");
            return null;
        }

        if (!$context->isTrackingMethodSet()) {
            $context->setTrackingMethod(Pap_Common_Transaction::TRACKING_METHOD_IP_ADDRESS);
        }
        $context->debug('Visitor affiliate recognized from IP, id: '.$visitorAffiliate->getId(). ', accountId: '. $visitorAffiliate->getAccountId());
        $context->setVisitorAffiliate($visitorAffiliate);
    }
 private function initVisitsWhere(Gpf_SqlBuilder_WhereClause $where) {
     $visitorCondition = new Gpf_SqlBuilder_CompoundWhereCondition();
     $visitorCondition->add(Pap_Db_Table_Visits::VISITORID, '=', $this->visitorId);
     if ($this->ip != '') {
         $visitorCondition->add(Pap_Db_Table_Visits::IP, '=', $this->ip, 'OR');
     }
     $where->addCondition($visitorCondition);
     
     $accountCondition = new Gpf_SqlBuilder_CompoundWhereCondition();
     $accountCondition->add(Pap_Db_Table_Visits::ACCOUNTID, '=', $this->accountId);
     if ($this->accountId == Gpf_Db_Account::DEFAULT_ACCOUNT_ID) { 
         $accountCondition->add(Pap_Db_Table_Visits::ACCOUNTID, '=', '', 'OR');
     }
     $where->addCondition($accountCondition);
     
     $where->add(Pap_Db_Table_Visits::DATEVISIT, '<=', $this->toDate->toDateTime());
 }
Example #13
0
    /**
     *
     * @return Gpf_DateTime_Range
     */
    public function getDateRange(Gpf_DateTime $now = null) {
        if($now === null) {
            $now = new Gpf_DateTime();
        }
        if ($this->getDate() == Pap_Features_PerformanceRewards_Rule::DATE_ALL_TIME
        || $this->getDate() == Pap_Features_PerformanceRewards_Rule::DATE_ALL_UNPAID_COMMISSIONS) {
            $range = new Gpf_DateTime_Range();
            return $range;
        }

        if ($this->getDate() == Pap_Features_PerformanceRewards_Rule::DATE_SINCE_DAY_OF_LAST_MONTH) {
            $from = $now->getMonthStart();
            $from->addMonth(-1);
            $from->addDay($this->getSince() - 1);
            $to = $now->getMonthStart();
            $to->addDay(-1);
            return new Gpf_DateTime_Range($from, $to);
        }
        $filter = new Gpf_SqlBuilder_Filter();
        $result = $filter->decodeDatePreset($this->getDate());
        return new Gpf_DateTime_Range(new Gpf_DateTime($result['dateFrom']), new Gpf_DateTime($result['dateTo']));
    }
    public function getNumberOfRecordsWithSameOrderId($orderId, $transType, $periodInHours, $parentTransId, $visitDateTime) {
        $select = new Gpf_SqlBuilder_SelectBuilder();

        $select->select->add("count(transid)", "count");
        $select->from->add(Pap_Db_Table_Transactions::getName());
        if($orderId == '') {
            $condition = new Gpf_SqlBuilder_CompoundWhereCondition();
            $condition->add(Pap_Db_Table_Transactions::ORDER_ID, '=', '', 'OR');
            $condition->add(Pap_Db_Table_Transactions::ORDER_ID, '=', null, 'OR');
            $select->where->addCondition($condition);
        } else {
            $select->where->add(Pap_Db_Table_Transactions::ORDER_ID, "=", $orderId);
        }
        $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "=", $transType);
        $select->where->add(Pap_Db_Table_Transactions::TIER, "=", "1");
        $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "<>", Pap_Common_Constants::STATUS_DECLINED);
        if($periodInHours > 0) {
            $dateFrom = new Gpf_DateTime($visitDateTime);
            $dateFrom->addHour(-1*$periodInHours);
            $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, ">", $dateFrom->toDateTime());
        }
        if($parentTransId != null && $parentTransId != '') {
            $select->where->add(Pap_Db_Table_Transactions::PARRENT_TRANSACTION_ID, "<>", $parentTransId);
        }

        $recordSet = new Gpf_Data_RecordSet();
        $recordSet->load($select);

        foreach($recordSet as $record) {
            return $record->get("count");
        }
        return 0;
    }
Example #15
0
 public function isValid()
 {
     $validTo = new Gpf_DateTime($this->get(Gpf_Db_Table_QuickTasks::VALIDTO));
     return $validTo->compare(new Gpf_DateTime()) > 0;
 }
Example #16
0
    private function assignPayoutVariablesToTemplate(Gpf_Templates_Template $template) {
        $template->assignAttributes($this->user);
        $template->assign('vat_number', $this->vatNumber);
        $template->assign('reg_number', $this->regNumber);
        $template->assign('amount_of_reg_capital', $this->amountOfRegCapital);
        $template->assign('vat_percentage', $this->vatPercentage);
        $template->assign('payoutcurrency', $this->currency->getName());
        $template->assign('affiliate_note', $this->getAffiliateNote());
        $template->assign('payment', $this->getAmount());
        $template->assign('amount', str_replace('.', ',', $this->getAmount()));
        $template->assign('currency', $this->currency->getName());

        if ($this->payoutOption != null) {
            $template->assign('payoutmethod', $this->_localize($this->payoutOption->getName()));
        }
        $template->assign('payment_vat_part', $this->amountVatPart);
        $template->assign('payment_incl_vat', $this->amountWithVat);
        $template->assign('payment_excl_vat', $this->amountWithoutWat);

        $historyItem = $this->getPayoutHistoryItem();
        if ($historyItem === null) {
            
            $template->assign('date', Gpf_Common_DateUtils::getDateInLocaleFormat());
            $template->assign('time', Gpf_Common_DateUtils::getTimeInLocaleFormat());
        } else {
            $time = new Gpf_DateTime($historyItem->getDateInserted());
            $template->assign('date', Gpf_Common_DateUtils::getDateInLocaleFormat($time->toTimestamp()));
            $template->assign('time', Gpf_Common_DateUtils::getTimeInLocaleFormat($time->toTimestamp()));
        }
        $template->assign('invoicenumber',$this->getInvoiceNumber());

        if ($this->payoutOptionFields != null) {
            $userPayoutOptions = Pap_Db_Table_UserPayoutOptions::getInstance()->getValues(
            $this->payoutOption->getFormId(), $this->user->getId());
            foreach ($this->payoutOptionFields as $payoutOptionField) {
                $code = $payoutOptionField->get('code');
                if (array_key_exists($code, $userPayoutOptions)) {
                    $template->assign($code, $userPayoutOptions[$code]->getValue());
                }
            }
        }
    }
Example #17
0
    /**
     * @throws Gpf_DbEngine_NoRowException
     * @param $accountId
     * @return String
     */
    public function getNextInvoiceDateFrom($accountId) {
		$lastInvoiceDateTo = $this->getLastInvoiceVariable($accountId, self::DATE_TO);
		$date = new Gpf_DateTime($lastInvoiceDateTo);
        $date->addDay(1);
        return $date->getDayStart()->toDateTime();
    }
Example #18
0
 public static function getServerHours($clientHours)
 {
     $serverHours = Gpf_DateTime::secondsToHours(Gpf_DateTime::hoursToSeconds($clientHours) - Gpf_Session::getInstance()->getTimeOffset());
     return $serverHours < 0 ? 24 + $serverHours : $serverHours;
 }
Example #19
0
	private function getClickParamsArray(Pap_Db_ClickImpression $click, Pap_Contexts_Click $context, Pap_Common_Banner $banner=null) {
	    $columns = array();
	    $columns[Pap_Db_Table_ClicksImpressions::ACCOUNTID] = $context->getAccountId();
        $columns[Pap_Db_Table_ClicksImpressions::USERID] = $context->getUserObject()->getId();
        $columns[Pap_Db_Table_ClicksImpressions::BANNERID] = $banner == null ? '' : $banner->getId();
        $columns[Pap_Db_Table_ClicksImpressions::PARENTBANNERID] = $banner == null ? '' : $banner->getParentBannerId();
        $columns[Pap_Db_Table_ClicksImpressions::CAMPAIGNID] = $context->getCampaignObject() == null ? '' : $context->getCampaignObject()->getId();
        $columns[Pap_Db_Table_ClicksImpressions::COUNTRYCODE] = $context->getCountryCode();
        $columns[Pap_Db_Table_ClicksImpressions::CDATA1] = $context->getExtraDataFromRequest(1);
        $columns[Pap_Db_Table_ClicksImpressions::CDATA2] = $context->getExtraDataFromRequest(2);
        $columns[Pap_Db_Table_ClicksImpressions::CHANNEL] = $this->getChannel($context);
        $timeNow = new Gpf_DateTime($context->getVisitDateTime());
        $columns[Pap_Db_Table_ClicksImpressions::DATEINSERTED] = $timeNow->format("Y-m-d H:00:00");
        return $columns;
	}
 /**
  * @param $daysCount
  * @return Gpf_DateTime
  */
 protected function getLastDate($daysCount)
 {
     $date = new Gpf_DateTime();
     $date->addDay($daysCount * -1);
     return $date;
 }
Example #21
0
    /**
     * returns latest undeclined click from the given IP address
     *
     * @param string $ip
     * @param int $periodInSeconds
     * @return unknown
     */
    public function getLatestClickFromIP($ip, $periodInSeconds) {
        $select = new Gpf_SqlBuilder_SelectBuilder();

        $select->select->add(Pap_Db_Table_RawClicks::USERID, "userid");
        $select->select->add(Pap_Db_Table_RawClicks::CHANNEL, "channel");
        $select->from->add(Pap_Db_Table_RawClicks::getName());
        $select->where->add(Pap_Db_Table_RawClicks::IP, "=", $ip);
        $select->where->add(Pap_Db_Table_RawClicks::RTYPE, "<>", Pap_Db_ClickImpression::STATUS_DECLINED);
        $dateFrom = new Gpf_DateTime();
        $dateFrom->addSecond(-1*$periodInSeconds);
        $select->where->add(Pap_Db_Table_RawClicks::DATETIME, ">", $dateFrom->toDateTime());
        $select->orderBy->add(Pap_Db_Table_RawClicks::DATETIME, false);
        $select->limit->set(0, 1);

        $recordSet = new Gpf_Data_RecordSet();
        $recordSet->load($select);

        foreach($recordSet as $record) {
        	return array('userid' => $record->get("userid"), 'channel' => $record->get("channel"));
        }
        return null;
    }
Example #22
0
    /**
     * @return boolean
     */
    protected function isValidDate() {
        $date = new Gpf_DateTime();
        $timeStamp = $date->toTimeStamp();

        //   $validFrom = strtotime($this->getValidFrom());
        //   $validTo = strtotime($this->getValidTo());
        $validFrom = Gpf_Common_DateUtils::getTimestamp($this->getValidFrom());
        $validTo = Gpf_Common_DateUtils::getTimestamp($this->getValidTo());

        if ($validFrom == false || $validTo == false) {
            return false;
        }
        if ($timeStamp > $validFrom && $timeStamp < $validTo) {
            return true;
        }
        return false;
    }
Example #23
0
 public function setAllTime()
 {
     $this->from = Gpf_DateTime::min();
     $this->to = Gpf_DateTime::min();
 }
	private function formatTransactionDate($created){
		$createdStamp = Gpf_Common_DateUtils::getTimeStamp($created);
		$datetime = new Gpf_DateTime();
		$today = $datetime->getDayStart();
		$yesterday = $datetime->getDayStart();
		$yesterday->addDay(-1);

		if($createdStamp >= $today->toTimeStamp()){
			return $this->_("today");
		}
		if($createdStamp >= $yesterday->toTimeStamp()){
			return $this->_("yesterday");
		}
		return Gpf_Common_DateUtils::getDate($createdStamp);
	}
Example #25
0
 public function getNumberOfUsersFromSameIP($ip, $periodInSeconds)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add("count(au.authid)", "count");
     $select->from->add(Pap_Db_Table_Users::getName(), 'pu');
     $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'qu', 'pu.' . Pap_Db_Table_Users::ACCOUNTUSERID . '=qu.' . Gpf_Db_Table_Users::ID);
     $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'au.' . Gpf_Db_Table_AuthUsers::ID . '=qu.' . Gpf_Db_Table_Users::AUTHID . ' and qu.' . Gpf_Db_Table_Users::ROLEID . "='" . Pap_Application::DEFAULT_ROLE_AFFILIATE . "'");
     $select->where->add('au.' . Gpf_Db_Table_AuthUsers::IP, "=", $ip);
     $dateFrom = new Gpf_DateTime();
     $dateFrom->addSecond(-1 * $periodInSeconds);
     $select->where->add(Pap_Db_Table_Users::DATEINSERTED, ">", $dateFrom->toDateTime());
     $recordSet = new Gpf_Data_RecordSet();
     $recordSet->load($select);
     foreach ($recordSet as $record) {
         return $record->get("count");
     }
     return 0;
 }
 private function processAllRefunds() {
     $targetTime = new Gpf_DateTime();
     $targetTime->addMonth(-Gpf_Settings::get(ccBill_Config::PROCESS_REBILL_TIMEFRAME));
     $targetTimeFlag = strftime('%Y%m%d', $targetTime->toTimeStamp());
     while ($targetTimeFlag != $this->getTimeProgress()) {
         Gpf_Log::debug('ccBill rebill process task progress: ' . $this->getTimeProgress());
         $progress = $this->getProgress();
         $ansver = $this->getTransactionsListForPeriod($progress);
         if (strpos($ansver, 'Too many requests')) {
             Gpf_Log::debug('Postponding task for one more hour');
             $this->interrupt(3700);
         } else {
             $this->processCsvList($ansver);
         }
         $this->setProgress($this->getNextTimeProgress($progress));
     }
 }
Example #27
0
 public function loadHistoricalRates()
 {
     $rawXmlData = file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml');
     $xml = new SimpleXMLElement($rawXmlData);
     $lastDate = null;
     $lastRates = null;
     Gpf_Log::debug('Loading to db...');
     foreach ($xml->{"Cube"}->{"Cube"} as $dailyRates) {
         $attr = $dailyRates->attributes();
         $date = new Gpf_DateTime($attr['time']);
         Gpf_Log::debug('Loading rates for ' . $date->toDate());
         $dayBefore = new Gpf_DateTime($attr['time']);
         $dayBefore->addDay(1);
         if ($lastDate !== null && $dayBefore->toDate() != $lastDate->toDate()) {
             Gpf_Log::debug('Last date was ' . $lastDate->toDate() . '! Extending last saved rates validFrom parameters...');
             foreach ($lastRates as $rate) {
                 Gpf_Log::debug('Extending validFrom for currency ' . $rate->getValidFrom() . ' - ' . $rate->getValidTo() . ' - ' . $rate->getTargetCurrency() . ' to value ' . $dayBefore->toDate() . ' 00:00:00');
                 $rate->setValidFrom($dayBefore->toDate() . ' 00:00:00');
                 $rate->update(array(Gpf_Db_Table_CurrencyRates::VALID_FROM));
             }
         }
         Gpf_Log::debug('Saving rates for ' . $date->toDate());
         $lastRates = array();
         foreach ($dailyRates->{"Cube"} as $currencyRate) {
             $info = $currencyRate->attributes();
             Gpf_Log::debug('Saving EUR to ' . $info['currency'] . ', rate=' . $info['rate']);
             $rate = $this->saveDailyRate($date, (string) $info['currency'], (double) $info['rate']);
             $lastRates[] = $rate;
         }
         $lastDate = new Gpf_DateTime($attr['time']);
     }
     Gpf_Log::debug('Load complete');
 }
 protected function checkDates(Pap_Db_BannerInRotator $banner){
     $from = $this->form->getFieldValue(Pap_Db_Table_BannersInRotators::VALID_FROM);
     $to = $this->form->getFieldValue(Pap_Db_Table_BannersInRotators::VALID_UNTIL);
     
     
     if ($from == null && $to == null) {
         throw(new Gpf_Exception($this->_("Rotator banner can not contain same banner twice")));
     }
             
     $fromDb = $banner->getValidFrom();
     $toDb = $banner->getValidUntil();
     
     if ($fromDb == null && $toDb == null) {
         throw(new Gpf_Exception($this->_("Rotator banner can not contain same banner twice")));
     }
     
     $dateFrom = new Gpf_DateTime($fromDb);
     $dateFrom->getClientTime()->toDateTime();
     
     $dateUntil = new Gpf_DateTime($toDb);
     $dateUntil->getClientTime()->toDateTime();
     
     $errorMsg = "Date is coliding with other date: ".$dateFrom->getClientTime()->toDateTime()." -> ".$dateUntil->getClientTime()->toDateTime();
     
     if ($from == null && $to != null){
         if ($to < $fromDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if ($from != null && $to == null){
         if ($from > $toDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if ($fromDb == null && $toDb != null){
         if ($from > $toDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if ($fromDb != null && $toDb == null){
         if ($to < $fromDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if (($from < $fromDb && $to < $fromDb) || ($from > $toDb && $to > $toDb)) {
         return;
     }
     throw(new Gpf_Exception($this->_($errorMsg)));
 }
Example #29
0
 public function setSleepTime($sleepSeconds)
 {
     $time = new Gpf_DateTime();
     $time->addSecond($sleepSeconds);
     $this->setSleepUntil($time);
 }
    private function insertUser($record) {
    	$user = new Pap_Affiliates_User();
    	$user->setId($record->get('userid'));
    	$user->setRefId(($record->get('refid') != '' ? $record->get('refid') : $record->get('userid')));
    	$user->setPassword($record->get('rpassword'));
    	$user->setUserName($record->get('username'));
    	$user->setFirstName($record->get('name'));
    	$user->setLastName($record->get('surname'));
    	$user->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID);
    	$user->setDateInserted($record->get('dateinserted'));
    	if ($record->get('minimumpayout') != NULL) {
    		$user->setMinimumPayout($record->get('minimumpayout'));
    	} else {
    		$user->setMinimumPayout(Gpf_Settings::get(Pap_Settings::PAYOUTS_MINIMUM_PAYOUT_SETTING_NAME));
    	}
    	if($record->get('dateapproved') != null && $record->get('dateapproved') != '') {
    		$user->setDateApproved($record->get('dateapproved'));
    	}
    	if (Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')) == Pap_Common_Constants::STATUS_APPROVED && 
    	$user->getDateApproved() == null) {
    		$actualDate = new Gpf_DateTime();
    		$user->setDateApproved($actualDate->toDateTime());
    	}
    	$user->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')));
    	$user->setType('A');
        $user->set('numberuserid',1);
        
    	$this->setAffiliateField($user, $record, 'street');
    	$this->setAffiliateField($user, $record, 'city');
    	$this->setAffiliateField($user, $record, 'company_name');
    	$this->setAffiliateField($user, $record, 'state');
    	$this->setAffiliateField($user, $record, 'zipcode');
    	$this->setAffiliateField($user, $record, 'weburl');
    	$this->setAffiliateField($user, $record, 'phone');
    	$this->setAffiliateField($user, $record, 'fax');
    	$this->setAffiliateField($user, $record, 'tax_ssn');
    	$this->setAffiliateField($user, $record, 'country');
    	$this->setAffiliateField($user, $record, 'data1');
    	$this->setAffiliateField($user, $record, 'data2');
    	$this->setAffiliateField($user, $record, 'data3');
    	$this->setAffiliateField($user, $record, 'data4');
    	$this->setAffiliateField($user, $record, 'data5');

    	$user->setSendNotification(false);
    	$user->setPayoutOptionId($this->savePayoutData($record->get('userid')));
    	$user->save();
    	
    	// handle parent id
        $parentUserId = $record->get('parentuserid');
        if($parentUserId != '') {
            $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder();
            $updateBuilder->from->add(Pap_Db_Table_Users::getName());
            $updateBuilder->set->add(Pap_Db_Table_Users::PARENTUSERID, $parentUserId);
            $updateBuilder->where->add(Pap_Db_Table_Users::ID, '=', $record->get('userid'));
            try {
                $updateBuilder->executeOne();
            } catch (Gpf_Exception $e) {
                Pap3Compatibility_Migration_OutputWriter::log("<br/>Error setting parentuserid: ".$e->getMessage());
            }
        }
        
    	
    	$this->countUsers++;
    }