StaffSync Documentation
Welcome to the StaffSync documentation! This section covers all provided code files for the staff management and payroll system. Below you'll find explanations, key code snippets, and design details for each component.
admin.js — Admin Login Logic
This script handles the admin login process on the admin portal. It validates the entered username and password against a hardcoded credential and, if valid, redirects to the admin dashboard.
Key Features:
- Grabs credentials from input fields.
- Validates them against a static object.
- Redirects upon success or alerts on failure.
const obj = { username: "[email protected]", password: "123456", };
document.querySelector("#login").addEventListener("click", function(e) {
e.preventDefault();
const username = document.querySelector("#username").value.trim();
const password = document.querySelector("#password").value.trim();
if (username == obj.username) {
if (password == obj.password) {
window.location.href = "/Portals/Admin/AdminDashboard.html";
} else {
alert("Inavlid Password");
}
} else {
alert("Invalid Username");
}
});
Usage:
- Simple, client-side form authentication for demonstration or basic intranet use.
- Alerts give feedback for incorrect username or password.
addnewUser.css — Add New User Form Styling
This stylesheet defines the aesthetic and responsive layout for the "Add New User" page. It leverages variables (from style.css) and provides a clean, modern interface.
Highlights:
- Gradient backgrounds.
- Card-based form with rounded corners and drop shadows.
- Modern input fields and button styles.
- Responsive design for various device widths.
body {
background: linear-gradient(135deg, var(--bg) 0%, #e2e8f0 100%);
min-height: 100vh;
color: var(--text-primary);
line-height: 1.6;
}
.page-container { ... }
.form-container { ... }
input:focus { border-color: var(--primary); ... }
.btn:hover { transform: translateY(-2px); ... }
addUser.html — Add New User Page
This HTML page presents a form for admins to add new users to the system. The page includes:
- Back navigation.
- A form with fields for name, email, password, role, and employee ID.
- Uses
addnewUser.cssfor styling.
Main Structure:
<form id="addUserForm">
<label for="name">Name</label>
<input type="text" id="name" name="name" required>
...
<button type="submit" class="btn">Add User</button>
</form>
Purpose:
- To create new user accounts (admin or staff).
adminDashboard.css — Admin Dashboard Styling
Styles the admin dashboard, providing a sidebar navigation with a modern UI.
Key Classes:
.sidebar: Vertical navigation..main-content: Main dashboard area..stat-card,.table-container: For dashboard statistics and employee tables.- Media queries ensure responsiveness.
Notable Elements:
- Statistic cards with icons.
- Stylish employee table with hover effects.
adminDashboard.html — Admin Dashboard Interface
The admin dashboard presents an overview of staff, key statistics, and navigation.
Sections:
- Sidebar: For navigation (Dashboard, Assign Task, Attendance, Payroll, Add User, Logout).
- Top Header: Search bar and admin profile.
- Stats: Total employees, present today, on leave.
- Employee Table: Shows sample employee data.
HTML Structure Snippet:
<nav class="sidebar-nav">
<a href="#" class="active"><i class="fas fa-th-large"></i> Dashboard</a>
<a href="/Portals/Admin/Asign Task/asignTask.html">...</a>
...
</nav>
<table id="employeeTable">
<thead>...</thead>
<tbody>
<tr>
<td><div class="emp-name">Ali Khan</div>...</td>
...
</tr>
...
</tbody>
</table>
asigntask.css — Assign Task Page Styling
Defines the layout and style for the task assignment interface.
- Gradient backgrounds.
- Card-based sections for task forms.
- Clean input and select styling.
- Responsive design with media queries.
Example Usage:
.page-header { background: linear-gradient(135deg, var(--primary), var(--secondary)); ... }
.action-btn:hover { transform: translateY(-2px); ... }
adminLogin.css — Admin Login Page Styling
Styles the admin login interface with a split panel design.
- Left: Login form.
- Right: Welcome panel with branding and feature list.
- Modern, soft gradients, focus effects, and rounded corners.
adminLogin.html — Admin Login Page
The HTML entry for admin login.
Features:
- Form for admin credentials.
- Integrated with
admin.jsfor logic. - Includes a welcoming right panel with branding and feature highlights.
Structure:
<form id="submit">
<input id="username" type="email" placeholder="Email" required />
<input id="password" type="password" placeholder="Password" required />
<button id="login">Login</button>
</form>
asignTask.html — Assign Task Interface
Enables the admin to assign tasks to employees.
Key Components:
- Back navigation.
- Form with:
- Employee selector (dropdown).
- Task title and description.
- Submit button.
Structure:
<form id="taskForm">
<select id="employee" name="employee">...</select>
<input type="text" id="taskTitle" ... />
<textarea id="taskDescription" ...></textarea>
<button type="submit" class="action-btn">Assign Task</button>
</form>
attendence.css — Attendance Page Styling
Styles the attendance management page.
- Gradient backgrounds.
- Card-based containers for controls and tables.
- Modern, easy-to-read table design.
- Responsive for all device sizes.
attendence.html — Attendance Management Page
Allows tracking and editing of employee attendance records.
Features:
- Date picker for selecting attendance date.
- Table of employees with:
- ID, Name, Department, Attendance Status (editable), Check-in/out times.
Snippet:
<input type="date" id="attendanceDate" />
<table class="attendance-table">
<tbody id="attendanceTableBody">
<tr>
<td><span class="employee-id">EMP-001</span></td>
...
<td>
<select>
<option value="present">Present</option>
<option value="absent">Absent</option>
<option value="late">Late</option>
</select>
</td>
...
</tr>
</tbody>
</table>
paySlip.css — Pay Slip Styling
Styles the payroll slip management page.
- Card-based interface for employee info, earnings, deductions, and summary.
- Clean, professional salary input rows.
- Highlighted summary and responsive layout.
paySlip.html — Pay Slip Management Page
Enables HR/admins to generate and review employee pay slips.
Sections:
- Employee Information: ID, Name, Department, Pay Period, Working Days.
- Earnings: Basic pay, Overtime, Bonus, Allowance.
- Deductions: Tax, Fine, Other Deduction.
- Summary: Gross earnings, Total deductions, Net pay.
- Action: Calculate button (linked to JavaScript).
Structure:
<input type="number" id="basicPay" placeholder="0.00" />
...
<button class="calculate-btn">
<i class="fas fa-calculator"></i> Calculate Pay Slip
</button>
index.html — System Landing Page
Entry point for the application. Allows users to choose between Admin and User portals.
Features:
- Branding and welcome message.
- Two cards: Admin Portal and User Dashboard.
- Buttons redirect to respective login pages.
<div class="card admin-card">
...
<form action="Logins/adminLogin.html">
<button class="btn admin-btn" type="submit">Login as Admin</button>
</form>
</div>
<div class="card user-card">
...
<form action="Logins/userLogin.html">
<button class="btn user-btn">Login as User</button>
</form>
</div>
user.js — User Login Logic
Handles the login logic for users (staff/employees).
Workflow:
- Reads credentials from input fields.
- Checks them against a hardcoded user object.
- Redirects to the user dashboard on match.
- Alerts on mismatch.
const user = { username: "[email protected]", password: "user", };
document.querySelector("#submit").onclick = function (e) {
e.preventDefault();
const username = document.querySelector("#username").value;
const password = document.querySelector("#password").value;
if (username == user.username) {
if (password == user.password) {
window.location.href = "/Portals/User/UserDashboard.html";
}
} else {
alert("Wrong Data");
}
};
style.css — Core Global Styles
Defines the global look & feel, color palette, and shared card/button styles for the whole system.
Core Concepts:
- CSS variables for theme consistency.
- Flexbox and grid layouts.
- Card and button styling.
- Responsive adjustments.
:root {
--primary: #1E3A8A;
--secondary: #3B82F6;
--employee: #0D9488;
--bg: #F1F5F9;
--card: #FFFFFF;
--text-primary: #0F172A;
--text-muted: #64748B;
--success: #16A34A;
--error: #DC2626;
}
.card { ... }
.btn { ... }
@media (max-width: 768px) { ... }
paySlip.js — Pay Slip Calculation Logic
Adds interactivity to the pay slip page by calculating gross earnings, deductions, and net pay when the user clicks "Calculate Pay Slip".
Workflow:
- Reads values from all earnings and deduction inputs.
- Sums up each category.
- Displays the results in formatted currency.
document.addEventListener("DOMContentLoaded", function() {
// Get references...
calculateBtn.addEventListener("click", calculate);
function calculate() {
// Parse values as numbers
const basicPay = parseFloat(basicPayInput.value) ;
...
// Calculate totals
const totalEarnings = basicPay + overtime + bonus + allowance;
const totalDeductions = tax + fine + deduction;
const grossEarnings = totalEarnings;
const netPay = grossEarnings - totalDeductions;
// Update display
...
}
});
UserDashboard.css — User Dashboard Styling
A polished, modern stylesheet for the user (staff) dashboard.
Features:
- Bright and engaging color scheme.
- Responsive dashboard and card layout.
- Attendance calendar, stats, profile, and payslip sections.
- Consistent button, card, and table styling.
userLogin.css — User Login Page Styling
Styles the user login page.
Design Elements:
- Split screen with branding on the left, form on the right.
- Input group icons.
- Gradient backgrounds and button hover effects.
- Responsive for mobile devices.
UserDashboard.html — User Dashboard Interface
The central hub for users to review their information, stats, and recent activity.
Sections:
- Header: Branding, notifications, profile dropdown.
- Welcome: Personalized greeting, last login, working days.
- Stats: Pending tasks, attendance, salary.
- Content Grid: Pending tasks, attendance calendar, latest payslip, profile details.
Structure:
<div class="dashboard-container">
<header class="top-header">...</header>
<main class="main-content">
<div class="content-wrapper">
<div class="welcome-section">...</div>
<div class="stats-grid">...</div>
<div class="content-grid">
<!-- Tasks, Attendance, Payslip, Profile -->
</div>
</div>
</main>
</div>
userLogin.html — User Login Page
Used by staff or employees to access their dashboard.
Features:
- Branding and welcome on the left.
- Login form on the right.
- Email and password fields.
- "Forgot password" link (static).
- Uses
user.jsfor authentication logic.
<form action="/Portals/User/UserDashboard.html">
<div class="input-group">
<i class="fas fa-envelope"></i>
<input required id="username" type="email" placeholder="Email" />
</div>
<div class="input-group">
<i class="fas fa-lock"></i>
<input type="password" id="password" placeholder="Password" required />
</div>
<button id="submit" type="submit" >LOGIN</button>
</form>
System Authentication Flow
Below is a diagram illustrating the basic authentication and navigation flow for both admin and user logins:
flowchart TD
A[Landing Page] -->|Admin Login| B[Admin Login Page]
A -->|User Login| F[User Login Page]
B -->|Submit Credentials| C{Credentials Valid?}
F -->|Submit Credentials| G{Credentials Valid?}
C -- Yes --> D[Admin Dashboard]
C -- No --> E[Show Error]
G -- Yes --> H[User Dashboard]
G -- No --> I[Show Error]
API Endpoints
Note: The current codebase does not implement server-side APIs. All authentication and data management are client-side only (for demo purposes). For a production system, you would implement backend APIs for authentication, user management, attendance, payroll, etc.
{
"title": "No Real API Endpoints",
"content": "All authentication and data flows are handled on the client side with static data. No network calls or backend APIs are present in this code."
}
Key Takeaways
- Separation of admin and user workflows with dedicated login and dashboard pages.
- Modern, consistent UI/UX using shared styles and design tokens.
- Client-side logic for authentication and payroll calculations.
- Extendability: Easily add backend APIs by swapping out the JS logic for API calls.
{
"title": "Security Warning",
"content": "Current login logic uses hardcoded credentials and client-side authentication. For real deployments, implement secure, server-side authentication and data management."
}
File Relationships
flowchart TD
style[style.css]
adminLoginCSS[adminLogin.css]
userLoginCSS[userLogin.css]
adminDashboardCSS[adminDashboard.css]
UserDashboardCSS[UserDashboard.css]
addnewUserCSS[addnewUser.css]
asigntaskCSS[asigntask.css]
paySlipCSS[paySlip.css]
attendenceCSS[attendence.css]
adminLoginHTML[adminLogin.html]
userLoginHTML[userLogin.html]
adminDashboardHTML[adminDashboard.html]
UserDashboardHTML[UserDashboard.html]
addUserHTML[addUser.html]
asignTaskHTML[asignTask.html]
paySlipHTML[paySlip.html]
attendenceHTML[attendence.html]
indexHTML[index.html]
adminJS[admin.js]
userJS[user.js]
paySlipJS[paySlip.js]
indexHTML --> style
adminLoginHTML --> adminLoginCSS
adminLoginHTML --> adminJS
userLoginHTML --> userLoginCSS
userLoginHTML --> userJS
adminDashboardHTML --> adminDashboardCSS
UserDashboardHTML --> UserDashboardCSS
addUserHTML --> addnewUserCSS
asignTaskHTML --> asigntaskCSS
paySlipHTML --> paySlipCSS
paySlipHTML --> paySlipJS
attendenceHTML --> attendenceCSS
If you need to extend StaffSync with real backend integration, use server-side APIs for authentication, user management, attendance, and payroll data.
End of documentation for StaffSync codebase.