Creating an Office Management System involves several components, including a MySQL database schema, file structure, layout design using Bootstrap 5, and complete PHP scripts for user authentication and management. Below is a comprehensive guide to help you set up your system.

Project Introduction

The Office Management System is designed to enhance the efficiency and productivity of office operations by providing a centralized platform for managing various aspects of office activities. This system allows users to manage documents, tasks, projects, meetings, resources, attendance, expenses, and notifications seamlessly. By utilizing a MySQL database, the system ensures secure storage and easy retrieval of data, making it an essential tool for administrators, managers, and employees in any organization.

Project Objectives

  • To create a user-friendly interface for managing office documents and tasks.
  • To enable efficient project management, including task assignment and tracking.
  • To facilitate scheduling and management of meetings within the organization.
  • To manage office resources effectively, ensuring availability and proper allocation.
  • To track employee attendance and manage leave requests efficiently.
  • To handle expense management, including submission and approval processes.
  • To implement a notification system to keep users informed about important updates and tasks.

Project Modules

  1. User Management: Handles user registration, login, and role-based access control for admins, managers, and employees.
  2. Document Management: Allows users to upload, manage, and track documents associated with various projects and tasks.
  3. Task Management: Enables the creation, assignment, and tracking of tasks related to different projects.
  4. Project Management: Manages project details, including descriptions, timelines, and associated tasks.
  5. Meeting Management: Facilitates scheduling and management of meetings, including notifications for participants.
  6. Resource Management: Tracks office resources, including equipment, rooms, and supplies, ensuring their availability.
  7. Attendance Management: Monitors employee attendance, including status updates for present, absent, or on leave.
  8. Expense Management: Manages employee expenses, including submission, approval, and tracking of expense reports.
  9. Notification System: Sends notifications to users regarding tasks, meetings, and other important updates.

1. MySQL Database Schema


