Stundenaufzeichnung/src/routes/dokumente/+page.svelte

133 lines
2.6 KiB
Svelte
Raw Normal View History

2025-01-17 13:32:28 +01:00
<script lang="ts">
2025-02-04 21:41:16 +01:00
import type { PageProps } from "./$types";
import { enhance } from "$app/forms";
import { isoToLocalDate, padInt } from "$lib/util";
let { data, form } : PageProps = $props();
2025-01-17 13:32:28 +01:00
</script>
2025-02-04 21:41:16 +01:00
<div>
<h1>Dokumente</h1>
<form method="POST" id="create_est" action="?/create_estimate" use:enhance></form>
<form method="POST" id="create_rec" action="?/create_record" use:enhance></form>
<table>
<caption>Dokument erstellen</caption>
<tbody>
<tr>
<td>Stundenliste</td>
<td>
<input form="create_rec" style:width="2ch" name="month" /> -
<input form="create_rec" style:width="4ch" name="year" placeholder="Jahr" value={new Date().getFullYear()} />
</td>
<td>
<button form="create_rec" type="submit">Erstellen</button>
</td>
</tr>
<tr>
<td>Stundenschätzung</td>
<td>
<input form="create_est" style:width="1ch" name="quarter" />. Quartal
<input form="create_est" style:width="4ch" name="year" placeholder="Jahr" value={new Date().getFullYear()} />
</td>
<td>
<button form="create_est" type="submit">Erstellen</button>
</td>
</tr>
</tbody>
</table>
<div style:width="100%" style="text-align: center;">{!(form?.success) ? form?.message : "Dokument erstellt."}</div>
<div style:height="20px"></div>
2025-01-17 13:32:28 +01:00
<table>
2025-02-04 21:41:16 +01:00
<caption>Erstellte Dokumente</caption>
2025-01-17 13:32:28 +01:00
<thead>
<tr>
2025-02-04 21:41:16 +01:00
<th style:width="30ch">Dateiname</th>
<th style:width="15ch">Erstellt</th>
2025-01-17 13:32:28 +01:00
<th style:width="12ch">Aktion</th>
</tr>
</thead>
<tbody>
2025-02-04 21:41:16 +01:00
{#each data.documents as doc}
<tr>
<td>{doc.name}</td>
<td>{`${isoToLocalDate(doc.timestamp.toISOString())} um ${padInt(doc.timestamp.getHours(), 2)}:${padInt(doc.timestamp.getMinutes(), 2)}:${padInt(doc.timestamp.getSeconds(), 2)}`}</td>
<td>
<form method="GET" action={`dokumente/${doc.path}`}>
<button type="submit">Download</button>
</form>
</td>
</tr>
2025-01-17 13:32:28 +01:00
{/each}
<tr></tr>
</tbody>
2025-02-04 21:41:16 +01:00
{#if data.documents.length === 0}
<tfoot>
<tr>
<td class="td-no-elements" colspan="999">Noch keine Dokumente</td>
</tr>
</tfoot>
{/if}
2025-01-17 13:32:28 +01:00
</table>
2025-02-04 21:41:16 +01:00
</div>
2025-01-17 13:32:28 +01:00
<style>
2025-02-04 21:41:16 +01:00
h1 {
width: 100%;
text-align: center;
font-size: 25px;
font-weight: bold;
}
2025-01-17 13:32:28 +01:00
form {
width: fit-content;
border: none;
}
table {
2025-02-04 21:41:16 +01:00
width: auto;
2025-01-17 13:32:28 +01:00
margin: auto;
border-collapse: collapse;
border: 1px solid;
}
tbody > tr > td {
text-align: center;
}
tbody > tr:nth-child(odd) {
background: gray;
}
tbody > tr:nth-child(even) {
background: lightgray;
}
tbody > tr > td:last-of-type {
display: inline-flex;
}
tfoot {
border-top: 1px solid black;
}
.td-no-elements {
text-align: center;
}
</style>