From d02ebc25ab2d27ef72893aef4cc4e4b402634d42 Mon Sep 17 00:00:00 2001 From: jhuesser Date: Thu, 7 Jun 2018 11:20:53 +0200 Subject: [PATCH] send new incident to subscriber --- classes/incident.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/classes/incident.php b/classes/incident.php index 4ced1db..19f5e73 100644 --- a/classes/incident.php +++ b/classes/incident.php @@ -159,8 +159,22 @@ class Incident implements JsonSerializable $stmt->bind_param("ii", $service, $status_id); $stmt->execute(); $query = $stmt->get_result(); + + $query = $mysqli->query("SELECT * FROM services_subscriber WHERE serviceIDFK=" . $service); + while($subscriber = $query->fetch_assoc()){ + $subscriberQuery = $mysqli->query("SELECT * FROM subscribers WHERE userID=" . $subscriber['userIDFK']); + while($subscriberData = $subscriberQuery->fetch_assoc()){ + $telegramID = $subscriberData['telegramID']; + $firstname = $subscriberData['firstname']; + $lastname = $subscriberData['lastname']; + + $tg_message = urlencode('Hi ' . $firstname . chr(10) . 'There is a status update on a service that you have subscribed. View online'); + $response = json_decode(file_get_contents("https://api.telegram.org/bot" . TG_BOT_API_TOKEN . "/sendMessage?chat_id=" . $telegramID . "&parse_mode=HTML&text=" . $tg_message)); + + } + } - header("Location: ".WEB_URL."/admin"); + // header("Location: ".WEB_URL."/admin"); } }