, * Andreas Österreicher */ require_once ('../../config/cis.config.inc.php'); require_once ('../../include/phrasen.class.php'); require_once ('../../include/functions.inc.php'); require_once ('../../include/coodle.class.php'); require_once ('../../include/datum.class.php'); require_once ('../../include/mail.class.php'); require_once ('../../include/benutzer.class.php'); require_once ('../../include/reservierung.class.php'); require_once ('../../include/stunde.class.php'); require_once ('../../include/stundenplan.class.php'); require_once ('../../include/mitarbeiter.class.php'); header("Content-Type: text/html; charset=utf-8"); $sprache = getSprache(); $p = new phrasen($sprache); $datum_obj = new datum(); $message = ''; $mailMessage = ''; $saveOk = null; $ersteller = false; $abgeschlossen = false; $coodle_id = (isset($_GET['coodle_id']) ? $_GET['coodle_id'] : ''); $coodle = new coodle(); if (! $coodle->load($coodle_id)) die($coodle->errormsg); // Überprüfen ob Coodle Status laufend oder abgeschlossen hat if (! $coodle->checkStatus($coodle_id)) die($p->t('coodle/umfrageNichtGueltig')); // authentifizierung if (! isset($_GET['zugangscode'])) { $uid = get_uid(); if (! $coodle->checkBerechtigung($coodle_id, $uid)) die($p->t('coodle/keineBerechtigung')); // überprüfen ob ersteller gleich uid ist if ($coodle->ersteller_uid == $uid) $ersteller = true; } else { if (! $coodle->checkBerechtigung($coodle_id, '', $_GET['zugangscode'])) die($p->t('coodle/keineBerechtigung')); } // checkboxen speichern if (isset($_POST['save'])) { $coodle_help = new coodle(); $error = false; $teilnehmer_uid = ''; // Ressource ID von Zugangscode oder UID holen und Beiträge löschen if (isset($_GET['zugangscode'])) { // Einträge löschen $coodle_help->getRessourceFromUser($coodle_id, '', $_GET['zugangscode']); $coodle_ressource_termin = $coodle_help->deleteRessourceTermin($coodle_id, $coodle_help->coodle_ressource_id); $teilnehmer_uid = $coodle_help->coodle_ressource_id; } else { if ($coodle_help->RessourceExists($coodle_id, $uid)) { $coodle_help->getRessourceFromUser($coodle_id, $uid); $coodle_ressource_termin = $coodle_help->deleteRessourceTermin($coodle_id, $coodle_help->coodle_ressource_id); $teilnehmer_uid = $coodle_help->coodle_ressource_id; } } // Einträge speichern foreach ($_POST as $key => $value) { if (mb_substr($key, 0, 5) == 'check') { $termin = explode('_', $key); $ressource_id = $termin[1]; $termin_id = $termin[2]; $coodle_ressource_termin = new coodle(); $coodle_ressource_termin->coodle_ressource_id = $ressource_id; $coodle_ressource_termin->coodle_termin_id = $termin_id; $coodle_ressource_termin->new = true; if (! $coodle_ressource_termin->saveRessourceTermin()) $error = true; } } if ($error) { $message .= "" . $p->t('global/fehlerBeimSpeichernDerDaten') . "
"; } else { $coodle_help->load($coodle_id); // email an ersteller senden wenn option aktiviert if ($coodle_help->mailversand && (! isset($_POST['auswahl_termin']))) sendBenachrichtigung($coodle_id, $teilnehmer_uid); $saveOk = true; } } // endgültige auswahl des termins speichern if (isset($_POST['auswahl_termin'])) { if ($ersteller) { $auswahl = $_POST['auswahl_termin']; if ($auswahl != '') { // setzte auswahl von termin_id auf true $coodle_help = new coodle(); $coodle_help->loadTermin($auswahl); $coodle_help->auswahl = true; // alle termine der coodle_id auf false setzen if (! $coodle_help->setTerminFalse($coodle_id)) exit('Fehler beim Update aufgetreten'); if (! $coodle_help->saveTermin(false)) $message .= "" . $p->t('global/fehlerBeimSpeichernDerDaten') . "
"; else $saveOk = true; $coodle_status = new coodle(); $coodle_status->load($coodle_id); $coodle_status->coodle_status_kurzbz = 'abgeschlossen'; $coodle_status->new = false; $coodle_status->save(); sendEmail($coodle_id); if ($coodle_help->datum < RES_TAGE_LEKTOR_BIS) { // Raum reservieren $coodle_raum = new coodle(); $coodle_raum->getRaumeFromId($coodle_id); // Ende Uhrzeit berechnen $date = new DateTime($coodle_help->datum . ' ' . $coodle_help->uhrzeit); $interval = new DateInterval('PT' . $coodle->dauer . 'M'); $date->add($interval); $uhrzeit_ende = $date->format('H:i:s'); foreach ($coodle_raum->result as $raum) { $stunde = new stunde(); $stunden = $stunde->getStunden($coodle_help->uhrzeit, $uhrzeit_ende); // Pruefen ob der Raum frei ist if (! RaumBelegt($raum->ort_kurzbz, $coodle_help->datum, $stunden)) { $reservierung_error = false; // Stunden reservieren foreach ($stunden as $stunde) { $raum_reservierung = new reservierung(); $raum_reservierung->studiengang_kz = '0'; $raum_reservierung->uid = $uid; $raum_reservierung->ort_kurzbz = $raum->ort_kurzbz; $raum_reservierung->datum = $coodle_help->datum; $raum_reservierung->stunde = $stunde; $raum_reservierung->titel = mb_substr($coodle->titel, 0, 10); $raum_reservierung->beschreibung = mb_substr($coodle->titel, 0, 32); $raum_reservierung->insertamum = date('Y-m-d H:i:s'); $raum_reservierung->insertvon = $uid; // $message.= "Reserviere $raum->ort_kurzbz Stunde $stunde:"; if (! $raum_reservierung->save(true)) $reservierung_error = true; } $message .= $p->t('coodle/raumErfolgreichReserviert', array( $raum->ort_kurzbz )) . '
'; } else { $message .= '' . $p->t('coodle/raumBelegt', array( $raum->ort_kurzbz )) . '
'; } } } else { $message .= '' . $p->t('coodle/raumNichtReserviert', array( $datum_obj->formatDatum(RES_TAGE_LEKTOR_BIS, 'd.m.Y') )) . '
'; } } } else $message .= '' . $p - t('global/keineBerechtigung') . ''; } $coodle->load($coodle_id); if ($coodle->coodle_status_kurzbz == 'abgeschlossen') $abgeschlossen = true; if (isset($_GET['resend'])) { if ($ersteller && $abgeschlossen) sendEmail($coodle_id); } ?> <?php echo $p->t('coodle/terminauswahl');?> ' . $p->t('coodle/coodle') . ''; if (! isset($_GET['zugangscode'])) echo "<< " . $p->t('coodle/zurueckZurUebersicht') . ""; echo '

