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

more magic

parent a3a58d03
......@@ -6,7 +6,7 @@ function GetNotifications( $status = 0 ){
global $conn;
$AccountID = $_SESSION['AccountID'];
$sql = "SELECT B.Message,B.Time
$sql = "SELECT B.Title,B.Time,B.Date
FROM Account_has_Notificatie A
INNER JOIN Notificatie B
ON B.NotificationID = A.Notificatie_NotificatieID
......@@ -19,8 +19,8 @@ function GetNotifications( $status = 0 ){
echo '
<a class="list-group-item" href="#">
<i class="fa fa-bullseye fa-fw"></i>
<strong>' . $row["Message"] . '</strong>
<span class="pull-right text-muted small"><em>' . $row["Time"] . '</em></span>
<strong>' . $row["Title"] . '</strong>
<span class="pull-right text-muted small"><em>' . $row["Time"] . $row['Date'] . '</em></span>
</a>
';
}
......
......@@ -169,18 +169,48 @@ else if ($ID == "IRPS001"){
ON A.AccountID = B.Account_AccountID
WHERE C.OuderID = '$OuderID';";
$result = $conn->query($sql);
$row = $result->fetch_assoc()
$Acname = $row['A.Voorletters'] . " " . $row['A.Achternaam'];
$Email= $row['A.Emailadres'];
$Oudername = $row['C.Voorletters'] . " " . $row['C.Achternaam'];
//set mail features.
$headers = 'From: <WatchDad@irp.nl>';
$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.";
//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())){
$Acname = $row['A.Voorletters'] . " " . $row['A.Achternaam'];
$Email= $row['A.Emailadres'];
$Oudername = $row['C.Voorletters'] . " " . $row['C.Achternaam'];
//set mail features.
$headers = 'From: <WatchDad@irp.nl>';
$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.";
//send the mail
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