Skip to main content

ใบอนุญาตปฏิบัติงาน (Work Permit) - Workflow

Prototype

นี่คือเอกสารสำหรับ Work Permit Prototype กรุณาทดสอบและส่ง feedback

Referenced Templates

  • Location: frontend/src/assets/templates/08-*-work-permit/ to 15-*-work-permit/

Application Flow Diagram

The complete Safety App workflow showing all roles and document flow:

Safety App - Main Flow

Open full size in new tab - Use Ctrl+scroll to zoom

Source file

safety-app-flow-v2.drawio.xml - Can be opened in draw.io for editing


Implementation Diagram (Dev Version)

The dev-version diagram shows the exact workflow states as implemented in code. This is the technical reference that always matches the codebase.

Work Permit Workflow (Dev)

Source files
  • SVG: frontend/src/assets/workflows/work-permit-workflow-dev.svg
  • Draw.io: frontend/src/assets/workflows/work-permit-workflow-dev.drawio.xml
  • States enum: WorkPermitWorkflowStates in work-permit-workflow.mock.ts
Maintenance

Cell IDs in the dev-version SVG match state keys directly (e.g., data-cell-id="prepare-prerequisites"). This makes it easy to update the diagram when workflow states change.


Workflow Diagram (Simplified)


States

Phase 1: Prerequisites

StateThai NameDescription
Startedเริ่มต้นสถานะเริ่มต้น
PreparePrerequisitesเตรียมเอกสารเบื้องต้นผู้รับเหมากรอก Doc 5, 6*, 4, 3
ReviewPrereqByWorkOwnerเจ้าของงานตรวจสอบเจ้าของงานตรวจสอบเอกสารทั้งหมด
ReviewPrereqBySafetyOfficerจป. ตรวจสอบรายชื่อจป. ตรวจสอบ Doc 4 (รายชื่อผู้ปฏิบัติงาน) แบบละเอียด

Phase 2: PTW Filling

StateThai NameDescription
FillInPermitInfoกรอกข้อมูลใบอนุญาตผู้รับเหมาเลือกประเภท PTW และกรอก Doc 7*-15

Phase 3: PTW Review (Parallel Co-Review)

StateThai NameDescription
ReviewPTWCoReviewตรวจสอบใบอนุญาตร่วมเจ้าของงาน + จป. + เจ้าของพื้นที่ ตรวจสอบร่วมกัน (ทั้ง 3 ต้องอนุมัติ)

Phase 4: Execution

StateThai NameDescription
WorkInProgressกำลังปฏิบัติงานอยู่ระหว่างปฏิบัติงานตาม PTW
RequestExtensionขอขยายเวลาผู้รับเหมากรอกคำขอขยายเวลา
ReviewExtCoReviewตรวจสอบคำขอขยายเวลาทั้ง 3 คน ตรวจสอบคำขอขยายเวลาร่วมกัน

Phase 5: Close & Evaluation

StateThai NameDescription
RequestCloseขอปิดงานผู้รับเหมากรอก Delivery Document
ClosePTWCoReviewตรวจสอบการปิดงานทั้ง 3 คน ตรวจสอบการส่งมอบงานร่วมกัน
Evaluationประเมินผลเจ้าของงาน (คุณภาพงาน) + จป. (ความปลอดภัย) กรอก Doc 16

Terminal States

StateThai NameDescription
Completedเสร็จสิ้นงานเสร็จสิ้นสมบูรณ์
Cancelledยกเลิกใบอนุญาตถูกยกเลิก

หมายเหตุ: * = conditional (ใช้เมื่อจำเป็นเท่านั้น เช่น Doc 6 เมื่อใช้ Mobile Crane, Doc 7 เมื่อใช้ Scaffolding)


Commands

Phase 1: Prerequisites

CommandThai NameFrom StateTo State
SubmitPrerequisitesส่งเอกสารเบื้องต้นPreparePrerequisitesReviewPrereqByWorkOwner
ApprovePrereqByWorkOwnerอนุมัติเอกสารเบื้องต้นReviewPrereqByWorkOwnerReviewPrereqBySafetyOfficer
RejectPrereqByWorkOwnerส่งกลับแก้ไขเอกสารReviewPrereqByWorkOwnerPreparePrerequisites
ApprovePrereqBySOอนุมัติรายชื่อผู้ปฏิบัติงานReviewPrereqBySafetyOfficerFillInPermitInfo
RejectPrereqBySOส่งกลับแก้ไขรายชื่อReviewPrereqBySafetyOfficerPreparePrerequisites