'; echo '
'; $coodle_help = new coodle(); $coodle_help->load($coodle_id); $alt = strtotime($coodle_help->insertamum); $differenz = time() - $alt; $differenz = $differenz / 86400; $benutzer = new benutzer(); $benutzer->load($coodle->ersteller_uid); // $ersteller_name = trim($benutzer->titelpre.' '.$benutzer->vorname.' '.$benutzer->nachname.' '.$benutzer->titelpost); $ersteller_name = trim($benutzer->vorname . ' ' . $benutzer->nachname); echo '

' . $coodle->titel . '

'; $erstellt = array( $ersteller_name, round($differenz) ); echo '' . $p->t('coodle/erstelltVon', $erstellt) . '
'; echo '' . $p->t('coodle/dauer') . ': ' . $coodle->dauer . ' min.

'; echo $coodle->beschreibung; echo '
'; if ($abgeschlossen) { $datum = new datum(); $coodle_abgeschlossen = new coodle(); $termin_id = $coodle_abgeschlossen->getTerminAuswahl($coodle_id); $coodle_abgeschlossen->loadTermin($termin_id); echo '

' . $p->t('coodle/umfrageAbgeschlossen', array( $datum->formatDatum($coodle_abgeschlossen->datum, 'd.m.Y') . ' ' . $coodle_abgeschlossen->uhrzeit )) . '
'; } echo '

