From 1f594c5b1b1d12ed79923432ec40b31078f4620e Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sun, 9 Aug 2020 14:04:44 +0100 Subject: [PATCH] Add update/close ability to tickets (#38) * Moving from old branch * Added new terminology Also added upload file page. Waiting for @luketainton to complete back end coding * Fixing old issues * :bug: Re-add favicon Signed-off-by: Luke Tainton * :sparkles: Implement update functionality Signed-off-by: Luke Tainton * :sparkles: Implement upload functionality Signed-off-by: Luke Tainton Co-authored-by: Alexander Davis --- app/public/css/custom.css | 16 +-- app/public/existing.php | 2 +- app/public/update.php | 212 ++++++++++++++++++++++++++++++++++++ app/public/upload.php | 221 ++++++++++++++++++++++++++++++++++++++ app/public/view.php | 38 ++----- 5 files changed, 449 insertions(+), 40 deletions(-) create mode 100644 app/public/update.php create mode 100644 app/public/upload.php diff --git a/app/public/css/custom.css b/app/public/css/custom.css index 30e38a9..aee9f9e 100644 --- a/app/public/css/custom.css +++ b/app/public/css/custom.css @@ -16,16 +16,16 @@ main > .container { padding: 60px 15px 0; } - + .footer { background-color: #f5f5f5; } - + .footer > .container { padding-right: 15px; padding-left: 15px; } - + code { font-size: 80%; } @@ -42,24 +42,24 @@ code { padding-bottom: 6rem; } } - + .jumbotron p:last-child { margin-bottom: 0; } - + .jumbotron h1 { font-weight: 300; } - + .jumbotron .container { max-width: 40rem; } - + footer { padding-top: 3rem; padding-bottom: 3rem; } - + footer p { margin-bottom: .25rem; } diff --git a/app/public/existing.php b/app/public/existing.php index 39cbdf0..d3a36d3 100644 --- a/app/public/existing.php +++ b/app/public/existing.php @@ -77,7 +77,7 @@
-
+
My Closed Requests
diff --git a/app/public/update.php b/app/public/update.php new file mode 100644 index 0000000..30d7642 --- /dev/null +++ b/app/public/update.php @@ -0,0 +1,212 @@ +prepare($stmt); + $sql->bindParam(':tktuuid', $_POST['rid']); + $sql->bindParam(':user', $_SESSION['uuid']); + $sql->bindParam(':msg', $_POST['msg']); + $sql->execute(); + } catch (PDOException $e) { + // echo("Error:
" . $e->getMessage() . "
"); + $new_ticket_alert = array("danger", "Failed to save update: " . $e->getMessage()); + } + header('Location: /view?rid=' . $_POST['rid'], true); + } else { // Form not yet submitted + // Get ticket + try { + $ticket_stmt = "SELECT * FROM tickets WHERE uuid=:uuid"; + $ticket_sql = $db->prepare($ticket_stmt); + $ticket_sql->bindParam(':uuid', $_GET['rid']); + $ticket_sql->execute(); + $ticket_sql->setFetchMode(PDO::FETCH_ASSOC); + $ticket_result = $ticket_sql->fetchAll(); + $request = $ticket_result[0]; + } catch (PDOException $e) { + $new_ticket_alert = array("danger", "Failed to get request: " . $e->getMessage()); + } + + // Get ticket updates + try { + $updates_stmt = "SELECT * FROM ticket_updates WHERE ticket=:uuid"; + $updates_sql = $db->prepare($updates_stmt); + $updates_sql->bindParam(':uuid', $_GET['rid']); + $updates_sql->execute(); + $updates_sql->setFetchMode(PDO::FETCH_ASSOC); + $updates_result = $updates_sql->fetchAll(); + } catch (PDOException $e) { + $new_ticket_alert = array("danger", "Failed to get updates: " . $e->getMessage()); + } + + // Get authorised subscribers + try { + $users_stmt = "SELECT user_uuid FROM ticket_subscribers WHERE ticket_uuid=:uuid"; + $users_sql = $db->prepare($users_stmt); + $users_sql->bindParam(':uuid', $_GET['rid']); + $users_sql->execute(); + $users_sql->setFetchMode(PDO::FETCH_ASSOC); + $users_result = $users_sql->fetchAll(); + } catch (PDOException $e) { + $new_ticket_alert = array("danger", "Failed to get subscribers: " . $e->getMessage()); + } + } + + + $authorised_users = array(); + foreach($users_result as $user) { + array_push($authorised_users, $user['user_uuid']); + } + + if (in_array($_SESSION['uuid'], $authorised_users) || $_SESSION['uuid'] == $request['created_by']) { + $is_authorised = true; + } else { + $is_authorised = false; + } + +?> + + + + +
+ + +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
Information
+
    +
  • +
    +
    + Status: + +
    +
    +
  • +
  • +
    +
    + Created by: + +
    +
    +
  • +
  • +
    +
    + Assigned to: + " . get_user_name($db, $request['assignee']) . ""); + } else { + echo("None"); + } ?> +
    +
    +
  • +
  • +
    +
    + Created: + +
    +
    +
  • +
  • +
    +
    + Last updated: + +
    +
    +
  • +
+
+
+ +
+
+
Updates
+
    + No updates"); + } else { + foreach($updates_result as $update) { + ?> +
  • +
    +
    + +
    +
    + +
    +
    +
  • + +
+
+
+ +
+
+
+
+
+
+
+ +
+
+ + +
+ +
+
+
+ +
+
+

You are not authorised to see this page.

+
+
+ + +
+ + diff --git a/app/public/upload.php b/app/public/upload.php new file mode 100644 index 0000000..7840c80 --- /dev/null +++ b/app/public/upload.php @@ -0,0 +1,221 @@ +toString(); + $file_name = $_FILES['file']['name']; + $file_size = $_FILES['file']['size']; + $file_type = $_FILES['file']['type']; + $file_tmp = $_FILES['file']['tmp_name']; + move_uploaded_file($file_tmp,"/srv/attachments/".$file_name); + $stmt = "INSERT INTO ticket_uploads (id, ticket, user, filename) VALUES (:fileuuid, :ticket, :user, :name)"; + $sql = $db->prepare($stmt); + $sql->bindParam(':fileuuid', $file_uuid); + $sql->bindParam(':ticket', $_POST['rid']); + $sql->bindParam(':user', $_SESSION['uuid']); + $sql->bindParam(':name', $file_name); + $sql->execute(); + } catch (PDOException $e) { + // echo("Error:
" . $e->getMessage() . "
"); + $new_ticket_alert = array("danger", "Failed to upload file: " . $e->getMessage()); + } + } + header('Location: /view?rid=' . $tkt_uuid, true); + } else { // Form not yet submitted + // Get ticket + try { + $ticket_stmt = "SELECT * FROM tickets WHERE uuid=:uuid"; + $ticket_sql = $db->prepare($ticket_stmt); + $ticket_sql->bindParam(':uuid', $_GET['rid']); + $ticket_sql->execute(); + $ticket_sql->setFetchMode(PDO::FETCH_ASSOC); + $ticket_result = $ticket_sql->fetchAll(); + $request = $ticket_result[0]; + } catch (PDOException $e) { + echo("Error: " . $e->getMessage()); + } + + // Get ticket updates + try { + $updates_stmt = "SELECT * FROM ticket_updates WHERE ticket=:uuid"; + $updates_sql = $db->prepare($updates_stmt); + $updates_sql->bindParam(':uuid', $_GET['rid']); + $updates_sql->execute(); + $updates_sql->setFetchMode(PDO::FETCH_ASSOC); + $updates_result = $updates_sql->fetchAll(); + } catch (PDOException $e) { + echo("Error: " . $e->getMessage()); + } + + // Get authorised subscribers + try { + $users_stmt = "SELECT user_uuid FROM ticket_subscribers WHERE ticket_uuid=:uuid"; + $users_sql = $db->prepare($users_stmt); + $users_sql->bindParam(':uuid', $_GET['rid']); + $users_sql->execute(); + $users_sql->setFetchMode(PDO::FETCH_ASSOC); + $users_result = $users_sql->fetchAll(); + } catch (PDOException $e) { + echo("Error: " . $e->getMessage()); + } + } + + + $authorised_users = array(); + foreach($users_result as $user) { + array_push($authorised_users, $user['user_uuid']); + } + + if (in_array($_SESSION['uuid'], $authorised_users) || $_SESSION['uuid'] == $request['created_by']) { + $is_authorised = true; + } else { + $is_authorised = false; + } + +?> + + + + +
+ + +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
Information
+
    +
  • +
    +
    + Status: + +
    +
    +
  • +
  • +
    +
    + Created by: + +
    +
    +
  • +
  • +
    +
    + Assigned to: + " . get_user_name($db, $request['assignee']) . ""); + } else { + echo("None"); + } ?> +
    +
    +
  • +
  • +
    +
    + Created: + +
    +
    +
  • +
  • +
    +
    + Last updated: + +
    +
    +
  • +
+
+
+ +
+
+
Updates
+
    + No updates"); + } else { + foreach($updates_result as $update) { + ?> +
  • +
    +
    + +
    +
    + +
    +
    +
  • + +
+
+
+ +
+
+
+
+
+
+
+ +
+
+ + +
+ +
+
+
+ +
+
+

You are not authorised to see this page.

+
+
+ + +
+ + diff --git a/app/public/view.php b/app/public/view.php index 94ece07..33b912f 100644 --- a/app/public/view.php +++ b/app/public/view.php @@ -75,12 +75,17 @@

+

+ Update the request + Add attachment(s) + Close the request +

-
+
Information
    @@ -132,7 +137,7 @@
-
+
Updates
    @@ -157,35 +162,6 @@
-
-
-
Actions
-
    -
  • -
    -
    - Send an update -
    -
    -
  • -
  • -
    -
    - Upload file(s) -
    -
    -
  • -
  • -
    -
    - Add/Remove request subscribers -
    -
    -
  • -
-
-
-