. */ require_once(__DIR__ . '/../conf.php'); require_once(__DIR__ . '/../login-ajax.php'); $response = new Response(); try { $contact = new Contact($_pdo, $_REQUEST['contactId']); $offer = $contact->createOffer(); $response->success = true; $response->message = "Offer #{$offer->id} has been succesfully created. Refresh the page."; } catch (PDOException $e) { $response->http_response_code(500); $response->success = false; $response->message = "The offer could not be created due to a PDO error ({$e->getMessage()})."; } catch (Exception $e) { $response->http_response_code(404); $response->success = false; $response->message = "The offer could not be created due to an error."; } echo $response->getJson();