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

error fixing

parent cfbd6ae3
......@@ -32,100 +32,100 @@ if ($ID == "IRPS001" ){
AND Status = '0';";
$result = $conn->query($sql);
//loop trough every activity
while ($row = $result->fetch_assoc()){
$starttime = $row['StartTime'];
$endtime = $row['EndTime'];
$Activity = $row['Activity'];
$daydate = $row['DayDate'];
//if the movement should be 0 and the status is 0 then it's a success scenario so status is updated to 1 (true/succes)
if ($row['Movement'] == 0){
$sql = "UPDATE Activiteiten
SET Status = '1'
WHERE StartTime = '$starttime'
AND EndTime = '$endtime'
AND Activity = '$Activity'
AND DayDate = '$daydate'
AND OuderID = '$OuderID';";
$conn->query($sql);
}
//if the movement shoudl be 1 but status is 0 there is a fail
if ($row['Movement'] == 1){
$message = "The scheduled activity:
\n Activity: '$Activity'
\n StartTime: '$starttime'
\n EndTime: '$endtime'
\n Did not register today ('$daydate'). We recommend taking action.";
//the notification is added to the database
$sql = "INSERT INTO Notificatie (`Date`,`Time`,`Message`, `Title`)
VALUES ('$daydate','$time','$message','Failed Activity';";
$result = $conn->query($sql);
if ($result === TRUE) {
$last_id = $conn->insert_id;
//see what accounts are connected to this elder.
$sql = "SELECT Account_AccountID FROM Account_has_AlleenstaandeOuder WHERE AlleenstaandeOuder_OuderID='$OuderID'";
while ($result && ($row = $result->fetch_assoc())){
$starttime = $row['StartTime'];
$endtime = $row['EndTime'];
$Activity = $row['Activity'];
$daydate = $row['DayDate'];
//if the movement should be 0 and the status is 0 then it's a success scenario so status is updated to 1 (true/succes)
if ($row['Movement'] == 0){
$sql = "UPDATE Activiteiten
SET Status = '1'
WHERE StartTime = '$starttime'
AND EndTime = '$endtime'
AND Activity = '$Activity'
AND DayDate = '$daydate'
AND OuderID = '$OuderID';";
$conn->query($sql);
}
//if the movement shoudl be 1 but status is 0 there is a fail
if ($row['Movement'] == 1){
$message = "The scheduled activity:
\n Activity: '$Activity'
\n StartTime: '$starttime'
\n EndTime: '$endtime'
\n Did not register today ('$daydate'). We recommend taking action.";
//the notification is added to the database
$sql = "INSERT INTO Notificatie (`Date`,`Time`,`Message`, `Title`)
VALUES ('$daydate','$time','$message','Failed Activity';";
$result = $conn->query($sql);
if ($result->num_rows > 0){
while($result && ($row = $result->fetch_assoc()))
{
$AccountID=$row["Account_AccountID"];
if ($result === TRUE) {
$last_id = $conn->insert_id;
//Get the email adres connected to the account
$sql = "SELECT Emailadres FROM Account WHERE AccountID='$AccountID'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$row = $result->fetch_assoc();
//Binding the return value to $Email
$Email=$row["Emailadres"];
} else {
echo "0 results";
}
//Get the Name connected to the account
$sql = "SELECT Voorletters,Achternaam FROM Account WHERE AccountID='$AccountID'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$row = $result->fetch_assoc();
//Binding the return to $AcName
$AcName=$row["Voorletters"] . " " . $row["Achternaam"];
} else {
echo "0 results";
}
//Connect the previous made notification to the appropriat accounts
$sql = "INSERT INTO Account_has_Notificatie (Notificatie_NotificatieID,Account_AccountID,Status)
VALUES ('$last_id','$AccountID',0)";
$result = $conn->query($sql);
//see what accounts are connected to this elder.
$sql = "SELECT Account_AccountID FROM Account_has_AlleenstaandeOuder WHERE AlleenstaandeOuder_OuderID='$OuderID'";
$result = $conn->query($sql);
if ($result->num_rows > 0){
while($result && ($row = $result->fetch_assoc()))
{
$AccountID=$row["Account_AccountID"];
//see how many notifications an account already has.
$sql = "SELECT *
FROM Account_has_Notificatie
WHERE Account_AccountID = $AccountID;";
$result = $conn->query($sql);
//if there are more then 1 notifications this means that multiple activities have failed and thus a email is send.
if ($result->num_rows > 1){
$sql = "INSERT INTO Berichten (Time,Message,Subject,Date)
VALUES ('$time','$message','Second Failed Activity','$date')";
//Get the email adres connected to the account
$sql = "SELECT Emailadres FROM Account WHERE AccountID='$AccountID'";
$result = $conn->query($sql);
if ($result === TRUE) {
$last_id = $conn->insert_id;
if ($result->num_rows > 0) {
// output data of each row
$row = $result->fetch_assoc();
//Binding the return value to $Email
$Email=$row["Emailadres"];
} else {
echo "0 results";
}
//sending the mail, $Email is initialized previously, $Msg is created above & $headers changes the sender information to irp@stienos.nl.
$headers = 'From: <activityalert@irp.nl>';
mail($Email,"Camera Alert","Beste $AcName $message",$headers);
//Get the Name connected to the account
$sql = "SELECT Voorletters,Achternaam FROM Account WHERE AccountID='$AccountID'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$row = $result->fetch_assoc();
//Binding the return to $AcName
$AcName=$row["Voorletters"] . " " . $row["Achternaam"];
} else {
echo "0 results";
}
//Connect the previous made notification to the appropriat accounts
$sql = "INSERT INTO Account_has_Notificatie (Notificatie_NotificatieID,Account_AccountID,Status)
VALUES ('$last_id','$AccountID',0)";
$result = $conn->query($sql);
$sql = "INSERT INTO Account_has_Berichten (Berichten_BerichtID,Account_AccountID,Status)
VALUES ($last_id,$AccountID,0";
$conn-query($sql);
//see how many notifications an account already has.
$sql = "SELECT *
FROM Account_has_Notificatie
WHERE Account_AccountID = $AccountID;";
$result = $conn->query($sql);
//if there are more then 1 notifications this means that multiple activities have failed and thus a email is send.
if ($result->num_rows > 1){
$sql = "INSERT INTO Berichten (Time,Message,Subject,Date)
VALUES ('$time','$message','Second Failed Activity','$date')";
$result = $conn->query($sql);
if ($result === TRUE) {
$last_id = $conn->insert_id;
}
//sending the mail, $Email is initialized previously, $Msg is created above & $headers changes the sender information to irp@stienos.nl.
$headers = 'From: <activityalert@irp.nl>';
mail($Email,"Camera Alert","Beste $AcName $message",$headers);
$sql = "INSERT INTO Account_has_Berichten (Berichten_BerichtID,Account_AccountID,Status)
VALUES ($last_id,$AccountID,0";
$conn-query($sql);
}
}
}
}
}
}
}
}
}
//if the ID is not null it comes from a camera and thus the status for the current event is updated.
......
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