feat: refine email routing logic, fix timezone + FK bugs, update DB schema & add full user dashboard

This commit is contained in:
2026-01-01 03:44:22 +05:30
Unverified
parent c28917ef49
commit 0de81cf56e
10 changed files with 115 additions and 92 deletions

View File

@@ -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!**

View File

@@ -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

View File

@@ -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"

View File

@@ -1,3 +1,49 @@
<?php
date_default_timezone_set('Asia/Kolkata');
$conn->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';
}
}
?>
<div class="max-w-6xl mx-auto w-full">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
@@ -5,7 +51,7 @@
<div class="group bg-neutral-800 rounded-lg border border-neutral-700/50 p-4 shadow-sm hover:border-blue-500/30 transition-all duration-300 flex items-center justify-between">
<div>
<h3 class="text-xs font-semibold text-neutral-400 uppercase tracking-wider group-hover:text-blue-400 transition-colors">Total Reports</h3>
<p class="text-2xl font-bold text-white mt-1">128</p>
<p class="text-2xl font-bold text-white mt-1"><?= $totalReports ?></p>
<p class="text-[10px] text-neutral-500 mt-1">All submissions overview</p>
</div>
<div class="p-3 bg-blue-500/10 rounded-lg group-hover:bg-blue-500/20 transition-colors">
@@ -17,8 +63,8 @@
<div class="group bg-neutral-800 rounded-lg border border-neutral-700/50 p-4 shadow-sm hover:border-yellow-500/30 transition-all duration-300 flex items-center justify-between">
<div>
<h3 class="text-xs font-semibold text-neutral-400 uppercase tracking-wider group-hover:text-yellow-400 transition-colors">Active Issues</h3>
<p class="text-2xl font-bold text-white mt-1">42</p>
<h3 class="text-xs font-semibold text-neutral-400 uppercase tracking-wider group-hover:text-yellow-400 transition-colors">Reports In Progress</h3>
<p class="text-2xl font-bold text-white mt-1"><?= $activeReports ?></p>
<p class="text-[10px] text-neutral-500 mt-1">In progress / Open</p>
</div>
<div class="p-3 bg-yellow-500/10 rounded-lg group-hover:bg-yellow-500/20 transition-colors">
@@ -30,8 +76,8 @@
<div class="group bg-neutral-800 rounded-lg border border-neutral-700/50 p-4 shadow-sm hover:border-green-500/30 transition-all duration-300 flex items-center justify-between">
<div>
<h3 class="text-xs font-semibold text-neutral-400 uppercase tracking-wider group-hover:text-green-400 transition-colors">Resolved</h3>
<p class="text-2xl font-bold text-white mt-1">86</p>
<h3 class="text-xs font-semibold text-neutral-400 uppercase tracking-wider group-hover:text-green-400 transition-colors">Resolved Reports</h3>
<p class="text-2xl font-bold text-white mt-1"><?= $resolvedReports ?></p>
<p class="text-[10px] text-neutral-500 mt-1">Successfully closed</p>
</div>
<div class="p-3 bg-green-500/10 rounded-lg group-hover:bg-green-500/20 transition-colors">
@@ -44,52 +90,55 @@
<div class="bg-neutral-800 rounded-lg border border-neutral-700 overflow-hidden shadow-sm">
<div class="px-4 py-3 border-b border-neutral-700 flex items-center justify-between bg-neutral-900/30">
<h3 class="text-sm font-semibold text-white">Recent Activity</h3>
<button class="text-xs text-blue-400 hover:text-blue-300 font-medium transition-colors">View All</button>
<div class="flex items-center gap-2">
<h3 class="text-sm font-semibold text-white">Recents on reports:</h3>
</div>
</div>
<div class="divide-y divide-neutral-700/50">
<div class="px-4 py-3 hover:bg-neutral-700/30 transition-colors flex items-center gap-3">
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center">
<svg class="w-4 h-4 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
</div>
<div class="flex-1 min-w-0 grid gap-0.5">
<div class="flex items-center justify-between">
<p class="text-sm font-medium text-neutral-200 truncate">
Issue <span class="text-white hover:underline cursor-pointer">#1231</span> Resolved
</p>
<span class="text-[10px] text-neutral-500 whitespace-nowrap">2h ago</span>
</div>
<p class="text-xs text-neutral-500 truncate">Water leakage in park <span>23/v/kpc-cst/33</span></p>
</div>
</div>
<?php if (count($recentActivity) > 0): ?>
<?php foreach ($recentActivity as $row): ?>
<?php
$statusColor = 'blue';
$iconPath = 'M12 4v16m8-8H4';
if ($row['status'] === 'Resolved') {
$statusColor = 'green';
$iconPath = 'M5 13l4 4L19 7';
} elseif ($row['status'] === 'In Progress') {
$statusColor = 'yellow';
$iconPath = 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z';
}
?>
<div class="px-4 py-3 hover:bg-neutral-700/30 transition-colors flex items-center gap-3">
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-blue-500/10 border border-blue-500/20 flex items-center justify-center">
<svg class="w-4 h-4 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
</div>
<div class="flex-1 min-w-0 grid gap-0.5">
<div class="flex items-center justify-between">
<p class="text-sm font-medium text-neutral-200 truncate">Issue 1234 submitted</p>
<span class="text-[10px] text-neutral-500 whitespace-nowrap">5h ago</span>
<div class="px-4 py-3 hover:bg-neutral-700/30 transition-colors flex items-center gap-3">
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-<?= $statusColor ?>-500/10 border border-<?= $statusColor ?>-500/20 flex items-center justify-center">
<svg class="w-4 h-4 text-<?= $statusColor ?>-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="<?= $iconPath ?>"/>
</svg>
</div>
<div class="flex-1 min-w-0 grid gap-0.5">
<div class="flex items-center justify-between">
<p class="text-sm font-medium text-neutral-200 truncate">
Issue <span class="text-white">#<?= $row['id'] ?></span> <?= htmlspecialchars($row['status']) ?>
</p>
<span class="text-[10px] text-neutral-400 whitespace-nowrap">
<?= time_elapsed_string($row['updated_at']) ?>
</span>
</div>
<p class="text-xs text-neutral-400 truncate">
<?= htmlspecialchars($row['title']) ?> • <span><?= htmlspecialchars($row['username']) ?></span>
</p>
</div>
</div>
<p class="text-xs text-neutral-500 truncate">Pothole on Main Street <span>23/v/kpc-cst/36</span></p>
<?php endforeach; ?>
<?php else: ?>
<div class="px-4 py-6 text-center text-sm text-neutral-500">
No recent activity found.
</div>
</div>
<div class="px-4 py-3 hover:bg-neutral-700/30 transition-colors flex items-center gap-3">
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-yellow-500/10 border border-yellow-500/20 flex items-center justify-center">
<svg class="w-4 h-4 text-yellow-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
</div>
<div class="flex-1 min-w-0 grid gap-0.5">
<div class="flex items-center justify-between">
<p class="text-sm font-medium text-neutral-200 truncate">Status: In Progress</p>
<span class="text-[10px] text-neutral-500 whitespace-nowrap">1d ago</span>
</div>
<p class="text-xs text-neutral-500 truncate">Broken Street Light <span>23/v/kpc-cst/37</span></p>
</div>
</div>
<?php endif; ?>
</div>
</div>