CREATE DATABASE office_management_system;
USE office_management_system;
-- Table for users
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
role ENUM('admin', 'manager', 'employee') DEFAULT 'employee',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Table for documents
CREATE TABLE documents (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
document_name VARCHAR(255) NOT NULL,
file_path VARCHAR(255) NOT NULL,
version INT DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Table for tasks
CREATE TABLE tasks (
id INT AUTO_INCREMENT PRIMARY KEY,
project_id INT NOT NULL,
assigned_to INT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
status ENUM('pending', 'in_progress', 'completed') DEFAULT 'pending',
due_date DATETIME,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (assigned_to) REFERENCES users(id) ON DELETE CASCADE
);
-- Table for projects
CREATE TABLE projects (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Table for meetings
CREATE TABLE meetings (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
scheduled_time DATETIME NOT NULL,
location VARCHAR(255),
created_by INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE
);
-- Table for resources
CREATE TABLE resources (
id INT AUTO_INCREMENT PRIMARY KEY,
resource_name VARCHAR(255) NOT NULL,
resource_type ENUM('equipment', 'room', 'supplies') NOT NULL,
availability BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Table for attendance
CREATE TABLE attendance (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
date DATE NOT NULL,
status ENUM('present', 'absent', 'leave') DEFAULT 'present',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Table for expenses
CREATE TABLE expenses (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
amount DECIMAL(10, 2) NOT NULL,
description TEXT,
date DATE NOT NULL,
status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Table for notifications
CREATE TABLE notifications (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
message TEXT NOT NULL,
is_read BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

2. File and Folder Structure


office_management_system/

├── config/
│ └── db.php

├── public/
│ ├── index.php
│ ├── login.php
│ ├── register.php
│ ├── dashboard.php
│ ├── documents.php
│ ├── tasks.php
│ ├── projects.php
│ ├── meetings.php
│ ├── resources.php
│ ├── attendance.php
│ ├── expenses.php
│ ├── notifications.php
│ └── admin_dashboard.php

├── includes/
│ ├── header.php
│ ├── footer.php
│ └── functions.php

├── assets/
│ ├── css/
│ │ └── styles.css
│ ├── js/
│ │ └── scripts.js
│ └── images/

└── vendor/
└── (Bootstrap and other libraries)

3. Layout Based Design with Bootstrap 5

Header (includes/header.php)


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/styles.css">
<title>Office Management System</title>
</head>
<body>
<div class="container">
<header class="my-4">
<h1>Office Management System</h1>
</header>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">Home</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="documents.php">Documents</a>
</li>
<li class="nav-item">
<a class="nav-link" href="tasks.php">Tasks</a>
</li>
<li class="nav-item">
<a class="nav-link" href="projects.php">Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="meetings.php">Meetings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="resources.php">Resources</a>
</li>
<li class="nav-item">
<a class="nav-link" href="attendance.php">Attendance</a>
</li>
<li class="nav-item">
<a class="nav-link" href="expenses.php">Expenses</a>
</li>
<li class="nav-item">
<a class="nav-link" href="notifications.php">Notifications</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login.php">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="register.php">Register</a>
</li>
</ul>
</div>
</div>
</nav>
<main class="my-4">

Footer (includes/footer.php)


</main>
<footer class="text-center my-4">
<p>© 2023 Office Management System. All rights reserved.</p>
</footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

4. PHP Code for User Authentication

Registration (public/register.php)


<?php
require '../config/db.php';
require '../includes/header.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$stmt = $conn->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $username, $email, $password);
$stmt->execute();
$stmt->close();
header("Location: login.php");
}
?>
<form method="POST" action="">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
<?php require '../includes/footer.php'; ?>

Login (public/login.php)


<?php
session_start();
require '../config/db.php';
require '../includes/header.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['role'] = $user['role'];
header("Location: dashboard.php");
} else {
echo "Invalid credentials.";
}
}
?>
<form method="POST" action="">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
<?php require '../includes/footer.php'; ?>

5. Additional PHP Scripts

Dashboard (public/dashboard.php)


<?php
session_start();
require '../config/db.php';
require '../includes/header.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
$user_id = $_SESSION['user_id'];
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?");
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
?>
<h2>Welcome, <?php echo $user['username']; ?></h2>
<p>Your role: <?php echo ucfirst($user['role']); ?></p>
<?php require '../includes/footer.php'; ?>

Document Management (public/documents.php)


<?php
session_start();
require '../config/db.php';
require '../includes/header.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$document_name = $_POST['document_name'];
$file_path = $_FILES['file']['name'];
$target_dir = "uploads/";
$target_file = $target_dir . basename($file_path);

// Upload file
move_uploaded_file($_FILES['file']['tmp_name'], $target_file);
$stmt = $conn->prepare("INSERT INTO documents (user_id, document_name, file_path) VALUES (?, ?, ?)");
$stmt->bind_param("iss", $_SESSION['user_id'], $document_name, $target_file);
$stmt->execute();
$stmt->close();
header("Location: documents.php");
}
?>
<h2>Manage Documents</h2>
<form method="POST" action="" enctype="multipart/form-data">
<div class="mb-3">
<label for="document_name" class="form-label">Document Name</label>
<input type="text" class="form-control" id="document_name" name="document_name" required>
</div>
<div class="mb-3">
<label for="file" class="form-label">Upload File</label>
<input type="file" class="form-control" id="file" name="file" required>
</div>
<button type="submit" class="btn btn-primary">Upload Document</button>
</form>
<h3>Existing Documents</h3>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Document Name</th>
<th>File Path</th>
<th>Uploaded At</th>
</tr>
</thead>
<tbody>
<?php
$stmt = $conn->prepare("SELECT * FROM documents WHERE user_id = ?");
$stmt->bind_param("i", $_SESSION['user_id']);
$stmt->execute();
$result = $stmt->get_result();
while ($doc = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $doc['id']; ?></td>
<td><?php echo $doc['document_name']; ?></td>
<td><a href="<?php echo $doc['file_path']; ?>" target="_blank">View</a></td>
<td><?php echo $doc['created_at']; ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php require '../includes/footer.php'; ?>

Task Management (public/tasks.php)


<?php
session_start();
require '../config/db.php';
require '../includes/header.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$project_id = $_POST['project_id'];
$assigned_to = $_POST['assigned_to'];
$title = $_POST['title'];
$description = $_POST['description'];
$due_date = $_POST['due_date'];
$stmt = $conn->prepare("INSERT INTO tasks (project_id, assigned_to, title, description, due_date) VALUES (?, ?, ?, ?, ?)");
$stmt->bind_param("iisss", $project_id, $assigned_to, $title, $description, $due_date);
$stmt->execute();
$stmt->close();
header("Location: tasks.php");
}
// Fetch users for assignment
$stmt = $conn->prepare("SELECT * FROM users WHERE role = 'employee'");
$stmt->execute();
$result = $stmt->get_result();
$employees = $result->fetch_all(MYSQLI_ASSOC);
// Fetch projects for the form
$stmt = $conn->prepare("SELECT * FROM projects");
$stmt->execute();
$result = $stmt->get_result();
$projects = $result->fetch_all(MYSQLI_ASSOC);
?>
<h2>Manage Tasks</h2>
<form method="POST" action="">
<div class="mb-3">
<label for="project_id" class="form-label">Select Project</label>
<select class="form-select" id="project_id" name="project_id" required>
<?php foreach ($projects as $project): ?>
<option value="<?php echo $project['id']; ?>"><?php echo $project['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label for="assigned_to" class="form-label">Assign To</label>
<select class="form-select" id="assigned_to" name="assigned_to" required>
<?php foreach ($employees as $employee): ?>
<option value="<?php echo $employee['id']; ?>"><?php echo $employee['username']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label for="title" class="form-label">Task Title</label>
<input type="text" class="form-control" id="title" name="title" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" required></textarea>
</div>
<div class="mb-3">
<label for="due_date" class="form-label">Due Date</label>
<input type="date" class="form-control" id="due_date" name="due_date" required>
</div>
<button type="submit" class="btn btn-primary">Add Task</button>
</form>
<?php require '../includes/footer.php'; ?>

6. Additional Features to Consider

User Profiles: Allow users to edit their profiles and manage their settings.

Advanced Reporting: Implement more sophisticated reporting features for better insights.

Mobile Responsiveness: Ensure the application is fully responsive for mobile users.

7. Security Measures

Input Validation: Ensure all user inputs are validated to prevent SQL injection and XSS attacks.

Password Security: Use strong hashing algorithms for storing passwords.

Session Security: Implement secure session management practices to protect user sessions.

8. Testing and Deployment

Unit Testing: Conduct unit tests for individual components to ensure they function correctly.

Integration Testing: Test the integration of different modules to ensure they work together seamlessly.

Deployment: Choose a reliable hosting provider and deploy the application, ensuring all configurations are optimized for performance.

9. Documentation

User Documentation: Create a user manual to guide users through the platform's features and functionalities.

Developer Documentation: Document the codebase and architecture for future reference and maintenance.

10. Future Enhancements

AI-Powered Insights: Implement machine learning algorithms to provide insights into employee performance and project management.

Mobile Application: Develop a mobile application for users to access the platform on the go.

Integration with Other Systems: Consider integrating with existing HR or project management systems for a more comprehensive solution.

This structured approach will help you build a comprehensive Office Management System that meets user needs and adapts to future requirements.