saveOrder($data, $logging); // On new order created from a quotation: link both records if ($new_id && $quotation_id > 0) { $pdo->prepare( "UPDATE ac_quotation SET order_id = :order_id, status = 5 WHERE id = :id AND company_id = :cid AND status = 2" )->execute([':order_id' => $new_id, ':id' => $quotation_id, ':cid' => $company_id]); } }); $answer['success'] = 1; if ($new_id) { $answer['new_id'] = $new_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)); ?>