More fixes

This commit is contained in:
Finley Ghosh 2026-01-13 22:56:08 +11:00
parent a464d48b88
commit afa9c9f731
3 changed files with 14 additions and 11 deletions

View file

@ -82,13 +82,13 @@ func main() {
goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Get).Methods("GET") goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Get).Methods("GET")
goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Delete).Methods("DELETE") goRouter.HandleFunc("/attachments/{id}", attachmentHandler.Delete).Methods("DELETE")
// PDF generation routes // PDF generation routes (under /api/pdf/* to avoid conflict with file server)
goRouter.HandleFunc("/pdf/generate-invoice", handlers.GenerateInvoicePDF).Methods("POST") goRouter.HandleFunc("/api/pdf/generate-invoice", handlers.GenerateInvoicePDF).Methods("POST")
goRouter.HandleFunc("/pdf/generate-quote", handlers.GenerateQuotePDF).Methods("POST") goRouter.HandleFunc("/api/pdf/generate-quote", handlers.GenerateQuotePDF).Methods("POST")
goRouter.HandleFunc("/pdf/generate-po", handlers.GeneratePurchaseOrderPDF).Methods("POST") goRouter.HandleFunc("/api/pdf/generate-po", handlers.GeneratePurchaseOrderPDF).Methods("POST")
goRouter.HandleFunc("/pdf/generate-packinglist", handlers.GeneratePackingListPDF).Methods("POST") goRouter.HandleFunc("/api/pdf/generate-packinglist", handlers.GeneratePackingListPDF).Methods("POST")
goRouter.HandleFunc("/pdf/generate-orderack", handlers.GenerateOrderAckPDF).Methods("POST") goRouter.HandleFunc("/api/pdf/generate-orderack", handlers.GenerateOrderAckPDF).Methods("POST")
goRouter.HandleFunc("/pdf/count-pages", handlers.CountPages).Methods("POST") goRouter.HandleFunc("/api/pdf/count-pages", handlers.CountPages).Methods("POST")
// Serve generated PDFs // Serve generated PDFs
pdfDir := os.Getenv("PDF_OUTPUT_DIR") pdfDir := os.Getenv("PDF_OUTPUT_DIR")

View file

@ -331,7 +331,6 @@ func (g *Generator) AddQuoteDetailsTable(data *QuotePDFData) {
// Set column widths for a 3-column table // Set column widths for a 3-column table
colWidth := 50.0 colWidth := 50.0
colY := g.pdf.GetY()
// Row 1: Delivery Time | Payment Terms | Days Valid // Row 1: Delivery Time | Payment Terms | Days Valid
g.pdf.SetX(15) g.pdf.SetX(15)

View file

@ -2,7 +2,7 @@
// Generate the Invoice PDF by calling the Go service instead of TCPDF. // Generate the Invoice PDF by calling the Go service instead of TCPDF.
$goBaseUrl = AppController::getGoBaseUrlOrFail(); $goBaseUrl = AppController::getGoBaseUrlOrFail();
$goEndpoint = $goBaseUrl . '/go/pdf/generate-invoice'; $goEndpoint = $goBaseUrl . '/go/api/pdf/generate-invoice';
$outputDir = Configure::read('pdf_directory'); $outputDir = Configure::read('pdf_directory');
@ -70,9 +70,13 @@ $curlErr = curl_error($ch);
curl_close($ch); curl_close($ch);
if ($httpCode < 200 || $httpCode >= 300) { if ($httpCode < 200 || $httpCode >= 300) {
echo "<p>Failed to generate PDF via Go service (HTTP $httpCode)."; echo "<p>Failed to generate PDF via Go service (HTTP $httpCode).<br>";
echo "Endpoint: " . htmlspecialchars($goEndpoint) . "<br>";
if ($curlErr) { if ($curlErr) {
echo " Error: $curlErr"; echo "Error: " . htmlspecialchars($curlErr) . "<br>";
}
if (!empty($response)) {
echo "Response: " . htmlspecialchars($response) . "<br>";
} }
echo "</p>"; echo "</p>";
exit; exit;