รายชื่อผู้อบรม (Training Enrollment) - Workflow
Last Updated: 2026-01-04 Status: Phase 3 Complete - Phase 4 Blocked
Reason dropdown feature causes infinite loop. Commands work without reasons but fail when dropdown is added. Investigation needed.
Overview
Training Enrollment workflow ช่วยให้ผู้รับเหมาสามารถส่งรายชื่อผู้ปฏิบัติงานเพื่อเข้ารับการอบรมความปลอดภัย โดย จป. จะเป็นผู้ตรวจสอบและอนุมัติรายชื่อ
Workflow Diagram
States
| State | Thai Name | Description | Expected Role |
|---|---|---|---|
| Started | เริ่มต้น | สถานะเริ่มต้น | - |
| FillInTrainingList | กรอกรายชื่อผู้อบรม | ผู้รับเหมาเลือกผู้ปฏิบัติงานที่ต้องการส่งเข้าอบรม | ผู้รับเหมา |
| ReviewBySafetyOfficer | จป. ตรวจสอบ | จป. ตรวจสอบและอนุมัติรายชื่อ | จป. |
| Completed | เสร็จสิ้น | รายชื่อได้รับการอนุมัติแล้ว | - |
| Rejected | ปฏิเสธ | รายชื่อถูกปฏิเสธ | - |
| Cancelled | ยกเลิก | ยกเลิกการส่งรายชื่อ | - |
Commands
| Command | Thai Name | From State | To State | Allowed Role |
|---|---|---|---|---|
| SubmitTrainingList | ส่งรายชื่อผู้อบรม | FillInTrainingList | ReviewBySafetyOfficer | ผู้รับเหมา |
| Cancel | ยกเลิก | FillInTrainingList | Cancelled | ผู้รับเหมา |
| ApproveTraining | อนุมัติรายชื่อ | ReviewBySafetyOfficer | Completed | จป. |
| RequestChange | ส่งกลับแก้ไข | ReviewBySafetyOfficer | FillInTrainingList | จป. |
| RejectTraining | ปฏิเสธรายชื่อ | ReviewBySafetyOfficer | Rejected | จป. |
RequestChange and RejectTraining will require selecting a reason from a dropdown. Currently blocked by infinite loop issue.
Form Edit Permissions
| State | Editable Documents | Editable By | Lock Reason |
|---|---|---|---|
| FillInTrainingList | Doc 23 (รายชื่อผู้อบรม) | ผู้รับเหมา | - |
| ReviewBySafetyOfficer | (all locked) | - | จป. กำลังตรวจสอบ |
| Completed | (all locked) | - | อนุมัติแล้ว |
| Rejected | (all locked) | - | ถูกปฏิเสธ |
| Cancelled | (all locked) | - | ยกเลิกแล้ว |
Document Forms
| Doc ID | Document | Thai Name | Description |
|---|---|---|---|
| 23 | Training Enrollment Form | รายชื่อผู้อบรม | ฟอร์มสำหรับเลือกผู้ปฏิบัติงานที่ต้องการส่งเข้าอบรม |
Form Fields
Training Enrollment Form (Doc 23)
| Section | Fields | Description |
|---|---|---|
| ข้อมูลการอบรม | บริษัท/Contractor | ชื่อผู้รับเหมา (อัตโนมัติจากระบบ) |
| วันที่อบรม | วันที่กำหนดจัดอบรม | |
| สถานที่อบรม | สถานที่จัดอบรม | |
| หมายเหตุ | หมายเหตุเพิ่มเติม (ถ้ามี) | |
| รายชื่อผู้อบรม | ตาราง | รายชื่อผู้ปฏิบัติงานพร้อม checkbox เลือก |
Worker Table Columns
| Column | Thai Name | Description |
|---|---|---|
| Checkbox | (เลือก) | เลือกผู้ปฏิบัติงานที่ต้องการส่งอบรม |
| No. | ลำดับ | ลำดับที่ |
| Name | ชื่อ-นามสกุล | ชื่อเต็มผู้ปฏิบัติงาน |
| ID Number | เลขประจำตัวประชาชน | เลขบัตรประชาชน 13 หลัก |
| Training Status | สถานะการอบรม | สถานะปัจจุบัน (ผ่าน/ไม่ผ่าน/หมดอายุ/รอการอบรม) |
| Status | สถานะ | แสดงไอคอนเมื่อเลือก |
Worker Validation
Before submitting, the system validates each selected worker and displays status icons:
Validation Checks
| Check | Icon | Description |
|---|---|---|
| ID Card Photo | ✅ / ⚠️ | Shows if worker has ID card document uploaded |
| Profile Photo | ✅ / ⚠️ | Shows if worker has profile photo uploaded |
| Blacklist Status | 🚫 | Warning if worker is on blacklist |
| Already Enrolled | ⚠️ | Warning if worker already enrolled in same session |
Validation Summary Panel
When issues are found, a summary panel appears at the top showing:
- Total workers with issues
- Breakdown by issue type
- "ดูเอกสารแนบ" (View Attachments) button to check worker documents
Automatic Deselection
Workers with critical issues (blacklisted, already enrolled) are automatically deselected when the form loads. Contractor must manually re-select them if they believe the issue is resolved.
Testing Instructions
Getting Started
- เข้าสู่ระบบด้วย role Contractor
- ไปที่ "งานของฉัน" (My Tasks)
- คลิก "สร้างงาน" → เลือก "รายชื่อผู้อบรม"
Test Scenarios
Scenario 1: ส่งรายชื่อสำเร็จ
- Contractor: สร้างงานใหม่ประเภท "รายชื่อผู้อบรม"
- Contractor: กรอกวันที่อบรม และสถานที่อบรม
- Contractor: เลือกผู้ปฏิบัติงานที่ต้องการส่งอบรม (ติ๊ก checkbox)
- Contractor: คลิก "ส่งรายชื่อผู้อบรม"
- Safety Officer: ตรวจสอบรายชื่อ
- Safety Officer: คลิก "อนุมัติรายชื่อ"
- สถานะเปลี่ยนเป็น "เสร็จสิ้น"
Scenario 2: ส่งกลับแก้ไข
- ทำขั้นตอน 1-5 จาก Scenario 1
- Safety Officer: คลิก "ส่งกลับแก้ไข"
- Contractor: แก้ไขรายชื่อ
- Contractor: ส่งใหม่อีกครั้ง
Scenario 3: ยกเลิก
- ทำขั้นตอน 1-3 จาก Scenario 1
- Contractor: คลิก "ยกเลิก"
- สถานะเปลี่ยนเป็น "ยกเลิก"
สิ่งที่ต้องตรวจสอบ
- สร้างงานใหม่ได้สำเร็จ
- ปุ่มคำสั่งแสดงตามสถานะถูกต้อง
- เลือก/ยกเลิกเลือกผู้ปฏิบัติงานได้
- สถานะเปลี่ยนตามคำสั่งถูกต้อง
- ฟอร์มล็อคเมื่ออยู่ในสถานะตรวจสอบ
Architecture Notes
Temporal.io Workflow
Training Enrollment ใช้ Temporal.io สำหรับ workflow orchestration:
- Task Creation: Task ถูกสร้างผ่าน
TrainingEnrollmentWorkflowService.ExecuteAsync() - Workflow: Temporal workflow ใน
TrainingEnrollmentWorkflow.csจัดการ state machine - Commands: Query Temporal workflow ผ่าน
GetCommandsAsync() - State Transitions: Update Temporal workflow ผ่าน method เช่น
SubmitTrainingListAsync(),ApproveTrainingAsync()
Key Backend Files
| File | Purpose |
|---|---|
SafetyApp.Workflows.TrainingEnrollment/TrainingEnrollmentWorkflow.cs | Temporal workflow (states, queries, updates) |
SafetyApp.Workflows.TrainingEnrollment/TrainingEnrollmentActivities.cs | Activity methods |
SafetyApp.Workflows.TrainingEnrollment/TrainingEnrollmentWorkflowService.cs | Temporal client wrapper |
SafetyApp.Application/Contracts/ITrainingEnrollmentWorkflowService.cs | Service interface |
SafetyApp.Infrastructure/Services/TaskCommandService.cs | Command execution routing |
Key Frontend Files
| File | Purpose |
|---|---|
training-enrollment-form.component.ts | Form component |
training-enrollment-form.model.ts | Form data model |
training-enrollment-svg-mapping.config.ts | SVG workflow diagram mapping |
Source Code Reference
Workflow is implemented as a Temporal.io workflow:
Project: backend/SafetyApp.Workflows.TrainingEnrollment/
| File | Description |
|---|---|
TrainingEnrollmentWorkflow.cs | State machine with [WorkflowQuery] and [WorkflowUpdate] methods |
TrainingEnrollmentActivities.cs | Activity methods for task creation, state updates |
DependencyInjection.cs | Temporal worker registration with task queue training-enrollment-task-queue |
Related Documentation
| Document | Description |
|---|---|
| Feature Overview | Implementation roadmap and phase details |
| Test Cases | Test scenarios and verification |
Version History
| Date | Version | Changes |
|---|---|---|
| 2025-12-29 | 1.0 | Initial prototype documentation |
| 2026-01-03 | 1.1 | Added validation (Phase 3) |
| 2026-01-04 | 1.2 | Added validation section, Phase 4 blocked note |
| 2026-01-06 | 1.3 | Added "Allowed Role" column to Commands table for easier validation |