From c50a323c25a0787ba2051b19721983776a229615 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 5 Feb 2015 00:40:47 +0100 Subject: Initial commit --- include/assignments-new.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/assignments-new.php (limited to 'include/assignments-new.php') diff --git a/include/assignments-new.php b/include/assignments-new.php new file mode 100644 index 0000000..2de3b1f --- /dev/null +++ b/include/assignments-new.php @@ -0,0 +1,45 @@ +. + */ + +require_once('./conf.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->getTitle()} 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(); \ No newline at end of file -- cgit v1.2.3