Phase 2: PTW Submission & Review

CommandThai NameFrom StateTo State
SubmitPTWส่งใบอนุญาตเพื่อตรวจสอบFillInPermitInfoReviewPTWCoReview
ApprovePTWอนุมัติใบอนุญาตReviewPTWCoReviewWorkInProgress
RequestChangePTWขอให้แก้ไขใบอนุญาตReviewPTWCoReviewFillInPermitInfo

Phase 3: Extension

CommandThai NameFrom StateTo State
RequestExtensionขอขยายเวลาWorkInProgressRequestExtension
SubmitExtensionส่งคำขอขยายเวลาRequestExtensionReviewExtCoReview
ApproveExtensionอนุมัติขยายเวลาReviewExtCoReviewWorkInProgress
RejectExtensionปฏิเสธขยายเวลาReviewExtCoReviewWorkInProgress

Phase 4: Close & Evaluation

CommandThai NameFrom StateTo State
RequestCloseขอปิดงานWorkInProgressRequestClose
SubmitCloseส่งคำขอปิดงานRequestCloseClosePTWCoReview
ApproveCloseอนุมัติปิดงานClosePTWCoReviewEvaluation
RejectCloseปฏิเสธปิดงานClosePTWCoReviewWorkInProgress
CompleteEvaluationเสร็จสิ้นการประเมินEvaluationCompleted

Cancel

CommandThai NameFrom StateTo State
CancelยกเลิกใบอนุญาตMost statesCancelled

Permit Types (DocumentForms 8-15)

IDTemplate FolderEnglish NameThai Name
808-work-at-height-work-permitWork at Height Permitใบอนุญาตปฏิบัติงานในที่สูง
909-chemical-work-permitChemical Work Permitใบอนุญาตงานกับวัตถุอันตรายหรือสารเคมี
1010-high-voltage-work-permitHigh Voltage Work Permitใบอนุญาตปฏิบัติงานไฟฟ้าแรงสูง
1111-hot-work-permitHot Work Permitใบอนุญาตงานเชื่อม/ตัด
1212-confined-space-work-permitConfined Space Work Permitใบอนุญาตงานในที่อับอากาศ
1313-general-work-permitGeneral Work Permitใบอนุญาตปฏิบัติงานทั่วไป
1414-radiation-work-permitRadiation Work Permitใบอนุญาตงานรังสี
1515-excavate-work-permitExcavate Work Permitใบอนุญาตงานขุดเจาะ

Pre-requisite Documents

Before filling out the Work Permit form (Part 1), the following documents must be prepared:

Doc IDDocumentThai NameDescription
03Risk Assessment (JSA)การวิเคราะห์งานเพื่อความปลอดภัยJob Safety Analysis for the work
04Manpower Name Listรายชื่อผู้ปฏิบัติงานList of trained workers
05Tool Listรายการเครื่องมือEquipment and tools required

These documents are shown in the "เอกสารเบื้องต้น" (Prerequisites) tab in the review task view.

Worker Selection

Workers in the Work Permit must be selected from the approved manpower list for the project. Only workers who have completed safety training are eligible.


These documents are generated for printing only and are accessible via the Print button in the task review toolbar.

Doc IDDocumentThai NameNodePurpose
20Training Attendance Sheetใบลงทะเบียนอบรม#22Worker safety training registration record
21Worker Badgesบัตรผู้ปฏิบัติงาน#22ID cards for authorized workers
22Worksite Posterพิมพ์ใบอนุญาต#23Posted work permit at the worksite

Workflow-Specific Documents

These documents are created specifically for the workflow and do not have corresponding .docx templates:

Doc IDDocumentThai NamePurpose
18Delivery Documentเอกสารส่งมอบงานWork completion handover document
19Extension Requestแบบฟอร์มขอขยายเวลาTime extension request form
Template Sources
  • From .docx templates: Doc 6-7 (Inspections), Doc 8-15 (Work Permits), Doc 16 (Evaluation)
  • Digital-only forms: Doc 18 (Delivery), Doc 19 (Extension) - designed for digital workflow
  • Print-only output: Doc 20-22 - generated from approved data

State-Documents Mapping

Each workflow state shows different documents in the UI. This mapping is defined in getWorkPermitDocumentFormIds().

StateDocuments Shown
prepare-prerequisitesDoc 5, 6*, 4, 3 (prerequisites)
review-prereq-by-work-ownerDoc 5, 6*, 4, 3 (prerequisites)
review-prereq-by-safety-officerDoc 5, 6*, 4, 3 (prerequisites)
fill-in-permit-infoDoc 7* + PTW forms (8-15) + prerequisites
review-ptw-co-reviewDoc 7* + PTW forms (8-15) + prerequisites
work-in-progressPTW forms + Doc 18 (Delivery) + Doc 19 (Extension Request)
request-extensionPTW forms + Doc 19 (Extension Request)
review-ext-co-reviewPTW forms + Doc 19 (Extension Request)
close-ptw-co-reviewDoc 18 (Delivery) + PTW forms
evaluationDoc 16 (Evaluation) + Doc 18 + PTW forms
completedDoc 16 + Doc 18 + PTW + prerequisites (all for reference)

Note: The request-close state is deprecated. The workflow goes directly from work-in-progress to close-ptw-co-review. The Delivery Document (Doc 18) is filled during work-in-progress state.

Legend: * = conditional document (Doc 6 when Mobile Crane, Doc 7 when Scaffolding)


Form Edit Permissions

Controls which roles can edit which documents at each state. Defined in getWorkPermitFormEditPermissions().

StateEditable DocumentsEditable ByLock Reason
prepare-prerequisitesDoc 3, 4, 5, 6*Contractor-
review-prereq-by-work-owner(all locked)-เจ้าของงานกำลังตรวจสอบ
review-prereq-by-safety-officer(all locked)-จป. กำลังตรวจสอบรายชื่อ
fill-in-permit-infoPTW forms, Doc 7*ContractorPrerequisites locked (อนุมัติแล้ว)
review-ptw-co-review(all locked)-กำลังตรวจสอบร่วม
work-in-progressDoc 18ContractorPTW locked (กำลังปฏิบัติงาน)
request-extensionPTW formsContractorกรอกคำขอขยายเวลา
review-ext-co-review(all locked)-กำลังตรวจสอบคำขอขยายเวลา
close-ptw-co-review(all locked)-กำลังตรวจสอบการส่งมอบงาน
evaluationDoc 16Work Owner, Safety OfficerDoc 18 locked (ส่งมอบงานแล้ว)
completed(all locked)-เสร็จสิ้นแล้ว

Expected Role per State

Shows which role(s) should be acting at each workflow state. Used for the role indicator badge in the UI. Defined in getWorkPermitExpectedRole().

StateExpected Role(s)Thai
prepare-prerequisitesContractorผู้รับเหมา
review-prereq-by-work-ownerWork Ownerเจ้าของงาน
review-prereq-by-safety-officerSafety Officerจป.
fill-in-permit-infoContractorผู้รับเหมา
review-ptw-co-reviewWork Owner + Safety Officer + Workspace Ownerตรวจสอบร่วม 3 คน
work-in-progressContractorผู้รับเหมา
request-extensionContractorผู้รับเหมา
review-ext-co-reviewWork Owner + Safety Officer + Workspace Ownerตรวจสอบร่วม 3 คน
close-ptw-co-reviewWork Owner + Safety Officer + Workspace Ownerตรวจสอบร่วม 3 คน
evaluationWork Owner + Safety Officerเจ้าของงาน + จป.
completed(terminal)-
cancelled(terminal)-

Five-Part Form Structure

Part 1: ผู้รับเหมากรอก (Contractor Fills In)

Template: Part 1: Contractor.html

SectionFields
PERMIT DETAILSPO No., Contractor, Permit Number, Date Issued, Start/End DateTime, Location
WORKER DETAILS10 rows: Name, Worker ID, Gender, Skillset
WORK DESCRIPTIONTextarea for work procedures
PPECheckboxes (varies by permit type)

Work at Height PPE Examples:

  • สายรัดนิรภัย (Safety Harness)
  • เชือกนิรภัย/สายช่วยชีวิต
  • บันได (Ladder)
  • รอกนิรภัย
  • นั่งร้าน (Scaffold)
  • ราวกันตก (Guard Rail)
  • ตาข่ายนิรภัย (Safety Net)
  • อุปกรณ์ลำเลียงสิ่งของ
  • ป้ายกำหนดเขตอันตราย

