<div id="reisekosten">
<meta charset="UTF-8">
<title>Reisekostenabrechnung</title>
<style>
:root {
--border: #cccccc;
--header-bg: #f5f5f5;
--accent: #005a9c;
--text: #333;
}
body {
font-family: Arial, sans-serif;
background: #f0f0f0;
margin: 0;
padding: 20px;
color: var(--text);
}
.wrapper {
max-width: 900px;
margin: auto;
background: #fff;
padding: 25px;
border: 1px solid var(--border);
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: var(--accent);
margin-bottom: 5px;
}
h2 {
color: var(--accent);
font-size: 14px;
margin: 20px 0 5px;
}
.section {
background: #fafafa;
border: 1px solid var(--border);
padding: 10px 15px 15px;
margin-bottom: 15px;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 11px;
}
th, td {
border: 1px solid var(--border);
padding: 4px 6px;
}
th {
background: var(--header-bg);
}
input[type="text"],
input[type="number"],
input[type="date"],
select {
width: 100%;
box-sizing: border-box;
padding: 3px 4px;
border: 1px solid var(--border);
font-size: 11px;
}
input[type="number"] {
text-align: right;
}
.right { text-align: right; }
.center { text-align: center; }
.footer-sum {
text-align: right;
font-weight: bold;
margin-top: 5px;
font-size: 11px;
}
.signature-block {
margin-top: 20px;
font-size: 11px;
}
.signature-lines {
margin-top: 40px;
display: flex;
justify-content: space-between;
gap: 10px;
}
.signature-lines div {
width: 48%;
border-top: 1px solid var(--border);
padding-top: 5px;
text-align: center;
}
.button-bar {
text-align: right;
margin-top: 20px;
}
button {
background: var(--accent);
color: #fff;
border: none;
padding: 8px 14px;
cursor: pointer;
font-size: 12px;
}
button:hover {
background: #00457a;
}
.page-break {
page-break-before: always;
}
</style>
<div class="wrapper">
<h1>Reisekostenabrechnung</h1>
<!-- Persönliche Daten -->
<div class="section">
<h2>Persönliche Daten</h2>
<table>
<tbody>
<tr>
<th>Name</th>
<td><input type="text" id="name"></td>
<th>Kostenstelle</th>
<td><input type="text" id="kostenstelle"></td>
</tr>
<tr>
<th>Projekt</th>
<td><input type="text" id="projekt"></td>
<th>Grund der Reise</th>
<td><input type="text" id="grund"></td>
</tr>
</tbody>
</table>
</div>
<!-- Öffentliche Verkehrsmittel -->
<div class="section">
<h2>Reisekosten – Öffentliche Verkehrsmittel</h2>
<table id="oeffentlich">
<thead>
<tr>
<th style="width:12%;">Datum</th>
<th>Beschreibung</th>
<th class="right" style="width:15%;">Gesamt (€)</th>
<th class="right" style="width:15%;">Im Voraus bezahlt (€)</th>
<th class="right" style="width:15%;">Erstattung (€)</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div class="footer-sum">
Summe öffentlicher Verkehrsmittel: <span id="sum-oeff">0.00</span> €
</div>
</div>
<div class="page-break"></div>
<!-- PKW -->
<div class="section">
<h2>Eigener PKW</h2>
<table id="pkw">
<thead>
<tr>
<th style="width:12%;">Datum</th>
<th>Von</th>
<th>Nach</th>
<th>Anlass</th>
<th class="right" style="width:10%;">KM</th>
<th class="right" style="width:12%;">Mitgenommene Personen</th>
<th class="right" style="width:15%;">Betrag (€)</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div class="footer-sum">
Summe PKW: <span id="sum-pkw">0.00</span> €
</div>
</div>
<!-- Hotel -->
<div class="section">
<h2>Übernachtung / Hotel</h2>
<table>
<thead>
<tr>
<th class="right">Hotelkosten (€)</th>
<th class="right">Bereits bezahlt (€)</th>
<th class="right">Erstattung (€)</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="number" id="hotel-gesamt" step="0.01"></td>
<td><input type="number" id="hotel-bezahlt" step="0.01"></td>
<td class="right"><span id="hotel-erst">0.00</span></td>
</tr>
</tbody>
</table>
</div>
<!-- Spesen -->
<div class="section">
<h2>Verpflegung / Spesen</h2>
<table id="spesen">
<thead>
<tr>
<th style="width:10%;">Tag</th>
<th class="right" style="width:12%;">Stunden</th>
<th class="center" style="width:12%;">Frühstück</th>
<th class="center" style="width:12%;">Mittag</th>
<th class="center" style="width:12%;">Abend</th>
<th class="right" style="width:15%;">Spesen (€)</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div class="footer-sum">
Summe Spesen: <span id="sum-spesen">0.00</span> €
</div>
</div>
<div class="page-break"></div>
<!-- Gesamtsumme -->
<div class="section">
<h2>Gesamtsumme</h2>
<table>
<tbody>
<tr>
<th class="right" style="width:60%;">Gesamterstattungsbetrag (€)</th>
<td class="right" style="width:40%;"><span id="sum-total">0.00</span></td>
</tr>
</tbody>
</table>
<div style="height:60px;"></div>
<div class="signature-block">
<div class="signature-lines">
<div>Mitarbeiter – Ort, Datum, Unterschrift</div>
<div>Buchhaltung – sachliche Richtigkeit</div>
</div>
</div>
</div>
<!-- PDF Button -->
<div class="button-bar">
<button id="pdfButton">PDF herunterladen</button>
</div>
</div> <!-- wrapper -->
<!-- PDF Script -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<script>
function num(v){return parseFloat(v)||0;}
function grundSpesen(h){
if(h>=24) return 24;
if(h>=14) return 12;
if(h>=8) return 6;
return 0;
}
function recalc(){
// Öffentliche Verkehrsmittel
let sumO=0;
for(let i=1;i<=8;i++){
let g=num(document.getElementById("oGesamt_"+i).value);
let b=num(document.getElementById("oBezahlt_"+i).value);
let e=Math.max(g-b,0);
document.getElementById("oErst_"+i).textContent=e.toFixed(2);
sumO+=e;
}
document.getElementById("sum-oeff").textContent=sumO.toFixed(2);
// PKW
let sumP=0;
for(let i=1;i<=4;i++){
let km=num(document.getElementById("pKm_"+i).value);
let pers=num(document.getElementById("pPers_"+i).value);
let bet=km*(0.25+0.15*pers);
document.getElementById("pBet_"+i).textContent=bet.toFixed(2);
sumP+=bet;
}
document.getElementById("sum-pkw").textContent=sumP.toFixed(2);
// Hotel
let hg=num(document.getElementById("hotel-gesamt").value);
let hb=num(document.getElementById("hotel-bezahlt").value);
let he=Math.max(hg-hb,0);
document.getElementById("hotel-erst").textContent=he.toFixed(2);
// Spesen
let sumS=0;
for(let i=1;i<=5;i++){
let h=num(document.getElementById("sStd_"+i).value);
let base=grundSpesen(h);
let red=0;
if(document.getElementById("sFr_"+i).checked) red+=base*0.20;
if(document.getElementById("sMi_"+i).checked) red+=base*0.35;
if(document.getElementById("sAb_"+i).checked) red+=base*0.35;
let sp=Math.max(base-red,0);
document.getElementById("sBet_"+i).textContent = sp.toFixed(2);
sumS+=sp;
}
document.getElementById("sum-spesen").textContent=sumS.toFixed(2);
// Gesamt
let total=sumO+sumP+he+sumS;
document.getElementById("sum-total").textContent=total.toFixed(2);
}
// Tabellen dynamisch erzeugen
(function(){
// ÖPNV
let o=document.querySelector("#oeffentlich tbody");
for(let i=1;i<=8;i++){
o.innerHTML+=`
<tr>
<td><input type="date" id="oDatum_${i}"></td>
<td><input type="text" id="oBesch_${i}"></td>
<td><input type="number" id="oGesamt_${i}" step="0.01"></td>
<td><input type="number" id="oBezahlt_${i}" step="0.01"></td>
<td class="right"><span id="oErst_${i}">0.00</span></td>
</tr>`;
}
// PKW
let p=document.querySelector("#pkw tbody");
for(let i=1;i<=4;i++){
p.innerHTML+=`
<tr>
<td><input type="date" id="pDatum_${i}"></td>
<td><input type="text" id="pVon_${i}"></td>
<td><input type="text" id="pNach_${i}"></td>
<td><input type="text" id="pAnlass_${i}"></td>
<td><input type="number" id="pKm_${i}" step="0.1"></td>
<td><input type="number" id="pPers_${i}" step="1"></td>
<td class="right"><span id="pBet_${i}">0.00</span></td>
</tr>`;
}
// Spesen
let s=document.querySelector("#spesen tbody");
for(let i=1;i<=5;i++){
s.innerHTML+=`
<tr>
<td>Tag ${i}</td>
<td><input type="number" id="sStd_${i}" step="0.5"></td>
<td class="center"><input type="checkbox" id="sFr_${i}"></td>
<td class="center"><input type="checkbox" id="sMi_${i}"></td>
<td class="center"><input type="checkbox" id="sAb_${i}"></td>
<td class="right"><span id="sBet_${i}">0.00</span></td>
</tr>`;
}
document.addEventListener("input", recalc);
document.addEventListener("change", recalc);
})();
// PDF Download
document.getElementById("pdfButton").addEventListener("click", function () {
const element = document.getElementById("reisekosten");
const opt = {
margin: 10,
filename: 'reisekosten.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
html2pdf().set(opt).from(element).save();
});
</script>
</div>