$choice) { $choice = (array) $choice; $recurring[(string) $frequency] = [ 'to' => intval($choice['to'] ?? 0), 'start' => (string) ($choice['start'] ?? ''), 'auto_send' => intval($choice['auto_send'] ?? 1), ]; } $error = ''; $result = quoteConvert($quote_id, [ 'date' => (string) ($_POST['date'] ?? ''), 'first_period' => !empty($_POST['first_period']), 'recurring' => $recurring, 'by' => 'the API (' . html_entity_decode($api_key_name, ENT_QUOTES, 'UTF-8') . ')', ], $error); if (!$result) { http_response_code(400); $return_arr['success'] = "False"; $return_arr['message'] = $error; echo json_encode($return_arr); exit(); } $update_count = 1; $return_arr['invoice_id'] = intval($result['invoice_id']); $return_arr['recurring_invoice_ids'] = array_map('intval', array_keys($result['recurring'])); $return_arr['references'] = array_values($result['numbers']); $reference = escapeSql(billingNumber('quote', $quote)); logAudit("API", "Success", "Invoiced quote $reference as " . escapeSql(implode(', ', $result['numbers'])) . " via API ($api_key_name)", $client_id); } // Output require_once '../update_output.php';