From dd23862e9ddaf3dc390c1a1069acc9c69f577c7f Mon Sep 17 00:00:00 2001 From: Simon Giesel Date: Fri, 14 Jul 2023 12:12:05 +0200 Subject: [PATCH] feat(webapp): add missing students export --- .../src/components/views/ViewStatePortal.vue | 29 ++++++++++++++++++- webapp/src/services/account.service.ts | 6 ++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/webapp/src/components/views/ViewStatePortal.vue b/webapp/src/components/views/ViewStatePortal.vue index 471941f..05a77eb 100644 --- a/webapp/src/components/views/ViewStatePortal.vue +++ b/webapp/src/components/views/ViewStatePortal.vue @@ -67,7 +67,10 @@ Verwaltung
- @@ -351,6 +354,30 @@ function showCreatedCompaniesPrintWindow(): void { } } +async function showMissingStudentsPrintWindow(): Promise { + const printWindow = window.open('', '', 'height=400,width=800'); + const missingStudents = await AccountService.getMissingStudents(); + if(!printWindow) { + alert('Druckansicht konnte nicht erstellt werden.'); + } else { + printWindow.document.write('Fehlende Schüler'); + printWindow.document.write(`

Fehlende Schüler am ${DateService.toShortString(new Date())}

`); + printWindow.document.write(''); + printWindow.document.write(''); + printWindow.document.write(''); + printWindow.document.write(''); + for(const student of missingStudents) { + printWindow.document.write(``); + printWindow.document.write(``); + } + printWindow.document.write(''); + printWindow.document.write('
SchülerKlasse
${student.firstName} ${student.lastName}${student.grade}
'); + printWindow.document.write(''); + printWindow.document.close(); + printWindow.print(); + } +} + onMounted(async () => { settings.value = await SettingsService.getSettings(); minWage.value = settings.value.minWage / 100; diff --git a/webapp/src/services/account.service.ts b/webapp/src/services/account.service.ts index 9db4a28..b8fda84 100644 --- a/webapp/src/services/account.service.ts +++ b/webapp/src/services/account.service.ts @@ -1,5 +1,6 @@ import { RecordSubscription, UnsubscribeFunc } from 'pocketbase'; import { AccountsListResponse, AccountsRecord, AccountsResponse, Collections } from '../types/pocketbase.types'; +import { DateService } from './date.service'; import { PocketbaseService } from './pocketbase.service'; const COLLECTION = PocketbaseService.getApi().collection(Collections.Accounts); @@ -31,6 +32,11 @@ export class AccountService { public static async updateWage(accountId: string, wageFactor: number): Promise { return COLLECTION.update(accountId, { wageFactor }); } + public static async getMissingStudents(): Promise { + return ((await COLLECTION.getFullList()).filter( + (account: AccountsResponse) => !DateService.isToday(new Date(account.lastCheckIn)), + )); + } public static async subscribeToAccountChanges( callback: (data: RecordSubscription)=> void, ): Promise {