'; $coodle_ressourcen = new coodle(); $coodle_ressourcen->getRessourcen($coodle_id); // alle termine der coodle umfrage holen $coodle_termine = new coodle(); $coodle_termine->getTermine($coodle_id); $datum = new datum(); $datum_colspan = ''; $mailadressen = '?subject=Coodle%20Umfrage%20' . htmlspecialchars($coodle->titel) . '&bcc='; echo "
"; // Für Colspan bei Datum $max_colspan = array(); foreach ($coodle_termine->result as $termin) { $max_colspan[] .= $termin->datum; } foreach ($coodle_termine->result as $termin) { $class_auswahl = 'normal'; $time = strtotime($termin->uhrzeit); $coodle_auswahl = new coodle(); // Falls es schon eine Auswahl gibt - hervorheben if ($coodle_auswahl->checkTerminAuswahl($coodle_id, $termin->coodle_termin_id)) $class_auswahl = 'auswahl'; // Colspan für Datum berechnen $count = array_count_values($max_colspan); $colspan = $count[$termin->datum]; if ($datum_colspan != $termin->datum && $termin->datum != '1900-01-01') echo ""; $datum_colspan = $termin->datum; } if ($ersteller) echo ''; echo ""; foreach ($coodle_termine->result as $termin) { $class_auswahl = 'normal_uhrzeit'; $time = strtotime($termin->uhrzeit); // Endzeit berechnen $ende = $time + ($coodle->dauer * 60); $coodle_auswahl = new coodle(); // Falls es schon eine Auswahl gibt - hervorheben if ($coodle_auswahl->checkTerminAuswahl($coodle_id, $termin->coodle_termin_id)) $class_auswahl = 'auswahl_uhrzeit'; if ($termin->datum != '1900-01-01') echo ""; else echo ''; } echo ""; foreach ($coodle_ressourcen->result as $ressource) { $name = ''; $benutzer = new benutzer(); // wenn uid gesetzt ist nimm uid if ($ressource->uid != '') { $benutzer->load($ressource->uid); // $name .= ($benutzer->titelpre!='')?$benutzer->titelpre.' ':''; $name .= $benutzer->vorname . ' '; $name .= $benutzer->nachname . ' '; // $name .= $benutzer->titelpost; $mailadressen .= $ressource->uid . '@' . DOMAIN . ';'; $ressource->anzeigename = $name; $ressource->vorname = $benutzer->vorname; $ressource->nachname = $benutzer->nachname; } // wenn uid nicht gesetzt ist nimm zugangscode if ($ressource->zugangscode != '' && $ressource->uid == '') { $name = $ressource->name; $ressource->anzeigename = $name; $ressource->vorname = $name; $ressource->nachname = $name; $mailadressen .= ';' . $ressource->email; } } // Sortiert die Ressourcen alphabetisch nach anzeigename function sortRessourcen($a, $b) { return strcmp($a->nachname . '' . $a->vorname, $b->nachname . '' . $b->vorname); } usort($coodle_ressourcen->result, "sortRessourcen"); $owner = false; // ressourcen durchlaufen foreach ($coodle_ressourcen->result as $ressource) { $owner = false; // Ist der User ident mit einer Ressource if (isset($_GET['zugangscode']) && $_GET['zugangscode'] == $ressource->zugangscode) $owner = true; if (! isset($_GET['zugangscode']) && $ressource->uid == $uid) $owner = true; if ($coodle_help->teilnehmer_anonym && ! $owner) continue; else { // Ort-Ressourcen ueberspringen if ($ressource->ort_kurzbz != '') continue; $class = 'normal'; // eigene Reihe farbig hervorheben if ($owner) $class = 'owner'; // Bei anonymen TeilnehmerInnen entfaellt das Hervorheben if ($coodle_help->teilnehmer_anonym) $class = 'normal'; echo ""; $termin_datum = ''; $disabled = false; $checked = false; $coodle_ressource = new coodle(); if (isset($_GET['zugangscode'])) { $coodle_ressource->getRessourceFromUser($coodle_id, '', $_GET['zugangscode']); if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) $disabled = true; } else { $coodle_ressource->getRessourceFromUser($coodle_id, $uid); if ($ressource->coodle_ressource_id != $coodle_ressource->coodle_ressource_id) $disabled = true; } if ($abgeschlossen) $disabled = true; // termine zu ressourcen anzeigen foreach ($coodle_termine->result as $termin) { $checked = false; $style = ''; if ($coodle_termine->checkTermin($termin->coodle_termin_id, $ressource->coodle_ressource_id)) $checked = true; if ($termin_datum != '' && $termin_datum != $termin->datum) $style = 'style="border-left: 1px solid #DCDDDF;"'; if ($coodle_help->termine_anonym && ! $owner && ! $ersteller) echo ""; else { if ($disabled) { if ($checked) echo ''; else echo ''; } else { // Der 01.01.1900 wird fuer "Keine Auswahl" verwendet. Beim anklicken der Checkbox werden alle anderen Checkboxen deaktiviert echo ''; } } $termin_datum = $termin->datum; } if ($ersteller) echo ""; echo ''; } } $disabled = $abgeschlossen ? 'disabled' : ''; // Counter fuer Anzahl der Auswahlen pro Termin $counter_arr = array(); foreach ($coodle_termine->result as $termin) { $countTermine = new coodle(); $countTermine->countTermin($termin->coodle_termin_id); $counter_arr[] = $countTermine->anzahl; } if ($coodle_help->teilnehmer_anonym) echo ''; elseif ($coodle_help->termine_anonym) echo ''; echo ''; foreach ($coodle_termine->result as $termin) { $countTermine = new coodle(); $countTermine->countTermin($termin->coodle_termin_id); if ($countTermine->anzahl == max($counter_arr)) echo ''; else echo ''; } if ($ersteller) echo ''; echo ""; if ($ersteller) { // buttons für auswahl des endgültigen termins echo ''; foreach ($coodle_termine->result as $termin) { $checked = ($termin->auswahl) ? 'checked' : ''; if ($termin->datum != '1900-01-01') echo ''; else echo ''; } echo ''; echo ""; } if ($ersteller && $abgeschlossen) echo ' '; echo '
" . $datum->formatDatum($termin->datum, 'd.m.Y') . "
" . date('H:i', $time) . " -
" . date('H:i', $ende) . "  
' . $p->t('coodle/keinTerminMoeglich') . '
" . $ressource->anzeigename . " datum == '1900-01-01' ? 'id="disableCheckboxes"' : '') . ' name="check_' . $ressource->coodle_ressource_id . '_' . $termin->coodle_termin_id . '">
Die TeilnehmerInnen dieser Umfrage sind anonym
Die Terminwahl dieser Umfrage erfolgt anonym
Summe der Einträge' . $p->t('coodle/keineAuswahl') . '
' . $p->t('coodle/auswahlEndtermin') . '
Mail an alle schicken
'; if ($ersteller && $abgeschlossen) echo ''; if ($saveOk === true) echo '
' . $p->t('global/erfolgreichgespeichert') . '
'; echo "
" . $message . '
' . $mailMessage; ?>
load($coodle_id)) { die("Fehler beim senden aufgetreten"); } $mitarbeiter = new mitarbeiter(); $person = new person(); $teilnehmer = new coodle(); $teilnehmer->getRessourceFromId($teilnehmer_id); if ($teilnehmer->zugangscode != '') $tn = $teilnehmer->name; else { $mitarbeiter->load($teilnehmer->uid); $person->load($mitarbeiter->person_id); $tn = $person->vorname . " " . $person->nachname; } $mitarbeiter->load($coodle_send->ersteller_uid); $person->load($mitarbeiter->person_id); $email = ''; $name = ''; $name .= ($person->titelpre != '') ? $person->titelpre . ' ' : ''; $name .= $person->vorname . ' ' . $person->nachname; $name .= ($person->titelpost != '') ? ' ' . $person->titelpost : ''; if ($person->geschlecht == 'w') $email .= 'Sehr geehrte Frau ' . $name . "!

