Commit ebf09e86 authored by S.Holzhauer's avatar S.Holzhauer

more magic

parent a3a58d03
...@@ -6,7 +6,7 @@ function GetNotifications( $status = 0 ){ ...@@ -6,7 +6,7 @@ function GetNotifications( $status = 0 ){
global $conn; global $conn;
$AccountID = $_SESSION['AccountID']; $AccountID = $_SESSION['AccountID'];
$sql = "SELECT B.Message,B.Time $sql = "SELECT B.Title,B.Time,B.Date
FROM Account_has_Notificatie A FROM Account_has_Notificatie A
INNER JOIN Notificatie B INNER JOIN Notificatie B
ON B.NotificationID = A.Notificatie_NotificatieID ON B.NotificationID = A.Notificatie_NotificatieID
...@@ -19,8 +19,8 @@ function GetNotifications( $status = 0 ){ ...@@ -19,8 +19,8 @@ function GetNotifications( $status = 0 ){
echo ' echo '
<a class="list-group-item" href="#"> <a class="list-group-item" href="#">
<i class="fa fa-bullseye fa-fw"></i> <i class="fa fa-bullseye fa-fw"></i>
<strong>' . $row["Message"] . '</strong> <strong>' . $row["Title"] . '</strong>
<span class="pull-right text-muted small"><em>' . $row["Time"] . '</em></span> <span class="pull-right text-muted small"><em>' . $row["Time"] . $row['Date'] . '</em></span>
</a> </a>
'; ';
} }
......
...@@ -169,8 +169,8 @@ else if ($ID == "IRPS001"){ ...@@ -169,8 +169,8 @@ else if ($ID == "IRPS001"){
ON A.AccountID = B.Account_AccountID ON A.AccountID = B.Account_AccountID
WHERE C.OuderID = '$OuderID';"; WHERE C.OuderID = '$OuderID';";
$result = $conn->query($sql); $result = $conn->query($sql);
//loop trough every account so they all get an email $row = $result->fetch_assoc()
while ($result && ($row = $result->fetch_assoc())){
$Acname = $row['A.Voorletters'] . " " . $row['A.Achternaam']; $Acname = $row['A.Voorletters'] . " " . $row['A.Achternaam'];
$Email= $row['A.Emailadres']; $Email= $row['A.Emailadres'];
$Oudername = $row['C.Voorletters'] . " " . $row['C.Achternaam']; $Oudername = $row['C.Voorletters'] . " " . $row['C.Achternaam'];
...@@ -179,8 +179,38 @@ else if ($ID == "IRPS001"){ ...@@ -179,8 +179,38 @@ else if ($ID == "IRPS001"){
$headers = 'From: <WatchDad@irp.nl>'; $headers = 'From: <WatchDad@irp.nl>';
$Msg = "Er zou beweging moeten zijn waargenomen volgens het leefpatroon dit is echter niet gebeurd! $Msg = "Er zou beweging moeten zijn waargenomen volgens het leefpatroon dit is echter niet gebeurd!
Kijk snel op stienos.nl/watchdad/ om te zien om welke activiteit dit gaat."; Kijk snel op stienos.nl/watchdad/ om te zien om welke activiteit dit gaat.";
//Create a notification
$sql = "INSERT INTO Notificatie (`Date`,`Time`,`Title`)
VALUES ('$date','$time','Geen Beweging');";
$result = $conn->query($sql);
if ($result === TRUE) {
$notificatieID = $conn->insert_id;
}
//add thee messaga to berichten in the database
$sql = "INSERT INTO Berichten (`Time`,`Message`,`Subject`,`Date`)
VALUES ('$time','$Msg','Geen beweging','$date');";
$result = $conn->query($sql);
//get the id of inserted message
if ($result === TRUE) {
$berichtID = $conn->insert_id;
}
//loop trough every account so they all get an email
while ($result && ($row = $result->fetch_assoc())){
//send the mail //send the mail
mail($Email,"Camera Alert","Beste $AcName $Msg",$headers); mail($Email,"Camera Alert","Beste $AcName $Msg",$headers);
//couple the message to appropriate accounts
$sql = "INSERT INTO Account_has_Berichten (`Berichten_BerichtID`,`Account_AccountID`,`Status`)
VALUES ('$berichtID','$AccountID',0);";
$conn->query($sql);
//couple notification to appropriate accounts
$sql = "INSERT INTO Account_has_Notificatie (`Notificatie_NotificatieID`,`Account_AccountID`)
VALUES ('$notificatieID','$AccountID');";
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment