35 public function isActive($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual =
false)
46 return $this->
checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value);
58 return $this->schedule_type;
71 return $this->schedule_value;
88 $this->schedule_type = $a_type;
89 $this->schedule_value = $a_value;
100 return array(self::SCHEDULE_TYPE_DAILY, self::SCHEDULE_TYPE_IN_MINUTES,
101 self::SCHEDULE_TYPE_IN_HOURS, self::SCHEDULE_TYPE_IN_DAYS,
102 self::SCHEDULE_TYPE_WEEKLY, self::SCHEDULE_TYPE_MONTHLY,
103 self::SCHEDULE_TYPE_QUARTERLY, self::SCHEDULE_TYPE_YEARLY);
114 protected function checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value)
116 if(!$a_schedule_type)
127 switch($a_schedule_type)
129 case self::SCHEDULE_TYPE_DAILY:
130 $last = date(
"Y-m-d", $a_ts_last_run);
131 $ref = date(
"Y-m-d", $now);
132 return ($last != $ref);
134 case self::SCHEDULE_TYPE_WEEKLY:
135 $last = date(
"Y-W", $a_ts_last_run);
136 $ref = date(
"Y-W", $now);
137 return ($last != $ref);
139 case self::SCHEDULE_TYPE_MONTHLY:
140 $last = date(
"Y-n", $a_ts_last_run);
141 $ref = date(
"Y-n", $now);
142 return ($last != $ref);
144 case self::SCHEDULE_TYPE_QUARTERLY:
145 $last = date(
"Y", $a_ts_last_run).
"-".ceil(date(
"n", $a_ts_last_run)/3);
146 $ref = date(
"Y", $now).
"-".ceil(date(
"n", $now)/3);
147 return ($last != $ref);
149 case self::SCHEDULE_TYPE_YEARLY:
150 $last = date(
"Y", $a_ts_last_run);
151 $ref = date(
"Y", $now);
152 return ($last != $ref);
154 case self::SCHEDULE_TYPE_IN_MINUTES:
155 $diff = floor(($now-$a_ts_last_run)/60);
156 return ($diff >= $a_schedule_value);
158 case self::SCHEDULE_TYPE_IN_HOURS:
159 $diff = floor(($now-$a_ts_last_run)/(60*60));
160 return ($diff >= $a_schedule_value);
162 case self::SCHEDULE_TYPE_IN_DAYS:
163 $diff = floor(($now-$a_ts_last_run)/(60*60*24));
164 return ($diff >= $a_schedule_value);
275 abstract public function getId();
310 abstract public function run();