saveOrder($data, $logging); // On new order created from a quotation: link both records if ($new_id && $source === 'quotation' && $source_id > 0) { $order->linkQuotationToOrder($source_id, $new_id); } }); $answer['success'] = 1; if ($new_id) { $answer['new_id'] = $new_id; (new UsageGuard($pdo1, $company_id, $packages))->increment(); } notify_node('order_updated', [], $company_id); } catch (PDOException $e) { $answer['message'] = 'Database error, please try again.'; http_response_code(500); } catch (Exception $e) { $answer['message'] = $e->getMessage(); http_response_code(400); } exit(json_encode($answer)); ?>