diff --git a/app/includes/app_functions.php b/app/includes/app_functions.php index 6d7bf28..293a02b 100644 --- a/app/includes/app_functions.php +++ b/app/includes/app_functions.php @@ -67,6 +67,26 @@ return $requests; } + function get_open_subscribed_requests($db) { + $requests = array(); + $sub_tickets_stmt = "SELECT ticket_uuid FROM ticket_subscribers WHERE user_uuid=:uuid AND status != 'Closed'"; + $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(); + foreach ($sub_tickets_result as $tkt) { + $stmt = "SELECT * FROM tickets WHERE uuid=:uuid"; + $sql = $db->prepare($stmt); + $sql->bindParam(':uuid', $tkt['ticket_uuid']); + $sql->execute(); + $sql->setFetchMode(PDO::FETCH_ASSOC); + $result = $sql->fetchAll(); + array_push($requests, $result[0]); + } + return $requests; + } + function get_request($db, $uuid) { $ticket_stmt = "SELECT * FROM tickets WHERE uuid=:uuid"; $ticket_sql = $db->prepare($ticket_stmt); diff --git a/app/public/index.php b/app/public/index.php index 596c640..a2c703e 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -4,7 +4,7 @@ if (is_signed_in()) { $requests = get_my_open_requests($db); - $subscriptions = get_subscribed_requests($db); + $subscriptions = get_open_subscribed_requests($db); } ?>