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-edit.php | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/assignments-edit.php (limited to 'include/assignments-edit.php') diff --git a/include/assignments-edit.php b/include/assignments-edit.php new file mode 100644 index 0000000..0e0801a --- /dev/null +++ b/include/assignments-edit.php @@ -0,0 +1,59 @@ +. + */ + +require_once('./conf.php'); + +$response = new response(); + +try { + $assignment = new assignment($_pdo, $_REQUEST['pk']); + + $name = explode('-', $_REQUEST['name']); + $what_to_edit = $name[count($name) - 1]; + switch ($what_to_edit) { + case 'title': + $response->success = $assignment->setTitle($_REQUEST['value']); + break; + case 'hours': + $response->success = $assignment->setHours($_REQUEST['value']); + break; + case 'price_per_hour': + $response->success = $assignment->setPricePerHour($_REQUEST['value']); + break; + case 'vat': + $response->success = $assignment->setVAT($_REQUEST['value']); + break; + default: + $response->http_response_code(404); + $response->success = false; + } + if (!$response->success && $response->http_response_code() == 200) { + $response->http_response_code(500); + $response->message = "The assignment could not be edited due to an error."; + } +} catch (PDOException $e) { + $response->http_response_code(500); + $response->success = false; + $response->message = "The assignment could not be edited 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 edited due to an exception."; +} +echo $response->message; \ No newline at end of file -- cgit v1.2.3