diff --git a/server/content/planning_list.php b/server/content/planning_list.php
index 85a23df..4b814ba 100644
--- a/server/content/planning_list.php
+++ b/server/content/planning_list.php
@@ -1,19 +1,27 @@
load('error', ['404', 'Seite existiert noch nicht']);
- $content .= '
';
- $content .= 'Die gesuchte Seite ist leider noch nicht verfügbar. ';
- $content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen. ';
- $content .= 'Wie wäre es mit der Homepage?';
- $content .= '
';
- $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']);
-
-?>
\ No newline at end of file
+
+ $sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name'];
+ $sp['backbutton'] = 'planning';
+ $sp['activenav'] = 5;
+
+ // Title
+ $content = 'Saison-Planungen ';
+ $content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
+
+ $sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
+
+ // Not loggedin
+ $content = 'Saison-Planungen ';
+ $content .= 'Um die Saison-Planungen anderer zu sehen, musst Du angemeldet sein.Melde Dich hier an oder registriere Dich jetzt kostenlos .
';
+
+ $sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
+
+ // Regattas
+ $content = $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text']);
+ $content .= '
';
+
+ $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
+
+ $sp['scripts'] .= $scripts->load('planning_list');
+
+?>
diff --git a/server/content/planning_view.php b/server/content/planning_view.php
index be4bf34..cf37f0c 100644
--- a/server/content/planning_view.php
+++ b/server/content/planning_view.php
@@ -16,7 +16,7 @@
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
$content .= '
';
- $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
+ $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
// Menu
$items = '';
diff --git a/server/scripts/planning_list.js b/server/scripts/planning_list.js
new file mode 100644
index 0000000..0cda710
--- /dev/null
+++ b/server/scripts/planning_list.js
@@ -0,0 +1,146 @@
+async function onUserClicked(id) {
+ var user = await dbGetData('users', id);
+ if (user !== null) {
+ location.href = LINK_PRE + 'planning_view?user=' + user.id;
+ }
+}
+
+function selectChange() {
+ var val = $('#select-year').val();
+
+ if (typeof siteScript === 'function') {
+ history.replaceState(null, '', '?year=' + val);
+ siteScript();
+ }
+}
+
+function initYear() {
+ var year = findGetParameter('year');
+ if (year === null) year = new Date().getFullYear();
+
+ $('#select-year').html('' + year + ' ');
+ $('#select-year').val(year);
+}
+
+var firstCall = true;
+var rows = [];
+var today;
+
+async function drawList () {
+ window.setTimeout(function () {
+ var list = '';
+ rows.forEach(function (entry) {
+ if (search($('#input-search').val(), entry.keywords)) {
+ list += entry.content;
+ }
+ });
+ $('#div-users').html(list);
+ }, 0);
+}
+
+var siteScript = async function() {
+ if (!isLoggedIn()) {
+ hideLoader();
+ return;
+ }
+
+ if (firstCall) {
+ firstCall = false;
+ initYear();
+ $('#select-year').change(selectChange);
+ $('#input-search').on('input', drawList);
+ }
+
+ var selectedYear = $('#select-year').val();
+ var minDate = parseDate(selectedYear + '-01-01');
+ var maxDate = parseDate(selectedYear + '-12-31');
+ var regattas = await dbGetRegattasRange(minDate, maxDate);
+ var plannings = {};
+ for (var i in regattas) {
+ var entry = regattas[i];
+ var planning = await dbGetDataIndex('plannings', 'regatta', entry.id);
+ for (p in planning) {
+ if (!(planning[p].user in plannings)) {
+ plannings[planning[p].user] = {
+ user: await dbGetData('users', planning[p].user),
+ regattas: [],
+ sailors: {}
+ };
+ }
+ plannings[planning[p].user].regattas.push(entry);
+ var sailor = null;
+ if (planning[p].steuermann !== null) sailor = await dbGetData('sailors', planning[p].steuermann);
+ if (sailor !== null) {
+ if (!(sailor.id in plannings[planning[p].user].sailors)) plannings[planning[p].user].sailors[sailor.id] = sailor.name;
+ }
+ var crew = planning[p].crew.split(',');
+ for (i in crew) {
+ sailor = await dbGetData('sailors', crew[i]);
+ if (sailor !== null) {
+ if (!(sailor.id in plannings[planning[p].user].sailors)) plannings[planning[p].user].sailors[sailor.id] = sailor.name;
+ }
+ }
+ }
+ }
+ plannings = Object.values(plannings);
+ plannings.sort(function(a,b){
+ return a.user.username.localeCompare(b.user.username);
+ });
+
+ var years = await dbGetData('years');
+ years.sort(function (a, b) {
+ if (a['year'] > b['year']) return -1;
+ if (a['year'] < b['year']) return 1;
+ return 0;
+ });
+ var options = '';
+ for (id in years) {
+ var year = years[id]['year'];
+ options += '' + year + ' ';
+ }
+ $('#select-year').html(options);
+ $('#select-year').val(selectedYear);
+
+ var count = plannings.length;
+ if (count > 0) {
+ $('#input-search').parent().show();
+
+ rows = [];
+
+ for (id in plannings) {
+ var entry = plannings[id];
+
+ var row = { keywords: [], content: '' };
+ row.keywords.push(entry.user.username);
+ for (i in entry.sailors) {
+ row.keywords.push(entry.sailors[i]);
+ }
+
+ row.content += '';
+
+ // ZEILE 1
+ row.content += '
';
+
+ // ZEILE 2
+ row.content += '
';
+
+ // Name
+ row.content += '
' + entry.user.username + '
';
+
+ // Count of regattas
+ row.content += '
' + entry.regattas.length + ' Regatten
';
+
+ row.content += '
';
+
+ rows.push(row);
+ }
+
+ drawList();
+
+ } else {
+ $('#div-users').html('Es hat noch niemand eine Saison-Planung erstellt');
+ $('#input-search').parent().hide();
+ }
+
+ hideLoader();
+}