Part 2: ตรวจสอบก่อนเริ่มงาน (Client Checklist)

Template: Part 2: Client (Check).html

Checklist items with ถูกต้อง/ไม่ถูกต้อง/หมายเหตุ (Pass/Fail/Remarks)

Work at Height Checklist (9 items):

  1. กำหนดเขตอันตรายที่อาจมีวัตถุตกหล่นและติดป้ายเตือน "พื้นที่อันตราย" ชัดเจน
  2. ตรวจสอบนั่งร้าน ระบุผู้ติดตั้ง/ผู้ควบคุมและความสามารถรับน้ำหนัก
  3. งานที่มีความสูงตั้งแต่ 4 เมตร มีการป้องกันการตกหล่น หรือวัสดุกระเด็น
  4. มีขั้นตอนการปฏิบัติงานและการควบคุมป้องกันอันตรายจากที่สูง
  5. ทำการชี้แจงการปฏิบัติงานและป้องกันอันตรายต่อผู้ปฏิบัติงาน
  6. อุปกรณ์ป้องกันอันตรายที่กำหนด อยู่ในสภาพพร้อมใช้งาน แข็งแรงและปลอดภัย
  7. ผู้ปฏิบัติงานแต่งกายเหมาะสมและสวมใส่ PPE ตลอดระยะเวลา
  8. เครื่องมืออุปกรณ์ที่ใช้มีสภาพปลอดภัยเป็นไปตามมาตรฐาน/กฎหมาย
  9. อื่นๆ ระบุ

Part 3: ลงนามให้ปฏิบัติงาน (Work Authorization)

Template: PART 3: ลงนามให้ปฏิบัติงาน.html

3 inspection phases with 3 signatures each:

PhaseDescriptionPurpose
การตรวจสอบก่อนเริ่มปฏิบัติงานตรวจสอบความปลอดภัยตามรายการที่ระบุข้างต้นจึงอนุญาตให้ปฏิบัติงานได้
การตรวจสอบขณะปฏิบัติงานตรวจสอบความปลอดภัยขณะที่มีการปฏิบัติงานไม่มีสิ่งที่ก่อให้เกิดอันตรายขึ้น
การตรวจสอบหลังปฏิบัติงานตรวจสอบความเรียบร้อยของพื้นที่ที่ปฏิบัติงานมีการจัดเก็บพื้นที่ปฏิบัติงานเรียบร้อย

Signers per phase (3 roles):

  1. ผู้คุมงาน (เจ้าของงาน) / Requester
  2. เจ้าหน้าที่ความปลอดภัยในการทำงาน (จป.)
  3. เจ้าของพื้นที่

Part 4: การขอขยายเวลางาน (Extension Request)

Template: PART 4: การขอขยายเวลางาน (ต่ออายุใบอนุญาต).html

Digital Form: Doc 19 - Extension Request Form (extension-request-form.component.ts)

FieldDescription
ตั้งแต่เวลาOriginal end time
ถึงเวลาNew end time (requested)

4 signatures required:

  1. ผู้ขออนุญาต (ผู้รับเหมา/หัวหน้า)
  2. ผู้คุมงาน (เจ้าของงาน) / Requester
  3. เจ้าหน้าที่ความปลอดภัยในการทำงาน
  4. เจ้าของพื้นที่

Part 5: การปิดใบอนุญาต (Work Completion)

Template: PART 5: การปิดใบอนุญาต (Complete of Working).html

Completion Investigation (6 categories)

CategoryThai NameColumns
General investigationการตรวจโดยการสังเกตทั่วไปPass / Fail / Improve / Fixed
Quantityการตรวจเชิงปริมาณ (ตามที่กำหนด)Pass / Fail / Improve / Fixed
Qualityการตรวจเชิงคุณภาพ (เทียบกับมาตรฐาน ฟังก์ชั่นการทำงาน)Pass / Fail / Improve / Fixed
Safety & Environmentด้านความปลอดภัย และสิ่งแวดล้อมPass / Fail / Improve / Fixed
Cleanliness & ReinstatedความสะอาดคืนสภาพเดิมPass / Fail / Improve / Fixed
System Testingทดสอบระบบเรียบร้อยPass / Fail / Improve / Fixed

Investigation Result

  • รับมอบ / Accepted
  • งานยังไม่สมบูรณ์ / Not Complete
  • ยกเลิกงาน / Rejected

3 signatures required:

  1. ผู้คุมงาน (เจ้าของงาน) / Requester
  2. เจ้าหน้าที่ความปลอดภัยในการทำงาน
  3. เจ้าของพื้นที่

Review Task UI

When viewing a Work Permit task, additional tabs are available:

TabThai NameDescription
งานDocumentsMain form view with permit documents
ข้อมูลโครงการProject InfoLinked project details (PR#, PO#, contractor, roles)
เอกสารเบื้องต้นPrerequisitesPre-requisite documents (Tool List, Manpower, JSA)
NotesNotesTask notes
LogsLogsTransaction history and visualization
WorkflowWorkflowWorkflow state diagram

Checklist Items Per Permit Type

Each permit type has specific checklist items (Part 2) tailored to the type of work:

Permit TypeChecklist Items
General Work (ID 13)7 items: Area inspection, tool safety, electrical isolation, work area barricade, risk assessment, PPE preparation
Work at Height (ID 8)9 items: Hazard zone, scaffold inspection, fall protection, work procedures, PPE condition
Hot Work (ID 11)10 items: Fire monitoring, ventilation, flammable materials, fire extinguisher, communication
Confined Space (ID 12)11 items: Air quality, entry/exit, rescue team, monitoring equipment
Chemical (ID 9)8 items: MSDS, chemical handling, containment, emergency procedures
High Voltage (ID 10)9 items: Power isolation, lockout/tagout, testing equipment
Radiation (ID 14)8 items: Radiation monitoring, shielding, dosimeter, safety equipment
Excavate (ID 15)9 items: Underground utilities, soil stability, cave-in protection
Dynamic Checklists

Checklist items are automatically loaded based on the permit type selected. See permit-type-configs.ts for the full list of items.


Testing Instructions

เข้าถึง Prototype

  1. เข้าสู่ระบบด้วย role ที่เหมาะสม
  2. ไปที่ "งานของฉัน" (My Tasks)
  3. เลือก task ที่เป็น Work Permit

Test Scenarios

  1. Part 1: กรอกข้อมูล, เพิ่ม/ลบรายชื่อผู้ปฏิบัติงาน, เลือก PPE
  2. Part 2: ตรวจสอบ checklist items, กด Submit/Reject
  3. Part 3: ดู 3 phases, จำลองการลงนาม
  4. Part 4: ทดสอบขอขยายเวลา
  5. Part 5: ทดสอบการปิดงาน

สิ่งที่ต้องตรวจสอบ

  • ข้อมูลแสดงผลถูกต้อง
  • Workflow state transitions ทำงานถูกต้อง
  • Form validation ทำงาน
  • การบันทึกข้อมูลสำเร็จ

Feedback

สิ่งที่ต้องการ Feedback

  1. Workflow: ลำดับขั้นตอนเหมาะสมหรือไม่?
  2. Form Fields: ฟิลด์ครบถ้วนตาม template หรือไม่?
  3. Checklist Items: รายการตรวจสอบถูกต้องหรือไม่?
  4. Roles & Signatures: บทบาทผู้ลงนามถูกต้องหรือไม่?
  5. Missing Features: มีอะไรที่ขาดหายไป?

วิธีส่ง Feedback

  • ติดต่อทีมพัฒนาโดยตรง
  • หรือสร้าง Issue ใน GitHub repository

Source Code Reference

All workflow definitions are in the frontend mock file (will be moved to backend when real workflow is implemented):

File: frontend/src/app/shared/mock/work-permit-workflow.mock.ts

ExportDescription
WorkPermitWorkflowStatesState enum (14 states)
WorkPermitWorkflowCommandsCommand enum (18 commands + Cancel)
WORK_PERMIT_COMMAND_CAPTIONSThai labels for commands
WORK_PERMIT_STATE_LABELSThai/English labels for states
getWorkPermitCommands()State → Commands mapping
getWorkPermitDocumentFormIds()State → Documents mapping
getWorkPermitFormEditPermissions()State → Edit permissions mapping
getWorkPermitExpectedRole()State → Expected role mapping

Related Files:

  • frontend/src/app/shared/enums/document-forms.ts - Document form IDs (1-22)
  • frontend/src/app/shared/mock/mock-work-permit-task.data.ts - Mock task data using the mappings
  • frontend/src/app/shared/config/workflow-state-metadata.config.ts - State metadata for UI