From 0de81cf56e08645b4580ee1d306099685e57a526 Mon Sep 17 00:00:00 2001 From: xodivorce Date: Thu, 1 Jan 2026 03:44:22 +0530 Subject: [PATCH] feat: refine email routing logic, fix timezone + FK bugs, update DB schema & add full user dashboard --- README.md | 2 +- ...a-xodivorce.sql => infra-xodivorce-in.sql} | 12 +- src/.env.example | 4 +- src/assets/users/_overview.php | 137 ++++++++++++------ src/assets/users/_reports.php | 8 +- src/core/actions/mail/report_config.php | 27 +--- src/core/actions/submit_report.php | 2 +- src/pages/dashboard.php | 3 + src/pages/token/google_oauth_token.php | 2 +- src/src/output.css | 10 -- 10 files changed, 115 insertions(+), 92 deletions(-) rename schema/{infra-xodivorce.sql => infra-xodivorce-in.sql} (99%) diff --git a/README.md b/README.md index f3bcdc85..a99267d7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ #### A real-time map-based reporting system for campus infrastructure issues, built to improve visibility, accountability, and resolution efficiency. [![status](https://img.shields.io/badge/status-active-brightgreen.svg?style=flat)](https://github.com/xodivorce/infra-xodivorce-in/) -[![version](https://img.shields.io/badge/version-v1.3.1-yellow.svg?style=flat)](https://github.com/xodivorce/infra-xodivorce-in/) +[![version](https://img.shields.io/badge/version-v1.3.2-yellow.svg?style=flat)](https://github.com/xodivorce/infra-xodivorce-in/) [![PRs](https://img.shields.io/badge/PRs-welcome-blue.svg?style=flat)](https://github.com/xodivorce/infra-xodivorce-in/) > **🥰 Like this project? Please consider giving it a Star (🌟) on GitHub to show us your appreciation. Thank you!** diff --git a/schema/infra-xodivorce.sql b/schema/infra-xodivorce-in.sql similarity index 99% rename from schema/infra-xodivorce.sql rename to schema/infra-xodivorce-in.sql index b1dce7ec..8213ab3b 100644 --- a/schema/infra-xodivorce.sql +++ b/schema/infra-xodivorce-in.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Host: localhost --- Generation Time: Dec 30, 2025 at 05:41 PM +-- Generation Time: Dec 31, 2025 at 09:27 PM -- Server version: 10.4.28-MariaDB -- PHP Version: 8.2.4 @@ -18,7 +18,7 @@ SET time_zone = "+00:00"; /*!40101 SET NAMES utf8mb4 */; -- --- Database: `infra-xodivorce` +-- Database: `infra-xodivorce-in` -- -- -------------------------------------------------------- @@ -142,7 +142,7 @@ CREATE TABLE `reports` ( `title` varchar(255) NOT NULL, `category` varchar(100) NOT NULL, `priority` enum('Low','Medium','High') NOT NULL DEFAULT 'Low', - `status` enum('Open','In Progress','Resolved') NOT NULL DEFAULT 'Open', + `status` enum('Opened','In Progress','Resolved') NOT NULL DEFAULT 'Opened', `location` varchar(255) NOT NULL, `image_path` varchar(255) DEFAULT NULL, `map_link` text DEFAULT NULL, @@ -3382,13 +3382,13 @@ ALTER TABLE `languages` -- AUTO_INCREMENT for table `password_resets` -- ALTER TABLE `password_resets` - MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=88; + MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89; -- -- AUTO_INCREMENT for table `reports` -- ALTER TABLE `reports` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22; -- -- AUTO_INCREMENT for table `translations` @@ -3400,7 +3400,7 @@ ALTER TABLE `translations` -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=71; -- -- Constraints for dumped tables diff --git a/src/.env.example b/src/.env.example index 1276993d..faa2a5d3 100644 --- a/src/.env.example +++ b/src/.env.example @@ -23,8 +23,8 @@ GOOGLE_REFRESH_TOKEN= "Your Google Refresh Token Here" GOOGLE_DRIVE_FOLDER_ID= "Your Google Drive Folder ID Here" # Contact Information of various departments -HELPDESK_EMAIL= "Your Helpdesk Email Here" -HELPDESK_PHONE= "Your Helpdesk Phone Here" +IT_HELPDESK_EMAIL= "Your Helpdesk Email Here" +IT_HELPDESK_PHONE= "Your Helpdesk Phone Here" MANAGEMENT_EMAIL= "Your Management Email Here" MANAGEMENT_PHONE= "Your Management Phone Here" HEALTH_EMAIL= "Your Health Email Here" diff --git a/src/assets/users/_overview.php b/src/assets/users/_overview.php index 23531bfc..7a0e11ea 100755 --- a/src/assets/users/_overview.php +++ b/src/assets/users/_overview.php @@ -1,3 +1,49 @@ +query("SET time_zone = '+05:30'"); + +$totalResult = $conn->query("SELECT COUNT(*) FROM reports"); +$totalReports = $totalResult->fetch_row()[0]; + +$activeResult = $conn->query("SELECT COUNT(*) FROM reports WHERE status IN ('Opened', 'In Progress')"); +$activeReports = $activeResult->fetch_row()[0]; + +$resolvedResult = $conn->query("SELECT COUNT(*) FROM reports WHERE status = 'Resolved'"); +$resolvedReports = $resolvedResult->fetch_row()[0]; + +$recentSql = "SELECT r.*, u.username + FROM reports r + JOIN users u ON r.user_id = u.id + ORDER BY r.updated_at DESC + LIMIT 5"; + +$recentResult = $conn->query($recentSql); +$recentActivity = $recentResult->fetch_all(MYSQLI_ASSOC); + +if (!function_exists('time_elapsed_string')) { + function time_elapsed_string($datetime, $full = false) { + $now = new DateTime; + $ago = new DateTime($datetime); + $diff = $now->diff($ago); + + $diff->w = floor($diff->d / 7); + $diff->d -= $diff->w * 7; + + $string = array('y' => 'yr', 'm' => 'mo', 'w' => 'wk', 'd' => 'd', 'h' => 'h', 'i' => 'min', 's' => 'sec'); + foreach ($string as $k => &$v) { + if ($diff->$k) { + $v = $diff->$k . '' . $v; + } else { + unset($string[$k]); + } + } + + if (!$full) $string = array_slice($string, 0, 1); + return $string ? implode(', ', $string) . ' ago' : 'just now'; + } +} +?> +
@@ -5,7 +51,7 @@

