summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/event/index.phtml
blob: cea191ed209b444cb9c488386fbd95adc92244a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<head>
<title>Pool Control</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<h1>Pool Control</h1>

<div id='calendar'
	style='margin: 3em 0; font-size: 13px'></div>

<script type="text/javascript">

$(document).ready(function() {iniCalendar();});

var opacityValue = .5;
var eventColor = {ev:null, color:null};
var selectedEvent = null; // keydown variable


// change border color of an event
  function eventSelected(event) {
	  if (eventColor.ev != null){
		  event.selected = false;
		  selectedEvent = null;
		  eventColor.ev.borderColor = eventColor.color;
		  }
	  event.selected = true;
	  selectedEvent = event;
	  eventColor.ev = event;
	  eventColor.color = event.borderColor;
	  event.borderColor = 'black';
	  $('#calendar').fullCalendar("rerenderEvents");

	  // dialog for deleting wdhEvents
		$(function() {
			$( "#deleteWdhEventDialog" ).dialog({
	            autoOpen: false,
	            width: 600,
				modal: true,
				title: 'Delete ' + selectedEvent.title,
	            buttons: {
	              "Cancel": function() { 
	                $(this).dialog("close");
	              }, 
	              "Delete just this Event": function() { 
	                $(this).dialog("close");
	                $("form:eq(1)").submit(); 
	              },
	              "Delete all Events": function() { 
	                $(this).dialog("close");
	                $("form:eq(2)").submit(); 
	              }
	            },
				open: function () {
                    //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
	            }
			});
		});
  }
  
// change view to addEvent
  function addEvent() {
	  self.location="/event/add/";
  }

	function showCalendar() {
		$("#calendar").show();
	}

	function hideCalendar() {
		$("#calendar").hide();
	}
	
	
	function setOpacity(type) {
		//alert(type);
		
		var events = $('#calendar').fullCalendar( 'clientEvents' , function(event) {
			if(event.category == type) {
				return true;}
			return false;
			});
		/*for( var i in events ) {
			alert(events[i].title);
		}*/
		//$('#calendar').fullCalendar( 'rerenderEvents' );			
	}


	
// fetch all poolevents of the selected #poolselectbox value
	function fetchPoolEvents(element) {
		var poolID = $("#poolselectbox option:selected").val();
		$('#calendar').fullCalendar("removeEvents");
		$('#calendar').fullCalendar("addEventSource", "/event/eventlist/poolID/" + poolID);		
	}

// delete selected event by key del(8) or entf(46)
	$(document).keydown(function (e) {
        if (e.keyCode == 8 || e.keyCode == 46 && selectedEvent.selected == true) {
            if(selectedEvent.repeat == 0) {
            if (confirm("Are you sure to delete " + selectedEvent.title + " ?")) {
                self.location="/event/delete/eventID/" + selectedEvent.id;
                $('#calendar').fullCalendar( 'removeEvents', selectedEvent.id );
                $('#calendar').fullCalendar( 'rerenderEvents' );     
              }
            }else $( "#deleteWdhEventDialog" ).dialog('open'); {
          }
        }
      });