View File

@@ -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);
?>
<button type="button" onclick="setStatusAndSubmit('')"
class="<?php echo getBtnClass($current_status === ''); ?>">All Reports</button>
<button type="button" onclick="setStatusAndSubmit('Open')"
class="<?php echo getBtnClass($current_status === 'Open'); ?>">Open</button>
<button type="button" onclick="setStatusAndSubmit('Opened')"
class="<?php echo getBtnClass($current_status === 'Opened'); ?>">Opened</button>
<button type="button" onclick="setStatusAndSubmit('In Progress')"
class="<?php echo getBtnClass($current_status === 'In Progress'); ?>">In Progress</button>
<button type="button" onclick="setStatusAndSubmit('Resolved')"

View File

@@ -4,7 +4,7 @@ use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require dirname(__DIR__, 2) . '/vendor/autoload.php';
define('HELPDESK_EMAIL', $_ENV['IT_HELPDESK_EMAIL'] ?? '');
define('IT_HELPDESK_EMAIL', $_ENV['IT_HELPDESK_EMAIL'] ?? '');
define('MANAGEMENT_EMAIL', $_ENV['MANAGEMENT_EMAIL'] ?? '');
define('HEALTH_EMAIL', $_ENV['HEALTH_EMAIL'] ?? '');
define('LIBRARY_EMAIL', $_ENV['LIBRARY_EMAIL'] ?? '');
@@ -26,14 +26,14 @@ function getDepartmentEmail($category)
return SECURITY_EMAIL;
case 'WiFi & Network Issue':
return HELPDESK_EMAIL;
return IT_HELPDESK_EMAIL;
case 'Library & Study Issue':
return LIBRARY_EMAIL;
case 'Other Issue':
default:
return HELPDESK_EMAIL;
return IT_HELPDESK_EMAIL;
}
}
@@ -69,25 +69,6 @@ function sendReportNotifications($report_id, $title, $category, $priority, $loca
$dept_email = getDepartmentEmail($category);
$dept_name = 'IT Helpdesk';
switch ($category) {
case 'Electrical Issue':
case 'Water & Plumbing Issue':
case 'HVAC (AC/Heating) Issue':
case 'Furniture & Fixtures Issue':
case 'Road & Pathway Damage Issue':
case 'Cleaning & Janitorial Issue':
$dept_name = 'Estate Management';
break;
case 'Security & Safety Issue':
case 'Lost & Stolen Issue':
$dept_name = 'Security';
break;
case 'Library & Study Issue':
$dept_name = 'Library';
break;
}
$domain = $_ENV['DOMAIN'] ?? $_SERVER['HTTP_HOST'];
$appname = $_ENV['APP_NAME'];
@@ -139,7 +120,7 @@ function sendReportNotifications($report_id, $title, $category, $priority, $loca
<tr>
<td style="padding:18px 16px 8px 16px;background:#ffffff;font-family:'Lexend Deca', -apple-system;">
<p style="font-size:16px;line-height:22px;color:#475569;margin:0 0 16px 0;font-family:'Lexend Deca', -apple-system;">
Hi <strong style="color:#0f172a;">{$dept_name}</strong> Team,
Hi <strong style="color:#0f172a;">{$appname}</strong> Team,
</p>
<p style="font-size:16px;line-height:22px;color:#475569;margin:0 0 16px 0;font-family:'Lexend Deca', -apple-system;">
<strong style="color:#0f172a;">{$appname}</strong> has received a report submission and the auto-email had sent a "<strong style="color:#0f172a;">Your Report Form Submission Received</strong>" template to the reporter.

View File

@@ -91,7 +91,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
$sql = "INSERT INTO reports (user_id, title, category, priority, location, map_link, image_path, status)
VALUES (?, ?, ?, ?, ?, ?, ?, 'Open')";
VALUES (?, ?, ?, ?, ?, ?, ?, 'Opened')";
$stmt = $conn->prepare($sql);
if ($stmt) {

View File

@@ -4,6 +4,9 @@ include './core/init.php';
include './core/connection.php';
include './core/router.php';
$conn->query("SET time_zone = '+05:30'");
date_default_timezone_set('Asia/Kolkata');
// Suppress all PHP errors in production environment
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);

View File

@@ -229,7 +229,7 @@ if (isset($_GET['code'])) {
Need Help? Checkout Github Docs</a>
<span class="w-px h-3 bg-slate-800"></span>
<span
class="text-xs font-bold text-blue-400 bg-blue-500/10 px-2 py-0.5 rounded-full border border-blue-500/20">v1.3.1</span>
class="text-xs font-bold text-blue-400 bg-blue-500/10 px-2 py-0.5 rounded-full border border-blue-500/20">v1.3.2</span>
</div>
<div class="flex items-center gap-2">

View File

@@ -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);