Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -397,6 +397,9 @@ func drawCustomerBalancePDF(
|
|||||||
totalY := pdf.GetY()
|
totalY := pdf.GetY()
|
||||||
totalX := marginL
|
totalX := marginL
|
||||||
for i, v := range totalsRow {
|
for i, v := range totalsRow {
|
||||||
|
if i >= len(summaryW) {
|
||||||
|
break
|
||||||
|
}
|
||||||
pdf.Rect(totalX, totalY, summaryW[i], totalH, "FD")
|
pdf.Rect(totalX, totalY, summaryW[i], totalH, "FD")
|
||||||
align := "L"
|
align := "L"
|
||||||
if i >= 7 {
|
if i >= 7 {
|
||||||
@@ -441,6 +444,9 @@ func drawCustomerBalancePDF(
|
|||||||
y := pdf.GetY()
|
y := pdf.GetY()
|
||||||
x := marginL
|
x := marginL
|
||||||
for i, v := range row {
|
for i, v := range row {
|
||||||
|
if i >= len(summaryW) {
|
||||||
|
break
|
||||||
|
}
|
||||||
pdf.Rect(x, y, summaryW[i], rowH, "")
|
pdf.Rect(x, y, summaryW[i], rowH, "")
|
||||||
align := "L"
|
align := "L"
|
||||||
if i >= 7 {
|
if i >= 7 {
|
||||||
@@ -520,6 +526,9 @@ func drawCustomerBalancePDF(
|
|||||||
rowY := pdf.GetY()
|
rowY := pdf.GetY()
|
||||||
rowX := marginL
|
rowX := marginL
|
||||||
for i, v := range line {
|
for i, v := range line {
|
||||||
|
if i >= len(detailW) {
|
||||||
|
break
|
||||||
|
}
|
||||||
pdf.Rect(rowX, rowY, detailW[i], rowH, "")
|
pdf.Rect(rowX, rowY, detailW[i], rowH, "")
|
||||||
align := "L"
|
align := "L"
|
||||||
if i >= 5 {
|
if i >= 5 {
|
||||||
@@ -557,6 +566,9 @@ func calcPDFRowHeight(pdf *gofpdf.Fpdf, row []string, widths []float64, wrapIdx
|
|||||||
if !wrapIdx[i] {
|
if !wrapIdx[i] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if i >= len(widths) || widths[i] <= 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
lines := pdf.SplitLines([]byte(strings.TrimSpace(v)), widths[i]-2)
|
lines := pdf.SplitLines([]byte(strings.TrimSpace(v)), widths[i]-2)
|
||||||
if len(lines) > maxLines {
|
if len(lines) > maxLines {
|
||||||
maxLines = len(lines)
|
maxLines = len(lines)
|
||||||
@@ -570,6 +582,9 @@ func calcPDFRowHeight(pdf *gofpdf.Fpdf, row []string, widths []float64, wrapIdx
|
|||||||
}
|
}
|
||||||
|
|
||||||
func drawPDFCellWrapped(pdf *gofpdf.Fpdf, value string, x, y, w, h float64, align string, lineH float64) {
|
func drawPDFCellWrapped(pdf *gofpdf.Fpdf, value string, x, y, w, h float64, align string, lineH float64) {
|
||||||
|
if w <= 2 || h <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
text := strings.TrimSpace(value)
|
text := strings.TrimSpace(value)
|
||||||
lines := pdf.SplitLines([]byte(text), w-2)
|
lines := pdf.SplitLines([]byte(text), w-2)
|
||||||
if len(lines) == 0 {
|
if len(lines) == 0 {
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ import (
|
|||||||
|
|
||||||
func ExportStatementAgingPDFHandler(_ *sql.DB) http.HandlerFunc {
|
func ExportStatementAgingPDFHandler(_ *sql.DB) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer func() {
|
||||||
|
if rec := recover(); rec != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("pdf panic: %v", rec), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
claims, ok := auth.GetClaimsFromContext(r.Context())
|
claims, ok := auth.GetClaimsFromContext(r.Context())
|
||||||
if !ok || claims == nil {
|
if !ok || claims == nil {
|
||||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||||
|
|||||||
Reference in New Issue
Block a user