54 lines
2.2 KiB
Markdown
54 lines
2.2 KiB
Markdown
# PLAN: Shift Scheduling System
|
|
|
|
Enable dynamic shift assignment and scheduling directly from the Shift Calendar matrix.
|
|
|
|
## 1. Context & Objectives
|
|
The user wants to manage employee schedules from `hr/shifts/calendar`.
|
|
- "Assigning" a shift creates or updates an `AttendanceRecord` as a scheduling placeholder.
|
|
- Supports bulk assignment across a **date range**.
|
|
- Includes a **Rest Day** toggle.
|
|
- Allows choosing from **Active Shifts**.
|
|
|
|
## 2. Technical Strategy
|
|
### Backend
|
|
- **Endpoint**: Implement `POST /hr/shifts/assign` in `ShiftController`.
|
|
- **Logic**: Use `CarbonPeriod` to iterate through dates and `updateOrCreate` on `AttendanceRecord`.
|
|
|
|
### Frontend
|
|
- **Enhancement**: Convert matrix cells into clickable triggers.
|
|
- **Component**: Integrate `CrudFormModal` for the scheduling form.
|
|
- **Data**: The `calendar` view must now provide a list of all active `available_shifts` for the dropdown.
|
|
|
|
## 3. Task Breakdown
|
|
|
|
### Phase 1: Backend Scaffolding
|
|
- [ ] Add `all_shifts` to the data returned by `ShiftController@calendar`.
|
|
- [ ] Implement `assignShift` method:
|
|
- Validate: `employee_id`, `start_date`, `end_date`, `shift_id`, `is_rest_day`.
|
|
- Iteration logic for date ranges.
|
|
- `AttendanceRecord::updateOrCreate` implementation.
|
|
|
|
### Phase 2: Frontend Interactivity
|
|
- [ ] Add Modal state transitions to `resources/js/pages/hr/shifts/calendar.tsx`.
|
|
- [ ] Implement `handleCellClick` to pre-populate the assignment form.
|
|
- [ ] Add `cursor-pointer` and hover styles to the grid badges.
|
|
|
|
### Phase 3: Scheduling Modal
|
|
- [ ] Configure `CrudFormModal` with:
|
|
- Date Range (Start/End).
|
|
- Shift Switcher (Dropdown).
|
|
- Rest Day Toggle.
|
|
- [ ] Implement `handleFormSubmit` and handle validation errors.
|
|
|
|
### Phase 4: Verification
|
|
- [ ] Test assigning a shift to a 7-day range.
|
|
- [ ] Test marking a day as a Rest Day and verify it shows as `RD`.
|
|
- [ ] Verify that assigned shifts appear in the grid after a successful update.
|
|
|
|
## 4. Agent Assignments
|
|
| Agent | Task |
|
|
|-------|------|
|
|
| Backend Specialist | Range assignment logic & Controller updates |
|
|
| Frontend Specialist | Calendar modal & Range selection UI |
|
|
| Quality Assurance | Gap verification between attendance & shifts |
|