Order Ack largely working
This commit is contained in:
parent
fe2db6d597
commit
ab17a17f25
|
|
@ -33,20 +33,6 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- cmc-network
|
- cmc-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
develop:
|
|
||||||
watch:
|
|
||||||
- action: rebuild
|
|
||||||
path: ./php/app
|
|
||||||
ignore:
|
|
||||||
- ./php/app/webroot/pdf
|
|
||||||
- ./php/app/webroot/attachments_files
|
|
||||||
- ./php/app/tmp
|
|
||||||
- action: sync
|
|
||||||
path: ./php/app/webroot/css
|
|
||||||
target: /var/www/cmc-sales/app/webroot/css
|
|
||||||
- action: sync
|
|
||||||
path: ./php/app/webroot/js
|
|
||||||
target: /var/www/cmc-sales/app/webroot/js
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: mariadb:latest
|
image: mariadb:latest
|
||||||
|
|
|
||||||
12
go/.env
Normal file
12
go/.env
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Database configuration
|
||||||
|
DB_HOST=db
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_USER=cmc
|
||||||
|
DB_PASSWORD=xVRQI&cA?7AU=hqJ!%au
|
||||||
|
DB_NAME=cmc
|
||||||
|
|
||||||
|
# Root database password (for dbshell-root)
|
||||||
|
DB_ROOT_PASSWORD=secureRootPassword
|
||||||
|
|
||||||
|
# Server configuration
|
||||||
|
PORT=8080
|
||||||
BIN
go/bin/server
BIN
go/bin/server
Binary file not shown.
BIN
go/bin/vault
Executable file
BIN
go/bin/vault
Executable file
Binary file not shown.
|
|
@ -101,11 +101,14 @@ type PackingListPDFData struct {
|
||||||
type OrderAckPDFData struct {
|
type OrderAckPDFData struct {
|
||||||
OrderAcknowledgement *db.Document
|
OrderAcknowledgement *db.Document
|
||||||
Customer *db.Customer
|
Customer *db.Customer
|
||||||
|
CmcReference string
|
||||||
EmailTo string
|
EmailTo string
|
||||||
Attention string
|
Attention string
|
||||||
IssueDateString string
|
IssueDateString string
|
||||||
YourReference string
|
YourReference string
|
||||||
JobTitle string
|
JobTitle string
|
||||||
|
CustomerOrderNumber string
|
||||||
|
CustomerABN string
|
||||||
BillTo string
|
BillTo string
|
||||||
ShipTo string
|
ShipTo string
|
||||||
ShipVia string
|
ShipVia string
|
||||||
|
|
|
||||||
|
|
@ -80,55 +80,59 @@ func (g *HTMLDocumentGenerator) BuildOrderAckHTML(data *OrderAckPDFData, totalPa
|
||||||
|
|
||||||
// Prepare template data
|
// Prepare template data
|
||||||
templateData := struct {
|
templateData := struct {
|
||||||
OrderAckNumber string
|
OrderAckNumber string
|
||||||
CompanyName string
|
CmcReference string
|
||||||
EmailTo string
|
CompanyName string
|
||||||
Attention string
|
EmailTo string
|
||||||
IssueDateString string
|
Attention string
|
||||||
YourReference string
|
IssueDateString string
|
||||||
JobTitle string
|
YourReference string
|
||||||
BillTo template.HTML
|
JobTitle string
|
||||||
ShipTo template.HTML
|
CustomerOrderNumber string
|
||||||
ShipVia string
|
BillTo template.HTML
|
||||||
FOB string
|
ShipTo template.HTML
|
||||||
PaymentTerms string
|
ShipVia string
|
||||||
CustomerABN string
|
FOB string
|
||||||
CurrencyCode string
|
PaymentTerms string
|
||||||
CurrencySymbol string
|
CustomerABN string
|
||||||
LineItems []OrderAckLineItemTemplateData
|
CurrencyCode string
|
||||||
Subtotal float64
|
CurrencySymbol string
|
||||||
GSTAmount float64
|
LineItems []OrderAckLineItemTemplateData
|
||||||
Total float64
|
Subtotal float64
|
||||||
ShowGST bool
|
GSTAmount float64
|
||||||
PageCount int
|
Total float64
|
||||||
CurrentPage int
|
ShowGST bool
|
||||||
FreightDetails template.HTML
|
PageCount int
|
||||||
LogoDataURI string
|
CurrentPage int
|
||||||
|
FreightDetails template.HTML
|
||||||
|
LogoDataURI string
|
||||||
}{
|
}{
|
||||||
OrderAckNumber: orderAckNumber,
|
OrderAckNumber: orderAckNumber,
|
||||||
CompanyName: data.Customer.Name,
|
CmcReference: data.CmcReference,
|
||||||
EmailTo: data.EmailTo,
|
CompanyName: data.Customer.Name,
|
||||||
Attention: data.Attention,
|
EmailTo: data.EmailTo,
|
||||||
IssueDateString: data.IssueDateString,
|
Attention: data.Attention,
|
||||||
YourReference: data.YourReference,
|
IssueDateString: data.IssueDateString,
|
||||||
JobTitle: data.JobTitle,
|
YourReference: data.YourReference,
|
||||||
BillTo: template.HTML(data.BillTo),
|
JobTitle: data.JobTitle,
|
||||||
ShipTo: template.HTML(data.ShipTo),
|
CustomerOrderNumber: data.CustomerOrderNumber,
|
||||||
ShipVia: data.ShipVia,
|
BillTo: template.HTML(data.BillTo),
|
||||||
FOB: data.FOB,
|
ShipTo: template.HTML(data.ShipTo),
|
||||||
PaymentTerms: data.PaymentTerms,
|
ShipVia: data.ShipVia,
|
||||||
CustomerABN: "",
|
FOB: data.FOB,
|
||||||
CurrencyCode: data.CurrencyCode,
|
PaymentTerms: data.PaymentTerms,
|
||||||
CurrencySymbol: data.CurrencySymbol,
|
CustomerABN: data.CustomerABN,
|
||||||
LineItems: lineItemsData,
|
CurrencyCode: data.CurrencyCode,
|
||||||
Subtotal: subtotal,
|
CurrencySymbol: data.CurrencySymbol,
|
||||||
GSTAmount: gstAmount,
|
LineItems: lineItemsData,
|
||||||
Total: total,
|
Subtotal: subtotal,
|
||||||
ShowGST: data.ShowGST,
|
GSTAmount: gstAmount,
|
||||||
PageCount: totalPages,
|
Total: total,
|
||||||
CurrentPage: currentPage,
|
ShowGST: data.ShowGST,
|
||||||
FreightDetails: template.HTML(data.FreightDetails),
|
PageCount: totalPages,
|
||||||
LogoDataURI: g.loadLogo("quote_logo.png"),
|
CurrentPage: currentPage,
|
||||||
|
FreightDetails: template.HTML(data.FreightDetails),
|
||||||
|
LogoDataURI: g.loadLogo("quote_logo.png"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define template functions
|
// Define template functions
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 10mm;
|
margin-top: -5mm;
|
||||||
|
margin-bottom: 8mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header h1 {
|
.header h1 {
|
||||||
|
|
@ -46,6 +47,10 @@
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.details-table td:last-child {
|
||||||
|
padding-right: 3mm;
|
||||||
|
}
|
||||||
|
|
||||||
.details-table td.label {
|
.details-table td.label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
width: 25%;
|
width: 25%;
|
||||||
|
|
@ -237,8 +242,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label">COMPANY NAME:</td>
|
<td class="label">COMPANY NAME:</td>
|
||||||
<td>{{.CompanyName}}</td>
|
<td>{{.CompanyName}}</td>
|
||||||
<td class="label">YOUR REFERENCE:</td>
|
<td class="label">CMC JOB#:</td>
|
||||||
<td>{{.YourReference}}</td>
|
<td>{{.JobTitle}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label">CONTACT:</td>
|
<td class="label">CONTACT:</td>
|
||||||
|
|
@ -246,10 +251,6 @@
|
||||||
<td class="label">EMAIL:</td>
|
<td class="label">EMAIL:</td>
|
||||||
<td>{{.EmailTo}}</td>
|
<td>{{.EmailTo}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="label">JOB TITLE:</td>
|
|
||||||
<td colspan="3">{{.JobTitle}}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- Address Boxes -->
|
<!-- Address Boxes -->
|
||||||
|
|
@ -269,7 +270,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 20%;">CUSTOMER ORDER NO</th>
|
<th style="width: 20%;">CUSTOMER ORDER NO</th>
|
||||||
<th style="width: 20%;">CMC JOB #</th>
|
<th style="width: 20%;">CMC REF</th>
|
||||||
<th style="width: 20%;">INCOTERMS 2010</th>
|
<th style="width: 20%;">INCOTERMS 2010</th>
|
||||||
<th style="width: 20%;">PAYMENT TERMS</th>
|
<th style="width: 20%;">PAYMENT TERMS</th>
|
||||||
<th style="width: 20%;">CUSTOMER ABN</th>
|
<th style="width: 20%;">CUSTOMER ABN</th>
|
||||||
|
|
@ -277,21 +278,19 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{.YourReference}}</td>
|
<td>{{if .CustomerOrderNumber}}{{.CustomerOrderNumber}}{{else}}-{{end}}</td>
|
||||||
<td>{{.JobTitle}}</td>
|
<td>{{if .CmcReference}}{{.CmcReference}}{{else}}-{{end}}</td>
|
||||||
<td>{{.FOB}}</td>
|
<td>{{.FOB}}</td>
|
||||||
<td>{{.PaymentTerms}}</td>
|
<td>{{.PaymentTerms}}</td>
|
||||||
<td>{{.CustomerABN}}</td>
|
<td>{{if .CustomerABN}}{{.CustomerABN}}{{else}}-{{end}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- Currency Code Header -->
|
<!-- Line Items Table with Currency Code -->
|
||||||
<div style="margin-bottom: 1mm; text-align: right; font-weight: bold; font-size: 9pt;">
|
<div style="margin-bottom: 1mm; text-align: right; font-weight: bold; font-size: 9pt;">
|
||||||
Shown in {{.CurrencyCode}}
|
Shown in {{.CurrencyCode}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Line Items Table -->
|
|
||||||
<table class="line-items">
|
<table class="line-items">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -362,20 +361,5 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Footer -->
|
|
||||||
<div class="footer">
|
|
||||||
<div class="services-title">CMC TECHNOLOGIES Provides Solutions in the Following Fields</div>
|
|
||||||
<div class="services-line1">
|
|
||||||
<span class="service-explosion">EXPLOSION PREVENTION AND PROTECTION</span> —
|
|
||||||
<span class="service-fire">FIRE PROTECTION</span> —
|
|
||||||
<span class="service-pressure">PRESSURE RELIEF</span> —
|
|
||||||
<span class="service-vision">VISION IN THE PROCESS</span>
|
|
||||||
</div>
|
|
||||||
<div class="services-line2">
|
|
||||||
<span class="service-flow">FLOW MEASUREMENT</span> —
|
|
||||||
<span class="service-process">PROCESS INSTRUMENTATION</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@ func GenerateOrderAckPDF(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
doc := &db.Document{ID: req.DocumentID}
|
doc := &db.Document{ID: req.DocumentID, CmcReference: req.CmcReference}
|
||||||
cust := &db.Customer{Name: req.CustomerName}
|
cust := &db.Customer{Name: req.CustomerName}
|
||||||
|
|
||||||
lineItems := make([]db.GetLineItemsTableRow, len(req.LineItems))
|
lineItems := make([]db.GetLineItemsTableRow, len(req.LineItems))
|
||||||
|
|
@ -574,11 +574,14 @@ func GenerateOrderAckPDF(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &pdf.OrderAckPDFData{
|
data := &pdf.OrderAckPDFData{
|
||||||
OrderAcknowledgement: doc,
|
OrderAcknowledgement: doc,
|
||||||
Customer: cust,
|
Customer: cust,
|
||||||
|
CmcReference: req.CmcReference,
|
||||||
EmailTo: req.EmailTo,
|
EmailTo: req.EmailTo,
|
||||||
Attention: req.Attention,
|
Attention: req.Attention,
|
||||||
IssueDateString: req.IssueDateString,
|
IssueDateString: req.IssueDateString,
|
||||||
YourReference: req.YourReference,
|
YourReference: req.YourReference,
|
||||||
JobTitle: req.JobTitle,
|
JobTitle: req.JobTitle,
|
||||||
|
CustomerOrderNumber: req.CustomerOrderNumber,
|
||||||
|
CustomerABN: req.CustomerABN,
|
||||||
BillTo: req.BillTo,
|
BillTo: req.BillTo,
|
||||||
ShipTo: req.ShipTo,
|
ShipTo: req.ShipTo,
|
||||||
ShipVia: req.ShipVia,
|
ShipVia: req.ShipVia,
|
||||||
|
|
@ -630,27 +633,30 @@ type OrderAckLineItemRequest = InvoiceLineItemRequest
|
||||||
|
|
||||||
// OrderAckPDFRequest payload
|
// OrderAckPDFRequest payload
|
||||||
type OrderAckPDFRequest struct {
|
type OrderAckPDFRequest struct {
|
||||||
DocumentID int32 `json:"document_id"`
|
DocumentID int32 `json:"document_id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
CustomerName string `json:"customer_name"`
|
CustomerName string `json:"customer_name"`
|
||||||
EmailTo string `json:"email_to"`
|
CmcReference string `json:"cmc_reference"`
|
||||||
Attention string `json:"attention"`
|
CustomerOrderNumber string `json:"customer_order_number"`
|
||||||
YourReference string `json:"your_reference"`
|
CustomerABN string `json:"customer_abn"`
|
||||||
JobTitle string `json:"job_title"`
|
EmailTo string `json:"email_to"`
|
||||||
IssueDate string `json:"issue_date"` // YYYY-MM-DD
|
Attention string `json:"attention"`
|
||||||
IssueDateString string `json:"issue_date_string"` // formatted date
|
YourReference string `json:"your_reference"`
|
||||||
BillTo string `json:"bill_to"`
|
JobTitle string `json:"job_title"`
|
||||||
ShipTo string `json:"ship_to"`
|
IssueDate string `json:"issue_date"` // YYYY-MM-DD
|
||||||
ShipVia string `json:"ship_via"`
|
IssueDateString string `json:"issue_date_string"` // formatted date
|
||||||
FOB string `json:"fob"`
|
BillTo string `json:"bill_to"`
|
||||||
PaymentTerms string `json:"payment_terms"`
|
ShipTo string `json:"ship_to"`
|
||||||
FreightDetails string `json:"freight_details"`
|
ShipVia string `json:"ship_via"`
|
||||||
EstimatedDelivery string `json:"estimated_delivery"`
|
FOB string `json:"fob"`
|
||||||
CurrencySymbol string `json:"currency_symbol"`
|
PaymentTerms string `json:"payment_terms"`
|
||||||
CurrencyCode string `json:"currency_code"`
|
FreightDetails string `json:"freight_details"`
|
||||||
ShowGST bool `json:"show_gst"`
|
EstimatedDelivery string `json:"estimated_delivery"`
|
||||||
LineItems []OrderAckLineItemRequest `json:"line_items"`
|
CurrencySymbol string `json:"currency_symbol"`
|
||||||
OutputDir string `json:"output_dir"`
|
CurrencyCode string `json:"currency_code"`
|
||||||
|
ShowGST bool `json:"show_gst"`
|
||||||
|
LineItems []OrderAckLineItemRequest `json:"line_items"`
|
||||||
|
OutputDir string `json:"output_dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountPagesRequest payload for page counting
|
// CountPagesRequest payload for page counting
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
||||||
5
php/app/.htaccess
Normal file
5
php/app/.htaccess
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
RewriteEngine on
|
||||||
|
RewriteRule ^$ webroot/ [L]
|
||||||
|
RewriteRule (.*) webroot/$1 [L]
|
||||||
|
</IfModule>
|
||||||
|
|
@ -77,6 +77,12 @@ Configure::write('email_directory', '/var/www/emails');
|
||||||
Configure::write('pdf_directory', $basedir.'webroot/pdf/');
|
Configure::write('pdf_directory', $basedir.'webroot/pdf/');
|
||||||
Configure::write('attachments_directory', $basedir.'webroot/attachments_files/');
|
Configure::write('attachments_directory', $basedir.'webroot/attachments_files/');
|
||||||
|
|
||||||
|
// Ensure Go service base URL is available to PHP when provided via environment
|
||||||
|
$goBaseUrl = getenv('GO_BASE_URL');
|
||||||
|
if (!empty($goBaseUrl)) {
|
||||||
|
Configure::write('go_base_url', rtrim($goBaseUrl, '/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application wide charset encoding
|
* Application wide charset encoding
|
||||||
|
|
|
||||||
|
|
@ -819,6 +819,12 @@ ENDINSTRUCTIONS;
|
||||||
$docType = $this->Document->getDocType($document);
|
$docType = $this->Document->getDocType($document);
|
||||||
$docTypeFullName = $this->Document->getDocFullName($docType);
|
$docTypeFullName = $this->Document->getDocFullName($docType);
|
||||||
|
|
||||||
|
// Normalize docType when missing or unexpected: infer orderAck if OrderAcknowledgement data exists
|
||||||
|
if (empty($docType) && !empty($document['OrderAcknowledgement']['id'])) {
|
||||||
|
$docType = 'orderAck';
|
||||||
|
$docTypeFullName = $this->Document->getDocFullName($docType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$currency = $this->Document->getCurrency($document);
|
$currency = $this->Document->getCurrency($document);
|
||||||
|
|
@ -933,11 +939,17 @@ ENDINSTRUCTIONS;
|
||||||
|
|
||||||
$job = $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id'])));
|
$job = $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id'])));
|
||||||
|
|
||||||
|
// Load enquiry from job
|
||||||
|
if ($job && isset($job['Job']['enquiry_id'])) {
|
||||||
|
$enquiry = $this->Document->OrderAcknowledgement->Job->Enquiry->read(null, $job['Job']['enquiry_id']);
|
||||||
|
}
|
||||||
|
|
||||||
$filename = $job['Job']['title'].'_OrderAcknowledgement';
|
$filename = $job['Job']['title'].'_OrderAcknowledgement';
|
||||||
$this->set('docTitle', $job['Job']['title']);
|
$this->set('docTitle', $job['Job']['title']);
|
||||||
|
|
||||||
$this->set('docTypeFullName', 'JOB'); //So it doesnt say CMC order Ack # in the pdf_shipping_billing_box. This string is too long
|
$this->set('docTypeFullName', 'JOB'); //So it doesnt say CMC order Ack # in the pdf_shipping_billing_box. This string is too long
|
||||||
$this->set('job', $job);
|
$this->set('job', $job);
|
||||||
|
$this->set('enquiry', $enquiry);
|
||||||
$this->set('issue_date_string', date('d F Y', strtotime($document['OrderAcknowledgement']['issue_date'])));
|
$this->set('issue_date_string', date('d F Y', strtotime($document['OrderAcknowledgement']['issue_date'])));
|
||||||
|
|
||||||
$this->set('ship_via', $document['OrderAcknowledgement']['ship_via']);
|
$this->set('ship_via', $document['OrderAcknowledgement']['ship_via']);
|
||||||
|
|
@ -958,6 +970,11 @@ ENDINSTRUCTIONS;
|
||||||
$template_name = 'pdf_packinglist';
|
$template_name = 'pdf_packinglist';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
// No matching template - log and render error
|
||||||
|
error_log("PDF generation: Unknown document type: " . $docType . " for Document ID: " . $document['Document']['id']);
|
||||||
|
echo "ERROR: Unknown document type for PDF generation";
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't set filename here - let the Go service and view handle it
|
// Don't set filename here - let the Go service and view handle it
|
||||||
|
|
@ -981,6 +998,12 @@ ENDINSTRUCTIONS;
|
||||||
|
|
||||||
$this->set('colWidths',$colWidths);
|
$this->set('colWidths',$colWidths);
|
||||||
|
|
||||||
|
// Ensure template_name was set by the switch; otherwise show error
|
||||||
|
if (!isset($template_name)) {
|
||||||
|
echo "<p>ERROR: Unknown document type '$docType' for document ID $id. Cannot render PDF.</p>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$this->render($template_name);
|
$this->render($template_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
// Generate the Order Acknowledgement PDF by calling the Go service (similar to invoice)
|
// Generate the Order Acknowledgement PDF by calling the Go service (similar to invoice)
|
||||||
|
error_log("=== pdf_orderack.ctp: Starting order ack PDF generation ===");
|
||||||
|
error_log("=== pdf_orderack.ctp: Document ID: " . (isset($document['Document']['id']) ? $document['Document']['id'] : 'UNDEFINED') . " ===");
|
||||||
|
|
||||||
|
if (!isset($document) || !isset($document['Document'])) {
|
||||||
|
error_log("=== pdf_orderack.ctp: ERROR - Document not set in view! ===");
|
||||||
|
echo "ERROR: Document data not available in view";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$goBaseUrl = AppController::getGoBaseUrlOrFail();
|
$goBaseUrl = AppController::getGoBaseUrlOrFail();
|
||||||
$goEndpoint = $goBaseUrl . '/go/document/generate/order-acknowledgement';
|
$goEndpoint = $goBaseUrl . '/go/document/generate/order-acknowledgement';
|
||||||
|
error_log("=== pdf_orderack.ctp: Go endpoint: " . $goEndpoint . " ===");
|
||||||
|
|
||||||
$outputDir = Configure::read('pdf_directory');
|
$outputDir = Configure::read('pdf_directory');
|
||||||
|
|
||||||
|
|
@ -67,40 +76,32 @@ if (isset($enquiry['Enquiry']['customer_reference']) && !empty($enquiry['Enquiry
|
||||||
$yourReference = 'Enquiry on ' . date('j M Y');
|
$yourReference = 'Enquiry on ' . date('j M Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate totals (match invoice structure)
|
|
||||||
$subtotal = isset($totals['subtotal']) ? $totals['subtotal'] : 0.0;
|
|
||||||
$gstAmount = isset($totals['gst']) ? $totals['gst'] : 0.0;
|
|
||||||
$total = isset($totals['total']) ? $totals['total'] : 0.0;
|
|
||||||
|
|
||||||
$payload = array(
|
$payload = array(
|
||||||
'document_id' => intval($document['Document']['id']),
|
'document_id' => intval($document['Document']['id']),
|
||||||
'order_ack_number' => $orderAckNumber,
|
|
||||||
'title' => $orderAckTitle,
|
'title' => $orderAckTitle,
|
||||||
'customer_name' => $customerName,
|
'customer_name' => $customerName,
|
||||||
'contact_email' => $contactEmail,
|
'cmc_reference' => isset($document['Document']['cmc_reference']) ? $document['Document']['cmc_reference'] : '',
|
||||||
'contact_name' => $contactName,
|
'email_to' => $contactEmail,
|
||||||
'user_first_name' => $userFirstName,
|
'attention' => $contactName,
|
||||||
'user_last_name' => $userLastName,
|
|
||||||
'user_email' => $userEmail,
|
|
||||||
'your_reference' => $yourReference,
|
'your_reference' => $yourReference,
|
||||||
|
'customer_order_number' => isset($job['Job']['customer_order_number']) ? $job['Job']['customer_order_number'] : '',
|
||||||
|
'job_title' => isset($job['Job']['title']) ? $job['Job']['title'] : '',
|
||||||
|
'issue_date' => isset($document['OrderAcknowledgement']['issue_date']) ? $document['OrderAcknowledgement']['issue_date'] : date('Y-m-d'),
|
||||||
|
'issue_date_string' => isset($issue_date_string) ? $issue_date_string : '',
|
||||||
|
'bill_to' => isset($document['Document']['bill_to']) ? $document['Document']['bill_to'] : '',
|
||||||
|
'ship_to' => isset($document['Document']['ship_to']) ? $document['Document']['ship_to'] : '',
|
||||||
'ship_via' => isset($document['OrderAcknowledgement']['ship_via']) ? $document['OrderAcknowledgement']['ship_via'] : '',
|
'ship_via' => isset($document['OrderAcknowledgement']['ship_via']) ? $document['OrderAcknowledgement']['ship_via'] : '',
|
||||||
'fob' => isset($document['OrderAcknowledgement']['fob']) ? $document['OrderAcknowledgement']['fob'] : '',
|
'fob' => isset($document['OrderAcknowledgement']['fob']) ? $document['OrderAcknowledgement']['fob'] : '',
|
||||||
|
'payment_terms' => isset($job['Customer']['payment_terms']) ? $job['Customer']['payment_terms'] : '',
|
||||||
|
'customer_abn' => isset($job['Customer']['abn']) ? $job['Customer']['abn'] : '',
|
||||||
|
'freight_details' => isset($document['Document']['shipping_details']) ? $document['Document']['shipping_details'] : '',
|
||||||
'estimated_delivery' => isset($document['OrderAcknowledgement']['estimated_delivery']) ? $document['OrderAcknowledgement']['estimated_delivery'] : '',
|
'estimated_delivery' => isset($document['OrderAcknowledgement']['estimated_delivery']) ? $document['OrderAcknowledgement']['estimated_delivery'] : '',
|
||||||
'issue_date' => $document['OrderAcknowledgement']['issue_date'],
|
|
||||||
'issue_date_string' => isset($issue_date_string) ? $issue_date_string : '',
|
|
||||||
'currency_symbol' => $currencySymbol,
|
'currency_symbol' => $currencySymbol,
|
||||||
'currency_code' => $currencyCode,
|
'currency_code' => $currencyCode,
|
||||||
'show_gst' => (bool)$gst,
|
'show_gst' => (bool)$gst,
|
||||||
'bill_to' => isset($document['Document']['bill_to']) ? $document['Document']['bill_to'] : '',
|
'subtotal' => $totals['subtotal'],
|
||||||
'ship_to' => isset($document['Document']['ship_to']) ? $document['Document']['ship_to'] : '',
|
'gst_amount' => $totals['gst'],
|
||||||
'shipping_details' => isset($document['Document']['shipping_details']) ? $document['Document']['shipping_details'] : '',
|
'total' => $totals['total'],
|
||||||
'customer_order_number' => isset($job['Job']['customer_order_number']) ? $job['Job']['customer_order_number'] : '',
|
|
||||||
'job_title' => isset($job['Job']['title']) ? $job['Job']['title'] : '',
|
|
||||||
'payment_terms' => isset($job['Customer']['payment_terms']) ? $job['Customer']['payment_terms'] : '',
|
|
||||||
'customer_abn' => isset($job['Customer']['abn']) ? $job['Customer']['abn'] : '',
|
|
||||||
'subtotal' => $subtotal,
|
|
||||||
'gst_amount' => $gstAmount,
|
|
||||||
'total' => $total,
|
|
||||||
'line_items' => $lineItems,
|
'line_items' => $lineItems,
|
||||||
'output_dir' => $outputDir
|
'output_dir' => $outputDir
|
||||||
);
|
);
|
||||||
|
|
@ -111,15 +112,22 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||||
|
|
||||||
|
error_log("=== pdf_orderack.ctp: Making curl request to Go service ===");
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
error_log("=== pdf_orderack.ctp: Curl response received: " . substr($response, 0, 200) . " ===");
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
$curlErr = curl_error($ch);
|
$curlErr = curl_error($ch);
|
||||||
|
error_log("=== pdf_orderack.ctp: HTTP Code: " . $httpCode . ", Curl Error: " . $curlErr . " ===");
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
if ($httpCode < 200 || $httpCode >= 300) {
|
if ($httpCode < 200 || $httpCode >= 300) {
|
||||||
echo "<p>Failed to generate Order Acknowledgement 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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue