public function __construct($type)
 {
     parent::__construct();
     $date = new Gpf_DateTime();
     $this->setDateInserted($date->toDateTime());
     $this->setType($type);
 }
예제 #2
0
 function __construct()
 {
     parent::__construct();
     $this->setApplication(Gpf_Application::getInstance()->getCode());
     $date = new Gpf_DateTime();
     $this->setDateinserted($date->toDateTime());
 }
	/**
	 * @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;
	}
	public function registerNotifications($session, $notificationId, $clientType){
		if($clientType=='android') $clientType = Gpf_Db_NotificationRegistration::TYPE_ANDROID;
		else $clientType = Gpf_Db_NotificationRegistration::TYPE_IOS;
		
		$this->loginFromSession($session);
		$notificationRegistration = new Gpf_Db_NotificationRegistration();
		$notificationRegistration->setNotificationId($notificationId);
		$notificationRegistration->setClientType($clientType);
		$notificationRegistration->setAccountUserId($this->user->getAccountUserId());
                $date = new Gpf_DateTime();
                $notificationRegistration->setRegistrationTime($date->toDateTime());
		$notificationRegistration->save();
		return new Pap_Mobile_Response(true);
	}
예제 #5
0
 /**
  * @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;
 }
 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());
 }
예제 #7
0
 public function getCurrentEurRate($targetcurrency)
 {
     $today = new Gpf_DateTime();
     Gpf_Log::debug('Getting currency for ' . $targetcurrency . ' on ' . $today->toDate());
     try {
         return $this->loadCurrencyRate('EUR', $targetcurrency, $today->toDateTime());
     } catch (Gpf_DbEngine_NoRowException $e) {
         Gpf_Log::debug('Rate for ' . $targetcurrency . ' in ' . $today->toDate() . ' not found, loading latest...');
     }
     $rawXmlData = file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
     $xml = new SimpleXMLElement($rawXmlData);
     $attrs = $xml->{"Cube"}->{"Cube"}->attributes();
     $time = $attrs['time'];
     foreach ($xml->{"Cube"}->{"Cube"}->{'Cube'} as $dailyRate) {
         $rateSettings = $dailyRate->attributes();
         Gpf_Log::debug('Currency ' . $rateSettings['currency'] . ' loaded from XML');
         if ($rateSettings['currency'] == $targetcurrency) {
             $this->saveDailyRate($today, $targetcurrency, (double) $rateSettings['rate']);
             return (double) $rateSettings['rate'];
         }
     }
 }
예제 #8
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;
 }
예제 #9
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;
    }
예제 #10
0
 /**
  *
  * @param $sleepUntil Gpf_DateTime
  */
 public function setSleepUntil(Gpf_DateTime $sleepUntil)
 {
     $this->set(Gpf_Db_Table_Tasks::SLEEP_UNTIL, $sleepUntil->toDateTime());
 }
예제 #11
0
    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++;
    }
예제 #12
0
    private function processRebill($rebill) {
        if ((Gpf_Settings::get(ccBill_Config::USE_RECURRING_COMMISSION)==Gpf::YES) && class_exists('Pap_Features_RecurringCommissions_RecurringCommissionsForm')) {
            $form = new Pap_Features_RecurringCommissions_RecurringCommissionsForm();
            try {
                $form->createCommissionsNoRpc($rebill[3]);
                Gpf_Log::debug('Ok - rebil processed by recurring commissions plugin');
                return;
            } catch (Exception $e) {
                Gpf_Log::debug('Processing by recurring commissions plugin failed: ' . $e->getMessage());
                return;
            }
        } else {
            Gpf_Log::debug('Processing by recurring commissions is DISABLED. Continuing the ordinary way...');
        }
        if ($this->rebillExists($rebill[5])) {
            Gpf_Log::debug('Rebill transaction id = ' . $rebill[5] . ' already exists - skipping');
            return;
        }
        try {
            $transaction = $this->findTransaction($rebill[3]);
        } catch (Gpf_Exception $e) {
            Gpf_Log::debug('Can not find original transaction for rebilling for transaction =' . $rebill[3] . ', reason: ' .$e->getMessage());
            return;
        }

        $newTransaction = new Pap_Common_Transaction();
        $newTransaction = clone $transaction;

        $date = new Gpf_DateTime(strtotime($rebill[4]));

        $newTransaction->setId('_NULL_');
        $newTransaction->setDateInserted($date->toDateTime());
        $newTransaction->setDateApproved($date->toDateTime());
        $newTransaction->setOrderId($rebill[5]);
        $newTransaction->setMerchantNote($this->_('Processed rebill from ccBill transaction: ' . $rebill[3]));
        $newTransaction->insert();

        $form = new Pap_Merchants_Transaction_TransactionsForm();
        $form->addMultiTierTransaction($transaction->getTotalCost(), $transaction->getCampaignId(), $transaction->getUserId(), $transaction->getCommissionTypeId(), $transaction->getStatus(), $newTransaction);
    }
예제 #13
0
    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;
    }
예제 #14
0
 public function __construct() {
     parent::__construct();
     $date = new Gpf_DateTime();
     $this->setDateCreated($date->toDateTime());
     $this->setStatus('U');
 }