-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reserveringen kunnen nu worden geannuleerd
- Loading branch information
Showing
5 changed files
with
248 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?PHP | ||
header('Content-Type: text/html; charset=utf-8'); | ||
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); | ||
header("Cache-Control: post-check=0, pre-check=0", false); | ||
header("Pragma: no-cache"); | ||
|
||
$data = array(); | ||
$data["type"] = "error"; | ||
$data["message"] = "Onbekende error"; | ||
$data["data"] = array(); | ||
|
||
function returnError($msg) { | ||
global $data; | ||
$data["type"] = "error"; | ||
$data["message"] = $msg; | ||
$data["data"] = array(); | ||
header('Content-Type: application/json; charset=utf-8'); | ||
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); | ||
die(); | ||
} | ||
|
||
function returnWarning($msg) { | ||
global $data; | ||
$data["type"] = "warning"; | ||
$data["message"] = $msg; | ||
$data["data"] = array(); | ||
header('Content-Type: application/json; charset=utf-8'); | ||
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); | ||
die(); | ||
} | ||
|
||
function returnData($msg, $stuff) { | ||
global $data; | ||
$data["type"] = "success"; | ||
$data["message"] = $msg; | ||
$data["data"] = $stuff; | ||
header('Content-Type: application/json; charset=utf-8'); | ||
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); | ||
die(); | ||
} | ||
|
||
session_start(); | ||
|
||
if (!isset($_SESSION["zermelo_access_token"]) || empty($_SESSION["zermelo_access_token"])) { | ||
returnError("Je bent niet (meer) ingelogd! Log opnieuw in."); | ||
} | ||
else { | ||
if (!isset($_POST["id"]) || empty($_POST["id"])) { | ||
returnError("Geen reservering-ID opgegeven. Geef een reservering-ID op via POST id."); | ||
} | ||
|
||
require_once("db.php"); | ||
$damstedeDB = new DamstedeDB(); | ||
|
||
$reservation = $damstedeDB->getCartReservation($_POST["id"]); | ||
if ($reservation["user"] === $_SESSION["user"]["code"]) { | ||
if ($damstedeDB->cancelReservation($_POST["id"])) { | ||
returnData("De reservering is geannuleerd.", $damstedeDB->makeSafe($_POST["id"])); | ||
} | ||
else { | ||
returnError("Kon reservering niet annuleren. Probeer het later opnieuw."); | ||
} | ||
} | ||
else { | ||
returnError("Je kunt alleen reserveringen annuleren die je zelf hebt gemaakt."); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters