diff --git a/server/content/planning_view.php b/server/content/planning_view.php
index 85a23df..be4bf34 100644
--- a/server/content/planning_view.php
+++ b/server/content/planning_view.php
@@ -1,19 +1,35 @@
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-Planung - Regatten.net ' . $_CLASS['name'];
+ $sp['backbutton'] = 'planning_list';
+ $sp['activenav'] = 5;
+
+ // Title
+ $content = 'Saison-Planung ';
+ $content .= '
';
+ $content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
+
+ $sp['output'] .= $tpl->load('card', [$content]);
+
+ // Regattas
+ $content = '
';
+ $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']);
+
+ // Menu
+ $items = '';
+ $items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']);
+ $items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
+ $items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
+ $items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
+ $items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
+ $items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']);
+ $items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']);
+ $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]);
+
+ $sp['scripts'] .= $scripts->load('onRegattaClicked');
+ $sp['scripts'] .= $scripts->load('planning_view');
+
+?>
diff --git a/server/scripts/planning_view.js b/server/scripts/planning_view.js
new file mode 100644
index 0000000..c0cc616
--- /dev/null
+++ b/server/scripts/planning_view.js
@@ -0,0 +1,281 @@
+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 (entry == null) {
+ list += 'Heute ist der ' + formatDate('d.m.Y', today) + '
';
+ } else if (search($('#input-search').val(), entry.keywords)) {
+ list += entry.content;
+ }
+ });
+ $('#div-regattas').html(list);
+ }, 0);
+}
+
+var siteScript = async function() {
+ var userid = findGetParameter('user');
+ var user = null;
+ if (userid !== null) {
+ user = await dbGetData('users', userid);
+ }
+ if (user === null) {
+ location.href = LINK_PRE + 'planning_list';
+ return;
+ }
+
+ $('#p-username').text(user.username);
+
+ if (firstCall) {
+ firstCall = false;
+ initYear();
+ $('#select-year').change(selectChange);
+ $('#input-search').on('input', drawList);
+ }
+
+ today = getToday();
+
+ 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 = await dbGetDataIndex('plannings', 'user', user.id);
+ for (var i = regattas.length - 1; i >= 0; i --) {
+ var entry = regattas[i];
+ var okay = false;
+ for (p in plannings) {
+ if (plannings[p].regatta == entry.id) {
+ regattas[i].planning = plannings[p];
+ okay = true;
+ break;
+ }
+ }
+ if (!okay) {
+ regattas.splice(i, 1);
+ }
+ }
+ var regattaResults = [];
+ for (id in regattas) {
+ var entry = regattas[id];
+ var results = await dbGetDataIndex('results', 'regatta', entry['id']);
+ regattaResults[entry['id']] = (results.length > 0);
+ }
+
+ 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 = regattas.length;
+ if (count > 0) {
+ if (count == 1) {
+ $('#p-count').html('Es wurde 1 Regatta gefunden!');
+ } else {
+ $('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
+ }
+ $('#div-regattas').show();
+ $('#input-search').parent().show();
+
+ var heute = false;
+
+ rows = [];
+
+ for (id in regattas) {
+ var entry = regattas[id];
+ var club = null;
+ if (entry['club'] != null)
+ club = await dbGetData('clubs', entry['club']);
+ if (entry.planning.steuermann !== null) {
+ entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
+ }
+ var crewString = entry.planning.crew.split(',');
+ entry.planning.crew = [];
+ for (c in crewString) {
+ var sailor = await dbGetData('sailors', crewString[c]);
+ if (sailor !== null) {
+ entry.planning.crew.push(sailor.name);
+ }
+ }
+
+ var dateFrom = entry['dateFrom'];
+ var dateTo = entry['dateTo'];
+
+ var row = { keywords: [], content: '' };
+ row.keywords.push(entry['name']);
+ if (entry['number'] != null) row.keywords.push(entry['number']);
+ if (club != null) row.keywords.push(club['kurz'], club['name']);
+ if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
+ for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
+
+ if (!heute && (today <= dateFrom)) {
+ rows.push(null);
+ heute = true;
+ }
+
+ row.content += '';
+
+ // ZEILE 1
+ // Name
+ row.content += '
' + (entry['canceled'] == 1 ? '' : '') + entry['name'] + (entry['canceled'] == 1 ? ' ' : '') + '
';
+
+ // ZEILE 2
+ row.content += '
';
+
+ // Number
+ row.content += '
' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '
';
+
+ // Special
+ row.content += '
' + entry['special'] + '
';
+
+ // Club
+ row.content += '
' + ((club != null) ? club['kurz'] : '') + '
';
+
+ row.content += '
';
+
+ // ZEILE 3
+ row.content += '
';
+
+ // Date
+ if (entry['length'] < 1) {
+ if (formatDate('d.m', dateFrom) == '01.01') {
+ row.content += '
Datum noch unklar
';
+ } else {
+ row.content += '
' + formatDate("d.m.Y", dateFrom) + ' - Datum nicht final
';
+ }
+ } else {
+ row.content += '
' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '
';
+ }
+
+ // RLF
+ row.content += '
' + parseFloat(entry['rlf']).toFixed(2) + '
';
+
+ row.content += '
';
+
+ // ZEILE 4
+ row.content += '
';
+
+ // ZEILE 5
+ row.content += '
';
+ row.content += '
' + entry.planning.steuermann + '
';
+ row.content += '
';
+
+ // ZEILE 6...
+ for (var i in entry.planning.crew) {
+ row.content += '
';
+ row.content += '
' + entry.planning.crew[i] + '
';
+ row.content += '
';
+ }
+
+ row.content += '
';
+/*
+ // ZEILE 2
+ row.content += '';
+
+ // Number
+ row.content += '
' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '
';
+
+ // Club
+ row.content += '
' + ((club != null) ? club['kurz'] : '') + '
';
+
+ // Special
+ row.content += '
' + entry['special'] + '
';
+
+ // Icons
+ var icons = [];
+ if (entry['info'] != '')
+ icons.push('
');
+ if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1')) {
+ var color = '';
+ if (entry['meldungSchluss'] != null) {
+ var ms = 0;
+ if (entry['meldungEarly'] != null) {
+ ms = parseDate(entry['meldungEarly']);
+ }
+ if (ms < today) {
+ ms = parseDate(entry['meldungSchluss']);
+ }
+ var diff = Math.round((ms - today) / 86400000);
+ if (ms < today) {
+ color = ' color-red2-dark';
+ } else if (diff < 7) {
+ color = ' color-yellow2-dark';
+ }
+ }
+ icons.push('
');
+ }
+ if (entry['bericht'] != '')
+ icons.push('
');
+ if (entry['canceled'] == '1') {
+ icons.push('
');
+ } else if (regattaResults[entry['id']]) {
+ icons.push('
');
+ }
+ row.content += '
' + icons.join(' ') + '
';
+
+ row.content += '
';
+
+ // ZEILE 3
+ row.content += '';
+
+ // Date
+ if (entry['length'] < 1) {
+ if (formatDate('d.m', dateFrom) == '01.01') {
+ row.content += '
Datum noch unklar
';
+ } else {
+ row.content += '
' + formatDate("d.m.Y", dateFrom) + ' - Datum nicht final
';
+ }
+ } else {
+ row.content += '
' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '
';
+ }
+
+ // RLF
+ row.content += '
' + parseFloat(entry['rlf']).toFixed(2) + '
';
+
+ row.content += '
';
+*/
+ rows.push(row);
+ }
+
+ if (!heute) {
+ rows.push(null);
+ }
+
+ drawList();
+
+ } else {
+ $('#p-count').html(user.username + ' hat noch keine Regatten in seiner/ihrer Saison-Planung!');
+ $('#div-regattas').hide();
+ $('#input-search').parent().hide();
+ }
+
+ hideLoader();
+}