CC-3174 : Show builder
creating a scheduling system to work with the new timeline in mind using propel.
This commit is contained in:
parent
f5761fd03c
commit
3f3117cf0e
8 changed files with 175 additions and 27 deletions
70
airtime_mvc/application/models/Scheduler.php
Normal file
70
airtime_mvc/application/models/Scheduler.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
class Application_Model_Scheduler {
|
||||
|
||||
private $propSched;
|
||||
|
||||
public function __construct($id = null) {
|
||||
|
||||
if (is_null($id)) {
|
||||
$this->propSched = new CcSchedule();
|
||||
}
|
||||
else {
|
||||
$this->propSched = CcScheduleQuery::create()->findPK($id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public function findScheduledItems($starts, $ends) {
|
||||
|
||||
CcScheduleQuery::create()
|
||||
->filterByDbStarts(array('min' => $starts->format('Y-m-d H:i:s'), 'max' => $ends->format('Y-m-d H:i:s')))
|
||||
->find();
|
||||
}
|
||||
*/
|
||||
|
||||
public function addScheduledItem($starts, $duration, $adjustSched = true) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @param DateTime $starts
|
||||
*/
|
||||
public function updateScheduledItem($p_newStarts, $p_adjustSched = true) {
|
||||
|
||||
$origStarts = $this->propSched->getDbStarts(null);
|
||||
|
||||
$diff = $origStarts->diff($p_newStarts);
|
||||
|
||||
//item is scheduled further in future
|
||||
if ($diff->format("%R") === "+") {
|
||||
|
||||
CcScheduleQuery::create()
|
||||
->filterByDbStarts($this->propSched->getDbStarts(), Criteria::GREATER_THAN)
|
||||
->filterByDbId($this->propSched->getDbId(), Criteria::NOT_EQUAL)
|
||||
->find();
|
||||
|
||||
}
|
||||
//item has been scheduled earlier
|
||||
else {
|
||||
CcScheduleQuery::create()
|
||||
->filterByDbStarts($this->propSched->getDbStarts(), Criteria::GREATER_THAN)
|
||||
->filterByDbId($this->propSched->getDbId(), Criteria::NOT_EQUAL)
|
||||
->find();
|
||||
}
|
||||
}
|
||||
|
||||
public function removeScheduledItem($adjustSched = true) {
|
||||
|
||||
if ($adjustSched === true) {
|
||||
$duration = $this->propSched->getDbEnds('U') - $this->propSched->getDbStarts('U');
|
||||
|
||||
CcScheduleQuery::create()
|
||||
->filterByDbInstanceId()
|
||||
->filterByDbStarts()
|
||||
->find();
|
||||
}
|
||||
|
||||
$this->propSched->delete();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue