diff --git a/public/userarea/apilogic/process_import.php b/public/userarea/apilogic/process_import.php index 5096e46..03c6c0f 100644 --- a/public/userarea/apilogic/process_import.php +++ b/public/userarea/apilogic/process_import.php @@ -13,19 +13,22 @@ try { } catch (PDOException $e) { die("Connection failed: " . $e->getMessage()); } - -$method = $_POST['method']; -if ($method == 'intervention') { - $query = "SELECT * FROM temp_json_queue WHERE processed = 2"; - $stmt = $pdo->prepare($query); - $stmt->execute(); - $jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC); -} else { +// method validation +if (!isset($_POST['method'])) { $query = "SELECT * FROM temp_json_queue WHERE processed = 0"; $stmt = $pdo->prepare($query); $stmt->execute(); $jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC); } +else { + $method = $_POST['method']; + if($method == 'intervention'){ + $query = "SELECT * FROM temp_json_queue WHERE processed = 2"; + $stmt = $pdo->prepare($query); + $stmt->execute(); + $jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC); + } +} foreach ($jsonEntries as $entry) { $data = json_decode($entry['json_data'], true); @@ -132,6 +135,11 @@ foreach ($jsonEntries as $entry) { $result_TestName = $analysis['result_TestName']; $analysisgroupcode = $analysis['analysisgroupcode']; + // groupcode validation + if ($analysisgroupcode == '-' || $analysisgroupcode == '' || $analysisgroupcode == ' ') { + $analysisgroupcode = 'NO_GROUPCODE'; + } + $query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$analysisgroupcode'"; $stmt = $pdo->prepare($query); $res = $stmt->execute(); @@ -156,6 +164,11 @@ foreach ($jsonEntries as $entry) { $result_AnalytsName = $result['result_AnalytsName']; $cas = $result['cas']; + // cas validation + if ($cas == '-' || $cas == '' || $cas == ' ') { + $cas = 'NO_CAS'; + } + $query = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE cascompoundvocabulary LIKE '%$cas%'"; $stmt = $pdo->prepare($query); $res = $stmt->execute(); @@ -180,17 +193,21 @@ foreach ($jsonEntries as $entry) { } markAsProcessed($entry['id'], $pdo); + importHistory($pdo, $uuid); + die(json_encode(['code' => 'success'])); } else { markForIntervention($entry['id'], $pdo); + importHistory($pdo, $uuid); + die(json_encode(['code' => 'success', 'message' => 'Intervention'])); } } else { markForIntervention($entry['id'], $pdo); + importHistory($pdo, $uuid); + die(json_encode(['code' => 'success', 'message' => 'Intervention'])); } - importHistory($pdo, $uuid); } -die(json_encode(['code' => 'success'])); // Function definitions @@ -398,4 +415,6 @@ function markForIntervention($id, $pdo) $query = "UPDATE temp_json_queue SET processed = 2 WHERE id = :id"; $stmt = $pdo->prepare($query); $stmt->execute(['id' => $id]); + + $query = "INSERT INTO notifications (`title`,`description`) VALUES ('Intervention Required', 'Intervention required for JSON entry with ID $id')"; } diff --git a/public/userarea/importify/interventionlist.php b/public/userarea/importify/interventionlist.php index f2ba4d2..f7fc458 100644 --- a/public/userarea/importify/interventionlist.php +++ b/public/userarea/importify/interventionlist.php @@ -130,7 +130,16 @@ - + +
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/public/userarea/notifications/notifications.php b/public/userarea/notifications/notifications.php new file mode 100644 index 0000000..62d8ea5 --- /dev/null +++ b/public/userarea/notifications/notifications.php @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + +
+
+
+
+
+

Notifications

+
+
+
+ +
+
+
+
+
Records
+
+ + + + + + + + + + + connect_error) { + die("Connection failed: " . $conn->connect_error); + } + + // Query for rows with processed = 2 + $sql = "SELECT * FROM notifications"; + $result = $conn->query($sql); + + $all_notifications = []; + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $all_notifications[] = $row; + } + } + + $user_id = $_SESSION['iduserlogin']; + $all_notification_ids = array_column($all_notifications, 'id'); + $all_notification_ids_str = implode(',', $all_notification_ids); + + $sql = "SELECT notification_id + FROM seen_notifications + WHERE notification_id IN ($all_notification_ids_str) + AND user_id = $user_id"; + $result = $conn->query($sql); + $seen_notification_ids = []; + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $seen_notification_ids[] = $row['notification_id']; + } + } + + $seen_notifications = []; + foreach($all_notifications as $notification){ + if(in_array($notification['id'], $seen_notification_ids)){ + $seen_notifications[] = $notification; + } + } + + $unseen_notifications = array_udiff($all_notifications, $seen_notifications, function ($a, $b) { + return $a['id'] <=> $b['id']; + }); + + + // unseen notifications with mark as seen button and different color , seen without that + if(!empty($all_notifications)){ + foreach($all_notifications as $notification){ + if(in_array($notification, $unseen_notifications)){ + echo ""; + }else{ + echo ""; + } + echo ""; + echo ""; + echo ""; + if(in_array($notification, $unseen_notifications)){ + echo ""; + }else{ + echo ""; + } + echo ""; + } + } + + $conn->close(); + ?> + +
IDTitleDescriptionActions
" . $notification['id'] . "" . $notification['title'] . "" . $notification['description'] . " + +
+
+
+
+
+
+ +
+
+
+ + +
+
+ + + + + + + + + \ No newline at end of file