From 994884d3c96929f797a03bf881c6dbd6be8e58c2 Mon Sep 17 00:00:00 2001 From: kapsona777 Date: Sun, 27 Oct 2024 13:24:35 +0400 Subject: [PATCH 1/3] fixed bugs --- public/userarea/apilogic/process_import.php | 27 ++++++++++++------- .../userarea/importify/interventionlist.php | 14 +++++++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/public/userarea/apilogic/process_import.php b/public/userarea/apilogic/process_import.php index 5096e46..4269799 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); @@ -180,17 +183,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 diff --git a/public/userarea/importify/interventionlist.php b/public/userarea/importify/interventionlist.php index f2ba4d2..775b8fe 100644 --- a/public/userarea/importify/interventionlist.php +++ b/public/userarea/importify/interventionlist.php @@ -131,6 +131,14 @@ + +
+ +
+ + + + + + + + + \ 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