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/offers-edit.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/offers-edit.php (limited to 'include/offers-edit.php') diff --git a/include/offers-edit.php b/include/offers-edit.php new file mode 100644 index 0000000..b2a7156 --- /dev/null +++ b/include/offers-edit.php @@ -0,0 +1,59 @@ +. + */ + +require_once('./conf.php'); + +$response = new response(); + +try { + $offer = new offer($_pdo, $_REQUEST['pk']); + + $name = explode('-', $_REQUEST['name']); + $what_to_edit = $name[count($name) - 1]; + switch ($what_to_edit) { + case 'start_date': + $response->success = $offer->setStartDate(strtotime($_REQUEST['value'])); + break; + case 'end_date': + $response->success = $offer->setEndDate(strtotime($_REQUEST['value'])); + break; + case 'invoice_date': + $response->success = $offer->setInvoiceDate(strtotime($_REQUEST['value'])); + break; + case 'payment_received': + $response->success = $offer->setPaymentReceived(strtotime($_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 offer could not be edited due to an error."; + } +} catch (PDOException $e) { + $response->http_response_code(500); + $response->success = false; + $response->message = "The offer 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 offer could not be edited due to an exception."; +} +echo $response->message; \ No newline at end of file -- cgit v1.2.3