isset($li['item_number']) ? $li['item_number'] : '', 'quantity' => isset($li['quantity']) ? $li['quantity'] : '', 'title' => isset($li['title']) ? $li['title'] : '', 'unit_price' => isset($li['gross_unit_price']) ? floatval($li['gross_unit_price']) : 0.0, 'total_price' => isset($li['gross_price']) ? floatval($li['gross_price']) : 0.0, ); } } $payload = array( 'document_id' => 0, 'cmc_reference' => $quote['Enquiry']['title'], 'revision' => intval($quote['Quote']['revision']), 'created_date' => date('Y-m-d', strtotime($quote['Enquiry']['created'])), 'customer_name' => $quote['Customer']['name'], 'contact_email' => $quote['Contact']['email'], 'contact_name' => $quote['Contact']['first_name'].' '.$quote['Contact']['last_name'], 'user_first_name' => $quote['User']['first_name'], 'user_last_name' => $quote['User']['last_name'], 'user_email' => $quote['User']['email'], 'currency_symbol' => isset($quote['Currency']['symbol']) ? $quote['Currency']['symbol'] : '$', 'show_gst' => (bool)$quote['Enquiry']['gst'], 'commercial_comments' => isset($commercialDetails) ? $commercialDetails : '', 'line_items' => $lineItems, 'pages' => array_map(function($p) { return $p['content']; }, $quote['QuotePage']), '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 Quote PDF via Go service (HTTP $httpCode)."; if ($curlErr) { echo " Error: $curlErr"; } echo "

"; exit; } ?>