mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-30 18:39:28 +00:00
Coodle Erweiterungen
- Freebusy von Ressourcen anzeigen - Event Handler Move und Resize
This commit is contained in:
@@ -37,7 +37,7 @@ switch($work)
|
||||
|
||||
foreach($ort->result as $row)
|
||||
{
|
||||
echo html_entity_decode($row->ort_kurzbz.'| Ort | '.$row->bezeichnung."\n");
|
||||
echo html_entity_decode($row->ort_kurzbz.'|Ort|'.$row->bezeichnung."\n");
|
||||
}
|
||||
|
||||
$benutzer = new benutzer();
|
||||
@@ -47,7 +47,7 @@ switch($work)
|
||||
|
||||
foreach($benutzer->result as $row)
|
||||
{
|
||||
echo html_entity_decode($row->uid.'| Person | '.$row->nachname.' '.$row->vorname."\n");
|
||||
echo html_entity_decode($row->uid.'|Person|'.$row->nachname.' '.$row->vorname."\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012 FH Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at>
|
||||
*/
|
||||
require_once('../../../config/cis.config.inc.php');
|
||||
require_once('../../../include/ort.class.php');
|
||||
require_once('../../../include/benutzer.class.php');
|
||||
require_once('../../../include/ical.class.php');
|
||||
require_once('../../../include/wochenplan.class.php');
|
||||
|
||||
if(isset($_POST['id']))
|
||||
$id = $_POST['id'];
|
||||
|
||||
if(isset($_POST['typ']))
|
||||
$typ = $_POST['typ'];
|
||||
|
||||
if(isset($_POST['start']))
|
||||
$start = $_POST['start'];
|
||||
if(isset($_POST['end']))
|
||||
$end = $_POST['end'];
|
||||
|
||||
/*
|
||||
Beispiel JSON Event
|
||||
[
|
||||
{
|
||||
"id":111,
|
||||
"title":"Event1",
|
||||
"start":"2012-10-10",
|
||||
"url":"http:\/\/yahoo.com\/"
|
||||
},
|
||||
{
|
||||
"id":222,
|
||||
"title":"Event2",
|
||||
"start":"2012-10-20",
|
||||
"end":"2012-10-22",
|
||||
"url":"http:\/\/yahoo.com\/"
|
||||
}
|
||||
]
|
||||
*/
|
||||
$events=array();
|
||||
|
||||
switch($typ)
|
||||
{
|
||||
case 'Ort':
|
||||
// LVPlan/Reservierungen des Raumes holen
|
||||
|
||||
$stdplan = new wochenplan();
|
||||
$stdplan->load_data('ort',null,$id);
|
||||
|
||||
while($start<$end)
|
||||
{
|
||||
$i++;
|
||||
if(!date("w",$start))
|
||||
$start=jump_day($start,1);
|
||||
|
||||
$stdplan->init_stdplan();
|
||||
$datum=$start;
|
||||
$start+=604800; // eine Woche
|
||||
|
||||
// Stundenplan einer Woche laden
|
||||
if(!$stdplan->load_week($datum,'stundenplan'))
|
||||
{
|
||||
die($stdplan->errormsg);
|
||||
}
|
||||
|
||||
$result = $stdplan->draw_week_csv('return', LVPLAN_KATEGORIE);
|
||||
foreach($result as $row)
|
||||
{
|
||||
$item['id']=$id.$row['dtstart'].$row['dtend'];
|
||||
$item['title']=$id;
|
||||
$item['start']=fixDate($row['dtstart']);
|
||||
$item['end']=fixDate($row['dtend']);
|
||||
$item['allDay']=false;
|
||||
$item['editable']=false;
|
||||
$events[]=$item;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Person':
|
||||
|
||||
//FreeBusy Information holen
|
||||
$fp = fopen(APP_ROOT.'cis/public/freebusy.php/'.$id,'r');
|
||||
if (!$fp)
|
||||
{
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$doc = '';
|
||||
while (!feof($fp))
|
||||
{
|
||||
$line = fgets($fp);
|
||||
$doc.=$line;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
//FreeBusy Parsen
|
||||
$ical = new ical();
|
||||
$ical->parseFreeBusy($doc);
|
||||
|
||||
foreach($ical->dtresult as $row)
|
||||
{
|
||||
$item['id']=$id.$row['dtstart'].$row['dtend'];
|
||||
$item['title']=$id;
|
||||
$item['start']=fixDate($row['dtstart']);
|
||||
$item['end']=fixDate($row['dtend']);
|
||||
$item['allDay']=false;
|
||||
$item['editable']=false;
|
||||
$events[]=$item;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
echo json_encode($events);
|
||||
|
||||
function fixDate($date)
|
||||
{
|
||||
$jahr = mb_substr($date,0,4);
|
||||
$monat = mb_substr($date,4,2);
|
||||
$tag = mb_substr($date,6,2);
|
||||
$stunde = mb_substr($date,9,2);
|
||||
$minute = mb_substr($date,11,2);
|
||||
$sekunde = mb_substr($date,13,2);
|
||||
return $jahr.'-'.$monat.'-'.$tag.'T'.$stunde.':'.$minute.':'.$sekunde;
|
||||
}
|
||||
?>
|
||||
@@ -193,7 +193,7 @@ if($coodle->coodle_id=='')
|
||||
echo $p->t('coodle/neuerEintrag');
|
||||
else
|
||||
echo $p->t('coodle/bearbeiten');
|
||||
echo '</h4';
|
||||
echo '</h4>';
|
||||
/*
|
||||
echo '
|
||||
<fieldset style="width:100px;">
|
||||
|
||||
+114
-49
@@ -22,6 +22,7 @@ require_once('../../../include/functions.inc.php');
|
||||
require_once('../../../include/phrasen.class.php');
|
||||
require_once('../../../include/coodle.class.php');
|
||||
require_once('../../../include/datum.class.php');
|
||||
|
||||
$uid = get_uid();
|
||||
$sprache = getSprache();
|
||||
$p = new phrasen($sprache);
|
||||
@@ -138,42 +139,37 @@ echo '<html>
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
/* initialize the external events
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
$("#external-events div.external-event").each(function() {
|
||||
|
||||
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
|
||||
// it doesn"t need to have a start or end
|
||||
var eventObject = {
|
||||
title: $.trim($(this).text()) // use the element"s text as the event title
|
||||
$(document).ready(function()
|
||||
{
|
||||
// Coodle Termin initialisieren
|
||||
$("#external-events div.external-event").each(function()
|
||||
{
|
||||
var eventObject =
|
||||
{
|
||||
title: $.trim($(this).text()) // use the elements text as the event title
|
||||
};
|
||||
|
||||
// store the Event Object in the DOM element so we can get to it later
|
||||
$(this).data("eventObject", eventObject);
|
||||
|
||||
// make the event draggable using jQuery UI
|
||||
$(this).draggable({
|
||||
$(this).draggable(
|
||||
{
|
||||
zIndex: 999,
|
||||
revert: true, // will cause the event to go back to its
|
||||
revertDuration: 0 // original position after the drag
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* initialize the calendar
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
$("#calendar").fullCalendar({
|
||||
header: {
|
||||
left: "prev,next today",
|
||||
center: "title",
|
||||
right: "month,agendaWeek,agendaDay"
|
||||
},
|
||||
// Kalender Initialisieren
|
||||
$("#calendar").fullCalendar(
|
||||
{
|
||||
header: {
|
||||
left: "prev,next today",
|
||||
center: "title",
|
||||
right: "month,agendaWeek,agendaDay"
|
||||
},
|
||||
defaultView: "agendaWeek",
|
||||
timeFormat: {
|
||||
// for agendaWeek and agendaDay
|
||||
@@ -211,12 +207,14 @@ echo '<html>
|
||||
},
|
||||
editable: true,
|
||||
droppable: true, // this allows things to be dropped onto the calendar !!!
|
||||
drop: function(date, allDay) { // this function is called when something is dropped
|
||||
drop: function(date, allDay)
|
||||
{
|
||||
// this function is called when something is dropped
|
||||
|
||||
// retrieve the dropped element"s stored Event Object
|
||||
// retrieve the dropped elements stored Event Object
|
||||
var originalEventObject = $(this).data("eventObject");
|
||||
|
||||
// we need to copy it, so that multiple events don"t have a reference to the same object
|
||||
// we need to copy it, so that multiple events dont have a reference to the same object
|
||||
var copiedEventObject = $.extend({}, originalEventObject);
|
||||
|
||||
// assign it the date that was reported
|
||||
@@ -233,7 +231,40 @@ echo '<html>
|
||||
//$(this).remove();
|
||||
//}
|
||||
|
||||
}
|
||||
},
|
||||
eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view)
|
||||
{
|
||||
alert(
|
||||
event.title + " was moved " +
|
||||
dayDelta + " days and " +
|
||||
minuteDelta + " minutes."
|
||||
);
|
||||
|
||||
if (allDay) {
|
||||
alert("Event is now all-day");
|
||||
}else{
|
||||
alert("Event has a time-of-day");
|
||||
}
|
||||
|
||||
if (!confirm("Are you sure about this change?")) {
|
||||
revertFunc();
|
||||
}
|
||||
},
|
||||
eventResize: function(event,dayDelta,minuteDelta,revertFunc, ui, view)
|
||||
{
|
||||
|
||||
alert(
|
||||
"The end date of " + event.title + "has been moved " +
|
||||
dayDelta + " days and " +
|
||||
minuteDelta + " minutes."
|
||||
);
|
||||
|
||||
if (!confirm("is this okay?")) {
|
||||
revertFunc();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -277,12 +308,14 @@ echo '
|
||||
<div id="ressourcecontainer"></div>
|
||||
<input id="input_ressource" type="text" size="10" />
|
||||
<script>
|
||||
|
||||
// Formatieren des Eintrages im Autocomplete Feld
|
||||
function formatItem(row)
|
||||
{
|
||||
if(row[1]="Ort")
|
||||
return "O <i>" + row[0] + "<\/i> - "+ row[2] +" " + row[1];
|
||||
if(row[1]=="Ort")
|
||||
return "<i>" + row[0] + "<\/i> - "+ row[2] +" " + row[1];
|
||||
else
|
||||
return " <i>" + row[2] + "<\/i> - "+ row[0] +" " + row[1];
|
||||
return "<i>" + row[2] + "<\/i> - "+ row[0] +" " + row[1];
|
||||
}
|
||||
|
||||
function selectItem(li)
|
||||
@@ -290,25 +323,28 @@ echo '
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#input_ressource").autocomplete("coodle_autocomplete.php", {
|
||||
minChars:2,
|
||||
matchSubset:1,matchContains:1,
|
||||
width:300,
|
||||
cacheLength:0,
|
||||
onItemSelect:selectItem,
|
||||
formatItem:formatItem,
|
||||
extraParams:{"work":"ressource"}
|
||||
});
|
||||
|
||||
$("#input_ressource").result(function(event, data, formatted)
|
||||
{
|
||||
var uid = data[0];
|
||||
var typ = data[1];
|
||||
var bezeichnung = data[2];
|
||||
addRessource(uid, typ, bezeichnung);
|
||||
this.value="";
|
||||
});
|
||||
$(document).ready(function()
|
||||
{
|
||||
// Autocomplete Feld fuer Ressourcen initialisieren
|
||||
$("#input_ressource").autocomplete("coodle_autocomplete.php", {
|
||||
minChars:2,
|
||||
matchSubset:1,matchContains:1,
|
||||
width:300,
|
||||
cacheLength:0,
|
||||
onItemSelect:selectItem,
|
||||
formatItem:formatItem,
|
||||
extraParams:{"work":"ressource"}
|
||||
});
|
||||
|
||||
// Auswahl eines Eintrages im Autocomplete Feld
|
||||
$("#input_ressource").result(function(event, data, formatted)
|
||||
{
|
||||
var uid = data[0];
|
||||
var typ = data[1];
|
||||
var bezeichnung = data[2];
|
||||
addRessource(uid, typ, bezeichnung);
|
||||
this.value="";
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -322,6 +358,22 @@ echo '
|
||||
</a> \
|
||||
\'+bezeichnung+\' \
|
||||
<br /></span>\';
|
||||
|
||||
|
||||
$("#calendar").fullCalendar("addEventSource",
|
||||
{
|
||||
url:"coodle_events.php?code="+encodeURIComponent(id+typ),
|
||||
type: "POST",
|
||||
data: {
|
||||
typ: typ,
|
||||
id: id
|
||||
},
|
||||
error: function() {
|
||||
alert("Error fetching data for "+typ+" "+id);
|
||||
},
|
||||
color:"gray"
|
||||
//textColor:"black"
|
||||
});
|
||||
$("#ressourcecontainer").append(code);
|
||||
}
|
||||
|
||||
@@ -330,6 +382,19 @@ echo '
|
||||
*/
|
||||
function removeRessource(item, id, typ)
|
||||
{
|
||||
|
||||
$("#calendar").fullCalendar("removeEventSource",
|
||||
{
|
||||
url:"coodle_events.php?code="+encodeURIComponent(id+typ),
|
||||
type: "POST",
|
||||
data: {
|
||||
typ: typ,
|
||||
id: id
|
||||
},
|
||||
error: function() {
|
||||
alert("Error fetching data for "+typ+" "+id);
|
||||
}
|
||||
});
|
||||
$(item).parent().remove();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -95,5 +95,35 @@ class ical extends basis_db
|
||||
{
|
||||
return implode($this->result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Importiert ein FreeBusy File
|
||||
*
|
||||
* @param $ical
|
||||
* @param $typ
|
||||
*/
|
||||
public function parseFreeBusy($ical)
|
||||
{
|
||||
$rows = explode("\n",$ical);
|
||||
|
||||
$idx = count($this->result);
|
||||
$status=0;
|
||||
$dtstart='';
|
||||
$dtend='';
|
||||
|
||||
foreach($rows as $row)
|
||||
{
|
||||
if(mb_strstr($row,'FREEBUSY:'))
|
||||
{
|
||||
|
||||
$len = mb_strlen($row);
|
||||
$slashpos = mb_strpos($row, '/');
|
||||
$fblen = mb_strlen('FREEBUSY:');
|
||||
$dtstart = mb_substr($row, $fblen, $len-$slashpos);
|
||||
$dtend = mb_substr($row, $slashpos+1);
|
||||
$this->dtresult[]=array('dtstart'=>trim($dtstart),'dtend'=>trim($dtend));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user