resolve issues with new features
This commit is contained in:
@@ -675,7 +675,7 @@ async function fetchPdfSettings(): Promise<PdfSettings> {
|
||||
_pdfSettingsCacheTime = Date.now();
|
||||
return _pdfSettingsCache;
|
||||
} catch {
|
||||
return { pdf_header: '', pdf_footer: '' };
|
||||
return { pdf_header: '', pdf_footer: '', pdf_logo: '', pdf_org_name: '' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,9 +701,28 @@ async function generatePdf(
|
||||
doc.setFontSize(14);
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Kalender — ${monthLabel} ${year}`, 10, 12);
|
||||
doc.setFontSize(9);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text('Feuerwehr Rems', 250, 12);
|
||||
|
||||
// Right side: logo and/or org name
|
||||
const logoSize = 14;
|
||||
const logoX = 297 - 4 - logoSize; // 4mm right margin
|
||||
if (pdfSettings.pdf_logo) {
|
||||
try {
|
||||
const fmt = pdfSettings.pdf_logo.match(/^data:image\/(\w+);/)?.[1]?.toUpperCase() ?? 'PNG';
|
||||
doc.addImage(pdfSettings.pdf_logo, fmt === 'JPG' ? 'JPEG' : fmt, logoX, 2, logoSize, logoSize);
|
||||
} catch { /* ignore invalid image */ }
|
||||
}
|
||||
if (pdfSettings.pdf_org_name) {
|
||||
doc.setFontSize(9);
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.setTextColor(255, 255, 255);
|
||||
const nameW = doc.getTextWidth(pdfSettings.pdf_org_name);
|
||||
const nameX = (pdfSettings.pdf_logo ? logoX - 3 : 297 - 4) - nameW;
|
||||
doc.text(pdfSettings.pdf_org_name, nameX, 12);
|
||||
} else if (!pdfSettings.pdf_logo) {
|
||||
doc.setFontSize(9);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text('Feuerwehr Rems', 250, 12);
|
||||
}
|
||||
|
||||
// Custom header text
|
||||
let tableStartY = 22;
|
||||
@@ -796,9 +815,28 @@ async function generateBookingsPdf(
|
||||
doc.setFontSize(14);
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Fahrzeugbuchungen — ${kwLabel} · ${startLabel} – ${endLabel}`, 10, 12);
|
||||
doc.setFontSize(9);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text('Feuerwehr Rems', 250, 12);
|
||||
|
||||
// Right side: logo and/or org name
|
||||
const logoSize = 14;
|
||||
const logoX = 297 - 4 - logoSize;
|
||||
if (pdfSettings.pdf_logo) {
|
||||
try {
|
||||
const fmt = pdfSettings.pdf_logo.match(/^data:image\/(\w+);/)?.[1]?.toUpperCase() ?? 'PNG';
|
||||
doc.addImage(pdfSettings.pdf_logo, fmt === 'JPG' ? 'JPEG' : fmt, logoX, 2, logoSize, logoSize);
|
||||
} catch { /* ignore invalid image */ }
|
||||
}
|
||||
if (pdfSettings.pdf_org_name) {
|
||||
doc.setFontSize(9);
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.setTextColor(255, 255, 255);
|
||||
const nameW = doc.getTextWidth(pdfSettings.pdf_org_name);
|
||||
const nameX = (pdfSettings.pdf_logo ? logoX - 3 : 297 - 4) - nameW;
|
||||
doc.text(pdfSettings.pdf_org_name, nameX, 12);
|
||||
} else if (!pdfSettings.pdf_logo) {
|
||||
doc.setFontSize(9);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text('Feuerwehr Rems', 250, 12);
|
||||
}
|
||||
|
||||
// Custom header text
|
||||
let tableStartY = 22;
|
||||
@@ -2747,7 +2785,7 @@ export default function Kalender() {
|
||||
<TableContainer component={Paper} elevation={1}>
|
||||
<Table size="small" sx={{ tableLayout: 'fixed' }}>
|
||||
<TableHead>
|
||||
<TableRow sx={{ bgcolor: 'grey.100' }}>
|
||||
<TableRow sx={{ bgcolor: (theme) => theme.palette.mode === 'dark' ? 'grey.900' : 'grey.100' }}>
|
||||
<TableCell sx={{ width: 160, fontWeight: 700 }}>
|
||||
Fahrzeug
|
||||
</TableCell>
|
||||
@@ -2758,7 +2796,7 @@ export default function Kalender() {
|
||||
sx={{
|
||||
fontWeight: fnsIsToday(day) ? 700 : 400,
|
||||
color: fnsIsToday(day) ? 'primary.main' : 'text.primary',
|
||||
bgcolor: fnsIsToday(day) ? 'primary.50' : undefined,
|
||||
bgcolor: fnsIsToday(day) ? (theme) => theme.palette.mode === 'dark' ? 'primary.900' : 'primary.50' : undefined,
|
||||
}}
|
||||
>
|
||||
<Typography variant="caption" display="block">
|
||||
|
||||
Reference in New Issue
Block a user