Commit 49c1a356 authored by KYC's avatar KYC

StartTijd - Eindtijd check

parent a97ba38d
......@@ -39,6 +39,7 @@ function checkSet($inputFieldsCount, $inputFields) {
}
if(empty($_POST['getActivityID']) == FALSE){
if (checkSet($inputFieldsCount, $inputFields) != FALSE) {
$activityID = $_POST['getActivityID'];
if (empty($_POST['activiteit']) == FALSE && sanityCheck($_POST['activiteit'], 'string', 80) != FALSE) {
......@@ -88,9 +89,9 @@ if(empty($_POST['getActivityID']) == FALSE){
echo '<p ' . $redTextError . '>Uw opmerking bevat ' . strlen($_POST['opmerking']) .' karakters</p>';
echo '<p ' . $redTextError . '>Het maximaal aantal karakters is 80.</p>';
}
// check if it has 1 or more errors, if so run exit()
if ($errors >= 1) {
$errors = 0;
exit();
}
......@@ -124,6 +125,10 @@ if(empty($_POST['getActivityID']) == FALSE){
}
mysqli_close($conn);
} else {
// Default message if the form is POSTed without a single value
echo '<p ' . $redTextError . '>Vul alstublieft alle velden in</p>';
}
}
else{
// checks if all inputFields variables are not empty
......@@ -168,7 +173,7 @@ if (checkSet($inputFieldsCount, $inputFields) != FALSE) {
}
// check the POST variable Comment is correct
if (sanityCheck($_POST['opmerking'], 'string', 80) != FALSE) {
if (strlen($_POST['opmerking']) < 80) {
$comment = $_POST['opmerking'];
} else {
......@@ -177,8 +182,23 @@ if (checkSet($inputFieldsCount, $inputFields) != FALSE) {
echo '<p ' . $redTextError . '>Het maximaal aantal karakters is 80.</p>';
}
$selectQuery = "SELECT StartTime, EndTime, Activity, Day FROM Leefpatroon WHERE OuderID = '$OuderID'";
$result = $conn->query($selectQuery);
while ($row = $result->fetch_assoc()) {
// if StartTime is the same as another activity's one on the same day, exit
if ($startTime == $row["StartTime"] && $day == $row["Day"]) {
$errors++;
echo '<p ' . $redTextError . '>Er is al een activiteit geregistreerd op dezelfde Begintijd voor (' . $row["Activity"] . ').</p>';
// if StartTime is during another activity on the same day, exit
} else if ($row["StartTime"] < $startTime && $row["EndTime"] > $startTime && $day == $row["Day"]) {
$errors++;
echo '<p ' . $redTextError . '>Een andere activiteit is al geregistreerd om gemonitord te worden tijdens uw opgegeven Begintijd (' . $row["Activity"] . ').</p>';
}
}
// check if it has 1 or more errors, if so run exit()
if ($errors >= 1) {
$errors = 0;
exit();
}
......
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