summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/event/index.phtml
blob: c7358a4a59eb2c437cf0fdd1f04fd01811d8c650 (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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
<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 eventColor = {ev:null, color:null};
var selectedEvent = null; // keydown variable
var clickTmp = true;


// 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");
	  $('#calendar').unbind('eventClick');
  }
  
// change view to addEvent
  function addEvent() {
    if($("#poolselectbox option:selected").val() == 'Please choose a Pool') {
        $( "#noPoolSelectedDialog" ).dialog('open');
      } else {
	  self.location="/event/add/";}
  }

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

	function hideCalendar() {
		$("#calendar").hide();
	}
	
	
	function setOpacity(type, value) {
		var events = $('#calendar').fullCalendar( 'clientEvents' , function(event) {
			if(event.category == type) {
				event.opacity = value;
				}
			return false;
			});
		$('#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) {
            // check if the event is an wdhEvent
            if(selectedEvent.repeat == 0) {
            	  // dialog for deleting selected event
                $(function() {
                    $( "#eventDeleteDialog" ).dialog({
                            autoOpen: false,
                            width: 600,
                      modal: true,
                      title: "Delete " + selectedEvent.title,
                            buttons: {
                              "Cancel": function() {
                                $(this).dialog("close");
                              }, 
                              "OK": function() { 
                                $(this).dialog("close");
                                self.location="/event/delete/eventID/" + selectedEvent.id;
                                $('#calendar').fullCalendar( 'removeEvents', selectedEvent.id );
                                $('#calendar').fullCalendar( 'rerenderEvents' ); 
                              }
                            },
                      open: function () {
                            	  $(".ui-dialog-titlebar-close").hide();
                                //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
                            }
                    });
                  });
                $( "#eventDeleteDialog" ).dialog('open');
                
             // dialog for deleting selected wdhEvent 
            }else {    
             $(function() {
                $( "#eventDeleteWdhDialog" ).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");  
                        self.location="/event/delete/eventID/" + selectedEvent.id;
                      },
                      "Delete all Events": function() { 
                        $(this).dialog("close"); 
                      }
                    },
              open: function () {
                    	  $(".ui-dialog-titlebar-close").hide();
                          //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
                    }
            });
          });
             $( "#eventDeleteWdhDialog" ).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 ) {  
			   },

			  /* 
			  * no use for this because element.bind('dblclick') in eventRender Function
			  *
			  eventDblclick: function( event, jsEvent, view ) {
					  self.location = "/event/edit/eventID/" + event.id;
					  
			   },*/
			  
			  eventClick: function( event, jsEvent, view ) {

					  if(clickTmp) {
						  clickTmp = false;
						  setTimeout(function() {clickTmp = true} , 300);
						  eventSelected(event);
					  } else {
						  self.location = "/event/edit/eventID/" + event.id;  
					  }
			    },

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

					  if($("#poolselectbox option:selected").val() == 'Please choose a Pool') {
						  $( "#noPoolSelectedDialog" ).dialog('open');
					  } else {
			           $(function() {
			               $( "#eventAddDialog" ).dialog({
			                       autoOpen: false,
			                       width: 600,
			                 modal: true,
			                 title: "Add Event from " + startDate + " to " + endDate,
			                       buttons: {
			                         "Cancel": function() {
			                           $(this).dialog("close");
			                           $('#calendar').fullCalendar( 'unselect' );
			                         }, 
			                         "OK": function() { 
			                           $(this).dialog("close");
			                           self.location="/event/add/evstart/" + startDate + "/evend/" + endDate; 
			                         }
			                       },
			                 open: function () {
			                    	 $(".ui-dialog-titlebar-close").hide();
			                           //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
			                       }
			               });
			             });
			           $( "#eventAddDialog" ).dialog('open');
					  }
			    },
			   
			  eventResize: function( event, dayDelta, minuteDelta, revertFunc ) {

		             if (minuteDelta > 0) { length = 'longer';
		              }else{ length = 'shorter'; }

	                 $(function() {
                         $( "#defaultDialog" ).dialog({
                                 autoOpen: false,
                                 width: 600,
                           modal: true,
                           title: event.title + " is now " + minuteDelta + " minutes " + length,
                                 buttons: {
                                   "Cancel": function() { 
                                     $(this).dialog("close");
                                     revertFunc();
                                   }, 
                                   "OK": function() { 
                                     $(this).dialog("close");
                                     if (event.category == 'Boot' ) {
                                         revertFunc();
                                         // ERROR! initialize eventResizeBootDialog
                                         $(function() {
                                             $( "#eventResizeBootDialog" ).dialog({
                                                     autoOpen: false,
                                                     width: 600,
                                               modal: true,
                                               title: "ERROR: Try to resize " + event.title,
                                                     buttons: { 
                                                       "OK": function() { 
                                                         $(this).dialog("close");
                                                         revertFunc();
                                                       }
                                                     },
                                               open: function () {
                                                    	   $(".ui-dialog-titlebar-close").hide();
                                                    	   $(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
                                                     }
                                             });
                                           });
                                         $( "#eventResizeBootDialog" ).dialog('open');
                                         }
                                     else if (event.category == 'Shutdown' ) {
                                         revertFunc();
                                         // ERROR initialize eventResizeShutdownDialog
                                         $(function() {
                                                 $( "#eventResizeShutdownDialog" ).dialog({
                                                         autoOpen: false,
                                                         width: 600,
                                                   modal: true,
                                                   title: "ERROR: Try to resize " + event.title,
                                                         buttons: { 
                                                           "OK": function() { 
                                                             $(this).dialog("close");
                                                             revertFunc();
                                                           }
                                                         },
                                                   open: function () {
                                                        	   $(".ui-dialog-titlebar-close").hide();
                                                             $(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
                                                         }
                                                 });
                                               });
                                         $( "#eventResizeShutdownDialog" ).dialog('open');
                                         
                                   }
                                     // the event is no boot- or shutdown-Event, apply the changes 
                                     else $.post("/event/eventresize/evid/" + event.id + "/evend/" + event.end);
                                 }
                         },
                         open: function () {
                        	   $(".ui-dialog-titlebar-close").hide();
                                     //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
                                 }
                         });
                       });
	                 $( "#defaultDialog" ).dialog('open');
			    },
			    
			  eventDrop: function( event, dayDelta, minuteDelta, allDay, revertFunc ) {
					  
			    	if(event.repeat == 0) {

			    	$(function() {
			    		$( "#defaultDialog" ).dialog({
			                autoOpen: false,
			                width: 600,
			    			modal: true,
			    			title: event.title + " was moved to " + event.start,
			                buttons: {
			                  "Cancel": function() { 
			                    $(this).dialog("close");
			                    revertFunc();
			                  }, 
			                  "OK": function() { 
			                    $(this).dialog("close");
			                    $.post("/event/eventmove/evid/" + event.id + "/evstart/" + event.start + "/evend/" + event.end); 
			                  }
			                },
			    			open: function () {
			                  	$(".ui-dialog-titlebar-close").hide();
			                    //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
			                }
			    		});
			    	});
			    	$( "#defaultDialog" ).dialog('open');
			    	} else {    
			             $(function() {
			                 $( "#eventMoveWdhDialog" ).dialog({
			                     autoOpen: false,
			                     width: 600,
			               modal: true,
			               title: 'Move ' + event.title,
			                     buttons: {
			                       "Cancel": function() {
			                       $(this).dialog("close");
			                       revertFunc();
			                       }, 
			                       "Move just this Event": function() {
			                     	  $(this).dialog("close");  
			                     	 $.post("/event/eventmove/evid/" + event.id + "/evstart/" + event.start + "/evend/" + event.end);
			                       },
			                       "Move all Events": function() { 
			                         $(this).dialog("close"); 
			                         // TO DO: handle wdhEvents
			                       }
			                     },
			               open: function () {
			                     	  $(".ui-dialog-titlebar-close").hide();
			                           //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
			                     }
			             });
			           });
			              $( "#eventMoveWdhDialog" ).dialog('open');
			    	}
			    	
			    },

			  eventRender: function(event, element, view) {

					/*
					* no need for this
					*
					  element.bind('dblclick', function(){
						  self.location = "/event/edit/eventID/" + event.id;
						  })
					*/
			    	 
			    	/*
			    	* 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($("#poolselectbox option:selected").val() == 'Please choose a Pool') {
	        $( "#noPoolSelectedDialog" ).dialog('open');
	      } else {
		if($(this).hasClass("fc-state-active")) {
			$(this).removeClass("fc-state-active");
			setOpacity('Lecture', '.5');
		} else {$(this).addClass("fc-state-active"); setOpacity('Lecture', '1');}
	      }
		});
	$("#maintenance").click(function(){
	    if($("#poolselectbox option:selected").val() == 'Please choose a Pool') {
	          $( "#noPoolSelectedDialog" ).dialog('open');
	        } else {
	    if($(this).hasClass("fc-state-active")) {
	    	$(this).removeClass("fc-state-active");
	    	setOpacity('Maintenance', '.5');
	    } else {$(this).addClass("fc-state-active"); setOpacity('Maintenance', '1');}
	        }
	    });
	$("#boot").click(function(){
	    if($("#poolselectbox option:selected").val() == 'Please choose a Pool') {
	          $( "#noPoolSelectedDialog" ).dialog('open');
	        } else {
	    if($(this).hasClass("fc-state-active")) {
	    	$(this).removeClass("fc-state-active");
	    	setOpacity('Boot', '.5');
	    } else {$(this).addClass("fc-state-active"); setOpacity('Boot', '1');}
	        }
	    });
	$("#shutdown").click(function(){
	    if($("#poolselectbox option:selected").val() == 'Please choose a Pool') {
	          $( "#noPoolSelectedDialog" ).dialog('open');
	        } else {
	    if($(this).hasClass("fc-state-active")) {
	    	$(this).removeClass("fc-state-active");
	    	setOpacity('Shutdown', '.5');
	    } else {$(this).addClass("fc-state-active"); setOpacity('Shutdown', '1');}
	        }
	    });

	$("#addEvent").click(function(){
	    addEvent();
	    });
    
	// initialize noPoolSelectedDialog
	$(function() {
        $( "#noPoolSelectedDialog" ).dialog({
                autoOpen: false,
                width: 600,
          modal: true,
          title: "ERROR",
                buttons: { 
                  "OK": function() { 
                    $(this).dialog("close");
                  }
                },
          open: function () {
                	  $(".ui-dialog-titlebar-close").hide();
                    $(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
                }
        });
      });
    
	//fetch poollist from pbs database
	$.get("/event/getpoollist/", function(getpoollistresult){$("#poolselectbox").append(getpoollistresult);});
	
}

	

    		
</script>

<!-- DIALOG WINDOWS -->

<!-- delete wdhEvent -->
<div id="eventDeleteWdhDialog" style="display: none">
<p>This is a Wdh-Event!</p>
<p>Do you want to delete any event occurring this event or just the
selected one?</p>
</div>

<!-- move wdhEvent -->
<div id="eventMoveWdhDialog" style="display: none">
<p>This is a Wdh-Event!</p>
<p>Do you want to move any event occurring this event or just the
selected one?</p>
</div>

<!-- eventDelete -->
<div id="eventDeleteDialog" style="display: none">
<p>Are you sure to delete this Event?</p>
</div>

<!-- eventAdd -->
<div id="eventAddDialog" 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>

<!-- no pool selected -->
<div id="noPoolSelectedDialog" style="display: none">
<p>Please choose a Pool first!</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 />