# Employee Directory Feature

## Overview
The Employee Directory is an internal page that allows all employees to see and connect with their colleagues. It displays profile information, skills, hobbies, and professional details that employees choose to share.

## Purpose
- **Team Building**: Help employees get to know each other beyond work roles
- **Skill Discovery**: Find colleagues with specific skills or expertise
- **Collaboration**: Easily connect via email, phone, or social links
- **Culture**: Foster a friendly, transparent company culture

## Features

### Main Table View
- **Profile Pictures**: Avatar with initials fallback if no photo uploaded
- **Quick Info**: Name, position, department, location
- **Contact Icons**: Direct links to email and phone
- **Years of Experience**: Badge showing experience level
- **Search**: Search by name, department, or position

### Expandable Details (Click the Arrow)
When you click the arrow icon, you'll see:

#### Professional Info
- Email (clickable)
- Phone (clickable)
- Employee ID
- Hire date ("With Us Since")
- Timezone

#### Skills & Expertise
- Comma-separated skills displayed as tags
- Years of experience
- Education background
- Professional certifications
- Languages spoken

#### Personal Interests
- Hobbies
- Professional interests
- (Optional - only shows if employee has filled these in)

#### Get to Know Me
- Fun fact about the person
- Favorite quote
- (Optional - only shows if employee has filled these in)

#### Connect
- LinkedIn profile link
- Personal website link
- (Optional - only shows if employee has filled these in)

## Privacy & Control

### Opt-In/Opt-Out
Every user has a `show_in_directory` flag (default: 1/true)
- Set to `1`: Profile appears in directory
- Set to `0`: Profile is hidden from directory

To opt out, update your user record:
```sql
UPDATE users SET show_in_directory = 0 WHERE id = YOUR_USER_ID;
```

### What's Required vs Optional
**Always Shown (from employee record):**
- Name
- Position
- Department
- Email
- Status (only active employees shown)

**Optional (employee controls):**
- Profile picture
- Bio
- Hobbies
- Skills
- Interests
- LinkedIn/Website
- Fun fact
- Favorite quote
- Years of experience
- Education
- Certifications
- Languages

## Technical Details

### Database Schema
New fields added to `users` table:
```sql
- bio (TEXT)
- hobbies (TEXT)
- skills (TEXT) - comma-separated
- interests (TEXT)
- linkedin_url (VARCHAR 255)
- personal_website (VARCHAR 255)
- fun_fact (TEXT)
- favorite_quote (TEXT)
- years_of_experience (INT)
- education (TEXT)
- certifications (TEXT)
- languages (VARCHAR 255)
- timezone (VARCHAR 50)
- show_in_directory (TINYINT 1) - default 1
```

### Files Created/Modified

**New Files:**
- `database/migrations/030_add_employee_directory_profile_fields.sql` - Migration
- `database/migrations/030_sample_directory_data.sql` - Sample data (optional)
- `views/employees/directory.php` - Directory view
- `EMPLOYEE_DIRECTORY_README.md` - This file

**Modified Files:**
- `models/Employee.php` - Added `getDirectoryList()` method
- `controllers/EmployeeController.php` - Added `directory()` method
- `public/index.php` - Added route `/employees/directory`

### Route
```
GET /employees/directory
GET /employees/directory?search=keyword
```

### Permissions
- Accessible to all authenticated users (no special permission required)
- Only shows active employees with `show_in_directory = 1`

## Usage

### Accessing the Directory
Navigate to: `/employees/directory`

Or add it to the navigation menu:
```sql
INSERT INTO menu_items (name, url, icon, parent_id, sort_order) 
VALUES ('Employee Directory', '/employees/directory', 'bi-people-fill', NULL, 50);
```

### Updating Your Profile
Employees can update their profile information through:
1. **Direct database update** (for now)
2. **Profile settings page** (to be added - recommended future enhancement)

Example update:
```sql
UPDATE users SET 
    bio = 'Your bio here',
    skills = 'PHP, JavaScript, React',
    hobbies = 'Reading, hiking, cooking',
    linkedin_url = 'https://linkedin.com/in/yourprofile',
    fun_fact = 'I love dogs!',
    years_of_experience = 5
WHERE id = YOUR_USER_ID;
```

### Searching
Use the search box to filter by:
- First or last name
- Department name
- Position title

## Future Enhancements (Ideas)

1. **Profile Edit Page**: Let users edit their own profiles through UI
2. **Department Filter**: Add dropdown to filter by department
3. **Export to vCard**: Download contact info as vCard
4. **Birthday Display**: Show birthdays (with opt-in)
5. **Work Anniversary**: Celebrate work anniversaries
6. **Org Chart Integration**: Link to organizational chart
7. **Skill Matching**: Find people with complementary skills
8. **Availability Status**: Show who's in office/remote/OOO
9. **Direct Messaging**: Link to internal messaging system
10. **Photo Upload**: Easy way to upload profile pictures

## Design Notes

### Visual Style
- Matches the existing ledger expandable row pattern
- Uses Bootstrap Icons
- Responsive card-based layout for expanded view
- Gradient backgrounds for visual appeal
- Hover effects for interactivity
- Theme-aware (respects dark/light theme)

### User Experience
- **Fast Loading**: Only active employees fetched
- **Smooth Animations**: Caret rotation, row expansion
- **Mobile Friendly**: Responsive table with scrolling
- **Accessible**: Proper ARIA labels, keyboard navigation
- **Intuitive**: Clear visual cues for expandable rows

## Support

For questions or issues with the employee directory:
1. Check this README
2. Review the code comments in the files
3. Contact your system administrator

## Migration Steps

To enable this feature:

1. Run the migration:
```bash
mysql -u rpmbbu brickwal_m1_ds < database/migrations/030_add_employee_directory_profile_fields.sql
```

2. (Optional) Add sample data for testing:
```bash
mysql -u rpmbbu brickwal_m1_ds < database/migrations/030_sample_directory_data.sql
```

3. Access the directory at `/employees/directory`

4. (Optional) Add to navigation menu via Settings > Menu

## Notes

- No sensitive data (salary, SSN, etc.) is ever displayed
- All fields except name/email/position are optional
- Employees control what they share
- Only active employees appear in directory
- Search is case-insensitive
- Profile pictures should be stored in `uploads/avatars/` directory