"; else $email .= "Sehr geehrter Herr " . $name . "!

"; $link = APP_ROOT . 'cis/public/coodle.php?coodle_id=' . urlencode($coodle_id) . '&uid=' . urlencode($uid); $email .= $tn . ' hat einen Termin zu Ihrer Coodle-Umfrage mit dem Thema "' . $coodle->titel . '" ausgewählt.
Link zu Ihrer Coodle Umfrage

Mit freundlichen Grüßen

Fachhochschule Technikum Wien
Höchstädtplatz 6
1200 Wien'; $mail = new mail($coodle_send->ersteller_uid . '@' . DOMAIN, 'no-reply', 'Feedback zu Ihrer Coodle Umfrage "' . $coodle->titel . '"', 'Bitte sehen Sie sich die Nachricht in HTML Sicht an, um den Link vollständig darzustellen.'); $mail->setHTMLContent($email); if (! $mail->send()) die("Fehler beim senden des Mails aufgetreten"); } /** * Funktion sendet den ausgewählten Termin an alle Ressourcen aus der übergebenen Coodleumfrage * * @global phrasen $p * @param type $coodle_id * @param type $auswahl */ function sendEmail($coodle_id) { global $mailMessage; global $p; $coodle_help = new coodle(); $termin_id = $coodle_help->getTerminAuswahl($coodle_id); $coodle_help->loadTermin($termin_id); $coodle_ressource = new coodle(); $coodle_ressource->getRessourcen($coodle_id); $coodle = new coodle(); $coodle->load($coodle_id); $ort = ''; $teilnehmer = ''; foreach ($coodle_ressource->result as $row) { if ($row->ort_kurzbz != '') { if ($ort != '') $ort .= ', '; $ort .= "$row->ort_kurzbz"; } else { if ($row->uid != '') { $benutzer = new benutzer(); $benutzer->load($row->uid); $name = trim($benutzer->titelpre . ' ' . $benutzer->vorname . ' ' . $benutzer->nachname . ' ' . $benutzer->titelpost); $mail = $row->uid . '@' . DOMAIN; } else { $mail = $row->email; $name = $row->name; } $coodle_ressource_termin = new coodle(); $partstat = ''; if ($coodle_ressource_termin->checkTermin($termin_id, $row->coodle_ressource_id)) $partstat = 'ACCEPTED'; else $partstat = 'TENTATIVE'; $teilnehmer .= 'ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=' . $partstat . ';CN=' . $name . "\n :MAILTO:" . $mail . "\n"; } } $date = new DateTime($coodle_help->datum . ' ' . $coodle_help->uhrzeit); // Datum des Termins ins richtige Format bringen $dtstart = $date->format('Ymd\THis'); // Ende Datum berechnen $interval = new DateInterval('PT' . $coodle->dauer . 'M'); $date->add($interval); $dtend = $date->format('Ymd\THis'); $date = new DateTime(); $dtstamp = $date->format('Ymd\THis'); $benutzer = new benutzer(); $benutzer->load($coodle->ersteller_uid); $erstellername = trim($benutzer->titelpre . ' ' . $benutzer->vorname . ' ' . $benutzer->nachname . ' ' . $benutzer->titelpost); // Ical File erstellen $ical = "BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN VERSION:2.0 METHOD:PUBLISH BEGIN:VTIMEZONE TZID:Europe/Vienna BEGIN:DAYLIGHT TZOFFSETFROM:+0100 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU DTSTART:19810329T020000 TZNAME:GMT+02:00 TZOFFSETTO:+0200 END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:+0200 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU DTSTART:19961027T030000 TZNAME:GMT+01:00 TZOFFSETTO:+0100 END:STANDARD END:VTIMEZONE BEGIN:VEVENT ORGANIZER:MAILTO:" . $erstellername . " <" . $coodle->ersteller_uid . "@" . DOMAIN . " " . $teilnehmer . " DTSTART;TZID=Europe/Vienna:" . $dtstart . " DTEND;TZID=Europe/Vienna:" . $dtend . " LOCATION:" . $ort . " TRANSP:OPAQUE SEQUENCE:0 UID:FHCompleteCoodle" . $coodle_id . " DTSTAMP;TZID=Europe/Vienna:" . $dtstamp . " DESCRIPTION:" . strip_tags(html_entity_decode($coodle->beschreibung, ENT_QUOTES, 'UTF-8')) . " SUMMARY:" . strip_tags($coodle->titel) . " PRIORITY:5 CLASS:PUBLIC END:VEVENT END:VCALENDAR"; if (count($coodle_ressource->result) > 0) { foreach ($coodle_ressource->result as $row) { if ($row->uid != '') { $benutzer = new benutzer(); if (! $benutzer->load($row->uid)) { $mailMessage .= "Fehler beim Laden des Benutzers " . $coodle_ressource->convert_html_chars($row->uid); continue; } if ($benutzer->geschlecht == 'w') $anrede = "Sehr geehrte Frau "; else $anrede = "Sehr geehrter Herr "; $anrede .= $benutzer->titelpre . ' ' . $benutzer->vorname . ' ' . $benutzer->nachname . ' ' . $benutzer->titelpost; // Interner Teilnehmer $email = $row->uid . '@' . DOMAIN; } elseif ($row->email != '') { // Externe Teilnehmer $email = $row->email; $anrede = 'Sehr geehrte(r) Herr/Frau ' . $row->name; } else { // Raueme bekommen kein Mail continue; } $anrede = trim($anrede); $sign = $p->t('mail/signatur'); $datum = new datum(); $html = $anrede . '!

