workPro Documentation
┌─────┬──────────┬──────────────┬───────┬───────────┬─────────────┬────────┬──────────┬──────────┬──────────┐
│ # │ Name │ Email │ Phone │ Vendor │ Project │ DC │ Role │ Status │ Actions │
├─────┼──────────┼──────────────┼───────┼───────────┼─────────────┼────────┼──────────┼──────────┼──────────┤
│ 1 │ John Doe │ john@ex.com │ 12345 │ Vendor A │ Project X │ DC-1 │ [Admin] │ [Active] │ 👁 ✎ 🔒 │
│ 2 │ Jane Doe │ jane@ex.com │ 54321 │ Vendor B │ Project Y │ DC-2 │ [Staff] │ [Active] │ 👁 ✎ 🔒 │
│ 3 │ Bob Smith│ bob@ex.com │ 99999 │ - │ - │ - │[Superv] │ [Inactive]│ 👁 ✎ 🔒 🗑 │
└─────┴──────────┴──────────────┴───────┴───────────┴─────────────┴────────┴──────────┴──────────┴──────────┘
╔════════════════════════════════════════════╗
║ 👁 View User Details X ║
╠════════════════════════════════════════════╣
║ ║
║ Name: [John Doe ] ║
║ Email: [john@example.com ] ║
║ Phone: [1234567890 ] ║
║ Vendor: [Vendor A ] ║ ← NEW FIELD
║ Project: [Project X ] ║ ← NEW FIELD
║ DC: [DC-1 ] ║ ← NEW FIELD
║ Role: [Admin ] ║
║ Status: [Active ] ║
║ ║
╠════════════════════════════════════════════╣
║ [ Close ] ║
╚════════════════════════════════════════════╝
╔════════════════════════════════════════════════════════════════╗
║ 👤 Create New User X ║
╠════════════════════════════════════════════════════════════════╣
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ Name * │ Email * │ ║
║ │ [John Doe ] │ [john@example.com ] │ ║
║ │ Enter user's full name │ Must be a valid email... │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ Phone │ Role * │ ║
║ │ [1234567890 ] │ [Select role... ▼] │ ║
║ │ │ Admin │ ║
║ │ │ Staff │ ║
║ │ │ Supervisor │ ║
║ │ │ Field Worker │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ Vendor Name NEW │ Project Name NEW │ ║
║ │ [Select vendor... ▼] │ [Select project... ▼] │ ║
║ │ Vendor A │ (filtered by vendor) │ ║
║ │ Vendor B │ │ ║
║ │ Vendor C │ │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ DC Name NEW │ Status * │ ║
║ │ [Select DC... ▼] │ [Select status... ▼] │ ║
║ │ (filtered by project) │ Active │ ║
║ │ │ Inactive │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
╠════════════════════════════════════════════════════════════════╣
║ [ Cancel ] [ Create User ] ║
╚════════════════════════════════════════════════════════════════╝
╔════════════════════════════════════════════════════════════════╗
║ ✎ Edit User X ║
╠════════════════════════════════════════════════════════════════╣
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ Name * │ Email * │ ║
║ │ [John Doe ] │ [john@example.com ] │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ Phone │ Role * │ ║
║ │ [1234567890 ] │ [Admin ▼] │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ Vendor Name │ Project Name │ ║
║ │ [Vendor A ▼] │ [Project X ▼] │ ║
║ │ (auto-filtered) │ (auto-filtered) │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
║ ┌──────────────────────────┬──────────────────────────────┐ ║
║ │ DC Name │ Status * │ ║
║ │ [DC-1 ▼] │ [Active ▼] │ ║
║ │ (auto-filtered) │ Active │ ║
║ │ │ Inactive │ ║
║ └──────────────────────────┴──────────────────────────────┘ ║
║ ║
╠════════════════════════════════════════════════════════════════╣
║ [ Cancel ] [ Save Changes ] ║
╚════════════════════════════════════════════════════════════════╝
Load Dropdowns
LoadDropdowns()
├─ Fetch vendors, projects, DCs from API
├─ Populate all three select elements
└─ Store data in window.projectsData, window.dcsData
Vendor Selection
Vendor Dropdown Change Event
├─ Get selected vendorId
├─ Filter projects (where projectId.vendorId == selected)
├─ Repopulate Project dropdown
└─ Clear DC dropdown
Project Selection
Project Dropdown Change Event
├─ Get selected projectId
├─ Filter DCs (where dcId.projectId == selected)
└─ Repopulate DC dropdown
Edit Mode Special Handling
When opening Edit modal with pre-selected values:
├─ Set Vendor to user's vendorId
├─ Trigger change event (filters projects)
├─ Wait 100ms for projects to load
├─ Set Project to user's projectId
├─ Trigger change event (filters DCs)
├─ Wait 100ms for DCs to load
└─ Set DC to user's dcId
USER MANAGEMENT PAGE LOAD
│
├─ Load dropdowns.php
│ ├─ Returns: vendors[], projects[], dcs[]
│ └─ Populate all dropdowns + store globally
│
├─ Load users-list.php (DataTables AJAX)
│ ├─ Returns: users with vendorName, projectName, dcName
│ └─ Display 10-column table
│
└─ Ready for user interactions
USER VIEWS DETAILS (Click View Icon)
│
├─ Call users-view.php with userId
│ ├─ Query user JOIN vendor JOIN project JOIN dc
│ └─ Return: user data + names + IDs
│
└─ Display read-only View modal
USER CREATES NEW USER (Click New User Button)
│
├─ Show Create modal with 2-column layout
├─ User selects Vendor → projects auto-filter
├─ User selects Project → DCs auto-filter
├─ Click Create User button
│
├─ POST to users-create.php with all fields
│ ├─ Insert with vendorId, projectId, dcId
│ └─ Return: success message + user data
│
└─ Close modal, reload table
USER EDITS USER (Click Edit Icon)
│
├─ Call users-view.php with userId
│ └─ Return: user data + vendorId, projectId, dcId
│
├─ Show Edit modal with pre-filled values
├─ Cascade-filter dropdowns based on current IDs
├─ User can change any fields
│
├─ POST to users-edit.php with modified fields
│ ├─ Update all fields including new ones
│ └─ Return: updated user data
│
└─ Close modal, reload table
DataTables Search now includes:
Example: Searching for "Vendor A" will show all users assigned to Vendor A
Role Badges:
┌─────────────┐
│ Admin ▲ │ (Red badge - bg-danger)
├─────────────┤
│ Staff 🧑 │ (Blue badge - bg-info)
├─────────────┤
│ Other ○ │ (Gray badge - bg-secondary)
└─────────────┘
Status Badges:
┌──────────────┐
│ Active ✓ │ (Green badge - bg-success)
├──────────────┤
│ Inactive ✗ │ (Gray badge - bg-secondary)
└──────────────┘
Each row shows action buttons:
👁 = View User (shows all details in modal)
✎ = Edit User (allows modification of all fields)
🔒 = Change Password (dedicated password modal)
🗑 = Delete User (only shown for non-admin users)
Note: Delete button hidden for admin users (protection)
for attributes