Alpenwerk HR 0.1.0 Betrieb auf Windows Server - Die Anwendung läuft im IIS (HttpPlatformHandler) unter dem Konto des Anwendungspools, ohne Administratorrechte und ohne eigenen Windows-Dienst - Das Zertifikat kommt aus dem Zertifikatsspeicher; die Bindung folgt jeder Erneuerung automatisch - Neue Versionen mit aktualisieren.ps1 -Paket <zip>, mit Sicherung vorab; Rückstieg mit zuruecksetzen.ps1 - HR-Zugang für ganze Domains mit freischalten.ps1 -Domain; Einzelsperren haben Vorrang - Anmeldung ausschließlich über Microsoft Entra ID - Das Windows-Paket hängt an jedem Release Fachliche Erweiterungen - Änderungen per Austauschdatei importieren, mit Vorschau, Prüfung und Fehlerdatei - Einstellung: eigene Maske für externe Personen, Übernahme von Leiharbeitskräften, Planstellen zum Eintrittstag - Organisationsstruktur: Einheiten und Kostenstellen anlegen, umbenennen und abschließen; Suche nach Planstelle, Einheit und Kostenstelle - Historie: Austritt, Versetzung und Eintritt berichtigen oder zurücknehmen; Planstelle mit Bezeichnung - Abwesenheiten ohne Ende, geplante Abwesenheiten mit Art, Checklisten mit Anlass, auch zur Rückkehr - Berichte mit Mehrfachauswahl in allen Kriterien; Kostenstelle als Filter und Gruppierung - Stammdaten: mehrere Notfallkontakte, Lehrzeit, Ferialkraft, Altersteilzeit, erweiterte Beschäftigtengruppen und Geschlechtsangaben
159 lines
5.4 KiB
TypeScript
159 lines
5.4 KiB
TypeScript
import { Suspense } from "react";
|
|
import { ReportsPageClient } from "@/components/reports/ReportsPageClient";
|
|
import {
|
|
aggregateEvents,
|
|
aggregateReport,
|
|
parseEventDateParam,
|
|
parseEventGroupDimension,
|
|
parseEventSplitDimension,
|
|
parseEventSubtypes,
|
|
parseEventTypes,
|
|
parseGroupDimension,
|
|
parseIsoDateParam,
|
|
parseMeasure,
|
|
parseMode,
|
|
parseSplitDimension,
|
|
sumValues,
|
|
totalForRows,
|
|
} from "@/lib/reports";
|
|
import { parseCriteria } from "@/lib/report-criteria";
|
|
import { loadEventHistory, loadOrgLookups, loadSnapshotEmployees } from "@/lib/reports-data";
|
|
import { currentUserId } from "@/lib/auth/session";
|
|
import { withUser } from "@/lib/db";
|
|
|
|
// Nur die Parameter, die diese Seite selbst auswertet. Die Auswahlkriterien
|
|
// stehen ebenfalls in der Adresszeile, werden aber geschlossen von
|
|
// parseCriteria gelesen — siehe lib/report-criteria.ts.
|
|
type SearchParams = Record<string, string | string[] | undefined> & {
|
|
mode?: string;
|
|
measure?: string;
|
|
group?: string;
|
|
split?: string;
|
|
division?: string;
|
|
location?: string;
|
|
kostenstelle?: string;
|
|
status?: string;
|
|
asOf?: string;
|
|
eventType?: string;
|
|
eventSubtype?: string;
|
|
from?: string;
|
|
to?: string;
|
|
};
|
|
|
|
export default async function ReportsPage({ searchParams }: { searchParams: Promise<SearchParams> }) {
|
|
const params = await searchParams;
|
|
const mode = parseMode(params.mode);
|
|
|
|
// Both modes are parsed up front so the data load can start before
|
|
// anything is awaited. They group by different dimension sets, so the
|
|
// parsed values stay separate rather than being widened into one type.
|
|
const asOf = parseIsoDateParam(params.asOf);
|
|
const eventGroup = parseEventGroupDimension(params.group);
|
|
const eventSplit = parseEventSplitDimension(params.split);
|
|
const eventTypes = parseEventTypes(params.eventType);
|
|
const eventSubtypes = parseEventSubtypes(params.eventSubtype, eventTypes);
|
|
const from = parseEventDateParam(params.from);
|
|
const to = parseEventDateParam(params.to);
|
|
const measure = parseMeasure(params.measure);
|
|
const group = parseGroupDimension(params.group);
|
|
const split = parseSplitDimension(params.split);
|
|
const criteria = parseCriteria((k) => (typeof params[k] === "string" ? (params[k] as string) : undefined));
|
|
|
|
// The report data depends on neither the org lookups nor on who is signed
|
|
// in, so all three go out together. Against a remote database a round trip
|
|
// costs about as much as the query itself, so sequential waves would
|
|
// dominate this page's cost.
|
|
const userId = await currentUserId();
|
|
|
|
// Alles in einer Transaktion — dort gilt der Sitzungskontext, und der
|
|
// Lesestand ist über alle Abfragen hinweg derselbe.
|
|
const { lookups, units, locations, events, employees, savedReports, kostenstellen } = await withUser(userId, async (tx) => {
|
|
const [{ lookups, units, locations }, events, employees, savedReports, kostenstellen] = await Promise.all([
|
|
loadOrgLookups(tx),
|
|
mode === "events"
|
|
? loadEventHistory(tx, {
|
|
eventTypes,
|
|
eventSubtypes,
|
|
division: params.division,
|
|
location: params.location,
|
|
from,
|
|
to,
|
|
})
|
|
: Promise.resolve([]),
|
|
mode === "snapshot"
|
|
? loadSnapshotEmployees(tx, {
|
|
division: params.division,
|
|
location: params.location,
|
|
kostenstelle: params.kostenstelle,
|
|
status: params.status,
|
|
criteria,
|
|
asOf,
|
|
})
|
|
: Promise.resolve([]),
|
|
userId
|
|
? tx
|
|
.selectFrom("saved_reports")
|
|
.select(["id", "name", "config"])
|
|
.where("created_by", "=", userId)
|
|
.orderBy("created_at", "desc")
|
|
.execute()
|
|
: Promise.resolve([]),
|
|
// Für den Filter: alle Kostenstellen, auch beendete — ein Stichtag in
|
|
// der Vergangenheit kann eine meinen, die es heute nicht mehr gibt.
|
|
tx.selectFrom("cost_centers").select(["id", "code", "name"]).orderBy("code").execute(),
|
|
]);
|
|
return { lookups, units, locations, events, employees, savedReports, kostenstellen };
|
|
});
|
|
|
|
if (mode === "events") {
|
|
const rows = aggregateEvents(events, eventGroup, eventSplit, lookups);
|
|
|
|
return (
|
|
<Suspense>
|
|
<ReportsPageClient
|
|
mode="events"
|
|
eventGroup={eventGroup}
|
|
eventSplit={eventSplit ?? ""}
|
|
eventTypes={eventTypes}
|
|
eventSubtypes={eventSubtypes}
|
|
eventFilters={{ division: params.division ?? "", location: params.location ?? "", from: from ?? "", to: to ?? "" }}
|
|
rows={rows}
|
|
total={sumValues(rows)}
|
|
recordCount={events.length}
|
|
units={units}
|
|
locations={locations}
|
|
savedReports={savedReports}
|
|
/>
|
|
</Suspense>
|
|
);
|
|
}
|
|
|
|
const rows = aggregateReport(employees, measure, group, split, lookups, asOf);
|
|
|
|
return (
|
|
<Suspense>
|
|
<ReportsPageClient
|
|
mode="snapshot"
|
|
measure={measure}
|
|
group={group}
|
|
split={split ?? ""}
|
|
asOf={asOf ?? ""}
|
|
filters={{
|
|
division: params.division ?? "",
|
|
location: params.location ?? "",
|
|
kostenstelle: params.kostenstelle ?? "",
|
|
status: params.status ?? "",
|
|
}}
|
|
criteria={criteria}
|
|
rows={rows}
|
|
total={totalForRows(rows, measure)}
|
|
recordCount={employees.length}
|
|
units={units}
|
|
locations={locations}
|
|
kostenstellen={kostenstellen}
|
|
savedReports={savedReports}
|
|
/>
|
|
</Suspense>
|
|
);
|
|
}
|