Added regatta_plan

This commit is contained in:
Timon Ostertun
2020-09-26 19:22:46 +02:00
parent 364fd6fea0
commit 08e5afeb6e
3 changed files with 89 additions and 11 deletions

View File

@@ -1,19 +1,31 @@
<?php <?php
// TODO: Create site $sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'regattas';
$sp['activenav'] = 2;
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name']; // Title, Inputs
$sp['backbutton'] = true; $content = '<h1 id="h1-title"></h1>';
$content .= '<p id="p-title"></p>';
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']); $sp['output'] .= $tpl->load('card', [$content]);
$content .= '<p>';
$content .= 'Die gesuchte Seite ist leider noch nicht verf&uuml;gbar.<br>'; // Plannings
$content .= 'Wir arbeiten daran, sie schnellstm&ouml;glich zur Verf&uuml;gung zu stellen.<br>'; $content = '<p id="p-info" class="mb-0"></p>';
$content .= 'Wie w&auml;re es mit der Homepage?'; $thead = '<tr><th>Benutzer</th><th>Steuermann/-frau</th><th>Crew</th></tr>';
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-plannings', 'css-class' => 'mb-0 text-nowrap']);
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-plannings']);
// Info
$content = '<p>Du planst, hier hinzufahren, aber stehst nicht auf dieser Liste?<br>';
$content .= 'Das kannst Du &auml;ndern! ';
$content .= '<font class="show-loggedin">Erstelle einfach <a href="' . LINK_PRE . 'planning">hier</a> Deine eigene Saison-Planung.</font>';
$content .= '<font class="show-notloggedin"><a href="#" data-menu="menu-login">Melde Dich an</a> oder <a href="#" data-menu="menu-signup">registriere Dich kostenlos</a> und erstelle Deine eigene Saison-Planung.</font>';
$content .= '</p>'; $content .= '</p>';
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']); $sp['output'] .= $tpl->load('card', [$content]);
$sp['scripts'] .= $scripts->load('regatta_plan');
?> ?>

View File

@@ -2,6 +2,7 @@
$sp['title'] = 'Ergebnisse - Regatten.net ' . $_CLASS['name']; $sp['title'] = 'Ergebnisse - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = true; $sp['backbutton'] = true;
$sp['activenav'] = 2;
// Title, Inputs // Title, Inputs
$content = '<h1 id="h1-title"></h1>'; $content = '<h1 id="h1-title"></h1>';

View File

@@ -0,0 +1,65 @@
var siteScript = async function() {
var regattaId = findGetParameter('regatta');
if (regattaId == null) {
$('#h1-title').text('Regatta nicht gefunden');
hideLoader();
return;
}
var regatta = await dbGetData('regattas', regattaId);
if (regatta == null) {
$('#h1-title').text('Regatta nicht gefunden');
hideLoader();
return;
}
var dateFrom = parseDate(regatta['date']);
var dateTo = parseDate(regatta['date']);
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
$('#h1-title').text(regatta.name);
if (regatta.length < 1) {
if (formatDate('d.m', dateFrom) == '01.01') {
$('#p-title').html('<font class="color-red2-dark">Datum noch unklar</font>');
} else {
$('#p-title').html(formatDate('d.m.Y', dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font>');
}
} else {
$('#p-title').html(formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo));
}
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta.id);
if (plannings.length > 0) {
$('#table-plannings').show();
$('#p-info').hide();
var tbody = '';
for (var p in plannings) {
var planning = plannings[p];
tbody += '<tr>';
tbody += '<td>' + (await dbGetData('users', planning.user)).username + '</td>';
if (planning.steuermann != null) {
tbody += '<td>' + (await dbGetData('users', planning.user)).username + '</td>';
} else {
tbody += '<td>(noch unklar)</td>';
}
var crew = [];
var cr = planning.crew.split(',');
for (c in cr) {
var s = await dbGetData('sailors', cr[c]);
if (s != null) crew.push(s.name);
}
tbody += '<td>' + crew.join('<br>') + '</td>';
tbody += '</tr>';
}
$('#table-plannings').find('tbody').html(tbody);
} else {
$('#p-info').text('Niemand plant bisher, hier hinzufahren!');
$('#p-info').show();
$('#table-plannings').hide();
}
hideLoader();
}