summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSebastian Wagner2011-10-18 12:31:38 +0200
committerSebastian Wagner2011-10-18 12:31:38 +0200
commitf177cd97d0c9156add00c7cbb8f12540c421e5d0 (patch)
treef31c40589c687f7703a564491c0cf205b3af5bee /application
parentweitere Korrektur (diff)
downloadpoolctrl-f177cd97d0c9156add00c7cbb8f12540c421e5d0.tar.gz
poolctrl-f177cd97d0c9156add00c7cbb8f12540c421e5d0.tar.xz
poolctrl-f177cd97d0c9156add00c7cbb8f12540c421e5d0.zip
bugfix
Diffstat (limited to 'application')
-rwxr-xr-xapplication/controllers/EventController.php35
-rw-r--r--application/views/scripts/event/checkoverlapevents.phtml18
-rwxr-xr-xapplication/views/scripts/event/index.phtml3
3 files changed, 41 insertions, 15 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index db271ed..dfe8b78 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -664,25 +664,21 @@ class EventController extends Zend_Controller_Action
$eventID = $this->getRequest()->getParam('eventID');
$date = intval(strtotime(substr($this->getRequest()->getParam('date'), 0, 24)));
- $repeat = $this->getRequest()->getParam('repeat');
- if($repeat) {
- $events = $this->eventMapper->getDraggingEvents($eventID);
- } else {
- $events = $this->eventMapper->getDraggingEvent($eventID);
- }
+ $events['withrepeat'] = $this->eventMapper->getDraggingEvents($eventID);
+ $events['withoutrepeat'] = $this->eventMapper->getDraggingEvent($eventID);
$others = $this->eventMapper->getNotDraggingEvents($eventID);
// Calculate time shift
$diff=0;
- foreach($events as $e) {
+ foreach($events['withrepeat'] as $e) {
if($e['eventID'] == $eventID)
$diff = $date - strtotime($e['start']);
}
- // Check for overlap
- $overlaps = array();
- foreach($events as $e) {
+ // Check for overlap with repeat
+ $overlapswithrepeat = array();
+ foreach($events['withrepeat'] as $e) {
$enewstart = strtotime($e['start']) + $diff;
$enewend = strtotime($e['end']) + $diff;
@@ -690,13 +686,28 @@ class EventController extends Zend_Controller_Action
foreach($others as $o) {
if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start'])
|| $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']))
- $overlaps[] = $o;
+ $overlapswithrepeat[] = $o;
}
}
+
+ // Check for overlap without repeat
+ $overlapswithoutrepeat = array();
+ foreach($events['withoutrepeat'] 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']))
+ $overlapswithoutrepeat[] = $o;
+ }
+ }
$this->view->events = $events;
$this->view->others = $others;
- $this->view->overlaps = $overlaps;
+ $this->view->overlapswithrepeat = $overlapswithrepeat;
+ $this->view->overlapswithoutrepeat = $overlapswithoutrepeat;
}
diff --git a/application/views/scripts/event/checkoverlapevents.phtml b/application/views/scripts/event/checkoverlapevents.phtml
index 66916aa..5ce631b 100644
--- a/application/views/scripts/event/checkoverlapevents.phtml
+++ b/application/views/scripts/event/checkoverlapevents.phtml
@@ -1,17 +1,31 @@
<?php
// Output
//print_r($this->overlaps);
+//$overlaps[] = array();
-if(count($this->overlaps) == 0) {
+if(count($this->overlapswithrepeat) == 0) {
echo -1;
}
else {
echo '<ul id="conflictEvents">';
- foreach($this->overlaps as $o){
+ foreach($this->overlapswithrepeat as $o){
echo '<li>' . 'EventID: ' . $o['eventID'] . ', Title: ' . $o['title'] . ', Start: ' . $o['start'] . ', End: ' . $o['end'] . '</li>';
}
echo '</ul>';
// Echo contents of output, e.g. required values, such as title, date, etc.
//echo json_encode($this->overlaps);
}
+
+if(count($this->overlapswithoutrepeat) == 0) {
+ echo -1;
+}
+else {
+ echo '<ul id="conflictEvents">';
+ foreach($this->overlapswithoutrepeat as $o){
+ echo '<li>' . 'EventID: ' . $o['eventID'] . ', Title: ' . $o['title'] . ', Start: ' . $o['start'] . ', End: ' . $o['end'] . '</li>';
+ }
+ echo '</ul>';
+ // Echo contents of output, e.g. required values, such as title, date, etc.
+ //echo json_encode($this->overlaps);
+}
?> \ No newline at end of file
diff --git a/application/views/scripts/event/index.phtml b/application/views/scripts/event/index.phtml
index b22391d..d4da032 100755
--- a/application/views/scripts/event/index.phtml
+++ b/application/views/scripts/event/index.phtml
@@ -432,10 +432,11 @@ var dayClick = false;
});
});
- $.get("/event/checkoverlapevents/eventID/" + event.id + "/date/" + event.start + "/repeat/" + event.repeat, function(checkoverlapeventsresult){
+ $.get("/event/checkoverlapevents/eventID/" + event.id + "/date/" + event.start, function(checkoverlapeventsresult){
var cell = document.getElementById("conflicts");
cell.removeChild(cell.firstChild);
$("#conflicts").append(checkoverlapeventsresult);
+ alert(checkoverlapeventsresult.withrepeat + ' ' + checkoverlapeventsresult.withoutrepeat);
if(checkoverlapeventsresult == -1) {
isDroppable = true;
overlapevents = null;