summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authorSebastian Wagner2011-10-25 17:07:40 +0200
committerSebastian Wagner2011-10-25 17:07:40 +0200
commit2ca9ebc9793072c261a520f155e0d68b33066b7a (patch)
treed046061ee82cb33dd0fb747bc75afec08ecc9ec7 /application/models
parenterrorTimeDialog added (diff)
downloadpoolctrl-2ca9ebc9793072c261a520f155e0d68b33066b7a.tar.gz
poolctrl-2ca9ebc9793072c261a520f155e0d68b33066b7a.tar.xz
poolctrl-2ca9ebc9793072c261a520f155e0d68b33066b7a.zip
was weiß ich
Diffstat (limited to 'application/models')
-rwxr-xr-xapplication/models/EventMapper.php28
1 files changed, 16 insertions, 12 deletions
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 28f0e23..4092bc3 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -432,7 +432,7 @@ class Application_Model_EventMapper
public function getDraggingEvents($eventID) {
$db = Zend_Db_Table::getDefaultAdapter();
- $select = 'SELECT * FROM poolctrl_event WHERE title = (SELECT title FROM poolctrl_event WHERE eventID = ?)';
+ $select = 'SELECT * FROM poolctrl_event WHERE title = (SELECT title FROM poolctrl_event WHERE eventID = ?) AND poolctrl_event.repeat = 1';
$stmt = $db->query($select, array(''.$eventID));
$return = $stmt->fetchAll();
@@ -441,16 +441,10 @@ class Application_Model_EventMapper
}
public function getDraggingEvent($eventID) {
-
- $db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from(array('pce' => 'poolctrl_event'))
- ->where('pce.eventID = ?', $eventID);
- $stmt = $db->query($select);
- $return = $stmt->fetchAll();
-
+ $event = new Application_Model_Event();
+ $this->find($eventID, $event);
+ $return = $event->toArray();
return $return;
-
}
// Fetch all notDragging events
@@ -465,13 +459,23 @@ class Application_Model_EventMapper
}
- public function getOverlappingEvents($start, $end, $poolID) {
+ public function getOverlappingEvents($start, $end, $poolID, Application_Model_Event $event = null, $repeat = false) {
$db = Zend_Db_Table::getDefaultAdapter();
- $select = "SELECT * FROM poolctrl_event WHERE ( ( start <= '" . $start . "' AND end >= '" . $end . "' ) OR ( start <= '" . $end . "' AND end >= '" . $end . "' ) OR ( start <= '" . $start . "' AND end >= '" . $start . "' ) OR ( start = '" . $start . "' AND end = '" . $end . "' ) ) AND pbs_poolID = '" . $poolID . "'";
+ $return = array();
+ if($event != null) {
+ if($repeat) {
+ $select = "SELECT * FROM poolctrl_event WHERE ( ( start >= '" . $start . "' AND start <= '" . $end . "' ) OR ( start <= '" . $start . "' AND end IS NOT NULL AND end >= '" . $start . "' ) ) AND pbs_poolID = '" . $poolID . "' AND ( title <> '" . $event->getTitle() . "' OR ( title = '" . $event->getTitle() . "' AND poolctrl_event.repeat <> 1 ) )";
+ } else {
+ $select = "SELECT * FROM poolctrl_event WHERE ( ( start >= '" . $start . "' AND start <= '" . $end . "' ) OR ( start <= '" . $start . "' AND end IS NOT NULL AND end >= '" . $start . "' ) ) AND pbs_poolID = '" . $poolID . "' AND eventID <> '" . $event->getID() . "'";
+ }
+ } else {
+ $select = "SELECT * FROM poolctrl_event WHERE ( ( start >= '" . $start . "' AND start <= '" . $end . "' ) OR ( start <= '" . $start . "' AND end IS NOT NULL AND end >= '" . $start . "' ) ) AND pbs_poolID = '" . $poolID . "'";
+ }
$stmt = $db->query($select);
$results = $stmt->fetchAll();
foreach($results as $result) {
$event = new Application_Model_Event($result);
+ $event->setID($result['eventID']);
$return[] = $event;
}