make add/remove starter buttons date sensitive

This commit is contained in:
marko
2023-01-29 19:55:33 +01:00
parent 4ff0659f90
commit ece0ef5025
9 changed files with 492 additions and 196 deletions

View File

@@ -18,9 +18,10 @@ class eventPlaner
'wardship' => 'vormundschaft'
];
// request coming starts from the db
private static function getComingStarts($sinceDate = null, $userId = null)
{
$userId = $userId ?? $_SESSION['user']['userId'];
$userId = $userId ?? participo::getSessionUserId();
$sinceDate = $sinceDate ?? new DateTime();
$params = [
@@ -91,7 +92,7 @@ class eventPlaner
$ret = dbConnector::query($query);
$events = [];
foreach ($ret as $event) {
array_push($events, event::fromArray($event));
array_push($events, event::fromDbArray($event));
}
return $events;
}
@@ -108,39 +109,4 @@ class eventPlaner
}
return $ret;
}
// inserting html code
/** Generate the htmlCode for the list of upcoming starts of
*
* @return void
*/
public static function htmlComingStarts()
{
$comingStarts = self::getComingStarts();
$htmlTable = null;
if ($comingStarts) {
$htmlTable = '<table>'
. '<thead><tr><th>Datum</th><th>Veranstaltung</th><th>Starter</th><th></th></tr></thead>'
. '<tbody>';
foreach ($comingStarts as $s) {
$eventDeadline = DateTime::createFromFormat('Y-m-d', $s['deadline']);
$eventDate = DateTime::createFromFormat('Y-m-d', $s['eventDate']);
$today = new DateTime();
$htmlTable .= '<tr>'
. '<td>' . getHtmlSquareDate($eventDate) . '</td>'
. '<td>' . $s['eventName'] . '</td>'
. '<td>' . $s['userName'] . ', ' . $s['userFirstname'] . '</td>'
. '<td>' . ($eventDeadline >= $today ? Event::getHtmlRemoveStarterForm($s['eventId'], $s['userId']) : '') . '</td>'
// . '<td>' . $eventDeadline->format('Y-m-d') . ' <= ' . $today->format('Y-m-d') . ': ' . ($eventDeadline <= $today ? 'true' : 'false') . '</td>'
. '</tr>';
}
$htmlTable .= '</tbody></table>';
echo('<h2 id="comingStarts">Aktuelle Einschreibungen</h2>');
echo($htmlTable);
} else {
echo('<div>Keine Meldungen zu bevorstehenden Events<div>');
}
return;
}
}