Total Reports

-

128

+

All submissions overview

@@ -17,8 +63,8 @@
-

Active Issues

-

42

+

Reports In Progress

+

In progress / Open

@@ -30,8 +76,8 @@
-

Resolved

-

86

+

Resolved Reports

+

Successfully closed

@@ -44,52 +90,55 @@
-

Recent Activity

- +
+

Recents on reports:

+
-
-
- -
-
-
-

- Issue #1231 Resolved -

- 2h ago -
-

Water leakage in park • 23/v/kpc-cst/33

-
-
+ 0): ?> + + -
-
- -
-
-
-

Issue 1234 submitted

- 5h ago +
+
+ + + +
+ +
+
+

+ Issue # +

+ + + +
+

+ • +

+
-

Pothole on Main Street • 23/v/kpc-cst/36

+ + +
+ No recent activity found.
-
- -
-
- -
-
-
-

Status: In Progress

- 1d ago -
-

Broken Street Light • 23/v/kpc-cst/37

-
-
+
diff --git a/src/assets/users/_reports.php b/src/assets/users/_reports.php index 94a0f5fa..defd8c3d 100755 --- a/src/assets/users/_reports.php +++ b/src/assets/users/_reports.php @@ -25,7 +25,7 @@ if (count($whereClauses) > 0) { $whereSql = "WHERE " . implode(' AND ', $whereClauses); } -$limit = 6; +$limit = 4; $page = isset($_GET['p']) ? max(1, intval($_GET['p'])) : 1; $offset = ($page - 1) * $limit; @@ -34,7 +34,7 @@ $count_result = $conn->query($count_sql); $total_rows = $count_result->fetch_assoc()['total']; $total_pages = ceil($total_rows / $limit); -$sql = "SELECT r.*, u.username FROM reports r LEFT JOIN users u ON r.user_id = u.id $whereSql ORDER BY r.created_at DESC LIMIT $limit OFFSET $offset"; +$sql = "SELECT r.*, u.username FROM reports r LEFT JOIN users u ON r.user_id = u.id $whereSql ORDER BY r.id DESC LIMIT $limit OFFSET $offset"; $result = $conn->query($sql); ?> @@ -91,8 +91,8 @@ $result = $conn->query($sql); ?> - +
diff --git a/src/src/output.css b/src/src/output.css index d319f7ad..9cdbc091 100644 --- a/src/src/output.css +++ b/src/src/output.css @@ -47,11 +47,8 @@ --color-purple-600: oklch(55.8% 0.288 302.321); --color-purple-900: oklch(38.1% 0.176 304.987); --color-slate-200: oklch(92.9% 0.013 255.508); - --color-slate-300: oklch(86.9% 0.022 252.894); --color-slate-400: oklch(70.4% 0.04 256.788); --color-slate-500: oklch(55.4% 0.046 257.417); - --color-slate-600: oklch(44.6% 0.043 257.281); - --color-slate-700: oklch(37.2% 0.044 257.287); --color-slate-800: oklch(27.9% 0.041 260.031); --color-gray-100: oklch(96.7% 0.003 264.542); --color-gray-200: oklch(92.8% 0.006 264.531); @@ -59,7 +56,6 @@ --color-gray-500: oklch(55.1% 0.027 264.364); --color-gray-600: oklch(44.6% 0.03 256.802); --color-gray-800: oklch(27.8% 0.033 256.848); - --color-gray-900: oklch(21% 0.034 264.665); --color-neutral-200: oklch(92.2% 0 0); --color-neutral-300: oklch(87% 0 0); --color-neutral-400: oklch(70.8% 0 0); @@ -68,13 +64,11 @@ --color-neutral-700: oklch(37.1% 0 0); --color-neutral-800: oklch(26.9% 0 0); --color-neutral-900: oklch(20.5% 0 0); - --color-neutral-950: oklch(14.5% 0 0); --color-black: #000; --color-white: #fff; --spacing: 0.25rem; --container-xl: 36rem; --container-2xl: 42rem; - --container-3xl: 48rem; --container-4xl: 56rem; --container-5xl: 64rem; --container-6xl: 72rem; @@ -103,7 +97,6 @@ --font-weight-medium: 500; --font-weight-semibold: 600; --font-weight-bold: 700; - --tracking-tighter: -0.05em; --tracking-tight: -0.025em; --tracking-wide: 0.025em; --tracking-wider: 0.05em; @@ -740,9 +733,6 @@ .grow { flex-grow: 1; } - .border-collapse { - border-collapse: collapse; - } .-translate-y-full { --tw-translate-y: -100%; translate: var(--tw-translate-x) var(--tw-translate-y);