Creation of button and SQL
This commit is contained in:
27
app/public/actions/reopen.php
Normal file
27
app/public/actions/reopen.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$PAGE_NAME = "Close request";
|
||||
require_once __DIR__ . "/../../includes/prereqs.php";
|
||||
|
||||
$request = get_request($db, $_GET['rid']);
|
||||
$authorised_users = get_subscribers($db, $request);
|
||||
$is_authorised = isAuthorised($_SESSION['uuid'], $authorised_users, $request);
|
||||
|
||||
// Close request
|
||||
if ($is_authorised == true) {
|
||||
try {
|
||||
$stmt = "UPDATE tickets SET status='Reopened' WHERE uuid=:uuid";
|
||||
$sql = $db->prepare($stmt);
|
||||
$sql->bindParam(':uuid', $_GET['rid']);
|
||||
$sql->execute();
|
||||
} catch (PDOException $e) {
|
||||
$alert = array("danger", "Failed to reopen request: " . $e->getMessage());
|
||||
}
|
||||
$newURL = "/";
|
||||
echo("<script>window.location = '$newURL'</script>");
|
||||
} else {
|
||||
$alert = array("danger", "You are not authorised to close this request.");
|
||||
$newURL = "/view?rid=" . $request['uuid'];
|
||||
echo("<script>window.location = '$newURL'</script>");
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user