Die Terminumfrage zum Thema "' . $coodle_ressource->convert_html_chars($coodle->titel) . '" ist beendet.
Der Termin wurde auf den ' . $datum->formatDatum($coodle_help->datum, 'd.m.Y') . ' ' . $coodle_help->uhrzeit . ' festgelegt.

' . nl2br($sign); $text = $anrede . "!\n\nDie Terminumfrage zum Thema \"" . $coodle_help->convert_html_chars($coodle->titel) . '"\" ist beendet.\n Der Termin wurde auf den ' . $datum->formatDatum($coodle_help->datum, 'd.m.Y') . ' ' . $coodle_help->uhrzeit . " festgelegt\n. \n\n$sign"; $mail = new mail($email, 'no-reply@' . DOMAIN, 'Terminbestätigung - ' . $coodle->titel, $text); $mail->setHTMLContent($html); // ICal Termineinladung hinzufuegen $mail->addAttachmentPlain($ical, 'text/calendar', 'meeting.ics'); if ($mail->send()) { $mailMessage .= $p->t('coodle/mailVersandtAn', array( $email )) . "
"; } } } else { die($p->t('coodle/keineRessourcenVorhanden')); } } /** * * Prueft ob ein Raum belegt ist * * @param $ort_kurzbz * @param $datum * @param array $stunden */ function RaumBelegt($ort_kurzbz, $datum, $stunden) { foreach ($stunden as $stunde) { // Reservierungen pruefen $raum_reservierung = new reservierung(); if ($raum_reservierung->isReserviert($ort_kurzbz, $datum, $stunde)) { return true; } // Stundenplan abfragen $stundenplan = new stundenplan('stundenplan'); if ($stundenplan->isBelegt($ort_kurzbz, $datum, $stunde)) { return true; } // Stundenplan DEV abfragen $stundenplan = new stundenplan('stundenplandev'); if ($stundenplan->isBelegt($ort_kurzbz, $datum, $stunde)) { return true; } } return false; } ?>