. */ require_once(__DIR__ . '/../conf.php'); require_once(__DIR__ . '/../login-ajax.php'); $response = new Response(); try { $offer = new Offer($_pdo, $_REQUEST['offerId']); $assignment = $offer->createAssignment( $_REQUEST['title'], $_REQUEST['description'], $_REQUEST['hours'], $_REQUEST['price_per_hour'], $_REQUEST['vat'] ); $response->success = true; $response->message = "Assignment {$assignment->title} has been succesfully created. Refresh the page."; } catch (PDOException $e) { $response->http_response_code(500); $response->success = false; $response->message = "The assignment 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 assignment could not be created due to an error."; } echo $response->getJson();