// initialize fullCalendar
	function iniCalendar() {
		
		var calendar = $('#calendar').fullCalendar({

			  // fullCalendar header
				header: {
				  default: 'week',
					left: 'title',
					center: 'prev,next today',
					right: 'agendaWeek,agendaDay'
				},

				// set some default options
				editable: true,
				allDaySlot: false,
				selectable: true,
				selectHelper: true,
				defaultView: 'agendaWeek',
				allDay : false,
				allowCalEventOverlap: false,
		    	overlapEventsSeparate: false,
				slotMinutes: 30,
				defaultEventMinutes: 30,
				
				dayClick: function( date, allDay, jsEvent, view ) {
					
				},

			  eventMouseover: function( event, jsEvent, view ) {
			   }, 
			    
			  eventMouseout: function( event, jsEvent, view ) {  
			   },

			  /* 
			  * TO DO: implement dblclick-function 
			  *
			  dblclick: function( event, jsEvent, view ) {
					  alert('test');
			   },
			   */
				
			   eventClick: function( event, jsEvent, view ) {

				  /*
				  * TO DO: export eventEdit in dblClick function
				  *
					*event.dblclick(alert('test'););
					*$('#calendar').dblclick(function() { self.location = "/event/edit/eventID/" + event.id;});
					*/
					
					eventSelected(event);
					
			    },

			  select: function( startDate, endDate, allDay, jsEvent, view ) {

			    	  if (!confirm("Are you sure to add an Event from " + startDate + " to " + endDate + " ?")) {
			    		  $('#calendar').fullCalendar( 'unselect' );
					    }else {
						    self.location="/event/add/evstart/" + startDate + "/evend/" + endDate;
							  }
			    },
			   
			  eventResize: function( event, dayDelta, minuteDelta, revertFunc ) {
			    	  
			    	  if (minuteDelta > 0) { length = 'longer';
			    	  }else{ length = 'shorter'; }

			        if (!confirm( event.title + " is now " + minuteDelta + " minutes " + length +  ".\n\n" + "Are you sure about this change?")) {
			            revertFunc();
			        }else{
				        if (event.category == 'Boot' ) {revertFunc(); alert("You can´t change the EndTime of a BootEvent!");}
				        else if (event.category == 'Shutdown' ) {revertFunc(); alert("You can´t change the EndTime of a ShutdownEvent!");}
				        else $.post("/event/eventresize/evid/" + event.id + "/evend/" + event.end);
		              }

			    },
			    
			  eventDrop: function( event, dayDelta, minuteDelta, allDay, revertFunc ) {

			    	$(function() {
			    		$( "#defaultDialog" ).dialog({
			                autoOpen: false,
			                width: 600,
			    			modal: true,
			    			title: event.title + " was moved to " + event.start,
			                buttons: {
			                  "Cancel": function() { 
			                    $(this).dialog("close");
			                  }, 
			                  "OK": function() { 
			                    $(this).dialog("close");
			                    $("form:eq(1)").submit(); 
			                  }
			                },
			    			open: function () {
			                    //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
			                }
			    		});
			    	});
			    	//$( "#defaultDialog" ).dialog('open');
			        if (!confirm(event.title + " was moved to " + event.start + "\n\n" + "Are you sure about this change?")) {
			            revertFunc();
			        }else{
  		            $.post("/event/eventmove/evid/" + event.id + "/evstart/" + event.start + "/evend/" + event.end);
			        	  }

			    },

			  

			  eventRender: function(event, element, view) {
			    	 
			    	/*
			    	* TO DO: Eventhandler löschen bei eventClick, da sich sonst das qtip bindet 
				    *
			    	element.qtip({
	                      content: 
	                        'Title: ' + event.title + '<br/>' +
	                        'Type: ' + event.category + '<br/>' +
	                        'Note: ' + event.note + '<br/>' +
	                        'Participants: ' + event.participants,
	                      show: 'mouseover',
	                      hide: 'mouseout'
	                      });
                    */
                    
			    	if (view.name == 'agendaWeek') {
	                    
                    }
			    	if (view.name == 'agendaDay') {
			    		element.find('.fc-event-title').append("<br/> Type: " + event.category + "<br/> Note: " + event.note + "<br/> Participants: " + event.participants);
                    }
			    },

				viewDisplay: function(view) {
                    
			    	if (view.name == 'agendaWeek') 
                    {
                    }
			    	if (view.name == 'agendaDay') 
                    {
	                  }
			    }
				      
			}); 
		
	// EventType Buttons
	$('.fc-header-center').append('<span id="lecture" class="fc-button fc-state-default fc-corner-right fc-state-active"><span class="fc-button-inner"><span class="fc-button-content">Lecture</span><span class="fc-button-effect"><span></span></span></span></span>');
	$('.fc-header-center').append('<span id="maintenance" class="fc-button fc-state-default fc-corner-right fc-state-active"><span class="fc-button-inner"><span class="fc-button-content">Maintenance</span><span class="fc-button-effect"><span></span></span></span></span>');
	$('.fc-header-center').append('<span id="boot" class="fc-button fc-state-default fc-corner-right fc-state-active"><span class="fc-button-inner"><span class="fc-button-content">Boot</span><span class="fc-button-effect"><span></span></span></span></span>');
	$('.fc-header-center').append('<span id="shutdown" class="fc-button fc-state-default fc-corner-right fc-state-active"><span class="fc-button-inner"><span class="fc-button-content">Shutdown</span><span class="fc-button-effect"><span></span></span></span></span>');
	
	// PoolSelectBox
    $('.fc-header-left').append('<form name="PoolSelectForm"><select id="poolselectbox" name="PoolSelectbox" onChange="fetchPoolEvents(this); "><option>Please choose a Pool</option></select></form>');
    
    // Add Button
    $('.fc-header-right').append('<span id="addEvent" class="fc-button fc-state-default fc-state-hover"><span class="fc-button-inner"><span class="fc-button-content">Add Event</span><span class="fc-button-effect"><span></span></span></span></span>');

   // Change Button-Style
   $("#lecture").click(function(){
		if($(this).hasClass("fc-state-active")) {
			$(this).removeClass("fc-state-active");
			setOpacity('Lecture');
		} else {$(this).addClass("fc-state-active");}
		});
	$("#maintenance").click(function(){
	    if($(this).hasClass("fc-state-active")) {
	    	$(this).removeClass("fc-state-active");
	    	setOpacity('Maintenance');
	    } else {$(this).addClass("fc-state-active");}
	    });
	$("#boot").click(function(){
	    if($(this).hasClass("fc-state-active")) {
	    	$(this).removeClass("fc-state-active");
	    	setOpacity('Boot');
	    } else {$(this).addClass("fc-state-active");}
	    });
	$("#shutdown").click(function(){
	    if($(this).hasClass("fc-state-active")) {
	    	$(this).removeClass("fc-state-active");
	    	setOpacity('Shutdown');
	    } else {$(this).addClass("fc-state-active");}
	    });

	$("#addEvent").click(function(){
	    addEvent();
	    });
    

	//fetch poollist from pbs database
	$.get("/event/getpoollist/", function(getpoollistresult){$("#poolselectbox").append(getpoollistresult);});
	
	}

	

    		
