forked from Kispi/Core
feat(webapp): add missing students export
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d92696e2ff
commit
dd23862e9d
2 changed files with 34 additions and 1 deletions
|
@ -67,7 +67,10 @@
|
||||||
<MagnifyingGlassIcon class="h-6 w-6" />Verwaltung
|
<MagnifyingGlassIcon class="h-6 w-6" />Verwaltung
|
||||||
</template>
|
</template>
|
||||||
<div class="mt-4 flex h-full flex-col gap-4">
|
<div class="mt-4 flex h-full flex-col gap-4">
|
||||||
<button class="btn-disabled btn">
|
<button
|
||||||
|
class="btn"
|
||||||
|
@click="showMissingStudentsPrintWindow"
|
||||||
|
>
|
||||||
<QueueListIcon class="h-5 w-5" />
|
<QueueListIcon class="h-5 w-5" />
|
||||||
Fehlende Schüler
|
Fehlende Schüler
|
||||||
</button>
|
</button>
|
||||||
|
@ -351,6 +354,30 @@ function showCreatedCompaniesPrintWindow(): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function showMissingStudentsPrintWindow(): Promise<void> {
|
||||||
|
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('<html><head><title>Fehlende Schüler</title></head><body>');
|
||||||
|
printWindow.document.write(`<h1>Fehlende Schüler am ${DateService.toShortString(new Date())}</h1>`);
|
||||||
|
printWindow.document.write('<table style="border-collapse: collapse;">');
|
||||||
|
printWindow.document.write('<tbody>');
|
||||||
|
printWindow.document.write('<tr><th style="padding: 1rem; border: 1px solid black">Schüler</th>');
|
||||||
|
printWindow.document.write('<th style="padding: 1rem; border: 1px solid black">Klasse</th></tr>');
|
||||||
|
for(const student of missingStudents) {
|
||||||
|
printWindow.document.write(`<tr><td style="padding: 1rem; border: 1px solid black">${student.firstName} ${student.lastName}</td>`);
|
||||||
|
printWindow.document.write(`<td style="padding: 1rem; border: 1px solid black">${student.grade}</td></tr>`);
|
||||||
|
}
|
||||||
|
printWindow.document.write('</tbody>');
|
||||||
|
printWindow.document.write('</table>');
|
||||||
|
printWindow.document.write('</body></html>');
|
||||||
|
printWindow.document.close();
|
||||||
|
printWindow.print();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
settings.value = await SettingsService.getSettings();
|
settings.value = await SettingsService.getSettings();
|
||||||
minWage.value = settings.value.minWage / 100;
|
minWage.value = settings.value.minWage / 100;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { RecordSubscription, UnsubscribeFunc } from 'pocketbase';
|
import { RecordSubscription, UnsubscribeFunc } from 'pocketbase';
|
||||||
import { AccountsListResponse, AccountsRecord, AccountsResponse, Collections } from '../types/pocketbase.types';
|
import { AccountsListResponse, AccountsRecord, AccountsResponse, Collections } from '../types/pocketbase.types';
|
||||||
|
import { DateService } from './date.service';
|
||||||
import { PocketbaseService } from './pocketbase.service';
|
import { PocketbaseService } from './pocketbase.service';
|
||||||
|
|
||||||
const COLLECTION = PocketbaseService.getApi().collection(Collections.Accounts);
|
const COLLECTION = PocketbaseService.getApi().collection(Collections.Accounts);
|
||||||
|
@ -31,6 +32,11 @@ export class AccountService {
|
||||||
public static async updateWage(accountId: string, wageFactor: number): Promise<AccountsResponse> {
|
public static async updateWage(accountId: string, wageFactor: number): Promise<AccountsResponse> {
|
||||||
return COLLECTION.update(accountId, { wageFactor });
|
return COLLECTION.update(accountId, { wageFactor });
|
||||||
}
|
}
|
||||||
|
public static async getMissingStudents(): Promise<AccountsResponse[]> {
|
||||||
|
return ((await COLLECTION.getFullList<AccountsResponse>()).filter(
|
||||||
|
(account: AccountsResponse) => !DateService.isToday(new Date(account.lastCheckIn)),
|
||||||
|
));
|
||||||
|
}
|
||||||
public static async subscribeToAccountChanges(
|
public static async subscribeToAccountChanges(
|
||||||
callback: (data: RecordSubscription<AccountsResponse>)=> void,
|
callback: (data: RecordSubscription<AccountsResponse>)=> void,
|
||||||
): Promise<UnsubscribeFunc> {
|
): Promise<UnsubscribeFunc> {
|
||||||
|
|
Loading…
Reference in a new issue