summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapplication/controllers/EventController.php47
-rwxr-xr-xapplication/models/EventMapper.php24
-rw-r--r--application/views/scripts/event/checkoverlapevents.phtml11
3 files changed, 82 insertions, 0 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index f221753..b2ff1ae 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -621,6 +621,53 @@ class EventController extends Zend_Controller_Action
$this->view->poollist = $poollist;
}
+ public function checkoverlapeventsAction() {
+ if(!$this->acl->checkRight('eo')) {
+ $this->_redirect('/');
+ }
+ $this->_helper->layout->disableLayout();
+
+ $eventID = $this->getRequest()->getParam('eventID');
+ $date = intval(strtotime(substr($this->getRequest()->getParam('date'), 0, 24)));
+
+ $events = $this->eventMapper->getDraggingEvents($eventID);
+ $others = $this->eventMapper->getNotDraggingEvents($eventID);
+
+
+
+
+
+
+ // Fetch all events with same title as dragged one (fetch repeats)
+
+
+ // Calculate time shift
+ $diff=0;
+ foreach($events as $e) {
+ if($e['eventID'] == $eventID)
+ $diff = $date - strtotime($e['start']);
+ }
+
+ // Check for overlap
+ $overlaps = array();
+ foreach($events as $e) {
+
+ $enewstart = strtotime($e['start']) + $diff;
+ $enewend = strtotime($e['end']) + $diff;
+
+ foreach($others as $o) {
+ if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start'])
+ || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']))
+ $overlaps[] = $o;
+ }
+ }
+
+ $this->view->events = $events;
+ $this->view->others = $others;
+ $this->view->overlaps = $overlaps;
+
+ }
+
public function eventmoveAction() {
if(!$this->acl->checkRight('eo')) {
$this->_redirect('/');
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 91fdc4a..092ab63 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -412,4 +412,28 @@ class Application_Model_EventMapper
return $return;
}
+ public function getDraggingEvents($eventID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = 'SELECT * FROM poolctrl_event WHERE title = (SELECT title FROM poolctrl_event WHERE eventID = ?)';
+ $stmt = $db->query($select, array(''.$eventID));
+ $return = $stmt->fetchAll();
+
+ return $return;
+
+ }
+
+ public function getNotDraggingEvents($eventID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = 'SELECT * FROM poolctrl_event WHERE title <> (SELECT title FROM poolctrl_event WHERE eventID = ?)';
+ $stmt = $db->query($select, array(''.$eventID));
+ $return = $stmt->fetchAll();
+
+ return $return;
+
+ }
+
+ //$others[] = SELECT * FROM events WHERE id NOT IN (implode(',', $events_ids))
+
} \ No newline at end of file
diff --git a/application/views/scripts/event/checkoverlapevents.phtml b/application/views/scripts/event/checkoverlapevents.phtml
new file mode 100644
index 0000000..265da0b
--- /dev/null
+++ b/application/views/scripts/event/checkoverlapevents.phtml
@@ -0,0 +1,11 @@
+<?php
+// Output
+print_r($this->overlaps);
+
+if(count($this->overlaps) == 0) {
+ echo '-1';
+}
+else {
+ // Echo contents of output, e.g. required values, such as title, date, etc.
+}
+?> \ No newline at end of file