<<<<<<< HEAD
A modern web-based ticket management system for post office operations using Node.js and MySQL.
- XAMPP installed with MySQL running
- Node.js (version 14 or higher)
- MySQL database named
postofficeon localhost
You already have the postoffice database in phpMyAdmin. The setup script will create the required tables automatically.
npm installThis will install Node.js packages including mysql2.
npm run setupThis will:
- Connect to your XAMPP MySQL database
- Create required tables (users, services with main/sub categories, tickets, auditLog)
- Insert sample data (6 main concerns each with 2 sub‑categories)
npm startThe server will run on http://localhost:8000
The system uses XAMPP's default MySQL credentials:
- Host: localhost
- User: root
- Password: (empty)
- Database: postoffice
To use different credentials, edit the dbConfig in both db-setup.js and server.js:
const dbConfig = {
host: 'localhost',
user: 'root',
password: '',
database: 'postoffice'
};- Navigate to
http://localhost/phpmyadmin - Select the
postofficedatabase - View and manage tables: services, tickets, users, auditLog
The Node.js server exposes endpoints at http://localhost:8000/api/...
PostOffice/
├── server.js # Node.js HTTP server with MySQL API endpoints
├── db-setup.js # Database initialization script
├── package.json # Node.js dependencies
├── README.md # This file
├── ui/
│ ├── dashboard.html # Main dashboard page
│ ├── dashboard.js # Dashboard logic (API-driven)
│ ├── dashboard.css # Dashboard styles
│ ├── index.html # Login/homepage
│ ├── homepage.js # Homepage logic
│ └── homepage.css # Homepage styles
All endpoints base URL: http://localhost:8000
GET /api/tickets- Get all ticketsPOST /api/tickets- Create a new ticketPUT /api/tickets/:id- Update ticket statusDELETE /api/tickets/:id- Delete a ticket
GET /api/services- Get all main/sub category pairsPOST /api/services- Create a new category (requiresmainCategoryandsubCategoryin JSON body)
The UI for creating a ticket will always ask for an email address and no longer auto‑prefills the address of the currently logged in user.
GET /api/stats- Get dashboard statistics (total, pending, completed, in-progress)- [NEW]
POST /api/staff- create or fetch staff record by supplying{ userId }(returnsstaffId) - [NEW]
GET /api/joborders- list job orders (optionally filter with?staffId=) - [NEW]
POST /api/joborders- create a job order{ staffId, ticketId?, description?, status? } - [NEW]
PUT /api/joborders/:id- update job order fields (status/description/ticketId)
Database changes:
- added
stafftable linking back tousers - added
joborderstable for storing work performed by staff (statusaccepted/done)
UI additions:
- new staff portal at
/ui/staff.htmlwith corresponding CSS/JS. Staff logging in are redirected here and can accept/complete jobs; their activity is tracked in thejoborderstable for admin statistics.
GET /api/audit- Get audit trail entries (last 100)POST /api/audit- Log an audit event
Note: The
auditLogtable now includes anipAddresscolumn. Server endpoints automatically record the client IP for operations that mutate data, including:
- Ticket creation, updates, deletion
- Service category or sub-category creation/deletion
- Branch and department creation/deletion
- Notification creation and approval/rejection
- Job order creation and modifications
- Any manual
POST /api/auditrequests from the clientAdditional events can be logged by calling the
/api/auditendpoint. TheipAddressis captured from the incoming request, giving administrators visibility into where each action originated.
POST /api/login- User loginPOST /api/forgot-password- Request password reset email
id INT PRIMARY KEY AUTO_INCREMENT
name VARCHAR(255) NOT NULL
description TEXT
createdAt TIMESTAMPid INT PRIMARY KEY AUTO_INCREMENT
ticketId VARCHAR(255) UNIQUE
customerName VARCHAR(255)
serviceName VARCHAR(255)
status VARCHAR(50) (Pending, In Progress, Completed)
description TEXT
createdAt TIMESTAMP
updatedAt TIMESTAMPid INT PRIMARY KEY AUTO_INCREMENT
email VARCHAR(255) UNIQUE
password VARCHAR(255)
displayName VARCHAR(255)
role VARCHAR(50)
createdAt TIMESTAMPid INT PRIMARY KEY AUTO_INCREMENT
userEmail VARCHAR(255)
action VARCHAR(255)
entityType VARCHAR(50)
entityId VARCHAR(255)
details JSON
timestamp TIMESTAMP- ✅ Dashboard: Real-time statistics and recent ticket overview
- ✅ Ticket Management: Create, view, update, and delete tickets
- ✅ Services: Manage available post office services
- ✅ Audit Trail: Track all system actions and changes
- ✅ Settings: User preferences and theme customization
- ✅ Responsive Design: Works on desktop and mobile devices
- ✅ MySQL Integration: Persistent data storage via XAMPP
- Ensure XAMPP MySQL is running (check Services or XAMPP Control Panel)
- Verify database name is
postoffice
- Run
npm run setupto create tables and sample data
- Change PORT in server.js or kill the process using port 8000
- User authentication with password hashing
- Edit and delete service functionality
- Advanced reporting and analytics
- Email notifications
- Multi-language support
- Role-based access control (RBAC)
- Database backups
PhlPost Ticketing System
af8e24ad841acb8f17e99bfe2ad86976ac64bed0