.ics Download und PDF Layout korrigiert
This commit is contained in:
1 parent
dc20d7ec5a
commit
cc2e85c111
11 files changed
+424
-73
No files matched your search
+83
-47
@@ -77,6 +77,9 @@ func newPDF(orientation string) *fpdf.Fpdf {
|
||||
pdf.SetCreator("LektorenPlan Web", true)
|
||||
pdf.SetTitle("LektorenPlan – Gottesdienstplan", true)
|
||||
pdf.SetMargins(8.5, 8.5, 8.5)
|
||||
// The footer uses this alias for the total page count, which is only known
|
||||
// when the document is closed.
|
||||
pdf.AliasNbPages("{nb}")
|
||||
return pdf
|
||||
}
|
||||
|
||||
@@ -288,20 +291,16 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
columns = columns[:4]
|
||||
}
|
||||
|
||||
drawHeader := func(continuation bool) {
|
||||
drawHeader := func() {
|
||||
setColor(pdf, colors.accent)
|
||||
pdf.SetFont("Helvetica", "B", 6.4)
|
||||
pdf.SetXY(margin, margin)
|
||||
pdf.CellFormat(150, 3.4, tr("LEKTORENPLAN · "+strings.ToUpper(opts.tenant())), "", 0, "L", false, 0, "")
|
||||
|
||||
setColor(pdf, colors.ink)
|
||||
pdf.SetFont("Times", "B", 18)
|
||||
title := "Gottesdienstplan"
|
||||
if continuation {
|
||||
title = "Gottesdienstplan · Fortsetzung"
|
||||
}
|
||||
pdf.SetFont("Times", "B", 15.5)
|
||||
pdf.SetXY(margin, margin+4.6)
|
||||
pdf.CellFormat(150, 7, tr(title), "", 0, "L", false, 0, "")
|
||||
pdf.CellFormat(150, 7, tr("Gottesdienstplan"), "", 0, "L", false, 0, "")
|
||||
|
||||
setColor(pdf, colors.secondary)
|
||||
pdf.SetFont("Helvetica", "", 8.2)
|
||||
@@ -362,49 +361,16 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
pdf.SetFont("Helvetica", "", 5.8)
|
||||
pdf.SetXY(margin, y+2.6)
|
||||
pdf.CellFormat(150, 3, tr("LektorenPlan · "+r.ShortTitle()), "", 0, "L", false, 0, "")
|
||||
pdf.SetXY(pageWidth-margin-30, y+2.6)
|
||||
pdf.CellFormat(30, 3, tr(fmt.Sprintf("Seite %d", page)), "", 0, "R", false, 0, "")
|
||||
pdf.SetXY(pageWidth-margin-45, y+2.6)
|
||||
pdf.CellFormat(45, 3, tr(fmt.Sprintf("Seite %d von {nb}", page)), "", 0, "R", false, 0, "")
|
||||
}
|
||||
|
||||
rowHeight := func(row domain.DayPlanRow) float64 {
|
||||
height := 15.0
|
||||
if row.LiturgicalDay != nil {
|
||||
titles := wrap(pdf, tr, row.LiturgicalDay.DisplayTitle(), liturgyW-4, 3)
|
||||
readings := []string{}
|
||||
if !row.LiturgicalDay.Readings.IsEmpty() {
|
||||
readings = wrap(pdf, tr, row.LiturgicalDay.Readings.ShortLabel(), liturgyW-4, 3)
|
||||
}
|
||||
lit := 4.5 + float64(len(titles))*3.4 + float64(len(readings))*2.5
|
||||
if badge, _ := feastBadge(row.LiturgicalDay); badge != "" {
|
||||
lit += 4.2
|
||||
}
|
||||
if lit+2 > height {
|
||||
height = lit + 2
|
||||
}
|
||||
}
|
||||
for _, service := range row.Services {
|
||||
h := 5.0
|
||||
if service.Service.Location != nil && strings.TrimSpace(*service.Service.Location) != "" {
|
||||
h += 3.2
|
||||
}
|
||||
for _, role := range domain.AllRoles {
|
||||
if service.Service.RequiredCount(role) > 0 {
|
||||
h += 3.4
|
||||
}
|
||||
}
|
||||
h += 2.2
|
||||
if h > height {
|
||||
height = h
|
||||
}
|
||||
}
|
||||
if height > 53 {
|
||||
height = 53
|
||||
}
|
||||
return height
|
||||
return fullPlanRowHeight(pdf, tr, row, churchWidth, peopleByID)
|
||||
}
|
||||
|
||||
pdf.AddPage()
|
||||
drawHeader(false)
|
||||
drawHeader()
|
||||
drawColumnHeader()
|
||||
page := 1
|
||||
y := contentTop
|
||||
@@ -422,7 +388,7 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
drawFooter(page)
|
||||
page++
|
||||
pdf.AddPage()
|
||||
drawHeader(true)
|
||||
drawHeader()
|
||||
drawColumnHeader()
|
||||
y = contentTop
|
||||
}
|
||||
@@ -562,6 +528,76 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
return pdf.Error()
|
||||
}
|
||||
|
||||
// fullPlanRowHeight measures the space a day row actually needs. It mirrors the
|
||||
// drawing code so a day with several services in one church grows instead of
|
||||
// clipping the additional services.
|
||||
func fullPlanRowHeight(pdf *fpdf.Fpdf, tr func(string) string, row domain.DayPlanRow, churchWidth float64, people map[string]domain.Person) float64 {
|
||||
const liturgyWidth = 57.0
|
||||
// Base height covers the date cell including the optional SONNTAG label.
|
||||
height := 15.0
|
||||
if row.IsSunday() {
|
||||
height = 18.0
|
||||
}
|
||||
if row.LiturgicalDay != nil {
|
||||
style := "B"
|
||||
if !row.LiturgicalDay.IsFeast() {
|
||||
style = ""
|
||||
}
|
||||
pdf.SetFont("Times", style, 8.2)
|
||||
titles := wrap(pdf, tr, row.LiturgicalDay.DisplayTitle(), liturgyWidth-4, 3)
|
||||
lit := 1.6 + float64(len(titles))*3.3
|
||||
if badge, _ := feastBadge(row.LiturgicalDay); badge != "" {
|
||||
lit += 4.2
|
||||
}
|
||||
if !row.LiturgicalDay.Readings.IsEmpty() {
|
||||
pdf.SetFont("Helvetica", "", 5.6)
|
||||
readings := wrap(pdf, tr, row.LiturgicalDay.Readings.ShortLabel(), liturgyWidth-4, 3)
|
||||
lit += 0.4 + float64(len(readings))*2.5
|
||||
}
|
||||
lit += 2.0
|
||||
if lit > height {
|
||||
height = lit
|
||||
}
|
||||
}
|
||||
churchHeights := map[string]float64{}
|
||||
var churchOrder []string
|
||||
for _, service := range row.Services {
|
||||
// 1.4 top padding + 3.4 service line + 1.5 gap below the service.
|
||||
h := 6.3
|
||||
if service.Service.Location != nil && strings.TrimSpace(*service.Service.Location) != "" {
|
||||
h += 3.0
|
||||
}
|
||||
for _, role := range domain.AllRoles {
|
||||
if service.Service.RequiredCount(role) <= 0 {
|
||||
continue
|
||||
}
|
||||
prefix := "L: "
|
||||
if role == domain.RoleHelper {
|
||||
prefix = "K: "
|
||||
}
|
||||
names, open := namesFor(service, role, people)
|
||||
weight := ""
|
||||
if open > 0 {
|
||||
weight = "B"
|
||||
}
|
||||
pdf.SetFont("Helvetica", weight, 5.4)
|
||||
lines := wrap(pdf, tr, prefix+names, churchWidth-3, 2)
|
||||
h += float64(len(lines)) * 3.0
|
||||
}
|
||||
// Services in the same church column stack vertically.
|
||||
if _, ok := churchHeights[service.Church.ID]; !ok {
|
||||
churchOrder = append(churchOrder, service.Church.ID)
|
||||
}
|
||||
churchHeights[service.Church.ID] += h
|
||||
}
|
||||
for _, id := range churchOrder {
|
||||
if churchHeights[id] > height {
|
||||
height = churchHeights[id]
|
||||
}
|
||||
}
|
||||
return height
|
||||
}
|
||||
|
||||
// CompactPlan writes the A4 portrait service list.
|
||||
func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, people []domain.Person, opts Options) error {
|
||||
pdf := newPDF("P")
|
||||
@@ -655,8 +691,8 @@ func CompactPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, peopl
|
||||
pdf.SetFont("Helvetica", "", 5.8)
|
||||
pdf.SetXY(margin, y+2.6)
|
||||
pdf.CellFormat(150, 3, tr("LektorenPlan · kompakte Liste · "+r.ShortTitle()), "", 0, "L", false, 0, "")
|
||||
pdf.SetXY(pageWidth-margin-25, y+2.6)
|
||||
pdf.CellFormat(25, 3, tr(fmt.Sprintf("Seite %d", page)), "", 0, "R", false, 0, "")
|
||||
pdf.SetXY(pageWidth-margin-45, y+2.6)
|
||||
pdf.CellFormat(45, 3, tr(fmt.Sprintf("Seite %d von {nb}", page)), "", 0, "R", false, 0, "")
|
||||
}
|
||||
|
||||
rowHeight := func(service domain.ServiceWithAssignments) float64 {
|
||||
|
||||
Reference in new issue
Block a user