diff --git a/entity/Appointment_entity/Appointment_entity.aod b/entity/Appointment_entity/Appointment_entity.aod index ba5e554f0f9b4187a40fd003c4dc971096d5faec..adad963701310d253d8071a8bd8f54504195fd1c 100644 --- a/entity/Appointment_entity/Appointment_entity.aod +++ b/entity/Appointment_entity/Appointment_entity.aod @@ -5,41 +5,17 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <recordContainerType>JDITO</recordContainerType> <alias>Data_alias</alias> - <jDitoRecordAlias>Data_alias</jDitoRecordAlias> - <fields> - <element>UID</element> - <element>BACKGROUNDCOLOR</element> - <element>FONTCOLOR</element> - <element>ATTENDEESLENGTH</element> - <element>STARTDATE</element> - <element>ENDDATE</element> - <element>SUMMARY</element> - <element>ORGANIZER</element> - <element>ATTENDEES</element> - <element>STATUS</element> - <element>LINKS</element> - <element>DESCRIPTION</element> - <element>LOCATION</element> - <element>ICON</element> - <element>CLASSIFICATION</element> - <element>TRANSPARENCY</element> - <element>CATEGORIES</element> - <element>REMINDER</element> - <element>RRULE</element> - <element>RECURRENCEID</element> - <element>SAFESCOPEFIELD</element> - <element>MASTERBEGIN</element> - <element>MASTEREND</element> - </fields> + <jDitoRecordAlias></jDitoRecordAlias> + <fields /> <contentProcess>%aditoprj%/entity/Appointment_entity/contentProcess.js</contentProcess> <onInsert>%aditoprj%/entity/Appointment_entity/onInsert.js</onInsert> <onUpdate>%aditoprj%/entity/Appointment_entity/onUpdate.js</onUpdate> <onDelete>%aditoprj%/entity/Appointment_entity/onDelete.js</onDelete> + <recordContainer>jDitoRC</recordContainer> <entityFields> <entityField> <name>SUMMARY</name> <title>Betreff</title> - <fieldName>SUMMARY</fieldName> <valueProcess>%aditoprj%/entity/Appointment_entity/entityfields/summary/valueProcess.js</valueProcess> </entityField> <entityParameter> @@ -49,23 +25,19 @@ </entityParameter> <entityField> <name>DESCRIPTION</name> - <fieldName>DESCRIPTION</fieldName> </entityField> <entityField> <name>CLASSIFICATION</name> - <fieldName>CLASSIFICATION</fieldName> <possibleItemsProcess>%aditoprj%/entity/Appointment_entity/entityfields/classification/possibleItemsProcess.js</possibleItemsProcess> <valueProcess>%aditoprj%/entity/Appointment_entity/entityfields/classification/valueProcess.js</valueProcess> </entityField> <entityField> <name>BEGIN</name> - <fieldName>STARTDATE</fieldName> <selectionMode>SINGLE</selectionMode> <valueProcess>%aditoprj%/entity/Appointment_entity/entityfields/begin/valueProcess.js</valueProcess> </entityField> <entityField> <name>END</name> - <fieldName>ENDDATE</fieldName> <valueProcess>%aditoprj%/entity/Appointment_entity/entityfields/end/valueProcess.js</valueProcess> </entityField> <entityFieldGroup> @@ -79,23 +51,19 @@ </entityFieldGroup> <entityField> <name>STATUS</name> - <fieldName>STATUS</fieldName> <possibleItemsProcess>%aditoprj%/entity/Appointment_entity/entityfields/status/possibleItemsProcess.js</possibleItemsProcess> </entityField> <entityField> <name>LOCATION</name> - <fieldName>LOCATION</fieldName> </entityField> <entityField> <name>REMINDER_CHECK</name> </entityField> <entityField> <name>REMINDER</name> - <fieldName>REMINDER</fieldName> </entityField> <entityField> <name>CATEGORIES</name> - <fieldName>CATEGORIES</fieldName> <possibleItemsProcess>%aditoprj%/entity/Appointment_entity/entityfields/categories/possibleItemsProcess.js</possibleItemsProcess> <newItemsAllowed v="true" /> <valueProcess>%aditoprj%/entity/Appointment_entity/entityfields/categories/valueProcess.js</valueProcess> @@ -107,7 +75,6 @@ </entityField> <entityField> <name>TRANSPARENCY</name> - <fieldName>TRANSPARENCY</fieldName> </entityField> <entityActionGroup> <name>PartStatActionGroup</name> @@ -147,27 +114,70 @@ </entityParameter> <entityField> <name>ORGANIZER</name> - <fieldName>ORGANIZER</fieldName> </entityField> <entityField> <name>RRULE</name> - <fieldName>RRULE</fieldName> </entityField> <entityField> <name>RECURRENCEID</name> - <fieldName>RECURRENCEID</fieldName> </entityField> <entityField> <name>SAFESCOPEFIELD</name> - <fieldName>SAFESCOPEFIELD</fieldName> </entityField> <entityField> <name>MASTERBEGIN</name> - <fieldName>MASTERBEGIN</fieldName> </entityField> <entityField> <name>MASTEREND</name> - <fieldName>MASTEREND</fieldName> + </entityField> + <entityField> + <name>UID</name> + </entityField> + <entityField> + <name>ATTENDEESLENGTH</name> + </entityField> + <entityField> + <name>LINKS</name> + </entityField> + <entityField> + <name>ICON</name> </entityField> </entityFields> + <recordContainers> + <jDitoRecordContainer> + <name>jDitoRC</name> + <title>jDitoRC</title> + <description></description> + <jDitoRecordAlias>_____SYSTEMALIAS</jDitoRecordAlias> + <fields /> + <contentProcess>%aditoprj%/entity/Appointment_entity/recordcontainers/jditorc/contentProcess.js</contentProcess> + <onInsert>%aditoprj%/entity/Appointment_entity/recordcontainers/jditorc/onInsert.js</onInsert> + <onUpdate>%aditoprj%/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js</onUpdate> + <onDelete>%aditoprj%/entity/Appointment_entity/recordcontainers/jditorc/onDelete.js</onDelete> + <recordFields> + <element>UID.value</element> + <element>ATTENDEESLENGTH.value</element> + <element>BEGIN.value</element> + <element>END.value</element> + <element>SUMMARY.value</element> + <element>ORGANIZER.value</element> + <element>ATTENDEES.value</element> + <element>STATUS.value</element> + <element>LINKS.value</element> + <element>DESCRIPTION.value</element> + <element>LOCATION.value</element> + <element>ICON.value</element> + <element>CLASSIFICATION.value</element> + <element>TRANSPARENCY.value</element> + <element>CATEGORIES.value</element> + <element>REMINDER.value</element> + <element>REMINDER_CHECK.value</element> + <element>RRULE.value</element> + <element>RECURRENCEID.value</element> + <element>SAFESCOPEFIELD.value</element> + <element>MASTERBEGIN.value</element> + <element>MASTEREND.value</element> + </recordFields> + </jDitoRecordContainer> + </recordContainers> </entity> diff --git a/entity/Appointment_entity/contentProcess.js b/entity/Appointment_entity/contentProcess.js index 71a32131c78eed23471a30fd4eb709615496f6fb..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/Appointment_entity/contentProcess.js +++ b/entity/Appointment_entity/contentProcess.js @@ -1,79 +0,0 @@ -import("system.logging"); -import("system.result"); -import("system.vars"); -import("system.calendars"); -import("system.datetime"); -import("system.eMath"); -import("system.util"); - -// $param.entry is potentially a recurrence exception. -if(vars.exists("$param.entry")) -{ - var entry = JSON.parse(vars.getString("$param.entry")); - var masterEntry = null; - if (vars.exists("$param.masterEntry") && vars.get("$param.masterEntry") != "") { - masterEntry = JSON.parse(vars.get("$param.masterEntry")); - } - - //logging.log("Appointment is recurrence exception: " + (masterEntry != null)) - - var uid = entry[calendars.ID]; - var summary = entry[calendars.SUMMARY]; - var attendees = entry[calendars.AFFECTEDUSERS]; - var startdate = entry[calendars.DTSTART]; - var enddate = entry[calendars.DTEND]; - var links = entry[calendars.LINKS]; - var description = entry[calendars.DESCRIPTION]; - var organizer = entry[calendars.ORGANIZER2]["paramvalue"]; - var status = entry[calendars.STATUS]; - var location = entry[calendars.LOCATION]; - var reminder = entry[calendars.REMINDER_DURATION]; - var remindercheck = entry[calendars.HASREMINDER] - var classification = entry[calendars.CLASSIFICATION]; - var transparency = entry[calendars.TRANSPARENCY]; - var categories = entry[calendars.CATEGORIES]; - - var masterBegin = masterEntry != null ? masterEntry[calendars.DTSTART] : null - var masterEnd = masterEntry != null ? masterEntry[calendars.DTEND] : null - - // Recurrence - var recurrenceID = entry[calendars.RECURRENCEID]; - var rrule = null; - if (masterEntry != null) { // Entry is a recurrence exception, therefore get rrule from master - rrule = masterEntry[calendars.RRULE] != null ? masterEntry[calendars.RRULE][0] : null; - } else { - rrule = entry[calendars.RRULE] != null ? entry[calendars.RRULE][0] : null; - } - - //@TODO Icon - result.object([ - [uid, '', '', attendees.length, startdate, enddate, summary, organizer, - attendees, status, links, description, location, '', classification, - transparency, categories, reminder, rrule, recurrenceID, null, masterBegin, masterEnd] //reminder, remindercheck - ]); -} -else -{ - var filter = ( vars.exists("$param.p_filter") - && vars.get("$param.p_filter") != null - && vars.get("$param.p_filter") != undefined) ? vars.get("$param.p_filter") : ""; - - //For the Tableview in Task_Date - //var events = getEvents(filter); - var cond = { - TYPE_1: calendars.VEVENT - ,USER_1: vars.get("$sys.user") - ,COUNT: "1" - }; - //var entries = calendars.getExpandedEntries(cond, new Long(datetime.date()), new Long(eMath.addInt(datetime.date(), datetime.ONE_DAY * 7))); - - //for (i = 0; i < events.length; i++) - //{ - // events[i].push([""]) - // var count = events[i][3]; - // var iconInfo = (count > 1 ? "gruppentermin" : "einzeltermin"); - // var icon = (getIcon("termine_aufgaben", iconInfo)); - // events[i] = events[i].concat(icon); - //} - //result.object(events); -} diff --git a/entity/Appointment_entity/onDelete.js b/entity/Appointment_entity/onDelete.js index 39aa4153e2889fdca286ed24ded0e253a0594de2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/Appointment_entity/onDelete.js +++ b/entity/Appointment_entity/onDelete.js @@ -1,17 +0,0 @@ -import("system.neon"); -import("system.calendars"); -import("system.vars"); - -if (vars.exists("param.entry")) -{ - var entry = JSON.parse(vars.getString("param.entry")); - var reccurenceid = entry[calendars.RECURRENCEID]; - if (reccurenceid == undefined) reccurenceid = null; - calendars.removeEntryByUID(calendars.VEVENT, vars.get("$sys.user"), entry[calendars.ID], reccurenceid) -} - -if(vars.exists("$sys.ancestorimageuid") && vars.get("$sys.ancestorimageuid") != null) -{ - neon.closeImage(vars.getString("$sys.currentimage"), true); - neon.refresh(vars.get("$sys.ancestorimageuid")); -} \ No newline at end of file diff --git a/entity/Appointment_entity/onInsert.js b/entity/Appointment_entity/onInsert.js index 9bbaf367e6deb25aa244d9a5cd8f330a94e75501..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/Appointment_entity/onInsert.js +++ b/entity/Appointment_entity/onInsert.js @@ -1,290 +0,0 @@ -import("system.neon"); -import("system.calendars"); -import("system.vars"); -import("system.question"); -import("system.translate"); -import("system.text"); -import("system.datetime"); -import("system.db"); -import("system.result"); -import("system.tools"); - - -var event = JSON.parse(vars.getString("param.entry")); -var ok = false; - -event[calendars.TYPE] = calendars.VEVENT; -event[calendars.ATTENDEES] = vars.get("$field.ATTENDEES"); -event[calendars.STATUS] = vars.getString("$field.STATUS"); -event[calendars.SUMMARY] = vars.getString("$field.SUMMARY"); -event[calendars.LOCATION] = vars.get("$field.LOCATION"); -event[calendars.DESCRIPTION] = vars.get("$field.DESCRIPTION"); -event[calendars.DTSTART] = vars.get("$field.BEGIN"); -event[calendars.DTEND] = vars.get("$field.END"); -event[calendars.CLASSIFICATION] = vars.get("$field.CLASSIFICATION"); -event[calendars.TRANSPARENCY] = vars.get("$field.TRANSPARENCY"); -event[calendars.CATEGORIES] = vars.get("$field.CATEGORIES"); -if (vars.get("$field.REMINDER") != undefined && vars.get("$field.REMINDER") != "") -{ - event[calendars.HASREMINDER] = "true"; - event[calendars.REMINDER_DURATION] = vars.get("$field.REMINDER"); -} -event[calendars.ID] = calendars.insert([event])[0]; -vars.set("$image.editmode", calendars.MODE_UPDATE); -ok = true; - - - -// Liefert die Benutzer zurück, auf die keine Schreibrechte bestehen -function getReadOnlyUser() -{ - var writeable = calendars.getFullCalendarUsers(calendars.RIGHT_WRITE); - var affectedusers = vars.get("$image.affectedusers"); - var readonly = new Array(); - - for ( i = 0; i < affectedusers.length; i++) - { - var user = affectedusers[i][0]; - if (!isWriteable(user, writeable)) - readonly.push(affectedusers[i][3]); - } - return readonly; -} - -// Liefert TRUE, wenn der Benutzer bei denen mit Schreibberechtigungen enthalten ist -function isWriteable(user, writeable) -{ - for (var i = 0; i < writeable.length; i++) - { - if (writeable[i][0] == calendars.getCalendarUser(user)) - return true; - } - return false; -} - -// Berechnet das Ende der Recurrence -function recurrencend(event) -{ - var rec_end = vars.getString("$field.rec_end"); - - // Automatische Erkennung, was gewollt ist - if (rec_end == "") - { - if (vars.get("$field.rec_end_count") != "") - rec_end = "Endet nach Anzahl Terminen"; - else if (vars.get("$field.rec_end_date") != "") - rec_end = "Endet am"; - } - - if (rec_end == "" || rec_end == "Kein Enddatum") - { - // Nichts - } - else if (rec_end == "Endet nach Anzahl Terminen") - { - event[calendars.RRULE][0] += (";COUNT=" + vars.get("$field.rec_end_count")); - } - else if (rec_end == "Endet am") - { - var dat = vars.get("$field.rec_end_date"); - var start = vars.get("$field.start_date"); - var localTime = datetime.toDate(dat, translate.text("yyyyMMdd")) + datetime.toDate(start, "HHmmss"); - var utcTime = datetime.toLong(localTime, "yyyyMMddHHmmss"); - event[calendars.RRULE][0] += (";UNTIL=" + datetime.toDate(utcTime, "yyyyMMdd\'T\'HHmmss\'Z\'", "UTC")); - } -} - -/** - * Berechnet die Wiederholung - * - * @param event Das fertige Event. Hier die Reccurrence speichern - */ -function calcrecurrence(event) -{ - var rec_type = vars.get("$field.rec_type"); - - if (rec_type == "") - { - // Nichts - } - else if (rec_type == "Keine") - { - } - else if (rec_type == "Täglich") - { - rec_daily(event); - } - else if (rec_type == "Wöchentlich") - { - rec_weekly(event); - } - else if (rec_type == "Monatlich") - { - rec_monthly(event); - } - else if (rec_type == "Jährlich") - { - rec_yearly(event); - } - else - { - question.showMessage("Internal (1) " + rec_type); - } -} -/***********************/ -function rec_yearly(event) -{ - var rec_year = vars.get("$field.rec_yearly"); - var rec_yearly_month = vars.get("$field.rec_yearly_month"); - var rec_yearly_day = vars.get("$field.rec_yearly_day"); - var month; - var day; - - if (rec_year == "") - { - if (rec_yearly_month != "" && rec_yearly_day != "") - rec_year = "Jeden # #"; - else if (rec_yearly_month != "" && vars.get("$field.rec_yearly_day2") != "" && vars.get("$field.rec_yearly_number2") != "") - rec_year = "Am #. # im #"; - } - - if (rec_year == "" || (rec_yearly_month == "" && rec_yearly_day == "" )) - { - question.showMessage(translate.text("Jährliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); - } - else if (rec_year == "Jeden # #") - { - month = rec_yearly_month; - day = rec_yearly_day; - event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTHDAY="+day+";BYMONTH="+month); - } - else if (rec_year == "Am #. # im #") - { - month = vars.get("$field.rec_yearly_month2"); - day = vars.get("$field.rec_yearly_day2"); - var number = vars.get("$field.rec_yearly_number2"); - event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTH="+month+";BYDAY="+number+day); - } -} -/***********************/ -function rec_monthly(event) -{ - var rec_month = vars.get("$field.rec_month"); - var rec_monthly_day = vars.get("$field.rec_monthly_day"); - var rec_monthly_interval = vars.get("$field.rec_monthly_interval"); - var day; - var interval; - - if (rec_month == "") - - { - if (rec_monthly_day != "" && rec_monthly_interval != "") - rec_month = "Am #. jedes #. Monat"; - else if (vars.get("$field.rec_monthly_day2") != "" && vars.get("$field.rec_monthly_interval2") != "" && vars.get("$field.rec_monthly_weekday2") != "") - rec_month = "Am #. # jeden #. Monat"; - } - - if (rec_month == "" || (rec_monthly_day == "" && rec_monthly_interval != "")) - { - question.showMessage(translate.text("Monatliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); - } - else if (rec_month == "Am #. jedes #. Monat") - { - day = rec_monthly_day; - interval = rec_monthly_interval; - event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYMONTHDAY=" + day); - } - else if(rec_month == "Am #. # jeden #. Monat") - { - day = vars.get("$field.rec_monthly_day2"); - interval = vars.get("$field.rec_monthly_interval2"); - var weekday = vars.get("$field.rec_monthly_weekday2"); - event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYDAY=" + day + weekday); - } -} -/***********************/ -function rec_weekly(event) -{ - - var rec_weekly_intervall = vars.get("$field.rec_weekly_intervall"); - if (rec_weekly_intervall == "") - rec_weekly_intervall = "1"; - - var days = new Array(); - var count = 0; - if (vars.get("$field.rec_weekly_mo") == "true") - { - days[count] = "MO"; - count++; - } - if (vars.get("$field.rec_weekly_di") == "true") - { - days[count] = "TU"; - count++; - } - if (vars.get("$field.rec_weekly_mi") == "true") - { - days[count] = "WE"; - count++; - } - if (vars.get("$field.rec_weekly_do") == "true") - { - days[count] = "TH"; - count++; - } - if (vars.get("$field.rec_weekly_fr") == "true") - { - days[count] = "FR"; - count++; - } - if (vars.get("$field.rec_weekly_sa") == "true") - { - days[count] = "SA"; - count++; - } - if (vars.get("$field.rec_weekly_so") == "true") - { - days[count] = "SU"; - count++; - } - if (count > 0) - { - event[calendars.RRULE] = new Array("FREQ=WEEKLY;INTERVAL=" + rec_weekly_intervall + ";WKST=MO;BYDAY="); - for (var i = 0; i < count; i++) - { - event[calendars.RRULE][0] += days[i]; - if (i+1 < count) - { - event[calendars.RRULE][0] += ","; - } - } - } -} -/***********************/ -function rec_daily(event) -{ - var rec_dailytype = vars.get("$field.rec_dailytype"); - var rec_dailydays = vars.get("$field.rec_daily_days"); - if (rec_dailytype == "") - { - if (rec_dailydays != "") - rec_dailytype = "Alle # Tage"; - } - - if (rec_dailytype == "" || rec_dailydays == "") - { - question.showMessage(translate.text("Tägliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); - } - else if (rec_dailytype == "Alle # Tage") - { - event[calendars.RRULE] = new Array("FREQ=DAILY;INTERVAL=" + rec_dailydays); - } - else if (rec_dailytype == "Jeden Arbeitstag") - { - event[calendars.RRULE][0] = new Array("FREQ=WEEKLY;WKST=MO;BYDAY=MO,TU,WE,TH,FR"); - } - else - { - question.showMessage(translate.text("Internal (2)") + " " + rec_dailytype); - } -} \ No newline at end of file diff --git a/entity/Appointment_entity/onUpdate.js b/entity/Appointment_entity/onUpdate.js index f847e096577dfb0c7b24d4d5e884fd83acc96099..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/Appointment_entity/onUpdate.js +++ b/entity/Appointment_entity/onUpdate.js @@ -1,343 +0,0 @@ -import("system.neon"); -import("system.calendars"); -import("system.vars"); -import("system.question"); -import("system.translate"); -import("system.text"); -import("system.swing"); -import("system.datetime"); -import("system.db"); -import("system.result"); -import("system.tools"); - -// Dieser Prozess speichert die im Frame angezeigten Daten -// Je nach Modus (INSERT, EDIT) wird ein neuer Datensatz angelegt oder der alte editiert -if(vars.exists("$param.entry")) -{ - var event = JSON.parse(vars.getString("$param.entry")); - - var ok = false; - if ( calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS && event[calendars.ORGANIZER2]["cn"] != event[calendars.USER2]["cn"]) - { - question.showMessage(translate.text("Ein Gruppentermin kann nur durch den Organisator bearbeitet werden.")); - ok = true; - } - else - { - - event[calendars.TYPE] = calendars.VEVENT; - event[calendars.STATUS] = vars.getString("$field.STATUS"); - event[calendars.SUMMARY] = vars.getString("$field.SUMMARY"); - event[calendars.LOCATION] = vars.get("$field.LOCATION"); - event[calendars.DESCRIPTION] = vars.get("$field.DESCRIPTION"); - event[calendars.DTSTART] = vars.get("$field.BEGIN"); - event[calendars.DTEND] = vars.get("$field.END"); - event[calendars.HASREMINDER] = "false"; - event[calendars.CLASSIFICATION] = vars.get("$field.CLASSIFICATION"); - event[calendars.CATEGORIES] = vars.get("$field.CATEGORIES"); - event[calendars.AFFECTEDUSERS] = vars.get("$field.ATTENDEES"); - event[calendars.TRANSPARENCY] = vars.get("$field.TRANSPARENCY"); - if (vars.get("$field.REMINDER") != undefined && vars.get("$field.REMINDER") != "") - { - event[calendars.HASREMINDER] = "true"; - event[calendars.REMINDER_DURATION] = vars.get("$field.REMINDER"); - } - //event[calendars.AFFECTEDUSERS] = getAffectedUsers( event ); - // calcrecurrence(event); - // if (event[calendars.RRULE] != undefined) recurrencend(event); - // Links updaten - //swing.saveTableEdit("$comp.links"); - // Entweder jetzt neu anlegen oder nur updaten - - - calendars.updateEntry(event); - - ok = true; - } -} -// Liefert die AffectedUsers -function getAffectedUsers( pEvent ) -{ - var affectedusers = vars.get("$image.affectedusers"); - var attendess = pEvent[calendars.ATTENDEES] - var calendarusers = []; - for ( var i = 0; i < affectedusers.length; i++) - { - var insert = true; - for ( var y = 0; y < attendess.length; y++) - { - // Teilnehmer schon vorhanden - if ( text.encodeMS( [attendess[y]["paramvalue"], "CN:" + attendess[y]["cn"]] ) == affectedusers[i][0] ) - { - var userparts = [attendess[y]["paramvalue"]]; - if ( affectedusers[i][1] != "" && affectedusers[i][1] != "UNKNOWN" ) attendess[y]["partstat"] = affectedusers[i][1]; - for ( var part in attendess[y] ) if ( part != "paramvalue") userparts.push(part + ":" + attendess[y][part] ) - calendarusers.push( text.encodeMS(userparts) ); - insert = false; - break; - } - } - if ( insert ) // Teilnehmer noch nicht im Termin vorhanden - { - var resource = db.cell("select THEME from THEME where THEMEID = '" + affectedusers[i][0] + "'"); - if( resource != "" && tools.existUsers(resource) ) - calendarusers.push(text.encodeMS(text.decodeMS(calendars.getCalendarUser(resource)).concat("CUTYPE:RESOURCE"))); - else calendarusers.push(affectedusers[i][0]); - } - } - return text.encodeMS( calendarusers ); - } - -// Liefert die Benutzer zurück, auf die keine Schreibrechte bestehen -function getReadOnlyUser() -{ - var writeable = calendars.getFullCalendarUsers(calendars.RIGHT_WRITE); - var affectedusers = vars.get("$image.affectedusers"); - var readonly = new Array(); - - for ( i = 0; i < affectedusers.length; i++) - { - var user = affectedusers[i][0]; - if (!isWriteable(user, writeable)) - readonly.push(affectedusers[i][3]); - } - return readonly; -} - -// Liefert TRUE, wenn der Benutzer bei denen mit Schreibberechtigungen enthalten ist -function isWriteable(user, writeable) -{ - for (var i = 0; i < writeable.length; i++) - { - if (writeable[i][0] == calendars.getCalendarUser(user)) - return true; - } - return false; -} - -// Berechnet das Ende der Recurrence -function recurrencend(event) -{ - var rec_end = vars.getString("$comp.rec_end"); - - // Automatische Erkennung, was gewollt ist - if (rec_end == "") - { - if (vars.get("$comp.rec_end_count") != "") - rec_end = "Endet nach Anzahl Terminen"; - else if (vars.get("$comp.rec_end_date") != "") - rec_end = "Endet am"; - } - - if (rec_end == "" || rec_end == "Kein Enddatum") - { - // Nichts - } - else if (rec_end == "Endet nach Anzahl Terminen") - { - event[calendars.RRULE][0] += (";COUNT=" + vars.get("$comp.rec_end_count")); - } - else if (rec_end == "Endet am") - { - var dat = vars.get("$comp.rec_end_date"); - var start = vars.get("$comp.start_date"); - var localTime = datetime.toDate(dat, translate.text("yyyyMMdd")) + datetime.toDate(start, "HHmmss"); - var utcTime = datetime.toLong(localTime, "yyyyMMddHHmmss"); - event[calendars.RRULE][0] += (";UNTIL=" + datetime.toDate(utcTime, "yyyyMMdd\'T\'HHmmss\'Z\'", "UTC")); - } -} - -/** - * Berechnet die Wiederholung - * - * @param event Das fertige Event. Hier die Reccurrence speichern - */ -function calcrecurrence(event) -{ - var rec_type = vars.get("$comp.rec_type"); - - if (rec_type == "") - { - // Nichts - } - else if (rec_type == "Keine") - { - } - else if (rec_type == "Täglich") - { - rec_daily(event); - } - else if (rec_type == "Wöchentlich") - { - rec_weekly(event); - } - else if (rec_type == "Monatlich") - { - rec_monthly(event); - } - else if (rec_type == "Jährlich") - { - rec_yearly(event); - } - else - { - question.showMessage("Internal (1) " + rec_type); - } -} -/***********************/ -function rec_yearly(event) -{ - var rec_year = vars.get("$comp.rec_yearly"); - var rec_yearly_month = vars.get("$comp.rec_yearly_month"); - var rec_yearly_day = vars.get("$comp.rec_yearly_day"); - var month; - var day; - - if (rec_year == "") - { - if (rec_yearly_month != "" && rec_yearly_day != "") - rec_year = "Jeden # #"; - else if (rec_yearly_month != "" && vars.get("$comp.rec_yearly_day2") != "" && vars.get("$comp.rec_yearly_number2") != "") - rec_year = "Am #. # im #"; - } - - if (rec_year == "" || (rec_yearly_month == "" && rec_yearly_day == "" )) - { - question.showMessage(translate.text("Jährliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); - } - else if (rec_year == "Jeden # #") - { - month = rec_yearly_month; - day = rec_yearly_day; - event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTHDAY="+day+";BYMONTH="+month); - } - else if (rec_year == "Am #. # im #") - { - month = vars.get("$comp.rec_yearly_month2"); - day = vars.get("$comp.rec_yearly_day2"); - var number = vars.get("$comp.rec_yearly_number2"); - event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTH="+month+";BYDAY="+number+day); - } -} -/***********************/ -function rec_monthly(event) -{ - var rec_month = vars.get("$comp.rec_month"); - var rec_monthly_day = vars.get("$comp.rec_monthly_day"); - var rec_monthly_interval = vars.get("$comp.rec_monthly_interval"); - var day; - var interval; - - if (rec_month == "") - - { - if (rec_monthly_day != "" && rec_monthly_interval != "") - rec_month = "Am #. jedes #. Monat"; - else if (vars.get("$comp.rec_monthly_day2") != "" && vars.get("$comp.rec_monthly_interval2") != "" && vars.get("$comp.rec_monthly_weekday2") != "") - rec_month = "Am #. # jeden #. Monat"; - } - - if (rec_month == "" || (rec_monthly_day == "" && rec_monthly_interval != "")) - { - question.showMessage(translate.text("Monatliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); - } - else if (rec_month == "Am #. jedes #. Monat") - { - day = rec_monthly_day; - interval = rec_monthly_interval; - event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYMONTHDAY=" + day); - } - else if(rec_month == "Am #. # jeden #. Monat") - { - day = vars.get("$comp.rec_monthly_day2"); - interval = vars.get("$comp.rec_monthly_interval2"); - var weekday = vars.get("$comp.rec_monthly_weekday2"); - event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYDAY=" + day + weekday); - } -} -/***********************/ -function rec_weekly(event) -{ - - var rec_weekly_intervall = vars.get("$comp.rec_weekly_intervall"); - if (rec_weekly_intervall == "") - rec_weekly_intervall = "1"; - - var days = new Array(); - var count = 0; - if (vars.get("$comp.rec_weekly_mo") == "true") - { - days[count] = "MO"; - count++; - } - if (vars.get("$comp.rec_weekly_di") == "true") - { - days[count] = "TU"; - count++; - } - if (vars.get("$comp.rec_weekly_mi") == "true") - { - days[count] = "WE"; - count++; - } - if (vars.get("$comp.rec_weekly_do") == "true") - { - days[count] = "TH"; - count++; - } - if (vars.get("$comp.rec_weekly_fr") == "true") - { - days[count] = "FR"; - count++; - } - if (vars.get("$comp.rec_weekly_sa") == "true") - { - days[count] = "SA"; - count++; - } - if (vars.get("$comp.rec_weekly_so") == "true") - { - days[count] = "SU"; - count++; - } - if (count > 0) - { - event[calendars.RRULE] = new Array("FREQ=WEEKLY;INTERVAL=" + rec_weekly_intervall + ";WKST=MO;BYDAY="); - for (var i = 0; i < count; i++) - { - event[calendars.RRULE][0] += days[i]; - if (i+1 < count) - { - event[calendars.RRULE][0] += ","; - } - } - } -} -/***********************/ -function rec_daily(event) -{ - var rec_dailytype = vars.get("$comp.rec_dailytype"); - var rec_dailydays = vars.get("$comp.rec_daily_days"); - if (rec_dailytype == "") - { - if (rec_dailydays != "") - rec_dailytype = "Alle # Tage"; - } - - if (rec_dailytype == "" || rec_dailydays == "") - { - question.showMessage(translate.text("Tägliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); - } - else if (rec_dailytype == "Alle # Tage") - { - event[calendars.RRULE] = new Array("FREQ=DAILY;INTERVAL=" + rec_dailydays); - } - else if (rec_dailytype == "Jeden Arbeitstag") - { - event[calendars.RRULE][0] = new Array("FREQ=WEEKLY;WKST=MO;BYDAY=MO,TU,WE,TH,FR"); - } - else - { - question.showMessage(translate.text("Internal (2)") + " " + rec_dailytype); - } -} \ No newline at end of file diff --git a/entity/Appointment_entity/recordcontainers/jditorc/contentProcess.js b/entity/Appointment_entity/recordcontainers/jditorc/contentProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f0d247b9a064e851baf3fe1c2c46544ff7e6b0e1 --- /dev/null +++ b/entity/Appointment_entity/recordcontainers/jditorc/contentProcess.js @@ -0,0 +1,100 @@ +import("system.logging"); +import("system.result"); +import("system.vars"); +import("system.calendars"); +import("system.datetime"); +import("system.eMath"); +import("system.util"); + +// $param.entry is potentially a recurrence exception. +if(vars.exists("$param.entry")) +{ + var entry = JSON.parse(vars.getString("$param.entry")); + var masterEntry = null; + if (vars.exists("$param.masterEntry") && vars.get("$param.masterEntry") != "") { + masterEntry = JSON.parse(vars.get("$param.masterEntry")); + } + + //logging.log("Appointment is recurrence exception: " + (masterEntry != null)) + + var uid = entry[calendars.ID]; + var summary = entry[calendars.SUMMARY]; + var attendees = entry[calendars.AFFECTEDUSERS]; + var startdate = entry[calendars.DTSTART]; + var enddate = entry[calendars.DTEND]; + var links = entry[calendars.LINKS]; + var description = entry[calendars.DESCRIPTION]; + var organizer = entry[calendars.ORGANIZER2]["paramvalue"]; + var status = entry[calendars.STATUS]; + var location = entry[calendars.LOCATION]; + var reminder = entry[calendars.REMINDER_DURATION]; + var remindercheck = entry[calendars.HASREMINDER] + var classification = entry[calendars.CLASSIFICATION]; + var transparency = entry[calendars.TRANSPARENCY]; + var categories = entry[calendars.CATEGORIES]; + + var masterBegin = masterEntry != null ? masterEntry[calendars.DTSTART] : null + var masterEnd = masterEntry != null ? masterEntry[calendars.DTEND] : null + + // Recurrence + var recurrenceID = entry[calendars.RECURRENCEID]; + var rrule = null; + if (masterEntry != null) { // Entry is a recurrence exception, therefore get rrule from master + rrule = masterEntry[calendars.RRULE] != null ? masterEntry[calendars.RRULE][0] : null; + } else { + rrule = entry[calendars.RRULE] != null ? entry[calendars.RRULE][0] : null; + } + + //@TODO Icon + result.object([ + [ + uid, + attendees.length, + startdate, + enddate, + summary, + organizer, + attendees, + status, + links, + description, + location, + '', + classification, + transparency, + categories, + reminder, + remindercheck, + rrule, + recurrenceID, + null, + masterBegin, + masterEnd + ] + ]); +} +else +{ + var filter = ( vars.exists("$param.p_filter") + && vars.get("$param.p_filter") != null + && vars.get("$param.p_filter") != undefined) ? vars.get("$param.p_filter") : ""; + + //For the Tableview in Task_Date + //var events = getEvents(filter); + var cond = { + TYPE_1: calendars.VEVENT + ,USER_1: vars.get("$sys.user") + ,COUNT: "1" + }; + //var entries = calendars.getExpandedEntries(cond, new Long(datetime.date()), new Long(eMath.addInt(datetime.date(), datetime.ONE_DAY * 7))); + + //for (i = 0; i < events.length; i++) + //{ + // events[i].push([""]) + // var count = events[i][3]; + // var iconInfo = (count > 1 ? "gruppentermin" : "einzeltermin"); + // var icon = (getIcon("termine_aufgaben", iconInfo)); + // events[i] = events[i].concat(icon); + //} + //result.object(events); +} diff --git a/entity/Appointment_entity/recordcontainers/jditorc/onDelete.js b/entity/Appointment_entity/recordcontainers/jditorc/onDelete.js new file mode 100644 index 0000000000000000000000000000000000000000..39aa4153e2889fdca286ed24ded0e253a0594de2 --- /dev/null +++ b/entity/Appointment_entity/recordcontainers/jditorc/onDelete.js @@ -0,0 +1,17 @@ +import("system.neon"); +import("system.calendars"); +import("system.vars"); + +if (vars.exists("param.entry")) +{ + var entry = JSON.parse(vars.getString("param.entry")); + var reccurenceid = entry[calendars.RECURRENCEID]; + if (reccurenceid == undefined) reccurenceid = null; + calendars.removeEntryByUID(calendars.VEVENT, vars.get("$sys.user"), entry[calendars.ID], reccurenceid) +} + +if(vars.exists("$sys.ancestorimageuid") && vars.get("$sys.ancestorimageuid") != null) +{ + neon.closeImage(vars.getString("$sys.currentimage"), true); + neon.refresh(vars.get("$sys.ancestorimageuid")); +} \ No newline at end of file diff --git a/entity/Appointment_entity/recordcontainers/jditorc/onInsert.js b/entity/Appointment_entity/recordcontainers/jditorc/onInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..a5cd4a7eeb9c8339a024e0e000a8a6a86d8412f9 --- /dev/null +++ b/entity/Appointment_entity/recordcontainers/jditorc/onInsert.js @@ -0,0 +1,293 @@ +import("system.logging"); +import("system.neon"); +import("system.calendars"); +import("system.vars"); +import("system.question"); +import("system.translate"); +import("system.text"); +import("system.datetime"); +import("system.db"); +import("system.result"); +import("system.tools"); + +logging.log("appointment_entity.onInsert"); + +var event = JSON.parse(vars.getString("param.entry")); +var ok = false; + +event[calendars.TYPE] = calendars.VEVENT; +event[calendars.ID] = vars.get("$field.UID"); +event[calendars.ATTENDEES] = vars.get("$field.ATTENDEES"); +event[calendars.STATUS] = vars.getString("$field.STATUS"); +event[calendars.SUMMARY] = vars.getString("$field.SUMMARY"); +event[calendars.LOCATION] = vars.get("$field.LOCATION"); +event[calendars.DESCRIPTION] = vars.get("$field.DESCRIPTION"); +event[calendars.DTSTART] = vars.get("$field.BEGIN"); +event[calendars.DTEND] = vars.get("$field.END"); +event[calendars.CLASSIFICATION] = vars.get("$field.CLASSIFICATION"); +event[calendars.TRANSPARENCY] = vars.get("$field.TRANSPARENCY"); +event[calendars.CATEGORIES] = vars.get("$field.CATEGORIES"); +if (vars.get("$field.REMINDER") != undefined && vars.get("$field.REMINDER") != "") +{ + event[calendars.HASREMINDER] = "true"; + event[calendars.REMINDER_DURATION] = vars.get("$field.REMINDER"); +} +event[calendars.ID] = calendars.insert([event])[0]; +vars.set("$image.editmode", calendars.MODE_UPDATE); +ok = true; + + + +// Liefert die Benutzer zurück, auf die keine Schreibrechte bestehen +function getReadOnlyUser() +{ + var writeable = calendars.getFullCalendarUsers(calendars.RIGHT_WRITE); + var affectedusers = vars.get("$image.affectedusers"); + var readonly = new Array(); + + for ( i = 0; i < affectedusers.length; i++) + { + var user = affectedusers[i][0]; + if (!isWriteable(user, writeable)) + readonly.push(affectedusers[i][3]); + } + return readonly; +} + +// Liefert TRUE, wenn der Benutzer bei denen mit Schreibberechtigungen enthalten ist +function isWriteable(user, writeable) +{ + for (var i = 0; i < writeable.length; i++) + { + if (writeable[i][0] == calendars.getCalendarUser(user)) + return true; + } + return false; +} + +// Berechnet das Ende der Recurrence +function recurrencend(event) +{ + var rec_end = vars.getString("$field.rec_end"); + + // Automatische Erkennung, was gewollt ist + if (rec_end == "") + { + if (vars.get("$field.rec_end_count") != "") + rec_end = "Endet nach Anzahl Terminen"; + else if (vars.get("$field.rec_end_date") != "") + rec_end = "Endet am"; + } + + if (rec_end == "" || rec_end == "Kein Enddatum") + { + // Nichts + } + else if (rec_end == "Endet nach Anzahl Terminen") + { + event[calendars.RRULE][0] += (";COUNT=" + vars.get("$field.rec_end_count")); + } + else if (rec_end == "Endet am") + { + var dat = vars.get("$field.rec_end_date"); + var start = vars.get("$field.start_date"); + var localTime = datetime.toDate(dat, translate.text("yyyyMMdd")) + datetime.toDate(start, "HHmmss"); + var utcTime = datetime.toLong(localTime, "yyyyMMddHHmmss"); + event[calendars.RRULE][0] += (";UNTIL=" + datetime.toDate(utcTime, "yyyyMMdd\'T\'HHmmss\'Z\'", "UTC")); + } +} + +/** + * Berechnet die Wiederholung + * + * @param event Das fertige Event. Hier die Reccurrence speichern + */ +function calcrecurrence(event) +{ + var rec_type = vars.get("$field.rec_type"); + + if (rec_type == "") + { + // Nichts + } + else if (rec_type == "Keine") + { + } + else if (rec_type == "Täglich") + { + rec_daily(event); + } + else if (rec_type == "Wöchentlich") + { + rec_weekly(event); + } + else if (rec_type == "Monatlich") + { + rec_monthly(event); + } + else if (rec_type == "Jährlich") + { + rec_yearly(event); + } + else + { + question.showMessage("Internal (1) " + rec_type); + } +} +/***********************/ +function rec_yearly(event) +{ + var rec_year = vars.get("$field.rec_yearly"); + var rec_yearly_month = vars.get("$field.rec_yearly_month"); + var rec_yearly_day = vars.get("$field.rec_yearly_day"); + var month; + var day; + + if (rec_year == "") + { + if (rec_yearly_month != "" && rec_yearly_day != "") + rec_year = "Jeden # #"; + else if (rec_yearly_month != "" && vars.get("$field.rec_yearly_day2") != "" && vars.get("$field.rec_yearly_number2") != "") + rec_year = "Am #. # im #"; + } + + if (rec_year == "" || (rec_yearly_month == "" && rec_yearly_day == "" )) + { + question.showMessage(translate.text("Jährliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); + } + else if (rec_year == "Jeden # #") + { + month = rec_yearly_month; + day = rec_yearly_day; + event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTHDAY="+day+";BYMONTH="+month); + } + else if (rec_year == "Am #. # im #") + { + month = vars.get("$field.rec_yearly_month2"); + day = vars.get("$field.rec_yearly_day2"); + var number = vars.get("$field.rec_yearly_number2"); + event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTH="+month+";BYDAY="+number+day); + } +} +/***********************/ +function rec_monthly(event) +{ + var rec_month = vars.get("$field.rec_month"); + var rec_monthly_day = vars.get("$field.rec_monthly_day"); + var rec_monthly_interval = vars.get("$field.rec_monthly_interval"); + var day; + var interval; + + if (rec_month == "") + + { + if (rec_monthly_day != "" && rec_monthly_interval != "") + rec_month = "Am #. jedes #. Monat"; + else if (vars.get("$field.rec_monthly_day2") != "" && vars.get("$field.rec_monthly_interval2") != "" && vars.get("$field.rec_monthly_weekday2") != "") + rec_month = "Am #. # jeden #. Monat"; + } + + if (rec_month == "" || (rec_monthly_day == "" && rec_monthly_interval != "")) + { + question.showMessage(translate.text("Monatliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); + } + else if (rec_month == "Am #. jedes #. Monat") + { + day = rec_monthly_day; + interval = rec_monthly_interval; + event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYMONTHDAY=" + day); + } + else if(rec_month == "Am #. # jeden #. Monat") + { + day = vars.get("$field.rec_monthly_day2"); + interval = vars.get("$field.rec_monthly_interval2"); + var weekday = vars.get("$field.rec_monthly_weekday2"); + event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYDAY=" + day + weekday); + } +} +/***********************/ +function rec_weekly(event) +{ + + var rec_weekly_intervall = vars.get("$field.rec_weekly_intervall"); + if (rec_weekly_intervall == "") + rec_weekly_intervall = "1"; + + var days = new Array(); + var count = 0; + if (vars.get("$field.rec_weekly_mo") == "true") + { + days[count] = "MO"; + count++; + } + if (vars.get("$field.rec_weekly_di") == "true") + { + days[count] = "TU"; + count++; + } + if (vars.get("$field.rec_weekly_mi") == "true") + { + days[count] = "WE"; + count++; + } + if (vars.get("$field.rec_weekly_do") == "true") + { + days[count] = "TH"; + count++; + } + if (vars.get("$field.rec_weekly_fr") == "true") + { + days[count] = "FR"; + count++; + } + if (vars.get("$field.rec_weekly_sa") == "true") + { + days[count] = "SA"; + count++; + } + if (vars.get("$field.rec_weekly_so") == "true") + { + days[count] = "SU"; + count++; + } + if (count > 0) + { + event[calendars.RRULE] = new Array("FREQ=WEEKLY;INTERVAL=" + rec_weekly_intervall + ";WKST=MO;BYDAY="); + for (var i = 0; i < count; i++) + { + event[calendars.RRULE][0] += days[i]; + if (i+1 < count) + { + event[calendars.RRULE][0] += ","; + } + } + } +} +/***********************/ +function rec_daily(event) +{ + var rec_dailytype = vars.get("$field.rec_dailytype"); + var rec_dailydays = vars.get("$field.rec_daily_days"); + if (rec_dailytype == "") + { + if (rec_dailydays != "") + rec_dailytype = "Alle # Tage"; + } + + if (rec_dailytype == "" || rec_dailydays == "") + { + question.showMessage(translate.text("Tägliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); + } + else if (rec_dailytype == "Alle # Tage") + { + event[calendars.RRULE] = new Array("FREQ=DAILY;INTERVAL=" + rec_dailydays); + } + else if (rec_dailytype == "Jeden Arbeitstag") + { + event[calendars.RRULE][0] = new Array("FREQ=WEEKLY;WKST=MO;BYDAY=MO,TU,WE,TH,FR"); + } + else + { + question.showMessage(translate.text("Internal (2)") + " " + rec_dailytype); + } +} \ No newline at end of file diff --git a/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js b/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js new file mode 100644 index 0000000000000000000000000000000000000000..c26d2893e08bd0c013b16217fd08d75aee55a85f --- /dev/null +++ b/entity/Appointment_entity/recordcontainers/jditorc/onUpdate.js @@ -0,0 +1,343 @@ +import("system.neon"); +import("system.calendars"); +import("system.vars"); +import("system.question"); +import("system.translate"); +import("system.text"); +import("system.swing"); +import("system.datetime"); +import("system.db"); +import("system.result"); +import("system.tools"); + +// Dieser Prozess speichert die im Frame angezeigten Daten +// Je nach Modus (INSERT, EDIT) wird ein neuer Datensatz angelegt oder der alte editiert +if(vars.exists("$param.entry")) +{ + var event = JSON.parse(vars.getString("$param.entry")); + + var ok = false; + if ( calendars.getBackendType() == calendars.BACKEND_EXCHANGEWS && event[calendars.ORGANIZER2]["cn"] != event[calendars.USER2]["cn"]) + { + question.showMessage(translate.text("Ein Gruppentermin kann nur durch den Organisator bearbeitet werden.")); + ok = true; + } + else + { + event[calendars.ID] = vars.getString("$field.UID"); + event[calendars.TYPE] = calendars.VEVENT; + event[calendars.STATUS] = vars.getString("$field.STATUS"); + event[calendars.SUMMARY] = vars.getString("$field.SUMMARY"); + event[calendars.LOCATION] = vars.get("$field.LOCATION"); + event[calendars.DESCRIPTION] = vars.get("$field.DESCRIPTION"); + event[calendars.DTSTART] = vars.get("$field.BEGIN"); + event[calendars.DTEND] = vars.get("$field.END"); + event[calendars.HASREMINDER] = "false"; + event[calendars.CLASSIFICATION] = vars.get("$field.CLASSIFICATION"); + event[calendars.CATEGORIES] = vars.get("$field.CATEGORIES"); + event[calendars.AFFECTEDUSERS] = vars.get("$field.ATTENDEES"); + event[calendars.TRANSPARENCY] = vars.get("$field.TRANSPARENCY"); + if (vars.get("$field.REMINDER") != undefined && vars.get("$field.REMINDER") != "") + { + event[calendars.HASREMINDER] = "true"; + event[calendars.REMINDER_DURATION] = vars.get("$field.REMINDER"); + } + //event[calendars.AFFECTEDUSERS] = getAffectedUsers( event ); + // calcrecurrence(event); + // if (event[calendars.RRULE] != undefined) recurrencend(event); + // Links updaten + //swing.saveTableEdit("$comp.links"); + // Entweder jetzt neu anlegen oder nur updaten + + + calendars.updateEntry(event); + + ok = true; + } +} +// Liefert die AffectedUsers +function getAffectedUsers( pEvent ) +{ + var affectedusers = vars.get("$image.affectedusers"); + var attendess = pEvent[calendars.ATTENDEES] + var calendarusers = []; + for ( var i = 0; i < affectedusers.length; i++) + { + var insert = true; + for ( var y = 0; y < attendess.length; y++) + { + // Teilnehmer schon vorhanden + if ( text.encodeMS( [attendess[y]["paramvalue"], "CN:" + attendess[y]["cn"]] ) == affectedusers[i][0] ) + { + var userparts = [attendess[y]["paramvalue"]]; + if ( affectedusers[i][1] != "" && affectedusers[i][1] != "UNKNOWN" ) attendess[y]["partstat"] = affectedusers[i][1]; + for ( var part in attendess[y] ) if ( part != "paramvalue") userparts.push(part + ":" + attendess[y][part] ) + calendarusers.push( text.encodeMS(userparts) ); + insert = false; + break; + } + } + if ( insert ) // Teilnehmer noch nicht im Termin vorhanden + { + var resource = db.cell("select THEME from THEME where THEMEID = '" + affectedusers[i][0] + "'"); + if( resource != "" && tools.existUsers(resource) ) + calendarusers.push(text.encodeMS(text.decodeMS(calendars.getCalendarUser(resource)).concat("CUTYPE:RESOURCE"))); + else calendarusers.push(affectedusers[i][0]); + } + } + return text.encodeMS( calendarusers ); + } + +// Liefert die Benutzer zurück, auf die keine Schreibrechte bestehen +function getReadOnlyUser() +{ + var writeable = calendars.getFullCalendarUsers(calendars.RIGHT_WRITE); + var affectedusers = vars.get("$image.affectedusers"); + var readonly = new Array(); + + for ( i = 0; i < affectedusers.length; i++) + { + var user = affectedusers[i][0]; + if (!isWriteable(user, writeable)) + readonly.push(affectedusers[i][3]); + } + return readonly; +} + +// Liefert TRUE, wenn der Benutzer bei denen mit Schreibberechtigungen enthalten ist +function isWriteable(user, writeable) +{ + for (var i = 0; i < writeable.length; i++) + { + if (writeable[i][0] == calendars.getCalendarUser(user)) + return true; + } + return false; +} + +// Berechnet das Ende der Recurrence +function recurrencend(event) +{ + var rec_end = vars.getString("$comp.rec_end"); + + // Automatische Erkennung, was gewollt ist + if (rec_end == "") + { + if (vars.get("$comp.rec_end_count") != "") + rec_end = "Endet nach Anzahl Terminen"; + else if (vars.get("$comp.rec_end_date") != "") + rec_end = "Endet am"; + } + + if (rec_end == "" || rec_end == "Kein Enddatum") + { + // Nichts + } + else if (rec_end == "Endet nach Anzahl Terminen") + { + event[calendars.RRULE][0] += (";COUNT=" + vars.get("$comp.rec_end_count")); + } + else if (rec_end == "Endet am") + { + var dat = vars.get("$comp.rec_end_date"); + var start = vars.get("$comp.start_date"); + var localTime = datetime.toDate(dat, translate.text("yyyyMMdd")) + datetime.toDate(start, "HHmmss"); + var utcTime = datetime.toLong(localTime, "yyyyMMddHHmmss"); + event[calendars.RRULE][0] += (";UNTIL=" + datetime.toDate(utcTime, "yyyyMMdd\'T\'HHmmss\'Z\'", "UTC")); + } +} + +/** + * Berechnet die Wiederholung + * + * @param event Das fertige Event. Hier die Reccurrence speichern + */ +function calcrecurrence(event) +{ + var rec_type = vars.get("$comp.rec_type"); + + if (rec_type == "") + { + // Nichts + } + else if (rec_type == "Keine") + { + } + else if (rec_type == "Täglich") + { + rec_daily(event); + } + else if (rec_type == "Wöchentlich") + { + rec_weekly(event); + } + else if (rec_type == "Monatlich") + { + rec_monthly(event); + } + else if (rec_type == "Jährlich") + { + rec_yearly(event); + } + else + { + question.showMessage("Internal (1) " + rec_type); + } +} +/***********************/ +function rec_yearly(event) +{ + var rec_year = vars.get("$comp.rec_yearly"); + var rec_yearly_month = vars.get("$comp.rec_yearly_month"); + var rec_yearly_day = vars.get("$comp.rec_yearly_day"); + var month; + var day; + + if (rec_year == "") + { + if (rec_yearly_month != "" && rec_yearly_day != "") + rec_year = "Jeden # #"; + else if (rec_yearly_month != "" && vars.get("$comp.rec_yearly_day2") != "" && vars.get("$comp.rec_yearly_number2") != "") + rec_year = "Am #. # im #"; + } + + if (rec_year == "" || (rec_yearly_month == "" && rec_yearly_day == "" )) + { + question.showMessage(translate.text("Jährliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); + } + else if (rec_year == "Jeden # #") + { + month = rec_yearly_month; + day = rec_yearly_day; + event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTHDAY="+day+";BYMONTH="+month); + } + else if (rec_year == "Am #. # im #") + { + month = vars.get("$comp.rec_yearly_month2"); + day = vars.get("$comp.rec_yearly_day2"); + var number = vars.get("$comp.rec_yearly_number2"); + event[calendars.RRULE] = new Array("FREQ=YEARLY;BYMONTH="+month+";BYDAY="+number+day); + } +} +/***********************/ +function rec_monthly(event) +{ + var rec_month = vars.get("$comp.rec_month"); + var rec_monthly_day = vars.get("$comp.rec_monthly_day"); + var rec_monthly_interval = vars.get("$comp.rec_monthly_interval"); + var day; + var interval; + + if (rec_month == "") + + { + if (rec_monthly_day != "" && rec_monthly_interval != "") + rec_month = "Am #. jedes #. Monat"; + else if (vars.get("$comp.rec_monthly_day2") != "" && vars.get("$comp.rec_monthly_interval2") != "" && vars.get("$comp.rec_monthly_weekday2") != "") + rec_month = "Am #. # jeden #. Monat"; + } + + if (rec_month == "" || (rec_monthly_day == "" && rec_monthly_interval != "")) + { + question.showMessage(translate.text("Monatliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); + } + else if (rec_month == "Am #. jedes #. Monat") + { + day = rec_monthly_day; + interval = rec_monthly_interval; + event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYMONTHDAY=" + day); + } + else if(rec_month == "Am #. # jeden #. Monat") + { + day = vars.get("$comp.rec_monthly_day2"); + interval = vars.get("$comp.rec_monthly_interval2"); + var weekday = vars.get("$comp.rec_monthly_weekday2"); + event[calendars.RRULE] = new Array("FREQ=MONTHLY;INTERVAL=" + interval + ";BYDAY=" + day + weekday); + } +} +/***********************/ +function rec_weekly(event) +{ + + var rec_weekly_intervall = vars.get("$comp.rec_weekly_intervall"); + if (rec_weekly_intervall == "") + rec_weekly_intervall = "1"; + + var days = new Array(); + var count = 0; + if (vars.get("$comp.rec_weekly_mo") == "true") + { + days[count] = "MO"; + count++; + } + if (vars.get("$comp.rec_weekly_di") == "true") + { + days[count] = "TU"; + count++; + } + if (vars.get("$comp.rec_weekly_mi") == "true") + { + days[count] = "WE"; + count++; + } + if (vars.get("$comp.rec_weekly_do") == "true") + { + days[count] = "TH"; + count++; + } + if (vars.get("$comp.rec_weekly_fr") == "true") + { + days[count] = "FR"; + count++; + } + if (vars.get("$comp.rec_weekly_sa") == "true") + { + days[count] = "SA"; + count++; + } + if (vars.get("$comp.rec_weekly_so") == "true") + { + days[count] = "SU"; + count++; + } + if (count > 0) + { + event[calendars.RRULE] = new Array("FREQ=WEEKLY;INTERVAL=" + rec_weekly_intervall + ";WKST=MO;BYDAY="); + for (var i = 0; i < count; i++) + { + event[calendars.RRULE][0] += days[i]; + if (i+1 < count) + { + event[calendars.RRULE][0] += ","; + } + } + } +} +/***********************/ +function rec_daily(event) +{ + var rec_dailytype = vars.get("$comp.rec_dailytype"); + var rec_dailydays = vars.get("$comp.rec_daily_days"); + if (rec_dailytype == "") + { + if (rec_dailydays != "") + rec_dailytype = "Alle # Tage"; + } + + if (rec_dailytype == "" || rec_dailydays == "") + { + question.showMessage(translate.text("Tägliche Serie nicht genauer spezifiziert. Ignoriere Serie.")); + } + else if (rec_dailytype == "Alle # Tage") + { + event[calendars.RRULE] = new Array("FREQ=DAILY;INTERVAL=" + rec_dailydays); + } + else if (rec_dailytype == "Jeden Arbeitstag") + { + event[calendars.RRULE][0] = new Array("FREQ=WEEKLY;WKST=MO;BYDAY=MO,TU,WE,TH,FR"); + } + else + { + question.showMessage(translate.text("Internal (2)") + " " + rec_dailytype); + } +} \ No newline at end of file