</script>

<!-- DIALOG WINDOWS --> 

<!-- delete wdhEvent -->
<div id="deleteWdhEventDialog" style="display:none">
	<p>Do you want to delete any event occurring this event or just the selected?</p>
</div>

<!-- eventSelect -->
<div id="eventSelectDialog" style="display:none">
	<p>Are you sure to add this Event?</p>
</div>

<!-- eventResize boot -->
<div id="eventResizeBootDialog" style="display:none">
	<p>You can´t change the EndTime of a Boot Event!</p>
</div>

<!-- eventResize  shutdown -->
<div id="eventResizeShutdownDialog" style="display:none">
	<p>You can´t change the EndTime of a Shutdown Event!</p>
</div>

<!-- default -->
<div id="defaultDialog" style="display:none">
	<p>Are you sure about this change?</p>
</div>


<br />
<br />
<div class='listelement'><?php
if(count($this->eventlist)>0) {
	?> <?php
	foreach ($this->poollist as $pool):?>
<div id='pool<?php echo $pool->getID(); ?>' style='display: none;'>
<h2><?php echo $pool->getTitle(); ?></h2>
	<?php if(!isset($this->eventlist[$pool->getID()])) {
		echo "This Pool hasn't events yet";
	} else { ?> <?php $poolEvents = $this->eventlist[$pool->getID()]; ?> <?php foreach ($poolEvents as $event): ?>
<div class='element'>
<div class='content'>
<div class='actions'><a
	href="<?php echo $this->url(
						array(
							'controller' => 'event',
							'action'     => 'edit',
							'eventID'   =>  $event['eventID']
						),
						'default',
						true);?>"><img src='/media/img/edit.png' alt='Edit Group' /></a> <a
	href="<?php echo $this->url(
						array(
							'controller' => 'event',
							'action'     => 'delete',
							'eventID'   =>  $event['eventID']
						),
						'default',
						true);?>"><img src='/media/img/delete.png' alt='Delete Group' /></a>
</div>
<div class='title'><?php echo $event['title']; ?></div>
						<?php if($event['category']) {
							?>
<div class='subtitle'><?php echo $event['category']; ?></div>
							<?php
						} else {
							?>
<div class='subtitle'>&nbsp;</div>
							<?php
						}
						?>
<div class='details'><label>Start Time:</label>
<div class='item'><?php echo date ('d F Y - H:i', strtotime($event['start'])); ?>&nbsp;</div>
</div>
<div class='details'><label>End Time:</label>
<div class='item'><?php echo date ('d F Y - H:i', strtotime($event['end'])); ?>&nbsp;</div>
</div>
<div class='details'><label>Participants:</label>
<div class='item'><?php echo $event['participants']; ?>&nbsp;</div>
</div>
<div class='details'><label>Membership:</label>
<div class='item'><?php echo $event['pbs_person_name']; ?>&nbsp;</div>
</div>
<div class='details'><label>BootOs:</label>
<div class='item'><?php echo $event['pbs_bootos_title']; ?>&nbsp;</div>
</div>
<div class='details'><label>Repeat:</label>
<div class='item'><?php if($event['repeat']) echo 'yes'; else echo 'no'; ?>&nbsp;</div>
</div>
<div class='details'><label>Immediate:</label>
<div class='item'><?php if($event['immediate']) echo 'yes'; else echo 'no'; ?>&nbsp;</div>
</div>
<div class='details'><label>Note:</label>
<div class='item'><?php echo $event['note']; ?>&nbsp;</div>
</div>
</div>
</div>
<div class='clear'></div>
<?php endforeach ?> <?php } ?></div>
<?php endforeach ?> <?php } ?></div>
<br />
<br />