Schedules (جداول الورديات)
Manage employee shift schedules with bulk creation support across date ranges and specific days of the week.
Attributes
| Field | Type | Description |
|---|---|---|
id | integer | Primary key |
employee_id | integer | Employee FK |
shift_id | integer | Shift FK |
date | date | Schedule date |
status | enum | scheduled, attended, absent, on_leave |
API Endpoints
| Method | URL | Description |
|---|---|---|
GET | /api/hr/schedules | List schedules (filtered) |
POST | /api/hr/schedules/bulk | Bulk create schedules |
PUT | /api/hr/schedules/{id} | Update a schedule |
DELETE | /api/hr/schedules/{id} | Delete a schedule |
Query Parameters (List)
| Parameter | Type | Description |
|---|---|---|
employee_id | integer | Filter by employee |
department_id | integer | Filter by department |
shift_id | integer | Filter by shift |
date_from | date | Start date range |
date_to | date | End date range |
Bulk Create
Create schedules for multiple employees over a date range, specifying which days of the week:
bash
curl -X POST "https://moon-erp.elbaset.com/api/hr/schedules/bulk" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"employee_ids": [1, 2, 3],
"shift_id": 1,
"date_from": "2026-03-01",
"date_to": "2026-03-31",
"days_of_week": [0, 1, 2, 3, 4]
}'dart
final response = await dio.post('/api/hr/schedules/bulk', data: {
'employee_ids': [1, 2, 3],
'shift_id': 1,
'date_from': '2026-03-01',
'date_to': '2026-03-31',
'days_of_week': [0, 1, 2, 3, 4],
});
// Response: { "created": 66, "skipped": 0 }Days of Week
| Value | Day |
|---|---|
| 0 | Sunday |
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |
Business Rules
- Each employee can only have one schedule per date (unique constraint on
employee_id+date) - Bulk create skips existing records instead of failing (returns
createdandskippedcounts) - Schedules are paginated (50 per page), ordered by date then employee
- Supports filtering by department through employee relationship