Beitragspunkte for members, new Lumina logo
Members can be awarded contribution points for raids, events and other activities, shown with a golden heart-shaped coin. An award has an occasion, reason, date and points per member; members are picked with search and select all/none, and choosing a raid preselects its participants (signed up in a group and linked to a website account), fills in reason and date and names participants without an account. The + on a member's card awards to that member alone, negative points deduct, and awards can be deleted whole or per member. Balances are always computed from the awards. The ranking shows members as cards with gold/silver/bronze for the top three and the viewer's own balance in the header and sidebar. With only contributions.view it lists the best 25 places plus the viewer's own place; contributions.view_all or contributions.manage show everyone. The history of awards is paginated, using pagination now shared with the warehouse. The sidebar shows the new logo, and the login page and mobile top bar a wordmark cut from it with soft edges. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2f74c92b04
commit
852eee357d
17 changed files with 1403 additions and 60 deletions
39
README.md
39
README.md
|
|
@ -26,6 +26,8 @@ und wird später ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Berei
|
||||||
- Karte: interaktive Zoom-Karte aller Regionen (Verteron, Altgard, Elthen, Morheim, Poeta,
|
- Karte: interaktive Zoom-Karte aller Regionen (Verteron, Altgard, Elthen, Morheim, Poeta,
|
||||||
Ishalgen, Reshanta) mit Markern und Kategorie-Filtern, dazu Taktiken in Schritten, die
|
Ishalgen, Reshanta) mit Markern und Kategorie-Filtern, dazu Taktiken in Schritten, die
|
||||||
direkt auf die Karte gezeichnet werden
|
direkt auf die Karte gezeichnet werden
|
||||||
|
- Beitragspunkte: Punkte für Raids, Events und andere Aktivitäten an einzelne oder viele
|
||||||
|
Mitglieder vergeben, mit Rangliste und Verlauf
|
||||||
- Lagerhaus: Bestand der Legion mit Einlagerungen (wer hat was wann überreicht) und Entnahmen
|
- Lagerhaus: Bestand der Legion mit Einlagerungen (wer hat was wann überreicht) und Entnahmen
|
||||||
(wann, optional an wen), Gegenstandsliste aus dem Aion-2-Wiki mit rund 2.300 Einträgen
|
(wann, optional an wen), Gegenstandsliste aus dem Aion-2-Wiki mit rund 2.300 Einträgen
|
||||||
- Raids-Seite: zeigt anstehende Raid-Termine, Anforderungen, Gruppen und Anmeldungen,
|
- Raids-Seite: zeigt anstehende Raid-Termine, Anforderungen, Gruppen und Anmeldungen,
|
||||||
|
|
@ -390,6 +392,43 @@ Berechtigung `map.manage` werden nicht mehr benutzt und können bei bestehenden
|
||||||
gelöscht werden. Die alten Taktiken werden nicht übernommen: Sie lagen als Anteil eines
|
gelöscht werden. Die alten Taktiken werden nicht übernommen: Sie lagen als Anteil eines
|
||||||
selbst erstellten Kartenbildes vor, das mit den neuen Kacheln nicht übereinstimmt.
|
selbst erstellten Kartenbildes vor, das mit den neuen Kacheln nicht übereinstimmt.
|
||||||
|
|
||||||
|
### Beitragspunkte
|
||||||
|
|
||||||
|
Die Seite **Beitragspunkte** (`contributions.php`) vergibt Punkte an Mitglieder, für Raids,
|
||||||
|
Events oder alles andere, was die Legion voranbringt. Ihr Symbol ist eine goldene Münze in
|
||||||
|
Herzform (`assets/images/beitragspunkt.svg`).
|
||||||
|
|
||||||
|
- **Rangliste:** alle aktiven Mitglieder mit ihrem Punktestand als Karten, höchster zuerst.
|
||||||
|
Platz 1 bis 3 sind gold, silber und bronze umrandet, die eigene Karte hervorgehoben. Ein
|
||||||
|
Klick auf eine Karte zeigt nur die Vergaben dieses Mitglieds. Den eigenen Stand zeigt die
|
||||||
|
Seite oben und die Seitenleiste unter dem Namen.
|
||||||
|
- **Punkte vergeben** (`contributions_award.php`): Anlass (Raid, Event, Sonstiges), Grund,
|
||||||
|
Datum, Punkte pro Mitglied und optional eine Bemerkung. Die Mitglieder wählt man per Häkchen
|
||||||
|
aus, mit Suche und „Alle/Keine“. Beim Anlass Raid lässt sich ein Raid aus der Raid-API
|
||||||
|
wählen: Seine Teilnehmer (angemeldet in einer Gruppe) werden dann vorausgewählt, Grund und
|
||||||
|
Datum vorbelegt. Wer auf der Ersatzbank steht, wird nicht angekreuzt. Wer kein Website-Konto
|
||||||
|
mit Discord-Verknüpfung hat, wird genannt, kann aber keine Punkte bekommen.
|
||||||
|
- **Einzelne Mitglieder:** Das + an einer Karte öffnet das Formular mit genau diesem Mitglied.
|
||||||
|
- **Abzüge:** Negative Punkte ziehen ab, etwa für Korrekturen.
|
||||||
|
- **Verlauf** aller Vergaben mit Seiten: Punkte, Anlass, Grund, Datum, wer vergeben hat und die
|
||||||
|
beteiligten Mitglieder. Eine Vergabe lässt sich ganz löschen oder einzelne Mitglieder daraus
|
||||||
|
entfernen, die Punkte werden dann wieder abgezogen.
|
||||||
|
|
||||||
|
Der Punktestand wird nicht gespeichert, sondern aus den Vergaben berechnet (Tabellen
|
||||||
|
`contribution_awards` und `contribution_entries`). So kann er nicht vom Verlauf abweichen, und
|
||||||
|
Punkte lassen sich später auch ausgeben, ohne das System umzubauen.
|
||||||
|
|
||||||
|
Wer nur `contributions.view` hat, sieht in der Rangliste die besten 25 Plätze (bei Gleichstand
|
||||||
|
an der Grenze alle, die sich Platz 25 teilen) und darunter seinen eigenen Platz. Die
|
||||||
|
vollständige Rangliste zeigt die Seite mit `contributions.view_all` oder `contributions.manage`.
|
||||||
|
Die Grenze steht als `CONTRIBUTION_PUBLIC_RANKS` in `includes/contributions.php`.
|
||||||
|
|
||||||
|
Rechte: `contributions.view` (Top 25 und Verlauf ansehen), `contributions.view_all` (vollständige
|
||||||
|
Rangliste) und `contributions.manage`
|
||||||
|
(vergeben, abziehen, löschen). Beide legt die Website selbst an und gibt sie der Gruppe
|
||||||
|
„Administrator“. Anderen Gruppen muss man sie unter Berechtigungsgruppen zuweisen, den
|
||||||
|
Mitgliedern z.B. nur `contributions.view`.
|
||||||
|
|
||||||
### Lagerhaus
|
### Lagerhaus
|
||||||
|
|
||||||
Die Seite **Lagerhaus** (`warehouse.php`) führt Buch über die Gegenstände der Legion.
|
Die Seite **Lagerhaus** (`warehouse.php`) führt Buch über die Gegenstände der Legion.
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
|
||||||
|
|
||||||
.navbar-brand img {
|
.navbar-brand img {
|
||||||
display: block;
|
display: block;
|
||||||
height: 40px;
|
height: 48px;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,22 +85,23 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-brand {
|
.sidebar-brand {
|
||||||
padding: 0 0.65rem 1.5rem;
|
padding: 0 0.65rem 1rem;
|
||||||
font-size: 1.15rem;
|
font-size: 1.15rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-brand a { display: block; }
|
.sidebar-brand a { display: block; }
|
||||||
|
|
||||||
/* Das Logo ist sehr breit (Seitenverhaeltnis 480:108). Mit fester Hoehe waere es breiter
|
/* Das Logo ist quadratisch (Wappen mit Schriftzug). Ueber die volle Sidebar-Breite waere es
|
||||||
als die Sidebar und wuerde unten eine waagerechte Scrollleiste erzeugen - deshalb
|
fast 240px hoch - deshalb begrenzt und mittig, mit weichem Goldschein. */
|
||||||
skaliert es ueber die Breite und behaelt seine Hoehe nur als Obergrenze. */
|
|
||||||
.sidebar-brand img {
|
.sidebar-brand img {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 136px;
|
||||||
height: auto;
|
height: auto;
|
||||||
max-height: 56px;
|
margin: 0 auto;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.35), 0 6px 22px rgba(201, 162, 39, 0.18);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-brand a { color: var(--gold); }
|
.sidebar-brand a { color: var(--gold); }
|
||||||
|
|
@ -149,7 +150,7 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
|
||||||
|
|
||||||
.mobile-topbar-brand img {
|
.mobile-topbar-brand img {
|
||||||
display: block;
|
display: block;
|
||||||
height: 32px;
|
height: 40px;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2223,3 +2224,302 @@ a.page-link:hover { border-color: var(--gold); color: var(--gold); text-decorati
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- Beitragspunkte --- */
|
||||||
|
|
||||||
|
.app-content.bg-contributions {
|
||||||
|
background-image: linear-gradient(rgba(20, 20, 20, 0.7), rgba(20, 20, 20, 0.86)), url('/assets/images/Landscapes/web/landscape2-bg.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-coin { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }
|
||||||
|
|
||||||
|
.contribution-hero {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 1rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-hero-coin { filter: drop-shadow(0 4px 10px rgba(201, 162, 39, 0.35)); }
|
||||||
|
.contribution-hero-text { flex: 1; min-width: 220px; }
|
||||||
|
.contribution-hero-text h1 { margin: 0 0 0.25rem; }
|
||||||
|
.contribution-hero-text p { margin: 0; }
|
||||||
|
|
||||||
|
.contribution-hero-balance {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-hero-balance strong {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
font-size: 1.8rem;
|
||||||
|
color: var(--gold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.75rem 1.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-head h1, .contribution-head h2 {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.6rem;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-head input[type="search"] { width: auto; min-width: 240px; }
|
||||||
|
|
||||||
|
.contribution-filter-balance {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
padding: 0.15rem 0.6rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(201, 162, 39, 0.15);
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rangliste */
|
||||||
|
.contribution-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-card {
|
||||||
|
position: relative;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(35, 35, 35, 0.72);
|
||||||
|
transition: border-color 0.15s, transform 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-card:hover { border-color: var(--gold); transform: translateY(-2px); }
|
||||||
|
.contribution-card[hidden] { display: none; }
|
||||||
|
.contribution-card.is-me { border-color: rgba(201, 162, 39, 0.6); background: rgba(201, 162, 39, 0.08); }
|
||||||
|
.contribution-card.rank-1 { box-shadow: 0 0 0 1px #e8c35a inset, 0 0 18px rgba(232, 195, 90, 0.25); }
|
||||||
|
.contribution-card.rank-2 { box-shadow: 0 0 0 1px #c9ced6 inset; }
|
||||||
|
.contribution-card.rank-3 { box-shadow: 0 0 0 1px #c98a55 inset; }
|
||||||
|
|
||||||
|
.contribution-card-link {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
padding: 1rem 0.6rem 0.8rem;
|
||||||
|
color: var(--text);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-card-link:hover { color: var(--text); text-decoration: none; }
|
||||||
|
|
||||||
|
.contribution-rank {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.45rem;
|
||||||
|
left: 0.55rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rank-1 .contribution-rank { color: #e8c35a; }
|
||||||
|
.rank-2 .contribution-rank { color: #c9ced6; }
|
||||||
|
.rank-3 .contribution-rank { color: #c98a55; }
|
||||||
|
|
||||||
|
.contribution-card-name { font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
|
||||||
|
|
||||||
|
.contribution-card-points {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--gold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-card-add {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.35rem;
|
||||||
|
right: 0.35rem;
|
||||||
|
width: 26px;
|
||||||
|
height: 26px;
|
||||||
|
font-size: 1rem;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-card:hover .contribution-card-add,
|
||||||
|
.contribution-card-add:focus { opacity: 1; }
|
||||||
|
a.contribution-card-add:hover { text-decoration: none; }
|
||||||
|
|
||||||
|
@media (hover: none) {
|
||||||
|
.contribution-card-add { opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verlauf der Vergaben */
|
||||||
|
.contribution-awards { display: flex; flex-direction: column; gap: 0.6rem; }
|
||||||
|
|
||||||
|
.contribution-award {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(35, 35, 35, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-award-points {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 76px;
|
||||||
|
gap: 0.15rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-award-points strong { font-size: 1.25rem; color: var(--success); }
|
||||||
|
.contribution-award-points.negative strong { color: var(--danger); }
|
||||||
|
|
||||||
|
.contribution-award-body { flex: 1; min-width: 0; }
|
||||||
|
|
||||||
|
.contribution-award-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-award-note { margin: 0.3rem 0 0; font-size: 0.9rem; }
|
||||||
|
.contribution-award-meta { margin-top: 0.3rem; font-size: 0.8rem; }
|
||||||
|
|
||||||
|
.contribution-badge-raid { border-color: #d9534f; color: #ff8a86; }
|
||||||
|
.contribution-badge-event { border-color: var(--discord); color: #9aa3ff; }
|
||||||
|
.contribution-badge-other { border-color: var(--border); }
|
||||||
|
|
||||||
|
.contribution-award-members { margin-top: 0.4rem; font-size: 0.85rem; }
|
||||||
|
.contribution-award-members summary { cursor: pointer; color: var(--text-muted); }
|
||||||
|
.contribution-award-members[open] summary { margin-bottom: 0.4rem; }
|
||||||
|
|
||||||
|
.contribution-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
|
||||||
|
|
||||||
|
.contribution-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
padding: 0.15rem 0.3rem 0.15rem 0.6rem;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--bg-panel-alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-chip.highlight { border-color: var(--gold); }
|
||||||
|
.contribution-chip a { color: var(--text); }
|
||||||
|
|
||||||
|
button.contribution-chip-remove {
|
||||||
|
padding: 0 0.3rem;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.contribution-chip-remove:hover { background: none; color: var(--danger); }
|
||||||
|
|
||||||
|
.contribution-award-delete { flex-shrink: 0; }
|
||||||
|
|
||||||
|
.contribution-pages {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.75rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Formular */
|
||||||
|
.contribution-form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-form-wide { grid-column: 1 / -1; }
|
||||||
|
.contribution-form-grid [hidden] { display: none; }
|
||||||
|
|
||||||
|
.contribution-picker-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-picker-head label { margin-right: auto; }
|
||||||
|
.contribution-picker-head input[type="search"] { width: auto; min-width: 200px; }
|
||||||
|
.contribution-picker-count { font-weight: 400; color: var(--text-muted); }
|
||||||
|
.contribution-raid-info { margin: 0.5rem 0 0; }
|
||||||
|
|
||||||
|
.contribution-picker-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
|
||||||
|
gap: 0.4rem;
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
max-height: 420px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-pick {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0.4rem 0.6rem;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-pick[hidden] { display: none; }
|
||||||
|
.contribution-pick input { width: auto; }
|
||||||
|
.contribution-pick.checked { border-color: var(--gold); background: rgba(201, 162, 39, 0.1); }
|
||||||
|
.contribution-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.contribution-pick-points { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.8rem; color: var(--text-muted); }
|
||||||
|
|
||||||
|
.sidebar-points {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.25rem;
|
||||||
|
margin-top: 0.15rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--gold);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.contribution-form-grid { grid-template-columns: 1fr; }
|
||||||
|
.contribution-hero-balance { align-items: flex-start; }
|
||||||
|
.contribution-award { flex-wrap: wrap; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-top-label {
|
||||||
|
padding: 0.1rem 0.5rem;
|
||||||
|
border: 1px solid var(--gold);
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contribution-own { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
|
||||||
|
.contribution-own h3 { margin: 0 0 0.6rem; font-size: 1rem; }
|
||||||
|
.contribution-limit-note { margin: 1rem 0 0; font-size: 0.85rem; }
|
||||||
|
|
|
||||||
96
assets/images/beitragspunkt.svg
Normal file
96
assets/images/beitragspunkt.svg
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 64 64" role="img" aria-label="Beitragspunkt">
|
||||||
|
<title>Beitragspunkt</title>
|
||||||
|
<defs>
|
||||||
|
<!-- Pralle Herzform: breite, runde Boegen, stumpfe Spitze -->
|
||||||
|
<path id="bp-heart" d="M32 56.5C21 49.5 5.5 40 5.5 24.5 5.5 14.5 12.5 7.5 21.5 7.5c4.8 0 8.3 2.4 10.5 6.3 2.2-3.9 5.7-6.3 10.5-6.3 9 0 16 7 16 17 0 15.5-15.5 25-26.5 32z"/>
|
||||||
|
|
||||||
|
<!-- Kante: dunkles, warmes Gold -->
|
||||||
|
<linearGradient id="bp-edge" x1="0" y1="0" x2="1" y2="0">
|
||||||
|
<stop offset="0" stop-color="#6b3f05"/>
|
||||||
|
<stop offset="0.3" stop-color="#a86c10"/>
|
||||||
|
<stop offset="0.55" stop-color="#8a560b"/>
|
||||||
|
<stop offset="1" stop-color="#5a3404"/>
|
||||||
|
</linearGradient>
|
||||||
|
|
||||||
|
<!-- Abgeschraegter Rand: Licht von oben links -->
|
||||||
|
<linearGradient id="bp-bevel" x1="0.15" y1="0" x2="0.85" y2="1">
|
||||||
|
<stop offset="0" stop-color="#fff6c4"/>
|
||||||
|
<stop offset="0.3" stop-color="#f6cf52"/>
|
||||||
|
<stop offset="0.7" stop-color="#d0931c"/>
|
||||||
|
<stop offset="1" stop-color="#8e5a0c"/>
|
||||||
|
</linearGradient>
|
||||||
|
|
||||||
|
<!-- Gewoelbte Flaeche -->
|
||||||
|
<radialGradient id="bp-face" cx="0.36" cy="0.3" r="0.85">
|
||||||
|
<stop offset="0" stop-color="#fff3b0"/>
|
||||||
|
<stop offset="0.35" stop-color="#f7cd4b"/>
|
||||||
|
<stop offset="0.75" stop-color="#dc9f24"/>
|
||||||
|
<stop offset="1" stop-color="#b0710f"/>
|
||||||
|
</radialGradient>
|
||||||
|
|
||||||
|
<!-- Rand der Flaeche leicht vertieft (Schatten innen unten) -->
|
||||||
|
<linearGradient id="bp-face-rim" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#fff9d8" stop-opacity="0.9"/>
|
||||||
|
<stop offset="0.5" stop-color="#e2a52a" stop-opacity="0"/>
|
||||||
|
<stop offset="1" stop-color="#7a4a08" stop-opacity="0.9"/>
|
||||||
|
</linearGradient>
|
||||||
|
|
||||||
|
<!-- Erhabenes Herz in der Mitte -->
|
||||||
|
<linearGradient id="bp-relief" x1="0.2" y1="0" x2="0.8" y2="1">
|
||||||
|
<stop offset="0" stop-color="#fffbe0"/>
|
||||||
|
<stop offset="0.45" stop-color="#ffd966"/>
|
||||||
|
<stop offset="1" stop-color="#c98a16"/>
|
||||||
|
</linearGradient>
|
||||||
|
|
||||||
|
<!-- Weiches Glanzlicht -->
|
||||||
|
<radialGradient id="bp-shine" cx="0.5" cy="0.5" r="0.5">
|
||||||
|
<stop offset="0" stop-color="#ffffff" stop-opacity="0.95"/>
|
||||||
|
<stop offset="0.6" stop-color="#ffffff" stop-opacity="0.35"/>
|
||||||
|
<stop offset="1" stop-color="#ffffff" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
|
||||||
|
<clipPath id="bp-face-clip">
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(32 32) scale(0.8) translate(-32 -31)"/>
|
||||||
|
</clipPath>
|
||||||
|
|
||||||
|
<filter id="bp-blur" x="-20%" y="-20%" width="140%" height="140%">
|
||||||
|
<feGaussianBlur stdDeviation="1.6"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<!-- Schatten auf dem Untergrund -->
|
||||||
|
<ellipse cx="32" cy="60" rx="19" ry="2.6" fill="#000000" opacity="0.35" filter="url(#bp-blur)"/>
|
||||||
|
|
||||||
|
<!-- Muenzkante: mehrere Schichten nach unten versetzt ergeben die Dicke -->
|
||||||
|
<g fill="url(#bp-edge)">
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(0 4.5)"/>
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(0 3.5)"/>
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(0 2.5)"/>
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(0 1.5)"/>
|
||||||
|
</g>
|
||||||
|
<!-- Riffelung der Kante andeuten -->
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(0 3)" fill="none" stroke="#f0bf45" stroke-opacity="0.35" stroke-width="0.6" stroke-dasharray="0.8 1.4"/>
|
||||||
|
|
||||||
|
<!-- Rand mit Abschraegung -->
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" fill="url(#bp-bevel)" stroke="#5c3604" stroke-width="0.9"/>
|
||||||
|
|
||||||
|
<!-- Innere, gewoelbte Flaeche -->
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(32 32) scale(0.8) translate(-32 -31)" fill="url(#bp-face)"/>
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(32 32) scale(0.8) translate(-32 -31)" fill="none" stroke="url(#bp-face-rim)" stroke-width="2"/>
|
||||||
|
|
||||||
|
<!-- Erhabenes Herz: Schlagschatten, Lichtkante, Flaeche -->
|
||||||
|
<g transform="translate(32 33) scale(0.4) translate(-32 -31)">
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(2.2 3)" fill="#8a560b" opacity="0.55"/>
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" transform="translate(-1.2 -1.4)" fill="#fffbe6"/>
|
||||||
|
<use xlink:href="#bp-heart" href="#bp-heart" fill="url(#bp-relief)" stroke="#b07614" stroke-width="1.6"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- Glanzlicht auf der Woelbung (auf die Flaeche beschnitten) -->
|
||||||
|
<g clip-path="url(#bp-face-clip)">
|
||||||
|
<ellipse cx="22" cy="18" rx="10" ry="6.5" fill="url(#bp-shine)" transform="rotate(-28 22 18)"/>
|
||||||
|
</g>
|
||||||
|
<!-- Lichtreflex auf dem Rand -->
|
||||||
|
<path d="M12.5 15.5c2.6-4.6 8.4-6.6 13-4.2" fill="none" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round" opacity="0.85"/>
|
||||||
|
<circle cx="48.5" cy="14" r="1.5" fill="#ffffff" opacity="0.9"/>
|
||||||
|
<circle cx="50.5" cy="16.6" r="0.7" fill="#ffffff" opacity="0.7"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.7 KiB |
BIN
assets/images/logo-lumina.webp
Normal file
BIN
assets/images/logo-lumina.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
assets/images/logo-wordmark.webp
Normal file
BIN
assets/images/logo-wordmark.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
120
assets/js/contributions.js
Normal file
120
assets/js/contributions.js
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function matches(element, term) {
|
||||||
|
return term === '' || (element.dataset.name || '').indexOf(term) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Rangliste durchsuchen ----
|
||||||
|
var rankingSearch = document.getElementById('contribution-search');
|
||||||
|
var ranking = document.getElementById('contribution-ranking');
|
||||||
|
if (rankingSearch && ranking) {
|
||||||
|
var noMatch = document.getElementById('contribution-no-match');
|
||||||
|
rankingSearch.addEventListener('input', function () {
|
||||||
|
var term = rankingSearch.value.trim().toLowerCase();
|
||||||
|
var visible = 0;
|
||||||
|
ranking.querySelectorAll('.contribution-card').forEach(function (card) {
|
||||||
|
card.hidden = !matches(card, term);
|
||||||
|
if (!card.hidden) visible++;
|
||||||
|
});
|
||||||
|
if (noMatch) noMatch.hidden = visible > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Formular "Punkte vergeben" ----
|
||||||
|
var form = document.getElementById('contribution-form');
|
||||||
|
if (!form) return;
|
||||||
|
|
||||||
|
var picks = Array.prototype.slice.call(form.querySelectorAll('.contribution-pick'));
|
||||||
|
var boxes = picks.map(function (pick) { return pick.querySelector('input[type="checkbox"]'); });
|
||||||
|
var counter = document.getElementById('picker-count');
|
||||||
|
var pickerSearch = document.getElementById('picker-search');
|
||||||
|
var submit = document.getElementById('contribution-submit');
|
||||||
|
var pointsInput = document.getElementById('points');
|
||||||
|
|
||||||
|
function updateCount() {
|
||||||
|
var count = boxes.filter(function (box) { return box.checked; }).length;
|
||||||
|
counter.textContent = count === 0 ? '(keins ausgewählt)' : '(' + count + ' ausgewählt)';
|
||||||
|
picks.forEach(function (pick, i) { pick.classList.toggle('checked', boxes[i].checked); });
|
||||||
|
|
||||||
|
var points = parseInt(pointsInput.value, 10);
|
||||||
|
var label = 'Punkte vergeben';
|
||||||
|
if (count > 0 && points) {
|
||||||
|
label = points > 0
|
||||||
|
? points + ' Punkte an ' + count + (count === 1 ? ' Mitglied' : ' Mitglieder') + ' vergeben'
|
||||||
|
: Math.abs(points) + ' Punkte bei ' + count + (count === 1 ? ' Mitglied' : ' Mitgliedern') + ' abziehen';
|
||||||
|
}
|
||||||
|
submit.textContent = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
boxes.forEach(function (box) { box.addEventListener('change', updateCount); });
|
||||||
|
pointsInput.addEventListener('input', updateCount);
|
||||||
|
|
||||||
|
pickerSearch.addEventListener('input', function () {
|
||||||
|
var term = pickerSearch.value.trim().toLowerCase();
|
||||||
|
picks.forEach(function (pick) { pick.hidden = !matches(pick, term); });
|
||||||
|
});
|
||||||
|
|
||||||
|
// "Alle" / "Keine" wirken nur auf die gerade sichtbaren (gefilterten) Mitglieder.
|
||||||
|
function setVisible(checked) {
|
||||||
|
picks.forEach(function (pick, i) {
|
||||||
|
if (!pick.hidden) boxes[i].checked = checked;
|
||||||
|
});
|
||||||
|
updateCount();
|
||||||
|
}
|
||||||
|
document.getElementById('picker-all').addEventListener('click', function () { setVisible(true); });
|
||||||
|
document.getElementById('picker-none').addEventListener('click', function () { setVisible(false); });
|
||||||
|
|
||||||
|
// ---- Anlass und Raid ----
|
||||||
|
var category = document.getElementById('category');
|
||||||
|
var raidField = document.getElementById('raid-field');
|
||||||
|
var raidSelect = document.getElementById('raid_id');
|
||||||
|
var raidInfo = document.getElementById('raid-info');
|
||||||
|
var titleInput = document.getElementById('title');
|
||||||
|
var timeInput = document.getElementById('awarded_at');
|
||||||
|
var raidsEl = document.getElementById('contribution-raids');
|
||||||
|
var raids = raidsEl ? JSON.parse(raidsEl.textContent) : [];
|
||||||
|
var autoTitle = '';
|
||||||
|
|
||||||
|
function toggleRaidField() {
|
||||||
|
raidField.hidden = category.value !== 'raid';
|
||||||
|
if (raidField.hidden && raidInfo) raidInfo.hidden = true;
|
||||||
|
}
|
||||||
|
category.addEventListener('change', toggleRaidField);
|
||||||
|
toggleRaidField();
|
||||||
|
|
||||||
|
if (raidSelect) {
|
||||||
|
raidSelect.addEventListener('change', function () {
|
||||||
|
var raid = raids.filter(function (r) { return String(r.id) === raidSelect.value; })[0];
|
||||||
|
if (!raid) {
|
||||||
|
raidInfo.hidden = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Teilnehmer des Raids auswaehlen, alle anderen abwaehlen.
|
||||||
|
boxes.forEach(function (box) {
|
||||||
|
box.checked = raid.participants.indexOf(parseInt(box.value, 10)) !== -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Grund und Datum nur ueberschreiben, wenn nichts Eigenes eingetragen wurde.
|
||||||
|
if (titleInput.value === '' || titleInput.value === autoTitle) {
|
||||||
|
autoTitle = raid.title + (raid.date ? ' (' + raid.date + ')' : '');
|
||||||
|
titleInput.value = autoTitle;
|
||||||
|
}
|
||||||
|
if (raid.time) timeInput.value = raid.time;
|
||||||
|
|
||||||
|
var info = raid.participants.length + ' Teilnehmer ausgewählt.';
|
||||||
|
if (raid.bench.length) {
|
||||||
|
info += ' ' + raid.bench.length + ' auf der Ersatzbank (nicht ausgewählt).';
|
||||||
|
}
|
||||||
|
if (raid.withoutAccount.length) {
|
||||||
|
info += ' Ohne Website-Konto, daher keine Punkte möglich: ' + raid.withoutAccount.join(', ') + '.';
|
||||||
|
}
|
||||||
|
raidInfo.textContent = info;
|
||||||
|
raidInfo.hidden = false;
|
||||||
|
updateCount();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCount();
|
||||||
|
})();
|
||||||
243
contributions.php
Normal file
243
contributions.php
Normal file
|
|
@ -0,0 +1,243 @@
|
||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
|
require_once __DIR__ . '/includes/contributions.php';
|
||||||
|
require_permission('contributions.view');
|
||||||
|
|
||||||
|
$canManage = user_has_permission('contributions.manage');
|
||||||
|
$canViewAll = $canManage || user_has_permission('contributions.view_all');
|
||||||
|
$currentUser = current_user();
|
||||||
|
|
||||||
|
$balances = contribution_balances();
|
||||||
|
$myBalance = contribution_user_balance((int) $currentUser['id']);
|
||||||
|
|
||||||
|
// Rang: gleiche Punktzahl = gleicher Platz.
|
||||||
|
$rank = 0;
|
||||||
|
$lastPoints = null;
|
||||||
|
foreach ($balances as $index => $member) {
|
||||||
|
if ($lastPoints === null || (int) $member['points'] !== $lastPoints) {
|
||||||
|
$rank = $index + 1;
|
||||||
|
$lastPoints = (int) $member['points'];
|
||||||
|
}
|
||||||
|
$balances[$index]['rank'] = $rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ohne volle Sicht nur die besten Plaetze - bei Gleichstand an der Grenze alle, die sich den
|
||||||
|
// letzten Platz teilen. Der eigene Platz wird trotzdem angezeigt.
|
||||||
|
$myEntry = null;
|
||||||
|
foreach ($balances as $member) {
|
||||||
|
if ((int) $member['id'] === (int) $currentUser['id']) {
|
||||||
|
$myEntry = $member;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$visibleBalances = $canViewAll
|
||||||
|
? $balances
|
||||||
|
: array_values(array_filter($balances, static fn (array $m): bool => (int) $m['rank'] <= CONTRIBUTION_PUBLIC_RANKS));
|
||||||
|
$visibleIds = array_map(static fn (array $m): int => (int) $m['id'], $visibleBalances);
|
||||||
|
$showMyEntrySeparately = $myEntry !== null && !in_array((int) $myEntry['id'], $visibleIds, true);
|
||||||
|
$hiddenCount = count($balances) - count($visibleBalances);
|
||||||
|
|
||||||
|
// Verlauf, optional nur fuer ein Mitglied (Klick auf eine Karte).
|
||||||
|
$filterUserId = isset($_GET['user']) ? (int) $_GET['user'] : null;
|
||||||
|
$filterUser = null;
|
||||||
|
// Den Verlauf von Mitgliedern ausserhalb der sichtbaren Plaetze nur mit voller Sicht - sonst
|
||||||
|
// liesse sich die Rangliste ueber den Filter doch vollstaendig abfragen.
|
||||||
|
if ($filterUserId !== null && !$canViewAll && $filterUserId !== (int) $currentUser['id'] && !in_array($filterUserId, $visibleIds, true)) {
|
||||||
|
$filterUserId = null;
|
||||||
|
}
|
||||||
|
if ($filterUserId !== null) {
|
||||||
|
foreach ($balances as $member) {
|
||||||
|
if ((int) $member['id'] === $filterUserId) {
|
||||||
|
$filterUser = $member;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($filterUser === null) {
|
||||||
|
$stmt = db()->prepare("SELECT id, username, display_name, avatar_filename FROM users WHERE id = ?");
|
||||||
|
$stmt->execute([$filterUserId]);
|
||||||
|
$filterUser = $stmt->fetch() ?: null;
|
||||||
|
if ($filterUser) {
|
||||||
|
$filterUser['points'] = contribution_user_balance($filterUserId);
|
||||||
|
} else {
|
||||||
|
$filterUserId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$perPage = 20;
|
||||||
|
$totalAwards = contribution_award_count($filterUserId);
|
||||||
|
$pageCount = max(1, (int) ceil($totalAwards / $perPage));
|
||||||
|
$page = min($pageCount, max(1, (int) ($_GET['page'] ?? 1)));
|
||||||
|
$awards = contribution_awards($filterUserId, $perPage, ($page - 1) * $perPage);
|
||||||
|
|
||||||
|
$displayName = static fn (array $u): string => (string) ($u['display_name'] !== '' ? $u['display_name'] : $u['username']);
|
||||||
|
|
||||||
|
$renderCard = static function (array $member) use ($currentUser, $canManage, $displayName): void {
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
$isMe = (int) $member['id'] === (int) $currentUser['id'];
|
||||||
|
$rankClass = in_array((int) $member['rank'], [1, 2, 3], true) && (int) $member['points'] > 0 ? ' rank-' . (int) $member['rank'] : '';
|
||||||
|
?>
|
||||||
|
<div class="contribution-card<?= $isMe ? ' is-me' : '' ?><?= $rankClass ?>" data-name="<?= e(mb_strtolower($displayName($member))) ?>">
|
||||||
|
<a class="contribution-card-link" href="/contributions.php?user=<?= (int) $member['id'] ?>#verlauf" title="Verlauf von <?= e($displayName($member)) ?>">
|
||||||
|
<span class="contribution-rank">#<?= (int) $member['rank'] ?></span>
|
||||||
|
<?= avatar_html($member, 52) ?>
|
||||||
|
<span class="contribution-card-name"><?= e($displayName($member)) ?></span>
|
||||||
|
<span class="contribution-card-points"><?= contribution_coin(18) ?> <?= contribution_format((int) $member['points']) ?></span>
|
||||||
|
</a>
|
||||||
|
<?php if ($canManage): ?>
|
||||||
|
<a class="icon-button contribution-card-add" href="/contributions_award.php?user=<?= (int) $member['id'] ?>"
|
||||||
|
title="Punkte an <?= e($displayName($member)) ?> vergeben" aria-label="Punkte vergeben">+</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
};
|
||||||
|
|
||||||
|
$pageTitle = 'Beitragspunkte';
|
||||||
|
$containerWide = true;
|
||||||
|
include __DIR__ . '/includes/header.php';
|
||||||
|
?>
|
||||||
|
<div class="panel contribution-hero">
|
||||||
|
<img class="contribution-hero-coin" src="/assets/images/beitragspunkt.svg" alt="" width="72" height="72">
|
||||||
|
<div class="contribution-hero-text">
|
||||||
|
<h1>Beitragspunkte</h1>
|
||||||
|
<p class="text-muted">Punkte für Raids, Events und alles, was die Legion voranbringt.</p>
|
||||||
|
</div>
|
||||||
|
<div class="contribution-hero-balance" title="Dein Punktestand">
|
||||||
|
<span class="text-muted">Dein Punktestand</span>
|
||||||
|
<strong><?= contribution_coin(26) ?> <?= contribution_format($myBalance) ?></strong>
|
||||||
|
</div>
|
||||||
|
<?php if ($canManage): ?>
|
||||||
|
<a class="button" href="/contributions_award.php">Punkte vergeben</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel">
|
||||||
|
<div class="contribution-head">
|
||||||
|
<h2>Rangliste<?= $canViewAll ? '' : ' <span class="contribution-top-label">Top ' . CONTRIBUTION_PUBLIC_RANKS . '</span>' ?></h2>
|
||||||
|
<input type="search" id="contribution-search" placeholder="Mitglied suchen …" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
<?php if (empty($balances)): ?>
|
||||||
|
<p class="text-muted">Noch keine Mitglieder.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="contribution-grid" id="contribution-ranking">
|
||||||
|
<?php foreach ($visibleBalances as $member): ?>
|
||||||
|
<?php $renderCard($member); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted" id="contribution-no-match" hidden>Kein Mitglied passt zur Suche.</p>
|
||||||
|
<?php if ($showMyEntrySeparately): ?>
|
||||||
|
<div class="contribution-own">
|
||||||
|
<h3>Dein Platz</h3>
|
||||||
|
<div class="contribution-grid">
|
||||||
|
<?php $renderCard($myEntry); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($hiddenCount > 0): ?>
|
||||||
|
<p class="text-muted contribution-limit-note">
|
||||||
|
Angezeigt werden die besten <?= CONTRIBUTION_PUBLIC_RANKS ?> Plätze. Die vollständige Rangliste
|
||||||
|
(<?= count($balances) ?> Mitglieder) ist der Legionsleitung vorbehalten.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel" id="verlauf">
|
||||||
|
<div class="contribution-head">
|
||||||
|
<h2>
|
||||||
|
Verlauf<?= $filterUser ? ': ' . e($displayName($filterUser)) : '' ?>
|
||||||
|
<?php if ($filterUser): ?>
|
||||||
|
<span class="contribution-filter-balance"><?= contribution_coin(20) ?> <?= contribution_format((int) $filterUser['points']) ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</h2>
|
||||||
|
<?php if ($filterUser): ?>
|
||||||
|
<a href="/contributions.php#verlauf">Alle Vergaben anzeigen</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (empty($awards)): ?>
|
||||||
|
<p class="text-muted">Noch keine Beitragspunkte vergeben.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="contribution-awards">
|
||||||
|
<?php foreach ($awards as $award): ?>
|
||||||
|
<?php
|
||||||
|
$entries = $award['entries'];
|
||||||
|
$pointValues = array_unique(array_map(static fn (array $entry): int => (int) $entry['points'], $entries));
|
||||||
|
$uniform = count($pointValues) === 1 ? (int) reset($pointValues) : null;
|
||||||
|
$mine = null;
|
||||||
|
if ($filterUserId !== null) {
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
if ((int) $entry['user_id'] === $filterUserId) {
|
||||||
|
$mine = (int) $entry['points'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$shownPoints = $mine ?? $uniform;
|
||||||
|
?>
|
||||||
|
<article class="contribution-award">
|
||||||
|
<div class="contribution-award-points<?= $shownPoints !== null && $shownPoints < 0 ? ' negative' : '' ?>">
|
||||||
|
<?= contribution_coin(22) ?>
|
||||||
|
<strong><?= $shownPoints !== null ? contribution_format($shownPoints, true) : 'versch.' ?></strong>
|
||||||
|
<?php if ($mine === null && count($entries) > 1): ?>
|
||||||
|
<span class="text-muted">je Mitglied</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="contribution-award-body">
|
||||||
|
<div class="contribution-award-title">
|
||||||
|
<span class="badge contribution-badge-<?= e((string) $award['category']) ?>"><?= e(contribution_category_label((string) $award['category'])) ?></span>
|
||||||
|
<strong><?= e((string) $award['title']) ?></strong>
|
||||||
|
</div>
|
||||||
|
<?php if (!empty($award['note'])): ?>
|
||||||
|
<p class="contribution-award-note"><?= e((string) $award['note']) ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="contribution-award-meta text-muted">
|
||||||
|
<?= e(contribution_format_time($award['awarded_at'])) ?>
|
||||||
|
· <?= count($entries) ?> <?= count($entries) === 1 ? 'Mitglied' : 'Mitglieder' ?>
|
||||||
|
<?php if (!empty($award['author'])): ?>· vergeben von <?= e((string) $award['author']) ?><?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<details class="contribution-award-members"<?= count($entries) <= 6 ? ' open' : '' ?>>
|
||||||
|
<summary>Mitglieder anzeigen</summary>
|
||||||
|
<div class="contribution-chips">
|
||||||
|
<?php foreach ($entries as $entry): ?>
|
||||||
|
<span class="contribution-chip<?= (int) $entry['user_id'] === $filterUserId ? ' highlight' : '' ?>">
|
||||||
|
<a href="/contributions.php?user=<?= (int) $entry['user_id'] ?>#verlauf"><?= e((string) $entry['name']) ?></a>
|
||||||
|
<?php if ($uniform === null): ?>
|
||||||
|
<span class="text-muted"><?= contribution_format((int) $entry['points'], true) ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($canManage): ?>
|
||||||
|
<form class="inline-form" method="post" action="/contributions_action.php"
|
||||||
|
onsubmit="return confirm(<?= e(json_encode('„' . $entry['name'] . '“ aus dieser Vergabe entfernen? Die Punkte werden abgezogen.', JSON_UNESCAPED_UNICODE)) ?>);">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="remove_entry">
|
||||||
|
<input type="hidden" name="entry_id" value="<?= (int) $entry['id'] ?>">
|
||||||
|
<button type="submit" class="contribution-chip-remove" title="Aus der Vergabe entfernen" aria-label="Entfernen">×</button>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<?php if ($canManage): ?>
|
||||||
|
<form class="contribution-award-delete" method="post" action="/contributions_action.php"
|
||||||
|
onsubmit="return confirm(<?= e(json_encode('Vergabe „' . $award['title'] . '“ komplett löschen? Allen ' . count($entries) . ' Mitgliedern werden die Punkte wieder abgezogen.', JSON_UNESCAPED_UNICODE)) ?>);">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="delete_award">
|
||||||
|
<input type="hidden" name="award_id" value="<?= (int) $award['id'] ?>">
|
||||||
|
<button type="submit" class="icon-button icon-button-danger" title="Vergabe löschen" aria-label="Vergabe löschen"><?= icon('trash') ?></button>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</article>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<div class="contribution-pages">
|
||||||
|
<span class="text-muted">
|
||||||
|
Vergaben <?= ($page - 1) * $perPage + 1 ?>–<?= min($page * $perPage, $totalAwards) ?>
|
||||||
|
von <?= number_format($totalAwards, 0, ',', '.') ?>
|
||||||
|
</span>
|
||||||
|
<?php render_pagination('/contributions.php?' . ($filterUserId !== null ? 'user=' . $filterUserId . '&' : ''), $page, $pageCount, '#verlauf'); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/assets/js/contributions.js"></script>
|
||||||
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||||
119
contributions_action.php
Normal file
119
contributions_action.php
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
|
require_once __DIR__ . '/includes/contributions.php';
|
||||||
|
require_permission('contributions.manage');
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
redirect('/contributions.php');
|
||||||
|
}
|
||||||
|
verify_csrf();
|
||||||
|
|
||||||
|
$action = (string) ($_POST['action'] ?? '');
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
/** Zurueck ins Formular, mit Fehlermeldung und den bisherigen Eingaben. */
|
||||||
|
function contribution_fail(string $message): void
|
||||||
|
{
|
||||||
|
$_SESSION['contribution_form'] = [
|
||||||
|
'category' => (string) ($_POST['category'] ?? ''),
|
||||||
|
'raid_id' => (string) ($_POST['raid_id'] ?? ''),
|
||||||
|
'title' => (string) ($_POST['title'] ?? ''),
|
||||||
|
'awarded_at' => (string) ($_POST['awarded_at'] ?? ''),
|
||||||
|
'points' => (string) ($_POST['points'] ?? ''),
|
||||||
|
'note' => (string) ($_POST['note'] ?? ''),
|
||||||
|
'users' => array_map('intval', (array) ($_POST['users'] ?? [])),
|
||||||
|
];
|
||||||
|
set_flash('error', $message);
|
||||||
|
redirect('/contributions_award.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($action) {
|
||||||
|
// ---- Punkte vergeben ----
|
||||||
|
case 'create':
|
||||||
|
$category = (string) ($_POST['category'] ?? '');
|
||||||
|
if (!array_key_exists($category, CONTRIBUTION_CATEGORIES)) {
|
||||||
|
contribution_fail('Bitte einen Anlass auswählen.');
|
||||||
|
}
|
||||||
|
$title = trim((string) ($_POST['title'] ?? ''));
|
||||||
|
if ($title === '' || mb_strlen($title) > 150) {
|
||||||
|
contribution_fail('Bitte einen Grund mit höchstens 150 Zeichen angeben.');
|
||||||
|
}
|
||||||
|
$note = trim((string) ($_POST['note'] ?? ''));
|
||||||
|
if (mb_strlen($note) > 255) {
|
||||||
|
contribution_fail('Die Bemerkung darf höchstens 255 Zeichen lang sein.');
|
||||||
|
}
|
||||||
|
$points = filter_var($_POST['points'] ?? '', FILTER_VALIDATE_INT);
|
||||||
|
if ($points === false || $points === 0 || abs($points) > CONTRIBUTION_MAX_POINTS) {
|
||||||
|
contribution_fail('Bitte eine Punktzahl zwischen 1 und ' . number_format(CONTRIBUTION_MAX_POINTS, 0, ',', '.') . ' angeben (negativ für einen Abzug).');
|
||||||
|
}
|
||||||
|
$awardedAt = contribution_parse_time((string) ($_POST['awarded_at'] ?? ''));
|
||||||
|
if ($awardedAt === null) {
|
||||||
|
contribution_fail('Bitte ein gültiges Datum angeben (nicht in der Zukunft).');
|
||||||
|
}
|
||||||
|
$raidId = $category === 'raid' ? (int) ($_POST['raid_id'] ?? 0) : 0;
|
||||||
|
|
||||||
|
// Nur aktive Konten - doppelte oder unbekannte IDs fallen hier heraus.
|
||||||
|
$userIds = array_values(array_unique(array_filter(array_map('intval', (array) ($_POST['users'] ?? [])))));
|
||||||
|
if (!empty($userIds)) {
|
||||||
|
$placeholders = implode(',', array_fill(0, count($userIds), '?'));
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM users WHERE status = 'active' AND id IN ($placeholders)");
|
||||||
|
$stmt->execute($userIds);
|
||||||
|
$userIds = array_map('intval', $stmt->fetchAll(PDO::FETCH_COLUMN));
|
||||||
|
}
|
||||||
|
if (empty($userIds)) {
|
||||||
|
contribution_fail('Bitte mindestens ein Mitglied auswählen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
$pdo->prepare(
|
||||||
|
'INSERT INTO contribution_awards (category, title, note, raid_id, awarded_at, created_by) VALUES (?, ?, ?, ?, ?, ?)'
|
||||||
|
)->execute([$category, $title, $note !== '' ? $note : null, $raidId > 0 ? $raidId : null, $awardedAt, (int) current_user()['id']]);
|
||||||
|
$awardId = (int) $pdo->lastInsertId();
|
||||||
|
|
||||||
|
$insert = $pdo->prepare('INSERT INTO contribution_entries (award_id, user_id, points) VALUES (?, ?, ?)');
|
||||||
|
foreach ($userIds as $userId) {
|
||||||
|
$insert->execute([$awardId, $userId, $points]);
|
||||||
|
}
|
||||||
|
$pdo->commit();
|
||||||
|
|
||||||
|
$count = count($userIds);
|
||||||
|
$who = $count === 1 ? '1 Mitglied' : $count . ' Mitglieder';
|
||||||
|
set_flash('success', $points > 0
|
||||||
|
? contribution_format($points) . ' Beitragspunkte an ' . $who . ' vergeben.'
|
||||||
|
: contribution_format(-$points) . ' Beitragspunkte bei ' . $who . ' abgezogen.');
|
||||||
|
redirect('/contributions.php');
|
||||||
|
|
||||||
|
// ---- Ganze Vergabe loeschen ----
|
||||||
|
case 'delete_award':
|
||||||
|
$stmt = $pdo->prepare('DELETE FROM contribution_awards WHERE id = ?');
|
||||||
|
$stmt->execute([(int) ($_POST['award_id'] ?? 0)]);
|
||||||
|
set_flash($stmt->rowCount() > 0 ? 'success' : 'error', $stmt->rowCount() > 0 ? 'Vergabe gelöscht.' : 'Diese Vergabe gibt es nicht mehr.');
|
||||||
|
redirect('/contributions.php#verlauf');
|
||||||
|
|
||||||
|
// ---- Ein Mitglied aus einer Vergabe entfernen ----
|
||||||
|
case 'remove_entry':
|
||||||
|
$entryId = (int) ($_POST['entry_id'] ?? 0);
|
||||||
|
$stmt = $pdo->prepare('SELECT award_id FROM contribution_entries WHERE id = ?');
|
||||||
|
$stmt->execute([$entryId]);
|
||||||
|
$awardId = (int) $stmt->fetchColumn();
|
||||||
|
if ($awardId === 0) {
|
||||||
|
set_flash('error', 'Diesen Eintrag gibt es nicht mehr.');
|
||||||
|
redirect('/contributions.php#verlauf');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
$pdo->prepare('DELETE FROM contribution_entries WHERE id = ?')->execute([$entryId]);
|
||||||
|
// War es das letzte Mitglied, bliebe eine leere Vergabe uebrig - die faellt mit weg.
|
||||||
|
$left = $pdo->prepare('SELECT COUNT(*) FROM contribution_entries WHERE award_id = ?');
|
||||||
|
$left->execute([$awardId]);
|
||||||
|
if ((int) $left->fetchColumn() === 0) {
|
||||||
|
$pdo->prepare('DELETE FROM contribution_awards WHERE id = ?')->execute([$awardId]);
|
||||||
|
}
|
||||||
|
$pdo->commit();
|
||||||
|
|
||||||
|
set_flash('success', 'Mitglied aus der Vergabe entfernt.');
|
||||||
|
redirect('/contributions.php#verlauf');
|
||||||
|
|
||||||
|
default:
|
||||||
|
redirect('/contributions.php');
|
||||||
|
}
|
||||||
169
contributions_award.php
Normal file
169
contributions_award.php
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
|
require_once __DIR__ . '/includes/contributions.php';
|
||||||
|
require_once __DIR__ . '/includes/raids_api.php';
|
||||||
|
require_permission('contributions.manage');
|
||||||
|
|
||||||
|
$members = db()->query(
|
||||||
|
"SELECT u.id, u.username, u.display_name, u.avatar_filename, u.discord_id,
|
||||||
|
COALESCE(SUM(e.points), 0) AS points
|
||||||
|
FROM users u
|
||||||
|
LEFT JOIN contribution_entries e ON e.user_id = u.id
|
||||||
|
WHERE u.status = 'active'
|
||||||
|
GROUP BY u.id
|
||||||
|
ORDER BY COALESCE(NULLIF(u.display_name, ''), u.username)"
|
||||||
|
)->fetchAll();
|
||||||
|
|
||||||
|
$userIdByDiscord = [];
|
||||||
|
foreach ($members as $member) {
|
||||||
|
if (!empty($member['discord_id'])) {
|
||||||
|
$userIdByDiscord[(string) $member['discord_id']] = (int) $member['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raids fuer den Anlass "Raid": die Teilnehmer (Anmeldungen in einer Gruppe) werden im
|
||||||
|
// Formular vorausgewaehlt - soweit sie ein Website-Konto mit Discord-Verknuepfung haben.
|
||||||
|
$raids = [];
|
||||||
|
$raidsError = null;
|
||||||
|
try {
|
||||||
|
$apiRaids = fetch_raids('all');
|
||||||
|
usort($apiRaids, static fn (array $a, array $b): int => (int) ($b['timestamp'] ?? 0) <=> (int) ($a['timestamp'] ?? 0));
|
||||||
|
foreach (array_slice($apiRaids, 0, 40) as $raid) {
|
||||||
|
$participants = [];
|
||||||
|
$bench = [];
|
||||||
|
$withoutAccount = [];
|
||||||
|
foreach ((array) ($raid['signups'] ?? []) as $signup) {
|
||||||
|
$group = (int) ($signup['group'] ?? 0);
|
||||||
|
if ($group < 0 || ($signup['class'] ?? '') === 'Ausstehend') {
|
||||||
|
continue; // abgemeldet bzw. noch nicht bestaetigt
|
||||||
|
}
|
||||||
|
$userId = $userIdByDiscord[(string) ($signup['user_id'] ?? '')] ?? null;
|
||||||
|
if ($userId === null) {
|
||||||
|
$withoutAccount[] = (string) ($signup['name'] ?? '?');
|
||||||
|
} elseif ($group >= 1) {
|
||||||
|
$participants[] = $userId;
|
||||||
|
} else {
|
||||||
|
$bench[] = $userId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$timestamp = (int) ($raid['timestamp'] ?? 0);
|
||||||
|
$raids[] = [
|
||||||
|
'id' => (int) ($raid['raid_id'] ?? 0),
|
||||||
|
'title' => (string) ($raid['title'] ?? 'Raid'),
|
||||||
|
'date' => $timestamp ? date('d.m.Y H:i', $timestamp) : (string) ($raid['date'] ?? ''),
|
||||||
|
'time' => $timestamp ? date('Y-m-d\TH:i', $timestamp) : '',
|
||||||
|
'participants' => $participants,
|
||||||
|
'bench' => $bench,
|
||||||
|
'withoutAccount' => $withoutAccount,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$raidsError = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vorbelegung: nach einem Fehler die bisherigen Eingaben, sonst ggf. ein einzelnes Mitglied.
|
||||||
|
$old = $_SESSION['contribution_form'] ?? null;
|
||||||
|
unset($_SESSION['contribution_form']);
|
||||||
|
$preselectUser = isset($_GET['user']) ? (int) $_GET['user'] : 0;
|
||||||
|
$form = $old ?? [
|
||||||
|
'category' => $preselectUser ? 'other' : 'raid',
|
||||||
|
'raid_id' => '',
|
||||||
|
'title' => '',
|
||||||
|
'awarded_at' => contribution_now_input(),
|
||||||
|
'points' => '',
|
||||||
|
'note' => '',
|
||||||
|
'users' => $preselectUser ? [$preselectUser] : [],
|
||||||
|
];
|
||||||
|
$selected = array_map('intval', (array) ($form['users'] ?? []));
|
||||||
|
|
||||||
|
$pageTitle = 'Beitragspunkte vergeben';
|
||||||
|
$containerWide = true;
|
||||||
|
include __DIR__ . '/includes/header.php';
|
||||||
|
?>
|
||||||
|
<form class="panel contribution-form" method="post" action="/contributions_action.php" id="contribution-form">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="create">
|
||||||
|
|
||||||
|
<div class="contribution-head">
|
||||||
|
<h1><?= contribution_coin(32) ?> Beitragspunkte vergeben</h1>
|
||||||
|
<a href="/contributions.php">Zurück zur Übersicht</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="contribution-form-grid">
|
||||||
|
<div>
|
||||||
|
<label for="category">Anlass</label>
|
||||||
|
<select id="category" name="category">
|
||||||
|
<?php foreach (CONTRIBUTION_CATEGORIES as $key => $label): ?>
|
||||||
|
<option value="<?= e($key) ?>" <?= ($form['category'] ?? '') === $key ? 'selected' : '' ?>><?= e($label) ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="raid-field">
|
||||||
|
<label for="raid_id">Raid <span class="text-muted">(optional)</span></label>
|
||||||
|
<?php if ($raidsError === null): ?>
|
||||||
|
<select id="raid_id" name="raid_id">
|
||||||
|
<option value="">– keinen Raid auswählen –</option>
|
||||||
|
<?php foreach ($raids as $raid): ?>
|
||||||
|
<option value="<?= (int) $raid['id'] ?>" <?= (string) ($form['raid_id'] ?? '') === (string) $raid['id'] ? 'selected' : '' ?>>
|
||||||
|
<?= e($raid['title']) ?><?= $raid['date'] !== '' ? ' – ' . e($raid['date']) : '' ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<div class="field-hint" id="raid-hint">Wählt die Teilnehmer des Raids automatisch aus.</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="hidden" name="raid_id" value="">
|
||||||
|
<p class="field-hint">Die Raids konnten nicht geladen werden (<?= e($raidsError) ?>). Mitglieder bitte von Hand auswählen.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="contribution-form-wide">
|
||||||
|
<label for="title">Grund</label>
|
||||||
|
<input type="text" id="title" name="title" maxlength="150" required
|
||||||
|
value="<?= e((string) ($form['title'] ?? '')) ?>" placeholder="z.B. Festungskampf Verteron, Hilfe beim Handwerk …">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="points">Punkte pro Mitglied</label>
|
||||||
|
<input type="number" id="points" name="points" required step="1"
|
||||||
|
min="-<?= CONTRIBUTION_MAX_POINTS ?>" max="<?= CONTRIBUTION_MAX_POINTS ?>"
|
||||||
|
value="<?= e((string) ($form['points'] ?? '')) ?>" placeholder="z.B. 10">
|
||||||
|
<div class="field-hint">Negativ für einen Abzug.</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="awarded_at">Datum</label>
|
||||||
|
<input type="datetime-local" id="awarded_at" name="awarded_at" required value="<?= e((string) ($form['awarded_at'] ?? contribution_now_input())) ?>">
|
||||||
|
</div>
|
||||||
|
<div class="contribution-form-wide">
|
||||||
|
<label for="note">Bemerkung <span class="text-muted">(optional)</span></label>
|
||||||
|
<input type="text" id="note" name="note" maxlength="255" value="<?= e((string) ($form['note'] ?? '')) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="contribution-picker">
|
||||||
|
<div class="contribution-picker-head">
|
||||||
|
<label>Mitglieder <span class="contribution-picker-count" id="picker-count"></span></label>
|
||||||
|
<input type="search" id="picker-search" placeholder="Mitglied suchen …" autocomplete="off">
|
||||||
|
<button type="button" class="button-secondary button-small" id="picker-all">Alle</button>
|
||||||
|
<button type="button" class="button-secondary button-small" id="picker-none">Keine</button>
|
||||||
|
</div>
|
||||||
|
<p class="field-hint contribution-raid-info" id="raid-info" hidden></p>
|
||||||
|
<div class="contribution-picker-grid">
|
||||||
|
<?php foreach ($members as $member): ?>
|
||||||
|
<?php $name = (string) ($member['display_name'] !== '' ? $member['display_name'] : $member['username']); ?>
|
||||||
|
<label class="contribution-pick" data-name="<?= e(mb_strtolower($name)) ?>">
|
||||||
|
<input type="checkbox" name="users[]" value="<?= (int) $member['id'] ?>" <?= in_array((int) $member['id'], $selected, true) ? 'checked' : '' ?>>
|
||||||
|
<?= avatar_html($member, 32) ?>
|
||||||
|
<span class="contribution-pick-name"><?= e($name) ?></span>
|
||||||
|
<span class="contribution-pick-points"><?= contribution_coin(14) ?> <?= contribution_format((int) $member['points']) ?></span>
|
||||||
|
</label>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit" id="contribution-submit">Punkte vergeben</button>
|
||||||
|
<a class="button button-secondary" href="/contributions.php">Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script id="contribution-raids" type="application/json"><?= json_encode($raids, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) ?></script>
|
||||||
|
<script src="/assets/js/contributions.js"></script>
|
||||||
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||||
152
includes/contributions.php
Normal file
152
includes/contributions.php
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beitragspunkte: Punkte, die Mitglieder fuer Raids und andere Aktivitaeten bekommen.
|
||||||
|
*
|
||||||
|
* Eine Vergabe (contribution_awards) ist ein Anlass mit Grund und Datum, an dem ein oder
|
||||||
|
* mehrere Mitglieder beteiligt sind (contribution_entries, je Mitglied die Punkte). Der
|
||||||
|
* Punktestand wird nicht gespeichert, sondern aus der Summe berechnet - so kann er nie von
|
||||||
|
* der Historie abweichen, und spaeter lassen sich Punkte auch ausgeben (negative Eintraege).
|
||||||
|
*/
|
||||||
|
|
||||||
|
const CONTRIBUTION_CATEGORIES = [
|
||||||
|
'raid' => 'Raid',
|
||||||
|
'event' => 'Event',
|
||||||
|
'other' => 'Sonstiges',
|
||||||
|
];
|
||||||
|
|
||||||
|
// So viele Plaetze der Rangliste sieht jeder mit contributions.view - den Rest nur mit
|
||||||
|
// contributions.view_all (oder contributions.manage).
|
||||||
|
const CONTRIBUTION_PUBLIC_RANKS = 25;
|
||||||
|
|
||||||
|
// Obergrenze pro Mitglied und Vergabe - schuetzt vor Tippfehlern wie 10000 statt 100.
|
||||||
|
const CONTRIBUTION_MAX_POINTS = 10000;
|
||||||
|
|
||||||
|
function contribution_category_label(string $key): string
|
||||||
|
{
|
||||||
|
return CONTRIBUTION_CATEGORIES[$key] ?? $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Das Muenz-Symbol der Beitragspunkte. */
|
||||||
|
function contribution_coin(int $size = 20): string
|
||||||
|
{
|
||||||
|
return '<img class="contribution-coin" src="/assets/images/beitragspunkt.svg" alt="Beitragspunkte" '
|
||||||
|
. 'width="' . $size . '" height="' . $size . '">';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Punkte mit Tausenderpunkt, Abzuege mit echtem Minuszeichen. */
|
||||||
|
function contribution_format(int $points, bool $withSign = false): string
|
||||||
|
{
|
||||||
|
$formatted = number_format(abs($points), 0, ',', '.');
|
||||||
|
if ($points < 0) {
|
||||||
|
return '−' . $formatted;
|
||||||
|
}
|
||||||
|
return ($withSign && $points > 0 ? '+' : '') . $formatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Punktestand aller aktiven Mitglieder (auch 0), hoechster zuerst.
|
||||||
|
*
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
function contribution_balances(): array
|
||||||
|
{
|
||||||
|
return db()->query(
|
||||||
|
"SELECT u.id, u.username, u.display_name, u.avatar_filename,
|
||||||
|
COALESCE(SUM(e.points), 0) AS points,
|
||||||
|
COUNT(e.id) AS award_count
|
||||||
|
FROM users u
|
||||||
|
LEFT JOIN contribution_entries e ON e.user_id = u.id
|
||||||
|
WHERE u.status = 'active'
|
||||||
|
GROUP BY u.id
|
||||||
|
ORDER BY points DESC, COALESCE(NULLIF(u.display_name, ''), u.username)"
|
||||||
|
)->fetchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
function contribution_user_balance(int $userId): int
|
||||||
|
{
|
||||||
|
$stmt = db()->prepare('SELECT COALESCE(SUM(points), 0) FROM contribution_entries WHERE user_id = ?');
|
||||||
|
$stmt->execute([$userId]);
|
||||||
|
return (int) $stmt->fetchColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
function contribution_award_count(?int $userId): int
|
||||||
|
{
|
||||||
|
if ($userId === null) {
|
||||||
|
return (int) db()->query('SELECT COUNT(*) FROM contribution_awards')->fetchColumn();
|
||||||
|
}
|
||||||
|
$stmt = db()->prepare('SELECT COUNT(*) FROM contribution_entries WHERE user_id = ?');
|
||||||
|
$stmt->execute([$userId]);
|
||||||
|
return (int) $stmt->fetchColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vergaben mit ihren Empfaengern, neueste zuerst. Mit $userId nur die Vergaben, an denen
|
||||||
|
* dieses Mitglied beteiligt war.
|
||||||
|
*
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
function contribution_awards(?int $userId, int $limit, int $offset): array
|
||||||
|
{
|
||||||
|
$join = $userId !== null ? 'JOIN contribution_entries mine ON mine.award_id = a.id AND mine.user_id = ?' : '';
|
||||||
|
$stmt = db()->prepare(
|
||||||
|
"SELECT a.id, a.category, a.title, a.note, a.raid_id, a.awarded_at,
|
||||||
|
COALESCE(NULLIF(cu.display_name, ''), cu.username) AS author
|
||||||
|
FROM contribution_awards a
|
||||||
|
$join
|
||||||
|
LEFT JOIN users cu ON cu.id = a.created_by
|
||||||
|
ORDER BY a.awarded_at DESC, a.id DESC
|
||||||
|
LIMIT " . (int) $limit . ' OFFSET ' . (int) $offset
|
||||||
|
);
|
||||||
|
$stmt->execute($userId !== null ? [$userId] : []);
|
||||||
|
|
||||||
|
$awards = [];
|
||||||
|
foreach ($stmt->fetchAll() as $row) {
|
||||||
|
$row['entries'] = [];
|
||||||
|
$awards[(int) $row['id']] = $row;
|
||||||
|
}
|
||||||
|
if (empty($awards)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$ids = array_keys($awards);
|
||||||
|
$placeholders = implode(',', array_fill(0, count($ids), '?'));
|
||||||
|
$entryStmt = db()->prepare(
|
||||||
|
"SELECT e.id, e.award_id, e.user_id, e.points,
|
||||||
|
COALESCE(NULLIF(u.display_name, ''), u.username) AS name
|
||||||
|
FROM contribution_entries e
|
||||||
|
JOIN users u ON u.id = e.user_id
|
||||||
|
WHERE e.award_id IN ($placeholders)
|
||||||
|
ORDER BY name"
|
||||||
|
);
|
||||||
|
$entryStmt->execute($ids);
|
||||||
|
foreach ($entryStmt->fetchAll() as $entry) {
|
||||||
|
$awards[(int) $entry['award_id']]['entries'][] = $entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values($awards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Jetzt in deutscher Zeit fuer ein datetime-local-Feld. */
|
||||||
|
function contribution_now_input(): string
|
||||||
|
{
|
||||||
|
return (new DateTimeImmutable('now', new DateTimeZone('Europe/Berlin')))->format('Y-m-d\TH:i');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zeitpunkt aus einem datetime-local-Feld, null bei ungueltiger Eingabe oder weit in der Zukunft. */
|
||||||
|
function contribution_parse_time(string $value): ?string
|
||||||
|
{
|
||||||
|
$tz = new DateTimeZone('Europe/Berlin');
|
||||||
|
$time = DateTimeImmutable::createFromFormat('Y-m-d\TH:i', trim($value), $tz);
|
||||||
|
if ($time === false || $time > new DateTimeImmutable('+1 day', $tz)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $time->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
function contribution_format_time(?string $value): string
|
||||||
|
{
|
||||||
|
$time = $value ? strtotime($value) : false;
|
||||||
|
return $time ? date('d.m.Y H:i', $time) : '-';
|
||||||
|
}
|
||||||
|
|
@ -134,6 +134,7 @@ function icon(string $name): string
|
||||||
'at-sign' => '<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/>',
|
'at-sign' => '<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/>',
|
||||||
'chevron-down' => '<polyline points="6 9 12 15 18 9"/>',
|
'chevron-down' => '<polyline points="6 9 12 15 18 9"/>',
|
||||||
'check' => '<polyline points="20 6 9 17 4 12"/>',
|
'check' => '<polyline points="20 6 9 17 4 12"/>',
|
||||||
|
'heart' => '<path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1 1.1L12 21l7.8-7.5 1-1.1a5.5 5.5 0 0 0 0-7.8z"/>',
|
||||||
'box' => '<path d="M21 8 12 3 3 8v8l9 5 9-5z"/><path d="M3 8l9 5 9-5"/><line x1="12" y1="13" x2="12" y2="21"/>',
|
'box' => '<path d="M21 8 12 3 3 8v8l9 5 9-5z"/><path d="M3 8l9 5 9-5"/><line x1="12" y1="13" x2="12" y2="21"/>',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -226,3 +227,61 @@ function class_icon_url(string $className): ?string
|
||||||
|
|
||||||
return '/assets/images/Classes/normalized/' . $map[$key];
|
return '/assets/images/Classes/normalized/' . $map[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seitenzahlen fuer eine Blaetter-Leiste: immer die erste und letzte Seite, dazu zwei Seiten
|
||||||
|
* um die aktuelle herum, Luecken als null (wird als "..." angezeigt).
|
||||||
|
*
|
||||||
|
* @return array<int, int|null>
|
||||||
|
*/
|
||||||
|
function page_numbers(int $current, int $last): array
|
||||||
|
{
|
||||||
|
$pages = [];
|
||||||
|
$previous = 0;
|
||||||
|
for ($p = 1; $p <= $last; $p++) {
|
||||||
|
if ($p === 1 || $p === $last || abs($p - $current) <= 2) {
|
||||||
|
if ($previous && $p - $previous > 1) {
|
||||||
|
// Eine einzelne fehlende Seite lieber anzeigen als durch "..." ersetzen.
|
||||||
|
$pages[] = $p - $previous === 2 ? $p - 1 : null;
|
||||||
|
}
|
||||||
|
$pages[] = $p;
|
||||||
|
$previous = $p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blaetter-Leiste "Zurueck 1 ... 4 5 [6] 7 8 ... 20 Weiter". $baseUrl endet auf "?" oder "&",
|
||||||
|
* $anchor (z.B. "#verlauf") wird an jeden Link gehaengt.
|
||||||
|
*/
|
||||||
|
function render_pagination(string $baseUrl, int $page, int $pageCount, string $anchor = ''): void
|
||||||
|
{
|
||||||
|
if ($pageCount <= 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$link = static fn (int $number): string => e($baseUrl . 'page=' . $number . $anchor);
|
||||||
|
?>
|
||||||
|
<nav class="pagination" aria-label="Seiten">
|
||||||
|
<?php if ($page > 1): ?>
|
||||||
|
<a class="page-link" href="<?= $link($page - 1) ?>">‹ Zurück</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<span class="page-link disabled">‹ Zurück</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php foreach (page_numbers($page, $pageCount) as $number): ?>
|
||||||
|
<?php if ($number === null): ?>
|
||||||
|
<span class="page-gap">…</span>
|
||||||
|
<?php elseif ($number === $page): ?>
|
||||||
|
<span class="page-link active" aria-current="page"><?= $number ?></span>
|
||||||
|
<?php else: ?>
|
||||||
|
<a class="page-link" href="<?= $link($number) ?>"><?= $number ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($page < $pageCount): ?>
|
||||||
|
<a class="page-link" href="<?= $link($page + 1) ?>">Weiter ›</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<span class="page-link disabled">Weiter ›</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</nav>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,18 @@ $canViewPremades = $currentUser && user_has_permission('premades.view');
|
||||||
$canViewEvents = $currentUser && user_has_permission('events.view');
|
$canViewEvents = $currentUser && user_has_permission('events.view');
|
||||||
$canViewMap = $currentUser && user_has_permission('map.view');
|
$canViewMap = $currentUser && user_has_permission('map.view');
|
||||||
$canViewWarehouse = $currentUser && user_has_permission('warehouse.view');
|
$canViewWarehouse = $currentUser && user_has_permission('warehouse.view');
|
||||||
|
$canViewContributions = $currentUser && user_has_permission('contributions.view');
|
||||||
|
// Eigener Punktestand unten in der Seitenleiste.
|
||||||
|
$sidebarPoints = null;
|
||||||
|
if ($canViewContributions && $shellUser) {
|
||||||
|
try {
|
||||||
|
$pointsStmt = db()->prepare('SELECT COALESCE(SUM(points), 0) FROM contribution_entries WHERE user_id = ?');
|
||||||
|
$pointsStmt->execute([(int) $shellUser['id']]);
|
||||||
|
$sidebarPoints = (int) $pointsStmt->fetchColumn();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$sidebarPoints = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
$canViewMembers = $currentUser && user_has_permission('members.view');
|
$canViewMembers = $currentUser && user_has_permission('members.view');
|
||||||
$canViewReports = $currentUser && user_has_permission('reports.view');
|
$canViewReports = $currentUser && user_has_permission('reports.view');
|
||||||
$showAdminMenu = $canViewUsers || $canManageRoles || $canViewReports;
|
$showAdminMenu = $canViewUsers || $canManageRoles || $canViewReports;
|
||||||
|
|
@ -27,6 +39,7 @@ $isPremadesActive = $currentScript === 'premades.php';
|
||||||
$isEventsActive = $currentScript === 'events.php';
|
$isEventsActive = $currentScript === 'events.php';
|
||||||
$isMapActive = $currentScript === 'map.php';
|
$isMapActive = $currentScript === 'map.php';
|
||||||
$isWarehouseActive = $currentScript === 'warehouse.php';
|
$isWarehouseActive = $currentScript === 'warehouse.php';
|
||||||
|
$isContributionsActive = in_array($currentScript, ['contributions.php', 'contributions_award.php'], true);
|
||||||
$isMembersActive = $currentScript === 'members.php';
|
$isMembersActive = $currentScript === 'members.php';
|
||||||
$isReportsActive = $currentScript === 'reports.php';
|
$isReportsActive = $currentScript === 'reports.php';
|
||||||
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php', 'user_approve.php'], true);
|
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php', 'user_approve.php'], true);
|
||||||
|
|
@ -41,6 +54,8 @@ $pageBackgrounds = [
|
||||||
'events.php' => 'bg-events',
|
'events.php' => 'bg-events',
|
||||||
'map.php' => 'bg-map',
|
'map.php' => 'bg-map',
|
||||||
'warehouse.php' => 'bg-warehouse',
|
'warehouse.php' => 'bg-warehouse',
|
||||||
|
'contributions.php' => 'bg-contributions',
|
||||||
|
'contributions_award.php' => 'bg-contributions',
|
||||||
'members.php' => 'bg-members',
|
'members.php' => 'bg-members',
|
||||||
'users.php' => 'bg-admin',
|
'users.php' => 'bg-admin',
|
||||||
'user_form.php' => 'bg-admin',
|
'user_form.php' => 'bg-admin',
|
||||||
|
|
@ -94,11 +109,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
||||||
<button type="button" class="sidebar-toggle" aria-label="Menü öffnen" aria-expanded="false">
|
<button type="button" class="sidebar-toggle" aria-label="Menü öffnen" aria-expanded="false">
|
||||||
<?= icon('menu') ?>
|
<?= icon('menu') ?>
|
||||||
</button>
|
</button>
|
||||||
<a href="/" class="mobile-topbar-brand"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a>
|
<a href="/" class="mobile-topbar-brand"><img src="/assets/images/logo-wordmark.webp" alt="Lumina Ascendens" width="409" height="132"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-backdrop"></div>
|
<div class="sidebar-backdrop"></div>
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a></div>
|
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-lumina.webp" alt="Lumina Ascendens" width="400" height="400"></a></div>
|
||||||
<nav class="sidebar-nav">
|
<nav class="sidebar-nav">
|
||||||
<a href="/dashboard.php" class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
|
<a href="/dashboard.php" class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
|
||||||
<?= icon('home') ?><span class="label">Dashboard</span>
|
<?= icon('home') ?><span class="label">Dashboard</span>
|
||||||
|
|
@ -106,6 +121,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
||||||
<a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
|
<a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
|
||||||
<?= icon('profile') ?><span class="label">Mein Profil</span>
|
<?= icon('profile') ?><span class="label">Mein Profil</span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php if ($canViewContributions): ?>
|
||||||
|
<a href="/contributions.php" class="sidebar-link<?= $isContributionsActive ? ' active' : '' ?>" title="Beitragspunkte">
|
||||||
|
<?= icon('heart') ?><span class="label">Beitragspunkte</span>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
<?php if ($canViewMembers): ?>
|
<?php if ($canViewMembers): ?>
|
||||||
<a href="/members.php" class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
|
<a href="/members.php" class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
|
||||||
<?= icon('users') ?><span class="label">Mitglieder</span>
|
<?= icon('users') ?><span class="label">Mitglieder</span>
|
||||||
|
|
@ -165,7 +185,14 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
||||||
<div class="sidebar-footer">
|
<div class="sidebar-footer">
|
||||||
<div class="sidebar-user">
|
<div class="sidebar-user">
|
||||||
<?= avatar_html($currentUser, 36) ?>
|
<?= avatar_html($currentUser, 36) ?>
|
||||||
<div>Angemeldet als<br><strong><?= e($currentUser['display_name'] !== '' ? $currentUser['display_name'] : $currentUser['username']) ?></strong></div>
|
<div>
|
||||||
|
Angemeldet als<br><strong><?= e($currentUser['display_name'] !== '' ? $currentUser['display_name'] : $currentUser['username']) ?></strong>
|
||||||
|
<?php if ($sidebarPoints !== null): ?>
|
||||||
|
<a class="sidebar-points" href="/contributions.php" title="Deine Beitragspunkte">
|
||||||
|
<img src="/assets/images/beitragspunkt.svg" alt="" width="14" height="14"> <?= e(number_format($sidebarPoints, 0, ',', '.')) ?>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="/logout.php" class="sidebar-link" title="Abmelden">
|
<a href="/logout.php" class="sidebar-link" title="Abmelden">
|
||||||
<?= icon('log-out') ?><span class="label">Abmelden</span>
|
<?= icon('log-out') ?><span class="label">Abmelden</span>
|
||||||
|
|
@ -179,7 +206,7 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<header class="navbar">
|
<header class="navbar">
|
||||||
<div class="navbar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a></div>
|
<div class="navbar-brand"><a href="/"><img src="/assets/images/logo-wordmark.webp" alt="Lumina Ascendens" width="409" height="132"></a></div>
|
||||||
<div class="navbar-user">
|
<div class="navbar-user">
|
||||||
<?php if ($currentUser): ?>
|
<?php if ($currentUser): ?>
|
||||||
<a href="/logout.php">Abmelden</a>
|
<a href="/logout.php">Abmelden</a>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ const CORE_PERMISSIONS = [
|
||||||
['key' => 'map.tactics', 'description' => 'Taktiken auf der Karte anlegen, zeichnen und bearbeiten'],
|
['key' => 'map.tactics', 'description' => 'Taktiken auf der Karte anlegen, zeichnen und bearbeiten'],
|
||||||
['key' => 'warehouse.view', 'description' => 'Lagerhaus: Bestand und Verlauf einsehen'],
|
['key' => 'warehouse.view', 'description' => 'Lagerhaus: Bestand und Verlauf einsehen'],
|
||||||
['key' => 'warehouse.manage', 'description' => 'Lagerhaus: Gegenstände einlagern, entnehmen und Einträge löschen'],
|
['key' => 'warehouse.manage', 'description' => 'Lagerhaus: Gegenstände einlagern, entnehmen und Einträge löschen'],
|
||||||
|
['key' => 'contributions.view', 'description' => 'Beitragspunkte: Punktestände und Verlauf einsehen'],
|
||||||
|
['key' => 'contributions.view_all', 'description' => 'Beitragspunkte: vollständige Rangliste sehen (sonst nur die besten 25)'],
|
||||||
|
['key' => 'contributions.manage', 'description' => 'Beitragspunkte vergeben, abziehen und Vergaben löschen'],
|
||||||
['key' => 'members.view', 'description' => 'Mitgliederliste einsehen'],
|
['key' => 'members.view', 'description' => 'Mitgliederliste einsehen'],
|
||||||
['key' => 'reports.view', 'description' => 'Eingegangene Reports einsehen'],
|
['key' => 'reports.view', 'description' => 'Eingegangene Reports einsehen'],
|
||||||
['key' => 'reports.manage', 'description' => 'Reports löschen/archivieren und die Punkte-Gewichtung verwalten'],
|
['key' => 'reports.manage', 'description' => 'Reports löschen/archivieren und die Punkte-Gewichtung verwalten'],
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||||
const SCHEMA_VERSION = 3;
|
const SCHEMA_VERSION = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||||
|
|
@ -56,6 +56,35 @@ CREATE TABLE IF NOT EXISTS warehouse_movements (
|
||||||
INDEX idx_warehouse_movements_item (item_id),
|
INDEX idx_warehouse_movements_item (item_id),
|
||||||
INDEX idx_warehouse_movements_time (occurred_at)
|
INDEX idx_warehouse_movements_time (occurred_at)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||||
|
SQL,
|
||||||
|
'contribution_awards' => <<<'SQL'
|
||||||
|
CREATE TABLE IF NOT EXISTS contribution_awards (
|
||||||
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
-- raid, event, other (CONTRIBUTION_CATEGORIES in includes/contributions.php)
|
||||||
|
category VARCHAR(20) NOT NULL,
|
||||||
|
title VARCHAR(150) NOT NULL,
|
||||||
|
note VARCHAR(255) NULL,
|
||||||
|
-- Raid aus der Raid-API, wenn die Punkte fuer einen Raid vergeben wurden
|
||||||
|
raid_id INT UNSIGNED NULL,
|
||||||
|
awarded_at DATETIME NOT NULL,
|
||||||
|
created_by INT UNSIGNED NULL,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||||
|
INDEX idx_contribution_awards_time (awarded_at)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||||
|
SQL,
|
||||||
|
'contribution_entries' => <<<'SQL'
|
||||||
|
CREATE TABLE IF NOT EXISTS contribution_entries (
|
||||||
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
award_id INT UNSIGNED NOT NULL,
|
||||||
|
user_id INT UNSIGNED NOT NULL,
|
||||||
|
-- Negativ = Abzug
|
||||||
|
points INT NOT NULL,
|
||||||
|
UNIQUE KEY uq_contribution_entry (award_id, user_id),
|
||||||
|
FOREIGN KEY (award_id) REFERENCES contribution_awards(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
INDEX idx_contribution_entries_user (user_id)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||||
SQL,
|
SQL,
|
||||||
'settings' => <<<'SQL'
|
'settings' => <<<'SQL'
|
||||||
CREATE TABLE IF NOT EXISTS settings (
|
CREATE TABLE IF NOT EXISTS settings (
|
||||||
|
|
|
||||||
|
|
@ -150,29 +150,6 @@ function warehouse_movement_count(?int $itemId): int
|
||||||
return (int) $stmt->fetchColumn();
|
return (int) $stmt->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Seitenzahlen fuer eine Blaetter-Leiste: immer die erste und letzte Seite, dazu zwei Seiten
|
|
||||||
* um die aktuelle herum, Luecken als null (wird als "..." angezeigt).
|
|
||||||
*
|
|
||||||
* @return array<int, int|null>
|
|
||||||
*/
|
|
||||||
function warehouse_page_numbers(int $current, int $last): array
|
|
||||||
{
|
|
||||||
$pages = [];
|
|
||||||
$previous = 0;
|
|
||||||
for ($p = 1; $p <= $last; $p++) {
|
|
||||||
if ($p === 1 || $p === $last || abs($p - $current) <= 2) {
|
|
||||||
if ($previous && $p - $previous > 1) {
|
|
||||||
// Eine einzelne fehlende Seite lieber anzeigen als durch "..." ersetzen.
|
|
||||||
$pages[] = $p - $previous === 2 ? $p - 1 : null;
|
|
||||||
}
|
|
||||||
$pages[] = $p;
|
|
||||||
$previous = $p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Letzte Bewegungen, optional nur fuer einen Gegenstand.
|
* Letzte Bewegungen, optional nur fuer einen Gegenstand.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,39 @@ CREATE TABLE IF NOT EXISTS user_roles (
|
||||||
FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE
|
FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------
|
||||||
|
-- Beitragspunkte
|
||||||
|
-- --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- Eine Vergabe: Anlass (Raid, Event, ...) mit Grund und Datum.
|
||||||
|
CREATE TABLE IF NOT EXISTS contribution_awards (
|
||||||
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
-- raid, event, other (CONTRIBUTION_CATEGORIES in includes/contributions.php)
|
||||||
|
category VARCHAR(20) NOT NULL,
|
||||||
|
title VARCHAR(150) NOT NULL,
|
||||||
|
note VARCHAR(255) NULL,
|
||||||
|
-- Raid aus der Raid-API, wenn die Punkte fuer einen Raid vergeben wurden
|
||||||
|
raid_id INT UNSIGNED NULL,
|
||||||
|
awarded_at DATETIME NOT NULL,
|
||||||
|
created_by INT UNSIGNED NULL,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||||
|
INDEX idx_contribution_awards_time (awarded_at)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- Die beteiligten Mitglieder einer Vergabe mit ihren Punkten. Der Punktestand ist die Summe.
|
||||||
|
CREATE TABLE IF NOT EXISTS contribution_entries (
|
||||||
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
award_id INT UNSIGNED NOT NULL,
|
||||||
|
user_id INT UNSIGNED NOT NULL,
|
||||||
|
-- Negativ = Abzug
|
||||||
|
points INT NOT NULL,
|
||||||
|
UNIQUE KEY uq_contribution_entry (award_id, user_id),
|
||||||
|
FOREIGN KEY (award_id) REFERENCES contribution_awards(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
INDEX idx_contribution_entries_user (user_id)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------
|
||||||
-- Lagerhaus
|
-- Lagerhaus
|
||||||
-- --------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -208,30 +208,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
Einträge <?= ($page - 1) * $perPage + 1 ?>–<?= min($page * $perPage, $totalMovements) ?>
|
Einträge <?= ($page - 1) * $perPage + 1 ?>–<?= min($page * $perPage, $totalMovements) ?>
|
||||||
von <?= number_format($totalMovements, 0, ',', '.') ?>
|
von <?= number_format($totalMovements, 0, ',', '.') ?>
|
||||||
</span>
|
</span>
|
||||||
<?php if ($pageCount > 1): ?>
|
<?php render_pagination('/warehouse.php?' . ($filterItemId !== null ? 'item=' . $filterItemId . '&' : ''), $page, $pageCount, '#verlauf'); ?>
|
||||||
<?php $base = '/warehouse.php?' . ($filterItemId !== null ? 'item=' . $filterItemId . '&' : ''); ?>
|
|
||||||
<nav class="pagination" aria-label="Seiten des Verlaufs">
|
|
||||||
<?php if ($page > 1): ?>
|
|
||||||
<a class="page-link" href="<?= e($base . 'page=' . ($page - 1)) ?>#verlauf" title="Neuere Einträge">‹ Zurück</a>
|
|
||||||
<?php else: ?>
|
|
||||||
<span class="page-link disabled">‹ Zurück</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php foreach (warehouse_page_numbers($page, $pageCount) as $number): ?>
|
|
||||||
<?php if ($number === null): ?>
|
|
||||||
<span class="page-gap">…</span>
|
|
||||||
<?php elseif ($number === $page): ?>
|
|
||||||
<span class="page-link active" aria-current="page"><?= $number ?></span>
|
|
||||||
<?php else: ?>
|
|
||||||
<a class="page-link" href="<?= e($base . 'page=' . $number) ?>#verlauf"><?= $number ?></a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php if ($page < $pageCount): ?>
|
|
||||||
<a class="page-link" href="<?= e($base . 'page=' . ($page + 1)) ?>#verlauf" title="Ältere Einträge">Weiter ›</a>
|
|
||||||
<?php else: ?>
|
|
||||||
<span class="page-link disabled">Weiter ›</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</nav>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue