$li['item_number'], 'quantity' => $li['quantity'], 'title' => $li['title'], 'unit_price' => floatval($li['gross_unit_price']), 'total_price' => floatval($li['gross_price']) ); } $payload = array( 'document_id' => intval($document['Document']['id']), 'title' => $document['PurchaseOrder']['title'], 'principle_name' => isset($principle['Principle']['name']) ? $principle['Principle']['name'] : $document['PurchaseOrder']['ordered_from'], 'principle_reference' => $document['PurchaseOrder']['principle_reference'], 'issue_date' => $document['PurchaseOrder']['issue_date'], 'ordered_from' => $document['PurchaseOrder']['ordered_from'], 'dispatch_by' => $document['PurchaseOrder']['dispatch_by'], 'deliver_to' => $document['PurchaseOrder']['deliver_to'], 'shipping_instructions' => $document['PurchaseOrder']['shipping_instructions'], 'currency_symbol' => $currencySymbol, 'show_gst' => (bool)$gst, 'line_items' => $lineItems, 'output_dir' => $outputDir ); $ch = curl_init($goEndpoint); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlErr = curl_error($ch); curl_close($ch); if ($httpCode < 200 || $httpCode >= 300) { echo "
Failed to generate PO PDF via Go service (HTTP $httpCode)."; if ($curlErr) { echo " Error: $curlErr"; } echo "
"; exit; } ?>