2025-01-17 13:32:28 +01:00
|
|
|
import { toInt } from "$lib/util"
|
|
|
|
|
|
|
|
|
|
import { generateRecordPDF } from "$lib/server/PDFGen";
|
|
|
|
|
|
|
|
|
|
export async function load({ locals }) {
|
|
|
|
|
return {
|
2025-01-30 12:31:25 +01:00
|
|
|
availableMonths: locals.user.get_months(),
|
|
|
|
|
availableQuarters: locals.user.get_quarters()
|
2025-01-17 13:32:28 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const actions = {
|
|
|
|
|
create_pdf: async ({ locals, request }) => {
|
|
|
|
|
const data = await request.formData();
|
|
|
|
|
|
|
|
|
|
let month = toInt(data.get("month") ?? "");
|
|
|
|
|
let year = toInt(data.get("year") ?? "");
|
|
|
|
|
|
|
|
|
|
if (isNaN(year) || isNaN(month) || month > 12) {
|
|
|
|
|
return fail(400, {});
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-30 12:31:25 +01:00
|
|
|
generateRecordPDF(locals.user, new Date(year, month - 1));
|
2025-01-17 13:32:28 +01:00
|
|
|
|
|
|
|
|
return { success: true }
|
|
|
|
|
}
|
|
|
|
|
}
|