@@ -45,3 +45,18 @@ function create_alert($type, $msg) {
|
|||||||
$thisAlert = array($type, $msg);
|
$thisAlert = array($type, $msg);
|
||||||
array_push($_SESSION['alerts'], $thisAlert);
|
array_push($_SESSION['alerts'], $thisAlert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_user_name($db, $user_uuid) {
|
||||||
|
try {
|
||||||
|
$stmt = "SELECT given_name, family_name FROM users WHERE uuid=:uuid";
|
||||||
|
$sql = $db->prepare($stmt);
|
||||||
|
$sql->bindParam(':uuid', $user_uuid);
|
||||||
|
$sql->execute();
|
||||||
|
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$result = $sql->fetchAll();
|
||||||
|
$usr = $result[0]['given_name'] . " " . $result[0]['family_name'];
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
return $usr;
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,20 +43,6 @@
|
|||||||
return $tkt;
|
return $tkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_name($db, $user_uuid) {
|
|
||||||
try {
|
|
||||||
$stmt = "SELECT given_name, family_name FROM users WHERE uuid=:uuid";
|
|
||||||
$sql = $db->prepare($stmt);
|
|
||||||
$sql->bindParam(':uuid', $user_uuid);
|
|
||||||
$sql->execute();
|
|
||||||
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
|
||||||
$result = $sql->fetchAll();
|
|
||||||
$usr = $result[0]['given_name'] . " " . $result[0]['family_name'];
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
echo("Error: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
return $usr;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
@@ -85,8 +71,10 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php if (is_signed_in()) { ?>
|
<?php if (is_signed_in()) { ?>
|
||||||
<section>
|
<div class="container" style="margin-top: -5%">
|
||||||
<div class="card mx-auto" style="width: 80%;">
|
<div class="row">
|
||||||
|
<div class="col-sm">
|
||||||
|
<div class="card mx-auto">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<span class="mdi mdi-ticket-outline"></span> My Open Requests
|
<span class="mdi mdi-ticket-outline"></span> My Open Requests
|
||||||
</div>
|
</div>
|
||||||
@@ -113,10 +101,10 @@
|
|||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</div>
|
||||||
|
|
||||||
<section style="margin-top: 1%;">
|
<div class="col-sm">
|
||||||
<div class="card mx-auto" style="width: 80%;">
|
<div class="card mx-auto">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<span class="mdi mdi-rss"></span> My Subscribed Requests
|
<span class="mdi mdi-rss"></span> My Subscribed Requests
|
||||||
</div>
|
</div>
|
||||||
@@ -146,6 +134,9 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
155
app/public/index.php.old
Normal file
155
app/public/index.php.old
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
<?php
|
||||||
|
$PAGE_NAME = "Home";
|
||||||
|
require_once __DIR__ . "/../includes/header.php";
|
||||||
|
|
||||||
|
if (is_signed_in()) {
|
||||||
|
// Get user's own tickets
|
||||||
|
try {
|
||||||
|
$user_tickets_stmt = "SELECT uuid, id, title, description, status FROM tickets WHERE created_by=:uuid";
|
||||||
|
$user_tickets_sql = $db->prepare($user_tickets_stmt);
|
||||||
|
$user_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
|
||||||
|
$user_tickets_sql->execute();
|
||||||
|
$user_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$user_tickets_result = $user_tickets_sql->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get tickets user has subscribed to
|
||||||
|
try {
|
||||||
|
$sub_tickets_stmt = "SELECT ticket_uuid FROM ticket_subscribers WHERE user_uuid=:uuid";
|
||||||
|
$sub_tickets_sql = $db->prepare($sub_tickets_stmt);
|
||||||
|
$sub_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
|
||||||
|
$sub_tickets_sql->execute();
|
||||||
|
$sub_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$sub_tickets_result = $sub_tickets_sql->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_sub_ticket($db, $ticket_uuid) {
|
||||||
|
try {
|
||||||
|
$stmt = "SELECT * FROM tickets WHERE uuid=:uuid";
|
||||||
|
$sql = $db->prepare($stmt);
|
||||||
|
$sql->bindParam(':uuid', $ticket_uuid);
|
||||||
|
$sql->execute();
|
||||||
|
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$result = $sql->fetchAll();
|
||||||
|
$tkt = $result[0];
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
return $tkt;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_name($db, $user_uuid) {
|
||||||
|
try {
|
||||||
|
$stmt = "SELECT given_name, family_name FROM users WHERE uuid=:uuid";
|
||||||
|
$sql = $db->prepare($stmt);
|
||||||
|
$sql->bindParam(':uuid', $user_uuid);
|
||||||
|
$sql->execute();
|
||||||
|
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||||
|
$result = $sql->fetchAll();
|
||||||
|
$usr = $result[0]['given_name'] . " " . $result[0]['family_name'];
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
return $usr;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Begin page content -->
|
||||||
|
<main role="main" class="flex-shrink-0">
|
||||||
|
|
||||||
|
<section class="jumbotron text-center">
|
||||||
|
<div class="container">
|
||||||
|
<h1>Welcome to <?php echo($_ENV['APP_NAME']); ?></h1>
|
||||||
|
<p class="lead text-muted">
|
||||||
|
<?php
|
||||||
|
if ($_ENV['APP_NAME'] == "FHeD") {echo("The Free HelpDesk");} else {echo($_ENV['APP_NAME']);};
|
||||||
|
?>
|
||||||
|
is the one-stop shop for all of your IT-related needs. Let us know how we can help you by opening a request.
|
||||||
|
</p>
|
||||||
|
<?php if (is_signed_in()) { ?>
|
||||||
|
<p>
|
||||||
|
<a href='/new' class='btn btn-primary my-2'>Create a request</a>
|
||||||
|
<a href='/open' class='btn btn-secondary my-2'>View existing requests</a>
|
||||||
|
</p>
|
||||||
|
<?php } else { ?>
|
||||||
|
<p><b>Please log in to create or view requests.</b></p>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<?php if (is_signed_in()) { ?>
|
||||||
|
<section>
|
||||||
|
<div class="card mx-auto" style="width: 80%;">
|
||||||
|
<div class="card-header">
|
||||||
|
<span class="mdi mdi-ticket-outline"></span> My Open Requests
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php
|
||||||
|
if (count($user_tickets_result) == 0) {
|
||||||
|
echo("<center><b>No open tickets</b></center>");
|
||||||
|
} else {
|
||||||
|
foreach($user_tickets_result as $tkt) {
|
||||||
|
?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-10">
|
||||||
|
<span style="display: inline;" class="text-muted">#<?php echo(sprintf("%'.05d\n", $tkt["id"])); ?> </span><span><b><?php echo($tkt['title']); ?></b></span>
|
||||||
|
<p class="m-0"><?php echo($tkt['description']); ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a class="btn btn-success float-right" href="view?rid=<?php echo($tkt["uuid"]); ?>" role="button">Go</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php } } ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section style="margin-top: 1%;">
|
||||||
|
<div class="card mx-auto" style="width: 80%;">
|
||||||
|
<div class="card-header">
|
||||||
|
<span class="mdi mdi-rss"></span> My Subscribed Requests
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php
|
||||||
|
if (count($sub_tickets_result) == 0) {
|
||||||
|
echo("<center><b>No subscribed tickets</b></center>");
|
||||||
|
} else {
|
||||||
|
foreach($sub_tickets_result as $sub) {
|
||||||
|
$tkt = get_sub_ticket($db, $sub['ticket_uuid']);
|
||||||
|
$tkt_creator = get_user_name($db, $tkt['created_by']);
|
||||||
|
?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-10">
|
||||||
|
<span style="display: inline;" class="text-muted">#<?php echo sprintf("%'.05d\n", $tkt["id"]); ?> </span><span><b><?php echo($tkt['title']); ?></b></span> <span style="display: inline;" class="text-muted"><?php echo("(Creator: " . $tkt_creator . ")"); ?></span>
|
||||||
|
<p class="m-0"><?php echo($tkt['description']); ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a class="btn btn-success float-right" href="view?rid=<?php echo($tkt["uuid"]); ?>" role="button">Go</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php } } ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once __DIR__ . "/../includes/footer.php";
|
||||||
|
?>
|
||||||
@@ -40,8 +40,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header_remove("Location");
|
header('Location: /view?rid=' . $tkt_uuid, true);
|
||||||
header('Location: /view?rid=' . $tkt_uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_signed_in()) {
|
if (!is_signed_in()) {
|
||||||
@@ -58,14 +57,14 @@
|
|||||||
<?php
|
<?php
|
||||||
if(isset($new_ticket_alert)) {
|
if(isset($new_ticket_alert)) {
|
||||||
echo("
|
echo("
|
||||||
<section>
|
<div class='container'>
|
||||||
<div class='alert alert-" . $new_ticket_alert[0] . " alert-dismissible fade show' role='alert'>
|
<div class='alert alert-" . $new_ticket_alert[0] . " alert-dismissible fade show' role='alert'>
|
||||||
" . $new_ticket_alert[1] . "
|
" . $new_ticket_alert[1] . "
|
||||||
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
|
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
|
||||||
<span aria-hidden='true'>×</span>
|
<span aria-hidden='true'>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</div>
|
||||||
");
|
");
|
||||||
unset($new_ticket_alert);
|
unset($new_ticket_alert);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,18 @@
|
|||||||
echo("Error: " . $e->getMessage());
|
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
|
// Get authorised subscribers
|
||||||
try {
|
try {
|
||||||
$users_stmt = "SELECT user_uuid FROM ticket_subscribers WHERE ticket_uuid=:uuid";
|
$users_stmt = "SELECT user_uuid FROM ticket_subscribers WHERE ticket_uuid=:uuid";
|
||||||
@@ -47,12 +59,14 @@
|
|||||||
|
|
||||||
<?php if (!is_signed_in()) { ?>
|
<?php if (!is_signed_in()) { ?>
|
||||||
<section>
|
<section>
|
||||||
|
<div class="container">
|
||||||
<div class='alert alert-danger alert-dismissible fade show' role='alert'>
|
<div class='alert alert-danger alert-dismissible fade show' role='alert'>
|
||||||
You need to log in to access this page.
|
You need to log in to access this page.
|
||||||
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
|
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
|
||||||
<span aria-hidden='true'>×</span>
|
<span aria-hidden='true'>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<?php } else {
|
<?php } else {
|
||||||
if ($is_authorised == true) { ?>
|
if ($is_authorised == true) { ?>
|
||||||
@@ -61,6 +75,9 @@
|
|||||||
<h1><?php echo($request['title']); ?></h1>
|
<h1><?php echo($request['title']); ?></h1>
|
||||||
<p style="color: gray; font-style: italic;"><?php echo("#" . sprintf("%'.05d\n", $request["id"])); ?></p>
|
<p style="color: gray; font-style: italic;"><?php echo("#" . sprintf("%'.05d\n", $request["id"])); ?></p>
|
||||||
<p class="lead text-muted"><?php echo($request['description']); ?></p>
|
<p class="lead text-muted"><?php echo($request['description']); ?></p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
@@ -70,7 +87,44 @@
|
|||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<span style="display: inline;"><b>Status:</b> <?php echo($request['status']); ?></span>
|
<span style="display: inline;"><b>Status:</b></span>
|
||||||
|
<span style="display: inline; margin-left: 1%;"><?php echo($request['status']); ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;"><b>Creator:</b></span>
|
||||||
|
<span style="display: inline; margin-left: 1%;"><?php echo(get_user_name($db, $request['created_by'])); ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;"><b>Assignee:</b></span>
|
||||||
|
<?php if ($request['assignee'] != null) {
|
||||||
|
echo("<span style='display: inline; margin-left: 1%;'>" . get_user_name($db, $request['assignee']) . "</span>");
|
||||||
|
} else {
|
||||||
|
echo("<span class='text-muted' style='display: inline; margin-left: 1%;'>None</span>");
|
||||||
|
} ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;"><b>Created:</b></span>
|
||||||
|
<span style="display: inline; margin-left: 1%;"><?php echo($request['created_on']); ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;"><b>Updated:</b></span>
|
||||||
|
<span style="display: inline; margin-left: 1%;"><?php echo($request['last_updated']); ?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -82,26 +136,58 @@
|
|||||||
<div class="card mx-auto">
|
<div class="card mx-auto">
|
||||||
<div class="card-header"><span class="mdi mdi-update"></span> Updates</div>
|
<div class="card-header"><span class="mdi mdi-update"></span> Updates</div>
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php
|
||||||
|
if (count($updates_result) == 0) {
|
||||||
|
echo("<center><b>No updates</b></center>");
|
||||||
|
} else {
|
||||||
|
foreach($updates_result as $update) {
|
||||||
|
?>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-10">
|
<span style="display: inline;"><b><?php echo(get_user_name($db, $update['user'])); ?></b></span><span class="text-muted"><i><?php echo(" " . $update['created']); ?></i></span>
|
||||||
<span style="display: inline;" class="text-muted">#<?php echo(sprintf("%'.05d\n", $tkt["id"])); ?> </span><span><b><?php echo($tkt['title']); ?></b></span>
|
|
||||||
<p class="m-0"><?php echo($tkt['description']); ?></p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-2">
|
<div class="row">
|
||||||
<a class="btn btn-success float-right" href="view?rid=<?php echo($tkt["uuid"]); ?>" role="button">Go</a>
|
<span><?php echo($update['msg']); ?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php } } ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm">
|
||||||
|
<div class="card mx-auto">
|
||||||
|
<div class="card-header"><span class="mdi mdi-comment-edit-outline"></span> Actions</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;">Post an update</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;">Upload file(s)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<span style="display: inline;">Manage request subscribers</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p><?php print_r($request); ?></p>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
<?php } else if ($is_authorised == false) { ?>
|
<?php } else if ($is_authorised == false) { ?>
|
||||||
<section class="jumbotron text-center">
|
<section class="jumbotron text-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user