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));
 }
	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);
	}
Exemple #3
0
 private function init($time = null)
 {
     if ($time === null) {
         $this->timestamp = time();
         return;
     }
     if (is_int($time)) {
         $this->timestamp = $time;
         return;
     }
     $this->timestamp = Gpf_Common_DateUtils::getTimestamp($time);
 }
 public function isRunningOK()
 {
     $lastRunTime = $this->getLastRunTime();
     if ($lastRunTime == '' || Gpf_Common_DateUtils::getTimestamp($lastRunTime) < time() - self::MAX_CRON_PERIOD) {
         return false;
     }
     return true;
 }
Exemple #5
0
 /**
  * returns part of the date
  *
  * @param date $date in format YYYY-mm-dd
  * @param string $part - one of day/month/year
  * @return string
  */
 public static function getPart($date, $part)
 {
     $timestamp = Gpf_Common_DateUtils::getTimestamp($date);
     switch ($part) {
         case Gpf_Common_DateUtils::DAY:
             return date("d", $timestamp);
         case Gpf_Common_DateUtils::MONTH:
             return date("m", $timestamp);
         case Gpf_Common_DateUtils::YEAR:
             return date("Y", $timestamp);
     }
     return "";
 }
    /**
     * @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;
    }
Exemple #7
0
 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 prepareSales(Pap_Tracking_ActionTracker $saleTracker) {
    	$this->debug('Beginning preparing sales...');
        $sale = $saleTracker->createSale();
        $sale->setTotalCost($this->getTotalCost());
        $sale->setOrderID($this->getOrderID());
        $sale->setProductID($this->getProductID());
        $sale->setData1($this->_data1);
        $sale->setData2($this->_data2);
        $sale->setData3($this->_data3);
        $sale->setData4($this->_data4);
        $sale->setData5($this->_data5);
        $sale->setCoupon($this->_couponCode);
        $sale->setCurrency($this->_currency);
        $sale->setChannelId($this->_channelId);
        if ($this->dateTime != '') {
            $sale->setTimeStamp(Gpf_Common_DateUtils::getTimestamp($this->dateTime));
        }
        
        if ($this->getStatus()!='') {
            $sale->setStatus($this->getStatus());
        }
        if($this->getAffiliateID() != '' && $this->getCampaignID() != '') {
            $sale->setAffiliateID($this->getAffiliateID());
            $sale->setCampaignID($this->getCampaignID());
        }

        $this->setVisitorAndAccount($saleTracker, $this->getAffiliateID(), $this->getCampaignID(), $this->getCookie());
        $this->debug('Finish preparing sales...');
    }
 /**
  * Adds date filter to array
  *
  * @param array $data
  * @return array("dateFrom" => '', "dateTo" => '')
  */
 public function addDateValueToArray($data)
 {
     switch ($this->operator->getCode()) {
         case 'DP':
             $data = $this->getDatePresetTo();
             break;
         case 'D>':
         case 'D>=':
             $data["dateFrom"] = Gpf_DbEngine_Database::getDateString($this->getServerTime(Gpf_Common_DateUtils::getTimestamp($this->addTimePartToDate($this->value, '00:00:00'))));
             break;
         case 'D<=':
         case 'D<':
             $data["dateTo"] = Gpf_DbEngine_Database::getDateString($this->getServerTime(Gpf_Common_DateUtils::getTimestamp($this->addTimePartToDate($this->value, '23:59:59'))));
             break;
     }
     return $data;
 }
	public function loadTransactions($session,$from , $to){
		$this->loginFromSession($session);

		$selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
		$selectBuilder->select->add('count(*)', 'count');
		$selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), "t");
		if($this->isAffiliate()){
			$selectBuilder->where->add("t.".Pap_Db_Table_Transactions::USERID,'=',$this->user->getId());
		}
		$count = $selectBuilder->getOneRow()->get('count');

		$fromtime = null;
		if($count > 0){
			$selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
			$selectBuilder->select->add("t.".Pap_Db_Table_Transactions::DATE_INSERTED,'created');
			$selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), "t");
			if($this->isAffiliate()){
				$selectBuilder->where->add("t.".Pap_Db_Table_Transactions::USERID,'=',$this->user->getId());
			}
			$selectBuilder->limit->set(0, 1);
			$selectBuilder->orderBy->add("t.".Pap_Db_Table_Transactions::DATE_INSERTED, true);
			$fromtime = $selectBuilder->getOneRow()->get('created');
		}

		$response = $this->createTransactionResponse($this->createTransactionsSelect($from,$to));
		$response->all_count = (int)$count;
		$response->fromtime = (string)Gpf_Common_DateUtils::getTimestamp($fromtime);
		return $response;
	}
    /**
     * @return boolean
     */
    protected function isWeeklySendDay($dateFrom) {
        $weeklyDay = $this->accountSettings->get(Pap_Settings::NOTIFICATION_WEEKLY_REPORT_SENT_ON);

        if (!$this->wasCronStopped($dateFrom)) {
            return date('w', $this->time) == $weeklyDay;
        }

        $dateFromTimestamp = Gpf_Common_DateUtils::getTimestamp($dateFrom);

        $dateStart = new Gpf_DateTime($dateFromTimestamp);
        $dateStart->addWeek(-1);
        $dateEnd = new Gpf_DateTime($dateFromTimestamp);
        $lastWeek = Gpf_Common_DateUtils::addDateUnitToTimestamp($this->time, -1, Gpf_Common_DateUtils::WEEK);

        if ($lastWeek < $dateStart->getWeekStart()->toDateTime() ||
        $lastWeek > $dateEnd->getWeekEnd()->toDateTime()) {
            return false;
        }

        if ($lastWeek >= $dateStart->getWeekStart()->toDateTime() &&
        $lastWeek <= $dateStart->getWeekEnd()->toDateTime() &&
        date('w', $dateFromTimestamp) >= $weeklyDay) {
            return false;
        }

        if (date('w', $this->time) < $weeklyDay) {
            return false;
        }
        return true;
    }