/**
	 * @param String $className
	 * @return Gpf_Db_PlannedTask
	 */
	private function createTask($className) {
		$task = new Gpf_Db_PlannedTask();
		$task->setClassName($className);
		$task->setRecurrencePresetId('A');
		$task->setParams($this->getLastDateParams());
		$this->initAccountId($task);
		return $task;
	}
	/**
	 * @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;
	}
 private function updatePlannedTaskParams() {
     $plannedTask = new Gpf_Db_PlannedTask();
     $plannedTask->setClassName(Pap_Merchants_Config_EmailNotificationsFormBase::REPORTS_SEND_CLASS);
     $plannedTask->setAccountId($this->task->getAccountId());
     try {
         $plannedTask->loadFromData(array(Gpf_Db_Table_PlannedTasks::CLASSNAME, Gpf_Db_Table_PlannedTasks::ACCOUNTID));
         $plannedTask->setParams($this->getSerializedDateParams(Gpf_Common_DateUtils::getDate($this->time)));
         $plannedTask->setLastPlanDate(Gpf_Common_DateUtils::addDateUnit(Gpf_Common_DateUtils::getDate($this->time), 1, Gpf_Common_DateUtils::DAY));
         $plannedTask->save();
     } catch (Gpf_Exception $e) {
         Gpf_Log::error('Error during updating planned ReportsSendTask: ' . $e->getMessage());
     }
 }
Example #4
0
	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) {
		}
	}
Example #5
0
 /**
  * @return Gpf_Db_PlannedTask
  */
 private function createPlannedTask() {
     $plannedTask = new Gpf_Db_PlannedTask();
     $plannedTask->setClassName('Pap_Features_RecurringCommissions_Runner');
     return $plannedTask;
 }
 private function createCompressedCommissionTask() {
     $plannedTask = new Gpf_Db_PlannedTask();
     $plannedTask->setClassName('Pap_Features_CompressedCommissionPlacementModel_Task');
     return $plannedTask;
 }
Example #7
0
 private function getPlannedTask() {
 	$plannedTask = new Gpf_Db_PlannedTask();
     $plannedTask->setClassName('ccBill_CheckRebill');
     return $plannedTask;
 }
 /**
  * This method will be removed when all accounts will be able own affiliates
  */
 protected function initAccountId(Gpf_Db_PlannedTask $task) {
 	$task->setAccountId(Gpf_Application::getInstance()->getAccountId());
 }
	private function createPlannedTask() {
		$plannedTask = new Gpf_Db_PlannedTask();
        $plannedTask->setClassName('AutoApprovalCommissions_Runner');
        return $plannedTask;
	}
Example #10
0
 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();
         }
     }
 }
 protected function initAccountId(Gpf_Db_PlannedTask $task) {
 	$task->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());	
 }