Files
cwsvJudo/homepage/redesign2018/markdownExperiment/wkParticipo/lib/wkParticipoLib.inc.php
marko cba6521dc2 eventTermine in der Wettkampfplanung im MaterialDesign (in laufender Entwicklung)
geändert:       phpLib/cwsvJudo/wkKalender.php
	neue Datei:     wkParticipo/index.php
	neue Datei:     wkParticipo/lib/wkParticipoLib.inc.php
	neue Datei:     wkParticipo/wkParticipo.css
2018-07-22 06:52:52 +02:00

1261 lines
42 KiB
PHP

<?php
$startTyp = array( '1' => "Kämpfer", '2' => "Zuschauer", '3' => "keine Teilnahme" );
function getEventsStarterData($anMysqlConn, $anEventId){
$ret = array();
if( (string)(int)$anEventId != $anEventId ) return $ret;
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wkParticipo_Starter.id, ".
"wkParticipo_Starter.eventId, ".
"wkParticipo_Starter.userId, ".
"wkParticipo_Starter.fahrtId, ".
"wkParticipo_Starter.masse, ".
"wkParticipo_Starter.platz, ".
"wkParticipo_Users.id, ".
"wkParticipo_Users.vorname, ".
"wkParticipo_Users.name, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.bemerkungen, ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Routenplaner ".
"FROM wkParticipo_Starter ".
"JOIN wkParticipo_Users ON wkParticipo_Users.id = wkParticipo_Starter.userId ".
"JOIN wkParticipo_Events ON wkParticipo_Events.id = wkParticipo_Starter.eventId ".
"JOIN wettkampfkalender ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"WHERE wkParticipo_Events.id = '%s';",
$anMysqlConn->real_escape_string($anEventId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getStarterForEvent($anMysqlConn, $anEventId){
if( (string)(int)$anEventId == $anEventId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE eventId='%s';",
$anMysqlConn->real_escape_string($anEventId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
}
return $ret;
}
function getKaempferForEvent($anMysqlConn, $anEventId){
if( (string)(int)$anEventId == $anEventId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE eventId='%s' AND type='%s';",
$anMysqlConn->real_escape_string($anEventId),
$anMysqlConn->real_escape_string("1")
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
}
return $ret;
}
function getZuschauerForEvent($anMysqlConn, $anEventId){
if( (string)(int)$anEventId == $anEventId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE eventId='%s' AND type='%s';",
$anMysqlConn->real_escape_string($anEventId),
$anMysqlConn->real_escape_string("2")
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
}
return $ret;
}
function getFahrtenForEvent($anMysqlConn, $anEventId){
$ret = array();
if( (string)(int)$anEventId != $anEventId ) return $ret;
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wkParticipo_Fahrten.id, ".
"wkParticipo_Fahrten.eventId, ".
"wkParticipo_Fahrten.fahrerId, ".
"wkParticipo_Fahrten.plaetze, ".
"wkParticipo_Fahrten.mitfahrer, ".
"wkParticipo_Users.vorname, ".
"wkParticipo_Users.name ".
"FROM wkParticipo_Fahrten ".
"JOIN wkParticipo_Users ON wkParticipo_Users.id = wkParticipo_Fahrten.fahrerId ".
"WHERE wkParticipo_Fahrten.eventId = '%s';",
$anMysqlConn->real_escape_string($anEventId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
if( (string)(int)$anEventId == $anEventId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Fahrten WHERE eventId='%s';",
$anMysqlConn->real_escape_string($anEventId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
}
return $ret;
}
function getMitfahrer($anMysqlConn, $anFahrtId){
$ret = array();
$fahrt = getFahrtData($anMysqlConn, $anFahrtId);
$mitfahrerIds = array();
if( !empty($fahrt['mitfahrer']) )
$mitfahrerIds = explode(',', $fahrt['mitfahrer']);
foreach($mitfahrerIds as $mitfahrerId){
$starter = getStarterData($anMysqlConn, $mitfahrerId);
$user = getUserData($anMysqlConn, $starter['userId']);
array_push($ret, $user);
}
return $ret;
}
function getUsers($anMysqlConn){
$ret = array();
$query = sprintf(
"SELECT * FROM wkParticipo_Users;"
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getUsersStarts($anMysqlConn, $anUserId){
if( (string)(int)$anUserId == $anUserId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE userId='%s';",
$anMysqlConn->real_escape_string($anUserId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
}
return $ret;
}
function getUsersFahrten($anMysqlConn, $anUserId){
if( (string)(int)$anUserId == $anUserId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Fahrten WHERE fahrerId='%s';",
$anMysqlConn->real_escape_string($anUserId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
}
return $ret;
}
function getUsersWk($anMysqlConn, $anUserId){
$ret = array();
if( (string)(int)$anUserId == $anUserId ){
$starts = getUsersStarts($anMysqlConn, $anUserId);
foreach( $starts as $start){
$query = sprintf(
"SELECT * FROM wkParticipo_Events WHERE id='%s';",
$anMysqlConn->real_escape_string($start['eventId'])
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() ){
array_push( $ret, getWkData($anMysqlConn, $result['wkId']));
}
}
}
return $ret;
}
function getUserData($anMysqlConn, $anUserId){
$ret = array();
if( (string)(int)$anUserId == $anUserId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Users WHERE id='%s';",
$anMysqlConn->real_escape_string($anUserId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = $results->fetch_assoc();
}
return $ret;
}
function getStarterData($anMysqlConn, $anStarterId){
$ret = array();
if( (string)(int)$anStarterId == $anStarterId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE id='%s';",
$anMysqlConn->real_escape_string($anStarterId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = $results->fetch_assoc();
}
return $ret;
}
function getFahrtData($anMysqlConn, $anFahrtId){
$ret = array();
if( (string)(int)$anFahrtId == $anFahrtId ){
$query = sprintf(
"SELECT * FROM wkParticipo_Fahrten WHERE id='%s';",
$anMysqlConn->real_escape_string($anFahrtId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = $results->fetch_assoc();
}
return $ret;
}
function getEventData($anMysqlConn, $anEventId){
$ret = array();
if( (string)(int)$anEventId != $anEventId ) return $ret;
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.bemerkungen, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Ausschreibung, ".
"wettkampfkalender.Routenplaner ".
"FROM wkParticipo_Events ".
"JOIN wettkampfkalender ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"WHERE wkParticipo_Events.id = '%s';",
$anMysqlConn->real_escape_string($anEventId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
/// @ToDo: Anzahl Ergebnise auf ==1 testen
$ret = $results->fetch_assoc();
return $ret;
}
/// Daten eines einzelnen wkEvents via eventId abfragen
///
/// Ein wkEvent ist ein Event (welches nur die ID des Wettkampfes im
/// Wettkampfkalender enthält) erweitert um die Daten des Wettkampfes
/// selber.
/// Der Rückgabewert sollte vor Verwendung (und zur Fehlerbeheandlung)
/// auf NULL und/oder leeres Array getestet werden.
///
function getWkEventData($anMysqlConn, $anEventId){
$ret = array();
if( (string)(int)$anEventId != $anEventId ) return $ret;
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.bemerkungen, ".
"wkParticipo_Events.kvOptions, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Ausschreibung, ".
"wettkampfkalender.Routenplaner ".
"FROM wkParticipo_Events ".
"JOIN wettkampfkalender ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"WHERE wkParticipo_Events.id = '%s';",
$anMysqlConn->real_escape_string($anEventId)
);
$results = $anMysqlConn->query($query);
// if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n"); // Für eine detailierte Fehlermeldung zum Debuggen
if( !$results ) return NULL; // Bei einem Fehler bei der Abfrage soll NULL zurückgeliefert werden
// Da wir über den Primary Key abfragen, wird maximal ein Ergebnis geliefert
$ret = $results->fetch_assoc();
// Bei einem leeren Ergebnis (NULL oder leeres Array) soll ein leeres Array zurückgeliefert werden
if( empty($ret) ) return array();
array_walk(
$ret,
function (&$entry) {
$entry = iconv("ISO-8859-1", "UTF-8", $entry);
}
);
return $ret;
}
/// Daten aller kommenden wkEvents abfragen
///
/// Ein wkEvent ist ein Event (welches nur die ID des Wettkampfes im
/// Wettkampfkalender enthält) erweitert um die Daten des Wettkampfes
/// selber.
/// Der Rückgabewert sollte vor Verwendung (und zur Fehlerbeheandlung)
/// auf NULL und/oder leeres Array getestet werden.
///
function getCommingWkEvents($anMysqlConn){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.bemerkungen, ".
"wkParticipo_Events.kvOptions, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Ausschreibung, ".
"wettkampfkalender.Routenplaner ".
"FROM wkParticipo_Events ".
"JOIN wettkampfkalender ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"WHERE wettkampfkalender.Datum >= CURDATE() ".
"ORDER BY wettkampfkalender.Datum;"
);
// echo($query);die();
$results = $anMysqlConn->query($query);
// Bei einem Fehler bei der Abfrage soll NULL zurückgeliefert werden
if( !$results ){
echo("No Results: ".$anMysqlConn->error);
return NULL;
}
// Bei einem leeren Ergebnis (NULL oder leeres Array) soll ein leeres Array zurückgeliefert werden
if( empty($results) ) return array();
while( $result = $results->fetch_assoc() ){
array_walk(
$result,
function (&$entry) {
$entry = iconv("ISO-8859-1", "UTF-8", $entry);
}
);
array_push( $ret, $result);
}
//echo("Results: "); print_r($ret);
return $ret;
}
/// Abfrage der Daten eines Wettkampfes via ID
/// Da über den primary key abgefragt wird, erfolgt keine Kontrolle, ob
/// nur ein Ergebnis geliefert wurde
function getWkData($anMysqlConn, $anWkId){
$query = sprintf(
"SELECT * FROM wettkampfkalender WHERE lfdeNr='%s';",
$anMysqlConn->real_escape_string($anWkId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = $results->fetch_assoc();
return $ret;
}
function getAllEvents($anMysqlConn){
$query = sprintf( "SELECT * FROM wkParticipo_Events ORDER BY meldefrist DESC;" );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
/// Alle Userdaten abfragen
function getAllUsers($anMysqlConn){
$query = sprintf( "SELECT * FROM wkParticipo_Users;" );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getThisWeeksMeldefristen($anMysqlConn){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.wkId ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"WHERE wkParticipo_Events.meldefrist <= DATE_ADD(CURDATE(), INTERVAL 1 WEEK) AND wkParticipo_Events.meldefrist >= CURDATE() ".
"ORDER BY wkParticipo_Events.meldefrist;" );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
/// Zukünftige Wettkämpfe abfragen
function getCommingWk($anMysqlConn){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT lfdeNr, Datum, Veranstaltung, Altersklassen ".
"FROM wettkampfkalender ".
"WHERE wettkampfkalender.Datum >= CURDATE() ".
"ORDER BY wettkampfkalender.Datum ASC;"
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getStarterInfo($anMysqlConn, $anStarterId){
$ret = array();
if( (string)(int)$anStarterId != $anStarterId ) return $ret;
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Starter.id, ".
"wkParticipo_Starter.eventId, ".
"wkParticipo_Starter.masse, ".
"wkParticipo_Starter.platz ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"JOIN wkParticipo_Starter ".
"ON wkParticipo_Starter.eventId = wkParticipo_Events.id ".
"WHERE wkParticipo_Starter.id = '%s';",
$anMysqlConn->real_escape_string($anStarterId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getCommingFahrten($anMysqlConn){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Fahrten.id, ".
"wkParticipo_Fahrten.eventId, ".
"wkParticipo_Fahrten.FahrerId, ".
"wkParticipo_Fahrten.plaetze, ".
"wkParticipo_Fahrten.mitfahrer ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"JOIN wkParticipo_Fahrten ".
"ON wkParticipo_Events.id = wkParticipo_Fahrten.eventId ".
"WHERE wettkampfkalender.Datum >= CURDATE() ".
"ORDER BY wettkampfkalender.Datum;" );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getUsersCommingFahrten($anMysqlConn, $anUserId){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Routenplaner, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Fahrten.id, ".
"wkParticipo_Fahrten.eventId, ".
"wkParticipo_Fahrten.FahrerId, ".
"wkParticipo_Fahrten.plaetze, ".
"wkParticipo_Fahrten.mitfahrer ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"JOIN wkParticipo_Fahrten ".
"ON wkParticipo_Events.id = wkParticipo_Fahrten.eventId ".
"WHERE wettkampfkalender.Datum >= CURDATE() AND wkParticipo_Fahrten.FahrerId = '%s' ".
"ORDER BY wettkampfkalender.Datum;",
$anMysqlConn->real_escape_string($anUserId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getUsersCommingWkEvents($anMysqlConn, $anUserId, $someOptions=array() ){
// wir befinden uns in der Übergangsphase:
// - als Standard wird das derzeitige Verhalten definiert (ISO-8859-1
// und die Konvertierung erfolgt ausserhalb)
// - wenn einmal alle mbConvertEncoding weg sind, kann der Standard auf
// das gewünschte Verhalten umgestellt werden
if( empty($optionsArray['dbCharset']) ) $optionsArray['dbCharset'] = "ISO-8859-1";
//if( empty($optionsArray['outCharset']) ) $optionsArray['outCharset'] = "UTF-8";// das spätere, gewünschte Verhalten
if( empty($optionsArray['outCharset']) ) $optionsArray['outCharset'] = "ISO-8859-1";
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Routenplaner, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Starter.id, ".
"wkParticipo_Starter.eventId, ".
"wkParticipo_Starter.type ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"JOIN wkParticipo_Starter ".
"ON wkParticipo_Starter.eventId = wkParticipo_Events.id ".
"WHERE wettkampfkalender.Datum >= CURDATE() AND wkParticipo_Starter.userId = '%s' ".
"ORDER BY wettkampfkalender.Datum;",
$anMysqlConn->real_escape_string($anUserId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
// Zeichensatzkonvertierung
foreach($ret as &$entry){
array_walk(
$entry,
function (&$value, $key, $optionsArray) {
$value = iconv($optionsArray['dbCharset'], $optionsArray['outCharset'], $value);
},
$optionsArray
);
}
return $ret;
}
function getUsersWkEvents($anMysqlConn, $anUserId){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Routenplaner, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Starter.id, ".
"wkParticipo_Starter.eventId ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"JOIN wkParticipo_Starter ".
"ON wkParticipo_Starter.eventId = wkParticipo_Events.id ".
// "WHERE wettkampfkalender.Datum >= CURDATE() AND wkParticipo_Starter.userId = '%s' ".
"WHERE wkParticipo_Starter.userId = '%s' ".
"ORDER BY wettkampfkalender.Datum;",
$anMysqlConn->real_escape_string($anUserId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getUsersErgebnisse($anMysqlConn, $anUserId){
$ret = array();
$anMysqlConn->query("USE cwsvjudo;");
$query = sprintf(
"SELECT ".
"wettkampfkalender.lfdeNr, ".
"wettkampfkalender.Datum, ".
"wettkampfkalender.Veranstaltung, ".
"wettkampfkalender.Altersklassen, ".
"wettkampfkalender.Ort, ".
"wettkampfkalender.Routenplaner, ".
"wkParticipo_Events.id, ".
"wkParticipo_Events.meldefrist, ".
"wkParticipo_Events.wkId, ".
"wkParticipo_Starter.id, ".
"wkParticipo_Starter.eventId ,".
"wkParticipo_Starter.masse ,".
"wkParticipo_Starter.platz ".
"FROM wettkampfkalender ".
"JOIN wkParticipo_Events ".
"ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ".
"JOIN wkParticipo_Starter ".
"ON wkParticipo_Starter.eventId = wkParticipo_Events.id ".
"WHERE wettkampfkalender.Datum <= CURDATE() AND wkParticipo_Starter.userId = '%s' ".
"ORDER BY wettkampfkalender.Datum;",
$anMysqlConn->real_escape_string($anUserId) );
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getUsersMeldungen($anMysqlConn, $anUserId){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE userId='%s';",
$anMysqlConn->real_escape_string($anUserId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return $ret;
}
function getUsersMeldeStatus($anMysqlConn, $anEventId, $anUserId){
$query = sprintf(
"SELECT * FROM wkParticipo_Starter WHERE eventId='%s' AND userId='%s';",
$anMysqlConn->real_escape_string($anEventId),
$anMysqlConn->real_escape_string($anUserId)
);
$results = $anMysqlConn->query($query);
if( !$results ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$ret = array();
while( $result = $results->fetch_assoc() )
array_push( $ret, $result);
return !empty($ret);
}
function doMeldung($anMysqlConn, $anEventId, $anUserId){
if(
!in_array(
$anUserId,
explode(',', getUserData($mysqli, $_SESSION['user']['userId'])['kinder'])
)
) return "Sie dürfen diesen Starter nicht melden!";
$query = sprintf(
"SELECT id FROM wkParticipo_Starter WHERE eventId='%s' AND userId='%s';",
$mysqli->real_escape_string($_POST['f']['eventId']),
$mysqli->real_escape_string($_POST['f']['userId'])
);
$starterResults = $mysqli->query($query);
if( !$starterResults ) die("ERR: Fehler bei Datenbankabfrage (".$query.")!\n");
$starterResult = $starterResults->fetch_array();
if( $mysqli->affected_rows >= 1 )
return "ERR: Offenbar bereits gemeldet!";
$query = sprintf(
"INSERT INTO wkParticipo_Starter (eventId, userId) values (%s, %s);",
$mysqli->real_escape_string($_POST['f']['eventId']),
$mysqli->real_escape_string($_POST['f']['userId'])
);
$result = $mysqli->query($query);
if(!$result){
echo "Fehler bei der Meldung: " . mysql_error(); die();
}
$message['success'] =
"Neuer Starter userId " . $_POST['f']['userId'] . " für eventId " . $_POST['f']['eventId'];
return true;
}
function verteileMitfahrer($anMysqlConn, $anEventId){
$retMessage = array();
if( (string)(int)$anEventId == $anEventId ){
$starterData = getStarterForEvent($anMysqlConn, $anEventId);
$fahrtenData = getFahrtenForEvent($anMysqlConn, $anEventId);
// Bereits zugeordnete Starter ignorieren
// kontrollieren, ob der Starter auch wirklich in der Fahrt eingetragen ist
foreach( $starterData as $key => $starter ){
if( !empty($starter['fahrtId']) ){
$fahrt = getFahrtData($anMysqlConn, $starter['fahrtId']);
$mitfahrerIds = array();
if( !empty($fahrt['mitfahrer']) )
$mitfahrerIds = explode(',', $fahrt['mitfahrer']);
if( in_array($starter['id'], $mitfahrerIds) )
unset($starterData[$key]);
else{
// Sollte die Fahrt beim Starter eingetragen sein, aber nicht bei der Fahrt als Mitfahrer, lösche sie
$query = sprintf(
"UPDATE wkParticipo_Starter SET fahrtId='%s' WHERE id='%s';",
$anMysqlConn->real_escape_string( "" ),
$anMysqlConn->real_escape_string( $starter['id'] )
);
$result = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows != 1){
$retMessage['error'] .= "Fehler beim Ausführen des sqlRequestes \"".$query."\"\n";
return $retMessage;
}
}
}
}
foreach( $fahrtenData as $key => $fahrt ){
$mitfahrerIds = array();
if( !empty($fahrt['mitfahrer']) )
$mitfahrerIds = explode(',', $fahrt['mitfahrer']);
// Überbelegte Fahrten trimmen
while( count($mitfahrerIds) > (int)$fahrt['plaetze'] ){
$starterId = array_pop($mitfahrerIds);
$query = sprintf(
"UPDATE wkParticipo_Starter SET fahrtId='%s' WHERE id='%s';",
$anMysqlConn->real_escape_string( "" ),
$anMysqlConn->real_escape_string( $starterId )
);
$result = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows != 1){
$retMessage['error'] .= "verteileMitfahrer: Fehler beim Ausführen des sqlRequestes \"".$query."\", Fahrt: ".$fahrt['id']." Plätze: ".$fahrt['plaetze'].", Mitfahrer: ".implode('|', $mitfahrerIds)."<br />";
return $retMessage;
}
array_push($starterData, getStarterData($anMysqlConn, $starterId) );
}
$query = sprintf(
"UPDATE wkParticipo_Fahrten SET mitfahrer='%s' WHERE id='%s';",
$anMysqlConn->real_escape_string( empty($mitfahrerIds) ? "" : implode(',', $mitfahrerIds) ),
$anMysqlConn->real_escape_string( $fahrt['id'] )
);
$result = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows > 1){
$retMessage['error'] .= "verteileMittfahrer: Fehler beim Ausführen des sqlRequestes \"".$query."\"\n";
return $retMessage;
}
// volle Fahrten entfernen
if( count($mitfahrerIds) >= (int)$fahrt['plaetze'] ){
unset($fahrtenData[$key]);
}
}
uasort($starterData, function ($a, $b){
return ( (int)$a['id'] < (int)$b['id'] ? 1 : -1 );
});
uasort($fahrtenData, function ($a, $b){
return ( (int)$a['plaetze'] > (int)$b['plaetze'] ? 1 : -1 );
});
while( !empty($starterData) and !empty($fahrtenData) ){
echo "Starter:"; print_r($starterData); echo "\n";
echo "Fahrten:"; print_r($fahrtenData); echo "\n\n";
$fahrt = array_pop($fahrtenData);
$starter = array_pop($starterData);
$tempMessage = addMitfahrerToFahrt($anMysqlConn, $starter['id'], $fahrt['id']);
$retMessage['warning'] .= $tempMessage['warning'];
$retMessage['error'] .= $tempMessage['warning'];
$retMessage['success'] .= $tempMessage['success'];
$fahrt = getFahrtData($anMysqlConn, $fahrt['id']);
$mitfahrerIds = array();
if( !empty($fahrt['mitfahrer']) )
$mitfahrerIds = explode(',', $fahrt['mitfahrer']);
if( count($mitfahrerIds) < (int)$fahrt['plaetze'] ){
array_push( $fahrtenData, $fahrt );
}
}
if( !empty($starterData) )
$retMessage['warning'] .= "Achtung: nicht zugeordnete Starter!<br />";
}
return $retMessage;
}
function reseteMitfahrer($anMysqlConn, $anEventId){
$retMmessage = array();
if( (string)(int)$anEventId != $anEventId ){
$retMessage['error'] .= "Falsch formatierte eventId (".$anEventId.")<br />";
return $retMessage;
}
$query = sprintf(
"UPDATE wkParticipo_Starter SET fahrtId=NULL WHERE eventId='%s'",
$anMysqlConn->real_escape_string( $anEventId )
);
$result = $anMysqlConn->query($query);
if( !$result ){
$retMessage['error'] .= "Fehler beim Ausführen des sqlRequestes \"".$query."\"<br />";
//return $retMessage;
}
$query = sprintf(
"UPDATE wkParticipo_Fahrten SET mitfahrer='%s' WHERE eventId='%s'",
$anMysqlConn->real_escape_string( "" ),
$anMysqlConn->real_escape_string( $anEventId )
);
$result = $anMysqlConn->query($query);
if( !$result ){
$retMessage['error'] .= "Fehler beim Ausführen des sqlRequestes \"".$query."\"<br />";
return $retMessage;
}
return $retMessage;
}
// einem Event einen neuen Starter hinzufügen
/*
function createStarterForEvent($anMysqlConn, $anEventId, $anUserId){
$retMessage = array();
if( (string)(int)$anEventId != $anEventId or (string)(int)$anUserId != $anUserId ){
$retMessage['error'] .= "Falsch formatierte eventId (".$anEventId.") oder userId (".$anUserId.")<br />";
return $retMessage;
}
$event = getEventData($anMysqlConn, $anEventId);
if( empty($event) ){
$retMessage['error'] .= "eventId ".$anEventId." nicht gefunden<br />";
return $retMessage;
}
$user = getUserData($anMysqlConn, $anUserId);
if( empty($event) ){
$retMessage['error'] .= "userId ".$anUserId." nicht gefunden<br />";
return $retMessage;
}
if( getUsersMeldeStatus($anMysqlConn, $anEventId, $anUserId) ){
$retMessage['notice'] .= "userId ".$anUserId." bereits bei eventId ".$anEventId." eingeschrieben<br />";
return $retMessage;
}
$query = sprintf(
"INSERT INTO wkParticipo_Starter (eventId, userId) values (%s, %s);",
$anMysqlConn->real_escape_string($anEventId),
$anMysqlConn->real_escape_string($anUserId)
);
$result = $anMysqlConn->query($query);
if(!$result){
$retMessage['error'] .= "Fehler \"".mysql_error()."\" bei der sqlQuery \"".$query."\"<br />";
return $retMessage;
}
$retMessage['success'] = "Neuer Starter userId " . $anUserId . " für eventId " . $anEventId . " hinzugefügt";
return $retMessage;
}
*/
/// Einen Starter per userId mit typeId zu einem Event per eventId hinzufügen
/// Es erfolgt keine Überprüfung der Meldeberechtigung!
function createStarterForEvent($anMysqlConn, $anEventId, $anUserId, $aTypeId = "1"){
$retMessage = array();
if( (string)(int)$anEventId != $anEventId or (string)(int)$anUserId != $anUserId ){
$retMessage['error'] .= "Falsch formatierte eventId (".$anEventId.") oder userId (".$anUserId.")<br />";
return $retMessage;
}
$event = getEventData($anMysqlConn, $anEventId);
if( empty($event) ){
$retMessage['error'] .= "eventId ".$anEventId." nicht gefunden<br />";
return $retMessage;
}
$user = getUserData($anMysqlConn, $anUserId);
if( empty($event) ){
$retMessage['error'] .= "userId ".$anUserId." nicht gefunden<br />";
return $retMessage;
}
if( getUsersMeldeStatus($anMysqlConn, $anEventId, $anUserId) ){
$retMessage['notice'] .= "userId ".$anUserId." bereits bei eventId ".$anEventId." eingeschrieben<br />";
return $retMessage;
}
$query = sprintf(
"INSERT INTO wkParticipo_Starter (eventId, userId, type) values (%s, %s, %s);",
$anMysqlConn->real_escape_string($anEventId),
$anMysqlConn->real_escape_string($anUserId),
$anMysqlConn->real_escape_string($aTypeId)
);
$result = $anMysqlConn->query($query);
if(!$result){
$retMessage['error'] .= "Fehler \"".mysql_error()."\" bei der sqlQuery \"".$query."\"<br />";
return $retMessage;
}
$retMessage['success'] = "Neuer Starter userId " . $anUserId . " als Typ ".$aTypeId." für eventId " . $anEventId . " hinzugefügt";
return $retMessage;
}
function addMitfahrerToFahrt($anMysqlConn, $anStarterId, $anFahrtId){
$retMmessage = array();
if( (string)(int)$anStarterId != $anStarterId or (string)(int)$anFahrtId != $anFahrtId ){
$retMessage['error'] .= "Falsch formatierte starterId (".$anStartId.") oder fahrtId (".$anFahrtId.")<br />";
return $retMessage;
}
$fahrt = getFahrtData($anMysqlConn, $anFahrtId);
$starter = getStarterData($anMysqlConn, $anStarterId);
if( empty($fahrt) or empty($starter) or ($fahrt['eventId'] != $starter['eventId']) ){
$retMessage['error'] .= "eventId von Fahrt und Starter passen nicht: fahrtId['eventId']=\"".$fahrt['eventId']."\", starterId['eventId']=\"".$starter['eventId']."\"<br />";
return $retMessage;
}
$mitfahrerIds = array();
if( !empty($fahrt['mitfahrer']) )
$mitfahrerIds = explode(',', $fahrt['mitfahrer']);
if( in_array( $anStarterId, $mitfahrerIds) ){
$message['warning'] .= "Starter '".$anStarterId."' bereits in Fahrt '".$anFahrtId."' eingeschrieben!<br />";
return $retMessage;
}
if( !empty($starter['fahrtId']) ){
$retMessage['error'] .= "Der Starter \"".$anStarterId."\" ist bereits in der Fahrt \"".$starterId['fahrtId']."\"<br />";
return $retMessage;
}
if( count($mitfahrerIds) >= (int)$fahrt['plaetze'] ){
$retMessage['error'] .= "Fahrt \"".$anFahrtId."\" hat keine freien Plätze mehr!<br />";
return $retMessage;
}
array_push( $mitfahrerIds, $starter['id'] );
$query = sprintf(
"UPDATE wkParticipo_Fahrten SET mitfahrer='%s' WHERE id='%s';",
$anMysqlConn->real_escape_string( implode(',', $mitfahrerIds) ),
$anMysqlConn->real_escape_string( $fahrt['id'] )
);
$result = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows != 1){
$retMessage['error'] .= "verteileMitfahrer: Fehler beim Ausführen des sqlRequestes \"".$query."\"<br />";
return $retMessage;
}
$retMessage['success'] .= "Starter '". $starter['id'] . "' zur Fahrt '".$fahrt['id']."' hinzugefügt!<br />";
$query = sprintf(
"UPDATE wkParticipo_Starter SET fahrtId='%s' WHERE id='%s';",
$anMysqlConn->real_escape_string( $fahrt['id'] ),
$anMysqlConn->real_escape_string( $starter['id'] )
);
$result = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows != 1){
$retMessage['error'] .= "Fehler beim Ausführen des sqlRequestes \"".$query."\"<br />";
return $retMessage;
}
$retMessage['success'] .= "Fahrt '". $fahrt['id'] . " zum Starter '".$starter['id']."' hinzugefügt!<br />";
return $retMessage;
}
/// Einer Fahrt einen Mitfahrer entziehen
function shrinkFahrt($anMysqlConn, $fahrtId){
$retMessage = array();
if( (string)(int)$fahrtId == $fahrtId ){
$fahrt = getFahrtData($anMysqlConn, $fahrtId);
}
}
// Eine Fehler/Warnung/Notiz/Erfolgsmeldung als divBox im String zurückgeben
function htmlRetMessage($anRetMessage){
$retHtmlString = "";
if( !empty($anRetMessage) ){
$retHtmlString .= "<div style=\"border: 1px solid;\">";
if( !empty($anRetMessage['error']) ){
$retHtmlString .= "<div style=\"border: 1px solid;\">";
$retHtmlString .= "ERROR:<br />";
$retHtmlString .= $anRetMessage['error'];
$retHtmlString .= "</div>";
}
if( !empty($anRetMessage['warning']) ){
$retHtmlString .= "<div style=\"border: 1px solid;\">";
$retHtmlString .= "WARNING:<br />";
$retHtmlString .= $anRetMessage['warning'];
$retHtmlString .= "</div>";
}
if( !empty($anRetMessage['notice']) ){
$retHtmlString .= "<div style=\"border: 1px solid;\">";
$retHtmlString .= "Info:<br />";
$retHtmlString .= $anRetMessage['notice'];
$retHtmlString .= "</div>";
}
if( !empty($anRetMessage['success']) ){
$retHtmlString .= "<div style=\"border: 1px solid;\">";
$retHtmlString .= "SUCCESS:<br />";
$retHtmlString .= $anRetMessage['success'];
$retHtmlString .= "</div>";
}
$retHtmlString .= "</div>";
}
// print_r($anRetMessage);
return $retHtmlString;
}
function updateStarterErgebnis($anMysqlConn, $anStarterId, $anMass, $somePlaces){
$retMessage = array();
if( (string)(int)$anStarterId != $anStarterId ){
$retMessage['error'] .= "Falsch formatierte StarterId (".$anStarterId.")!<br />";
return $retMessage;
}
if( (string)(float)$anMass != $anMass and $anMass != "Offen" and $anMass != "-" ){
$retMessage['error'] .= "Falsch formatierte Masse (".$anMass.")<br />";
return $retMessage;
}
$plaetze = explode(',', $somePlaces);
foreach($plaetze as $platz){
if( (string)(int)$platz != $platz ){
$message['error'] .= "Falsch formatierte Platzierungen (".$somePlaces.")<br />";
return $retMessage;
}
}
$query = sprintf(
"UPDATE wkParticipo_Starter SET masse='%s', platz='%s' WHERE id='%s';",
$anMysqlConn->real_escape_string( $anMass ),
$anMysqlConn->real_escape_string( $somePlaces ),
$anMysqlConn->real_escape_string( $anStarterId )
);
$result = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows != 1){
$retMessage['error'] .= "updateStarterErgebnis: Fehler beim Ausführen des sqlRequestes \"".$query."\"<br />";
return $retMessage;
}
$retMessage['success'] .= "Dem Starter ".$anStarterId." wurde die Masse ".$anMass." und die Platzierung ".$somePlaces." zugeordnet!<br />";
return $retMessage;
}
/// Die KinderDaten eines Users abfragen
function getUsersKidsData($anMysqlConn, $anUserId){
$retArray = array();
if( (string)(int)$anUserId != $anUserId ) return $retArray;
$query = sprintf(
"SELECT kinder FROM wkParticipo_Users WHERE id='%s';",
$anMysqlConn->real_escape_string( $anUserId )
);
$results = $anMysqlConn->query($query);
if($anMysqlConn->affected_rows != 1) return $retArray;
$kinderIds = explode(',', $results->fetch_array()['kinder']);
foreach($kinderIds as $kindId){
array_push( $retArray, getUserData($anMysqlConn, $kindId) );
}
return $retArray;
};
// geklaut von
function addToGcalUrl(
$name,
$date,
$location = false
) {
// calculate the start and end dates, convert to ISO format
$startdate = date('Ymd',strtotime($date));
$enddate = date('Ymd',strtotime($startdate . ' + 1 day'));
// build the url
$url = 'http://www.google.com/calendar/event?action=TEMPLATE';
$url .= '&text=' . rawurlencode($name);
$url .= '&dates=' . $startdate . '/' . $enddate;
if ($location) {
$url .= '&location=' . rawurlencode($location);
}
// build the link output
return $url;
}
///---
///
///---
/// Erzeugen des htmlCodes der Infobox für ein wkEvent
function htmlWkEvent($aWkEvent, $starters, $fahrten){
$retHtml = "";
$retHtml .= "<fieldset><legend>". $aWkEvent['Veranstaltung'] ."</legend><div class=\"wkBox\">";
$retHtml .= "<div class=\"wkBoxWkData\" ><div>Wettkampfdaten</div><ul>";
$retHtml .= "<li>Datum: ";
if( empty($aWkEvent['Datum']) ){
$retHtml .= "fehlendes Datum";
}
else{
$retHtml .= "<time datetime=\"" . $aWkEvent['Datum'] . "\">" . $aWkEvent['Datum'] . "</time> <a class=\"touchLink\" href =\"" . addToGcalUrl( $aWkEvent['Veranstaltung'], $aWkEvent['Datum'] ) . "\" >In Google Calendar eintragen</a>";
}
$retHtml .= "</li>";
$retHtml .= "<li>Einschreibefrist: ";
if( empty($aWkEvent['meldefrist']) ){
$retHtml .= "fehlende Einschreibefrist";
}
else{
$retHtml .= "<time datetime=\"" . $aWkEvent['meldefrist'] . "\">" . $aWkEvent['meldefrist'] . "</time> <a class=\"touchLink\" href =\"" . addToGcalUrl( "Einschreibefrist " . $aWkEvent['Veranstaltung'], $aWkEvent['meldefrist'] ) . "\" >In Google Calendar eintragen</a>";
}
$retHtml .= "</li>";
$retHtml .= "<li>Wettkampf: ";
if( empty($aWkEvent['Veranstaltung']) ){
$retHtml .= "fehlender Wettkampfname";
}
else{
$retHtml .= $aWkEvent['Veranstaltung'];
}
$retHtml .= "</li>";
$retHtml .= "<li>Altersklassen: ";
if( empty( $aWkEvent['Altersklassen'] ) ){
$retHtml .= "fehlende Altersklassen";
}
else{
$retHtml .= $aWkEvent['Altersklassen'];
}
$retHtml .= "</li>";
if( !empty($_SESSION['login']) ){
// $starters = getStarterForEvent($mysqlConn, $aWkEvent['id']);
$retHtml .= "<li>angemeldete Starter: ";
if( empty($starters) ){
$retHtml .= "Noch hat sich niemand für diesen Wettkampf gemeldet!";
}
else{
$retHtml .= count($starters);
}
$retHtml .= "</li>";
// $fahrten = getFahrtenForEvent($mysqlConn, $aWkEvent['id']);
$anzPlätze = 0;
foreach($fahrten as $fahrt)
$anzPlätze += $fahrt['plaetze'];
$retHtml .= "<li" . ( ($anzPlätze<count($starters)) ? " style=\"color: red\"" : "" ) . ">Anzahl Plätze: " . $anzPlätze . "</li>";
if( !empty( $aWkEvent['bemerkungen'] ) ){
$retHtml .= "<li>Bemerkungen: " . $aWkEvent['bemerkungen'] . "</li>";
}
}
$retHtml .= "</ul></div>";
$retHtml .= "<nav style=\"width: 100%; clear: both;\"><ul>";
$retHtml .= "<li><a href =\"./showWkEvent.php?eventId=" . (isset( $aWkEvent['id'] ) ? $aWkEvent['id'] : "") . "\" ><div>Detailansicht</div></a></li>";
$retHtml .= "<li><a href =\"/ressourcen/phpLib/calendar.php?wkID=" . ($aWkEvent['wkId']) . "\" ><div>Termin als iCal</div></a></li>";
$retHtml .= "<li><a href =\"" . addToGcalUrl($aWkEvent['Veranstaltung'], $aWkEvent['Datum'] ) . "\"><div>In den Google Calendar</div></a></li>";
$retHtml .= "</ul></nav>";
$retHtml .= "<div>";
if (empty($_SESSION['login'])){
$retHtml .= "Ein Einschreiben ist nur eingeloggt möglich!";
}
else{
$retHtml .= "Für diesen Wettkampf ...";
$retHtml .= "<form action=\"./addStarter.php\" method=\"post\">";
$retHtml .= "<input type=\"hidden\" name=\"f[eventId]\" value=" . ( isset( $aWkEvent['id'] ) ? $aWkEvent['id'] : "") . " />";
if( date("Y-m-d") > $aWkEvent['meldefrist'] ){
$retHtml .= "<button type=\"submit\" disabled>ist die Einschreibefrist bereits abgelaufen!</button>";
$retHtml .= "<p>Frist für das Einschreiben verpasst? Für ein nachträgliches Eintragen mit dem Admin verständigen (<a href=\"mailto:cwsvjudo@arcor.de?Subject=" . ( rawurlencode("Meldefrist ".$aWkEvent['Veranstaltung']) ) . "\" target=\"_top\">Email an cwsvjudo@arcor.de</a>).</p>";
}
else{
$retHtml .= "<button type=\"submit\">einen Starter melden</button>";
}
$retHtml .= "</form>";
$retHtml .= "<form action=\"./addFahrt.php\" method=\"post\">";
$retHtml .= "<input type=\"hidden\" name=\"f[eventId]\" value=" . ( isset( $aWkEvent['id'] ) ? $aWkEvent['id'] : "" ) . "\" />";
if($aWkEvent['Datum'] > date("Y-m-d")){
$retHtml .= "<button type=\"submit\">eine Mitfahrgelegenheiten melden.</button>";
}
else{
$retHtml .= "<button type=\"submit\" disabled>ist es leider zu spät, noch Mitfahrgelegenheiten hinzuzufügen.</button>";
}
$retHtml .= "</form>";
}
$retHtml .= "</div></div></fieldset>";
return $retHtml;
}
?>