From 00b8995f8452f2eaa5885828164e122f9296503d Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 1 Dec 2025 17:00:32 +0700 Subject: [PATCH] 251201:1700 Prepare to version 1.5 use spec-kit --- .gemini/settings.json | 9 +- .prettierrc | 12 + .vscode/extensions.json | 58 +- .vscode/extensions.json.bak | 59 + .vscode/settings.json | 560 +-- .vscode/settings.json.bak | 559 +++ .vscode/{tasks.json => tasks.json.bak} | 0 backend/.prettierrc | 10 +- docs/8_lcbp3_v1_4_5.sql | 16 - docs/8_lcbp3_v1_4_5_seed.sql | 4010 +++++++++-------- frontend/tsconfig.json | 5 +- ...bp3.code-workspace => lcbp3.code-workspace | 167 +- .../03.11-document-numbering.md | 13 +- 13 files changed, 2788 insertions(+), 2690 deletions(-) create mode 100644 .prettierrc create mode 100644 .vscode/extensions.json.bak create mode 100644 .vscode/settings.json.bak rename .vscode/{tasks.json => tasks.json.bak} (100%) rename nap-dms.lcbp3.code-workspace => lcbp3.code-workspace (83%) diff --git a/.gemini/settings.json b/.gemini/settings.json index 2d44ff6..2085f97 100644 --- a/.gemini/settings.json +++ b/.gemini/settings.json @@ -1,8 +1,15 @@ { "general": { - "previewFeatures": true + "previewFeatures": true, + "enablePromptCompletion": true }, "ide": { "enabled": true + }, + "output": { + "format": "json" + }, + "ui": { + "showStatusInTitle": true } } \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..be625ad --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "singleQuote": true, + "semi": true, + "tabWidth": 2, + "useTabs": false, + "trailingComma": "es5", + "printWidth": 80, + "arrowParens": "always", + "endOfLine": "lf", + "bracketSpacing": true, + "jsxSingleQuote": false +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c461831..ef01b18 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,59 +1,3 @@ { - "recommendations": [ - // Linting & Formatting - "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode", - - // Code Quality & Error Handling - "usernamehw.errorlens", - "yoavbls.pretty-typescript-errors", - "aaron-bond.better-comments", - "gruntfuggly.todo-tree", - - // Framework & Language Support - "ashinzekene.nestjs", - "dsznajder.es7-react-js-snippets", - "orta.vscode-jest", - "bradlc.vscode-tailwindcss", - "heybourn.headwind", - "prisma.prisma", - - // API Testing - "rangav.vscode-thunder-client", - "formulahendry.auto-close-tag", - "formulahendry.auto-rename-tag", - - // Docker & DevOps - "ms-azuretools.vscode-docker", - "mtxr.sqltools", - "redhat.vscode-yaml", - "mikestead.dotenv", - "editorconfig.editorconfig", - - // Git - "eamodio.gitlens", - "mhutchie.git-graph", - "vivaxy.vscode-conventional-commits", - - // Path & Navigation - "christian-kohler.path-intellisense", - "christian-kohler.npm-intellisense", - "csstools.postcss", - - // CSS Enhancement - "pranaygp.vscode-css-peek", - - // Productivity - "alefragnani.bookmarks", - "chakrounanas.turbo-console-log", - "wallabyjs.console-ninja", - - // Icons & Theme - "pkief.material-icon-theme", - "bierner.markdown-mermaid" - - // AI Assistance (Optional - เลือก 1 อัน) - // "github.copilot", - // "tabnine.tabnine-vscode" - ] + "recommendations": ["ms-vscode.powershell"] } diff --git a/.vscode/extensions.json.bak b/.vscode/extensions.json.bak new file mode 100644 index 0000000..c461831 --- /dev/null +++ b/.vscode/extensions.json.bak @@ -0,0 +1,59 @@ +{ + "recommendations": [ + // Linting & Formatting + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + + // Code Quality & Error Handling + "usernamehw.errorlens", + "yoavbls.pretty-typescript-errors", + "aaron-bond.better-comments", + "gruntfuggly.todo-tree", + + // Framework & Language Support + "ashinzekene.nestjs", + "dsznajder.es7-react-js-snippets", + "orta.vscode-jest", + "bradlc.vscode-tailwindcss", + "heybourn.headwind", + "prisma.prisma", + + // API Testing + "rangav.vscode-thunder-client", + "formulahendry.auto-close-tag", + "formulahendry.auto-rename-tag", + + // Docker & DevOps + "ms-azuretools.vscode-docker", + "mtxr.sqltools", + "redhat.vscode-yaml", + "mikestead.dotenv", + "editorconfig.editorconfig", + + // Git + "eamodio.gitlens", + "mhutchie.git-graph", + "vivaxy.vscode-conventional-commits", + + // Path & Navigation + "christian-kohler.path-intellisense", + "christian-kohler.npm-intellisense", + "csstools.postcss", + + // CSS Enhancement + "pranaygp.vscode-css-peek", + + // Productivity + "alefragnani.bookmarks", + "chakrounanas.turbo-console-log", + "wallabyjs.console-ninja", + + // Icons & Theme + "pkief.material-icon-theme", + "bierner.markdown-mermaid" + + // AI Assistance (Optional - เลือก 1 อัน) + // "github.copilot", + // "tabnine.tabnine-vscode" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 807e69b..31c4986 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,559 +1,3 @@ { - // ======================================== - // EDITOR SETTINGS - // ======================================== - - // ขนาดตัวอักษรในโค้ด - "editor.fontSize": 14, - - // ความสูงของแต่ละบรรทัด - "editor.lineHeight": 1.6, - - // แสดงเส้นแนวตั้งที่ตำแหน่งตัวอักษรที่ 80 และ 120 - "editor.rulers": [80, 120], - - // เปิดใช้ minimap ขวามือ - "editor.minimap.enabled": true, - - // แสดงช่องว่างและ tab เป็นจุดและเส้น - "editor.renderWhitespace": "boundary", - - // เปิดใช้ bracket pair colorization - "editor.bracketPairColorization.enabled": true, - - // แสดงเส้นเชื่อม brackets - "editor.guides.bracketPairs": "active", - - // smooth scrolling - "editor.smoothScrolling": true, - - // cursor animation - "editor.cursorBlinking": "smooth", - "editor.cursorSmoothCaretAnimation": "on", - - // แสดง breadcrumb ด้านบน - "breadcrumbs.enabled": true, - - // word wrap ที่ขอบหน้าต่าง - "editor.wordWrap": "on", - - // ======================================== - // FORMAT ON SAVE - // ======================================== - - // format โค้ดอัตโนมัติเมื่อ save - "editor.formatOnSave": true, - - // format โค้ดเมื่อ paste - "editor.formatOnPaste": true, - - // ใช้ Prettier เป็น default formatter - "editor.defaultFormatter": "esbenp.prettier-vscode", - - // กำหนด formatter เฉพาะแต่ละภาษา - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[html]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[css]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[scss]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[markdown]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - - // ======================================== - // CODE ACTION ON SAVE - // ======================================== - - // รัน ESLint fix และจัดเรียง imports เมื่อ save - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit", - "source.organizeImports": "explicit", - "source.addMissingImports": "explicit" - }, - - // ======================================== - // PRETTIER SETTINGS - // ======================================== - - // ใช้ single quotes แทน double quotes - "prettier.singleQuote": true, - - // ใช้ semicolons ท้ายบรรทัด - "prettier.semi": true, - - // ความกว้างของ tab เป็น 2 spaces - "prettier.tabWidth": 2, - - // ใช้ spaces แทน tabs - "prettier.useTabs": false, - - // ใส่ trailing comma ใน ES5 (objects, arrays, etc.) - "prettier.trailingComma": "es5", - - // ความกว้างสูงสุดก่อนขึ้นบรรทัดใหม่ - "prettier.printWidth": 80, - - // ใส่ comma ท้ายสุดใน multiline - "prettier.arrowParens": "always", - - // ใช้ LF (Line Feed) แทน CRLF - "prettier.endOfLine": "lf", - - // ======================================== - // ESLINT SETTINGS - // ======================================== - - // เปิดใช้ ESLint - "eslint.enable": true, - - // รัน ESLint บนไฟล์เหล่านี้ - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact" - ], - - // แสดง ESLint status ใน status bar - "eslint.alwaysShowStatus": true, - - // ======================================== - // ERROR LENS SETTINGS - // ======================================== - - // เปิดใช้ Error Lens - "errorLens.enabled": true, - - // แสดง errors, warnings, และ info - "errorLens.enabledDiagnosticLevels": [ - "error", - "warning", - "info" - ], - - // ระยะห่างของข้อความจากโค้ด - "errorLens.padding": "0 1ch", - - // ตำแหน่งข้อความ error - "errorLens.messageTemplate": "$message", - - // แสดง error ท้ายบรรทัด - "errorLens.messageEnabled": true, - - // ======================================== - // TAILWIND CSS SETTINGS - // ======================================== - - // เปิดใช้ IntelliSense สำหรับ Tailwind - "tailwindCSS.emmetCompletions": true, - - // แสดง color preview - "tailwindCSS.colorDecorators": true, - - // เปิดใช้ suggestions - "tailwindCSS.suggestions": true, - - // ไฟล์ที่จะใช้ Tailwind IntelliSense - "tailwindCSS.includeLanguages": { - "typescript": "javascript", - "typescriptreact": "javascript" - }, - - // ======================================== - // HEADWIND (Tailwind Class Sorter) - // ======================================== - - // รัน Headwind เมื่อ save - "headwind.runOnSave": true, - - // ======================================== - // AUTO CLOSE/RENAME TAG - // ======================================== - - // เปิดใช้ auto close tag - "auto-close-tag.activationOnLanguage": [ - "html", - "xml", - "php", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact" - ], - - // เปิดใช้ auto rename tag - "auto-rename-tag.activationOnLanguage": [ - "html", - "xml", - "php", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact" - ], - - // ======================================== - // BETTER COMMENTS - // ======================================== - - // กำหนดสีและรูปแบบของ comments - "better-comments.tags": [ - { - "tag": "!", - "color": "#FF2D00", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "?", - "color": "#3498DB", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "//", - "color": "#474747", - "strikethrough": true, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "todo", - "color": "#FF8C00", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - }, - { - "tag": "*", - "color": "#98C379", - "strikethrough": false, - "underline": false, - "backgroundColor": "transparent", - "bold": false, - "italic": false - } - ], - - // ======================================== - // TODO TREE - // ======================================== - - // keywords ที่จะ highlight - "todo-tree.general.tags": [ - "TODO", - "FIXME", - "BUG", - "HACK", - "NOTE", - "XXX" - ], - - // highlight TODO ในโค้ด - "todo-tree.highlights.enabled": true, - - // แสดง TODO tree ใน activity bar - "todo-tree.tree.showInExplorer": false, - - // กำหนดสีของแต่ละ tag - "todo-tree.highlights.defaultHighlight": { - "foreground": "black", - "type": "text", - "opacity": 50 - }, - - "todo-tree.highlights.customHighlight": { - "TODO": { - "icon": "check", - "iconColour": "#FF8C00", - "foreground": "#FF8C00" - }, - "FIXME": { - "icon": "alert", - "iconColour": "#FF2D00", - "foreground": "#FF2D00" - }, - "BUG": { - "icon": "bug", - "iconColour": "#FF2D00", - "foreground": "#FF2D00" - }, - "NOTE": { - "icon": "note", - "iconColour": "#3498DB", - "foreground": "#3498DB" - } - }, - - // ======================================== - // GITLENS SETTINGS - // ======================================== - - // แสดง Git blame ใน status bar - "gitlens.statusBar.enabled": true, - - // แสดง current line blame - "gitlens.currentLine.enabled": true, - - // format ของ current line blame - "gitlens.currentLine.format": "${author}, ${agoOrDate}", - - // แสดง codelens (ข้อมูล Git เหนือฟังก์ชัน) - "gitlens.codeLens.enabled": true, - - // แสดง blame annotations - "gitlens.hovers.enabled": true, - - // ======================================== - // GIT SETTINGS - // ======================================== - - // เปิดใช้ Git - "git.enabled": true, - - // auto fetch ทุก 180 วินาที - "git.autofetch": true, - "git.autofetchPeriod": 180, - - // ยืนยันก่อน sync - "git.confirmSync": false, - - // enable smart commit - "git.enableSmartCommit": true, - - // ======================================== - // PATH INTELLISENSE - // ======================================== - - // mappings สำหรับ path aliases - "path-intellisense.mappings": { - "@": "${workspaceFolder}/src" - }, - - // ======================================== - // IMPORT COST - // ======================================== - - // แสดงขนาดของ imports - "importCost.showCalculatingDecoration": true, - - // เตือนเมื่อ import ใหญ่เกิน - "importCost.largePackageSize": 100, - "importCost.mediumPackageSize": 50, - "importCost.smallPackageSize": 20, - - // ======================================== - // JAVASCRIPT/TYPESCRIPT - // ======================================== - - // auto imports - "javascript.suggest.autoImports": true, - "typescript.suggest.autoImports": true, - - // update imports on file move - "javascript.updateImportsOnFileMove.enabled": "always", - "typescript.updateImportsOnFileMove.enabled": "always", - - // inlay hints - "javascript.inlayHints.parameterNames.enabled": "all", - "typescript.inlayHints.parameterNames.enabled": "all", - "javascript.inlayHints.functionLikeReturnTypes.enabled": true, - "typescript.inlayHints.functionLikeReturnTypes.enabled": true, - - // ======================================== - // EMMET - // ======================================== - - // เปิดใช้ Emmet - "emmet.includeLanguages": { - "javascript": "javascriptreact", - "typescript": "typescriptreact" - }, - - // trigger Emmet ด้วย Tab - "emmet.triggerExpansionOnTab": true, - - // ======================================== - // FILES - // ======================================== - - // auto save - "files.autoSave": "onFocusChange", - - // ลบ whitespace ท้ายบรรทัดเมื่อ save - "files.trimTrailingWhitespace": true, - - // เพิ่มบรรทัดว่างท้ายไฟล์ - "files.insertFinalNewline": true, - - // encoding - "files.encoding": "utf8", - - // line ending - "files.eol": "\n", - - // exclude files/folders จาก explorer - "files.exclude": { - "**/.git": true, - "**/.DS_Store": true, - "**/node_modules": true, - "**/.next": true, - "**/dist": true, - "**/build": true, - "**/.turbo": true - }, - - // ======================================== - // SEARCH - // ======================================== - - // exclude files/folders จากการค้นหา - "search.exclude": { - "**/node_modules": true, - "**/dist": true, - "**/build": true, - "**/.next": true, - "**/.turbo": true, - "**/coverage": true, - "**/.git": true, - "**/yarn.lock": true, - "**/package-lock.json": true, - "**/pnpm-lock.yaml": true - }, - - // ======================================== - // TERMINAL - // ======================================== - - // font size ใน terminal - "terminal.integrated.fontSize": 13, - - // line height ใน terminal - "terminal.integrated.lineHeight": 1.2, - - // smooth scrolling - "terminal.integrated.smoothScrolling": true, - - // ======================================== - // WORKBENCH - // ======================================== - - // icon theme - "workbench.iconTheme": "material-icon-theme", - - // color theme (เลือกตามชอบ) - // "workbench.colorTheme": "One Dark Pro", - - // แสดง activity bar - "workbench.activityBar.location": "default", - - // tree indent - "workbench.tree.indent": 15, - - // smooth scrolling - "workbench.list.smoothScrolling": true, - - // ======================================== - // EXPLORER - // ======================================== - - // compact folders - "explorer.compactFolders": false, - - // confirm before delete - "explorer.confirmDelete": true, - - // confirm drag and drop - "explorer.confirmDragAndDrop": false, - - // ======================================== - // JEST - // ======================================== - - // auto run tests - "jest.autoRun": "off", - - // แสดง coverage overlay - "jest.showCoverageOnLoad": false, - - // ======================================== - // DOCKER - // ======================================== - - // format docker files - "docker.languageserver.formatter.ignoreMultilineInstructions": true, - - // ======================================== - // YAML - // ======================================== - - // schemas สำหรับ YAML validation - "yaml.schemas": { - "https://json.schemastore.org/github-workflow.json": ".github/workflows/*.{yml,yaml}", - "https://json.schemastore.org/github-action.json": "action.{yml,yaml}", - "https://json.schemastore.org/prettierrc.json": ".prettierrc.{yml,yaml}" - }, - - // format YAML files - "yaml.format.enable": true, - - // ======================================== - // CONSOLE NINJA - // ======================================== - - // เปิดใช้ Console Ninja - "console-ninja.featureSet": "Community", - - // ======================================== - // REST CLIENT - // ======================================== - - // timeout สำหรับ HTTP requests (milliseconds) - "rest-client.timeoutinmilliseconds": 30000, - - // แสดงเวลาที่ใช้ในการ request - "rest-client.showResponseInDifferentTab": true, - - // ======================================== - // SECURITY - // ======================================== - - // trust workspace - "security.workspace.trust.untrustedFiles": "open", - - // ======================================== - // PERFORMANCE - // ======================================== - - // จำกัดจำนวนไฟล์ที่เปิดพร้อมกัน - "files.maxMemoryForLargeFilesMB": 4096, - - // ปิด crash reporter - "telemetry.telemetryLevel": "off" -} \ No newline at end of file + "terminal.integrated.cwd": "\"cwd\": \"D:\\\\nap-dms.lcbp3\\\\frontend\"" +} diff --git a/.vscode/settings.json.bak b/.vscode/settings.json.bak new file mode 100644 index 0000000..807e69b --- /dev/null +++ b/.vscode/settings.json.bak @@ -0,0 +1,559 @@ +{ + // ======================================== + // EDITOR SETTINGS + // ======================================== + + // ขนาดตัวอักษรในโค้ด + "editor.fontSize": 14, + + // ความสูงของแต่ละบรรทัด + "editor.lineHeight": 1.6, + + // แสดงเส้นแนวตั้งที่ตำแหน่งตัวอักษรที่ 80 และ 120 + "editor.rulers": [80, 120], + + // เปิดใช้ minimap ขวามือ + "editor.minimap.enabled": true, + + // แสดงช่องว่างและ tab เป็นจุดและเส้น + "editor.renderWhitespace": "boundary", + + // เปิดใช้ bracket pair colorization + "editor.bracketPairColorization.enabled": true, + + // แสดงเส้นเชื่อม brackets + "editor.guides.bracketPairs": "active", + + // smooth scrolling + "editor.smoothScrolling": true, + + // cursor animation + "editor.cursorBlinking": "smooth", + "editor.cursorSmoothCaretAnimation": "on", + + // แสดง breadcrumb ด้านบน + "breadcrumbs.enabled": true, + + // word wrap ที่ขอบหน้าต่าง + "editor.wordWrap": "on", + + // ======================================== + // FORMAT ON SAVE + // ======================================== + + // format โค้ดอัตโนมัติเมื่อ save + "editor.formatOnSave": true, + + // format โค้ดเมื่อ paste + "editor.formatOnPaste": true, + + // ใช้ Prettier เป็น default formatter + "editor.defaultFormatter": "esbenp.prettier-vscode", + + // กำหนด formatter เฉพาะแต่ละภาษา + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[scss]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[markdown]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + + // ======================================== + // CODE ACTION ON SAVE + // ======================================== + + // รัน ESLint fix และจัดเรียง imports เมื่อ save + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.organizeImports": "explicit", + "source.addMissingImports": "explicit" + }, + + // ======================================== + // PRETTIER SETTINGS + // ======================================== + + // ใช้ single quotes แทน double quotes + "prettier.singleQuote": true, + + // ใช้ semicolons ท้ายบรรทัด + "prettier.semi": true, + + // ความกว้างของ tab เป็น 2 spaces + "prettier.tabWidth": 2, + + // ใช้ spaces แทน tabs + "prettier.useTabs": false, + + // ใส่ trailing comma ใน ES5 (objects, arrays, etc.) + "prettier.trailingComma": "es5", + + // ความกว้างสูงสุดก่อนขึ้นบรรทัดใหม่ + "prettier.printWidth": 80, + + // ใส่ comma ท้ายสุดใน multiline + "prettier.arrowParens": "always", + + // ใช้ LF (Line Feed) แทน CRLF + "prettier.endOfLine": "lf", + + // ======================================== + // ESLINT SETTINGS + // ======================================== + + // เปิดใช้ ESLint + "eslint.enable": true, + + // รัน ESLint บนไฟล์เหล่านี้ + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + + // แสดง ESLint status ใน status bar + "eslint.alwaysShowStatus": true, + + // ======================================== + // ERROR LENS SETTINGS + // ======================================== + + // เปิดใช้ Error Lens + "errorLens.enabled": true, + + // แสดง errors, warnings, และ info + "errorLens.enabledDiagnosticLevels": [ + "error", + "warning", + "info" + ], + + // ระยะห่างของข้อความจากโค้ด + "errorLens.padding": "0 1ch", + + // ตำแหน่งข้อความ error + "errorLens.messageTemplate": "$message", + + // แสดง error ท้ายบรรทัด + "errorLens.messageEnabled": true, + + // ======================================== + // TAILWIND CSS SETTINGS + // ======================================== + + // เปิดใช้ IntelliSense สำหรับ Tailwind + "tailwindCSS.emmetCompletions": true, + + // แสดง color preview + "tailwindCSS.colorDecorators": true, + + // เปิดใช้ suggestions + "tailwindCSS.suggestions": true, + + // ไฟล์ที่จะใช้ Tailwind IntelliSense + "tailwindCSS.includeLanguages": { + "typescript": "javascript", + "typescriptreact": "javascript" + }, + + // ======================================== + // HEADWIND (Tailwind Class Sorter) + // ======================================== + + // รัน Headwind เมื่อ save + "headwind.runOnSave": true, + + // ======================================== + // AUTO CLOSE/RENAME TAG + // ======================================== + + // เปิดใช้ auto close tag + "auto-close-tag.activationOnLanguage": [ + "html", + "xml", + "php", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + + // เปิดใช้ auto rename tag + "auto-rename-tag.activationOnLanguage": [ + "html", + "xml", + "php", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + + // ======================================== + // BETTER COMMENTS + // ======================================== + + // กำหนดสีและรูปแบบของ comments + "better-comments.tags": [ + { + "tag": "!", + "color": "#FF2D00", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "?", + "color": "#3498DB", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "//", + "color": "#474747", + "strikethrough": true, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "todo", + "color": "#FF8C00", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "*", + "color": "#98C379", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + } + ], + + // ======================================== + // TODO TREE + // ======================================== + + // keywords ที่จะ highlight + "todo-tree.general.tags": [ + "TODO", + "FIXME", + "BUG", + "HACK", + "NOTE", + "XXX" + ], + + // highlight TODO ในโค้ด + "todo-tree.highlights.enabled": true, + + // แสดง TODO tree ใน activity bar + "todo-tree.tree.showInExplorer": false, + + // กำหนดสีของแต่ละ tag + "todo-tree.highlights.defaultHighlight": { + "foreground": "black", + "type": "text", + "opacity": 50 + }, + + "todo-tree.highlights.customHighlight": { + "TODO": { + "icon": "check", + "iconColour": "#FF8C00", + "foreground": "#FF8C00" + }, + "FIXME": { + "icon": "alert", + "iconColour": "#FF2D00", + "foreground": "#FF2D00" + }, + "BUG": { + "icon": "bug", + "iconColour": "#FF2D00", + "foreground": "#FF2D00" + }, + "NOTE": { + "icon": "note", + "iconColour": "#3498DB", + "foreground": "#3498DB" + } + }, + + // ======================================== + // GITLENS SETTINGS + // ======================================== + + // แสดง Git blame ใน status bar + "gitlens.statusBar.enabled": true, + + // แสดง current line blame + "gitlens.currentLine.enabled": true, + + // format ของ current line blame + "gitlens.currentLine.format": "${author}, ${agoOrDate}", + + // แสดง codelens (ข้อมูล Git เหนือฟังก์ชัน) + "gitlens.codeLens.enabled": true, + + // แสดง blame annotations + "gitlens.hovers.enabled": true, + + // ======================================== + // GIT SETTINGS + // ======================================== + + // เปิดใช้ Git + "git.enabled": true, + + // auto fetch ทุก 180 วินาที + "git.autofetch": true, + "git.autofetchPeriod": 180, + + // ยืนยันก่อน sync + "git.confirmSync": false, + + // enable smart commit + "git.enableSmartCommit": true, + + // ======================================== + // PATH INTELLISENSE + // ======================================== + + // mappings สำหรับ path aliases + "path-intellisense.mappings": { + "@": "${workspaceFolder}/src" + }, + + // ======================================== + // IMPORT COST + // ======================================== + + // แสดงขนาดของ imports + "importCost.showCalculatingDecoration": true, + + // เตือนเมื่อ import ใหญ่เกิน + "importCost.largePackageSize": 100, + "importCost.mediumPackageSize": 50, + "importCost.smallPackageSize": 20, + + // ======================================== + // JAVASCRIPT/TYPESCRIPT + // ======================================== + + // auto imports + "javascript.suggest.autoImports": true, + "typescript.suggest.autoImports": true, + + // update imports on file move + "javascript.updateImportsOnFileMove.enabled": "always", + "typescript.updateImportsOnFileMove.enabled": "always", + + // inlay hints + "javascript.inlayHints.parameterNames.enabled": "all", + "typescript.inlayHints.parameterNames.enabled": "all", + "javascript.inlayHints.functionLikeReturnTypes.enabled": true, + "typescript.inlayHints.functionLikeReturnTypes.enabled": true, + + // ======================================== + // EMMET + // ======================================== + + // เปิดใช้ Emmet + "emmet.includeLanguages": { + "javascript": "javascriptreact", + "typescript": "typescriptreact" + }, + + // trigger Emmet ด้วย Tab + "emmet.triggerExpansionOnTab": true, + + // ======================================== + // FILES + // ======================================== + + // auto save + "files.autoSave": "onFocusChange", + + // ลบ whitespace ท้ายบรรทัดเมื่อ save + "files.trimTrailingWhitespace": true, + + // เพิ่มบรรทัดว่างท้ายไฟล์ + "files.insertFinalNewline": true, + + // encoding + "files.encoding": "utf8", + + // line ending + "files.eol": "\n", + + // exclude files/folders จาก explorer + "files.exclude": { + "**/.git": true, + "**/.DS_Store": true, + "**/node_modules": true, + "**/.next": true, + "**/dist": true, + "**/build": true, + "**/.turbo": true + }, + + // ======================================== + // SEARCH + // ======================================== + + // exclude files/folders จากการค้นหา + "search.exclude": { + "**/node_modules": true, + "**/dist": true, + "**/build": true, + "**/.next": true, + "**/.turbo": true, + "**/coverage": true, + "**/.git": true, + "**/yarn.lock": true, + "**/package-lock.json": true, + "**/pnpm-lock.yaml": true + }, + + // ======================================== + // TERMINAL + // ======================================== + + // font size ใน terminal + "terminal.integrated.fontSize": 13, + + // line height ใน terminal + "terminal.integrated.lineHeight": 1.2, + + // smooth scrolling + "terminal.integrated.smoothScrolling": true, + + // ======================================== + // WORKBENCH + // ======================================== + + // icon theme + "workbench.iconTheme": "material-icon-theme", + + // color theme (เลือกตามชอบ) + // "workbench.colorTheme": "One Dark Pro", + + // แสดง activity bar + "workbench.activityBar.location": "default", + + // tree indent + "workbench.tree.indent": 15, + + // smooth scrolling + "workbench.list.smoothScrolling": true, + + // ======================================== + // EXPLORER + // ======================================== + + // compact folders + "explorer.compactFolders": false, + + // confirm before delete + "explorer.confirmDelete": true, + + // confirm drag and drop + "explorer.confirmDragAndDrop": false, + + // ======================================== + // JEST + // ======================================== + + // auto run tests + "jest.autoRun": "off", + + // แสดง coverage overlay + "jest.showCoverageOnLoad": false, + + // ======================================== + // DOCKER + // ======================================== + + // format docker files + "docker.languageserver.formatter.ignoreMultilineInstructions": true, + + // ======================================== + // YAML + // ======================================== + + // schemas สำหรับ YAML validation + "yaml.schemas": { + "https://json.schemastore.org/github-workflow.json": ".github/workflows/*.{yml,yaml}", + "https://json.schemastore.org/github-action.json": "action.{yml,yaml}", + "https://json.schemastore.org/prettierrc.json": ".prettierrc.{yml,yaml}" + }, + + // format YAML files + "yaml.format.enable": true, + + // ======================================== + // CONSOLE NINJA + // ======================================== + + // เปิดใช้ Console Ninja + "console-ninja.featureSet": "Community", + + // ======================================== + // REST CLIENT + // ======================================== + + // timeout สำหรับ HTTP requests (milliseconds) + "rest-client.timeoutinmilliseconds": 30000, + + // แสดงเวลาที่ใช้ในการ request + "rest-client.showResponseInDifferentTab": true, + + // ======================================== + // SECURITY + // ======================================== + + // trust workspace + "security.workspace.trust.untrustedFiles": "open", + + // ======================================== + // PERFORMANCE + // ======================================== + + // จำกัดจำนวนไฟล์ที่เปิดพร้อมกัน + "files.maxMemoryForLargeFilesMB": 4096, + + // ปิด crash reporter + "telemetry.telemetryLevel": "off" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json.bak similarity index 100% rename from .vscode/tasks.json rename to .vscode/tasks.json.bak diff --git a/backend/.prettierrc b/backend/.prettierrc index a20502b..be625ad 100644 --- a/backend/.prettierrc +++ b/backend/.prettierrc @@ -1,4 +1,12 @@ { "singleQuote": true, - "trailingComma": "all" + "semi": true, + "tabWidth": 2, + "useTabs": false, + "trailingComma": "es5", + "printWidth": 80, + "arrowParens": "always", + "endOfLine": "lf", + "bracketSpacing": true, + "jsxSingleQuote": false } diff --git a/docs/8_lcbp3_v1_4_5.sql b/docs/8_lcbp3_v1_4_5.sql index 9adfc8c..646608d 100644 --- a/docs/8_lcbp3_v1_4_5.sql +++ b/docs/8_lcbp3_v1_4_5.sql @@ -280,17 +280,6 @@ CREATE TABLE correspondence_types ( sort_order INT DEFAULT 0 COMMENT 'ลำดับการแสดงผล', is_active TINYINT(1) DEFAULT 1 COMMENT 'สถานะการใช้งาน ' ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'ตาราง Master เก็บประเภทเอกสารโต้ตอบ'; -INSERT INTO correspondence_types (type_code, type_name, sort_order, is_active) -VALUES ('RFA', 'Request for Approval', 1, 1), - ('RFI', 'Request for Information', 2, 1), - ('TRANSMITTAL', 'Transmittal', 3, 1), - ('EMAIL', 'Email', 4, 1), - ('INSTRUCTION', 'Instruction', 5, 1), - ('LETTER', 'Letter', 6, 1), - ('MEMO', 'Memorandum', 7, 1), - ('MOM', 'Minutes of Meeting', 8, 1), - ('NOTICE', 'Notice', 9, 1), - ('OTHER', 'Other', 10, 1); -- ตาราง Master เก็บสถานะของเอกสาร CREATE TABLE correspondence_status ( id INT PRIMARY KEY AUTO_INCREMENT COMMENT 'ID ของตาราง', @@ -650,11 +639,6 @@ CREATE TABLE circulation_status_codes ( sort_order INT DEFAULT 0 COMMENT 'ลำดับการแสดงผล', is_active TINYINT(1) DEFAULT 1 COMMENT 'สถานะการใช้งาน ' ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'ตาราง Master เก็บสถานะใบเวียน'; -INSERT INTO circulation_status_codes (code, description, sort_order) -VALUES ('OPEN', 'Open', 1), - ('IN_REVIEW', 'In Review', 2), - ('COMPLETED', 'ปCompleted', 3), - ('CANCELLED', 'Cancelled / Withdrawn', 9); -- ตาราง "แม่" ของใบเวียนเอกสารภายใน CREATE TABLE circulations ( id INT PRIMARY KEY AUTO_INCREMENT COMMENT 'ID ของตารางใบเวียน', diff --git a/docs/8_lcbp3_v1_4_5_seed.sql b/docs/8_lcbp3_v1_4_5_seed.sql index 4eaf83c..5eef44a 100644 --- a/docs/8_lcbp3_v1_4_5_seed.sql +++ b/docs/8_lcbp3_v1_4_5_seed.sql @@ -3,445 +3,449 @@ -- Deploy Seed Data -- ========================================================== -- Seed organization -INSERT INTO organizations (id, organization_code, organization_name) -VALUES (1, 'กทท.', 'การท่าเรือแห่งประเทศไทย'), - ( - 10, - 'สคฉ.3', - 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3' - ), - ( - 11, - 'สคฉ.3-01', - 'ตรวจรับพัสดุ ที่ปรึกษาควบคุมงาน' - ), - (12, 'สคฉ.3-02', 'ตรวจรับพัสดุ งานทางทะเล'), - ( - 13, - 'สคฉ.3-03', - 'ตรวจรับพัสดุ อาคารและระบบสาธารณูปโภค' - ), - ( - 14, - 'สคฉ.3-04', - 'ตรวจรับพัสดุ ตรวจสอบผลกระทบสิ่งแวดล้อม' - ), - (15, 'สคฉ.3-05', 'ตรวจรับพัสดุ เยียวยาการประมง'), - ( - 16, - 'สคฉ.3-06', - 'ตรวจรับพัสดุ งานก่อสร้าง ส่วนที่ 3' - ), - ( - 17, - 'สคฉ.3-07', - 'ตรวจรับพัสดุ งานก่อสร้าง ส่วนที่ 4' - ), - ( - 18, - 'สคฉ.3-xx', - 'ตรวจรับพัสดุ ที่ปรึกษาออกแบบ ส่วนที่ 4' - ), - (21, 'TEAM', 'Designer Consulting Ltd.'), - (22, 'คคง.', 'Construction Supervision Ltd.'), - (41, 'ผรม.1', 'Contractor งานทางทะเล'), - (42, 'ผรม.2', 'Contractor อาคารและระบบ'), - (43, 'ผรม.3', 'Contractor #3 Ltd.'), - (44, 'ผรม.4', 'Contractor #4 Ltd.'), - (31, 'EN', 'Third Party Environment'), - (32, 'CAR', 'Third Party Fishery Care'); +insert into organizations (id, organization_code, organization_name) +values (1, 'กทท.', 'การท่าเรือแห่งประเทศไทย'), + ( + 10, + 'สคฉ.3', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3' + ), + ( + 11, + 'สคฉ.3-01', + 'ตรวจรับพัสดุ ที่ปรึกษาควบคุมงาน' + ), + (12, 'สคฉ.3-02', 'ตรวจรับพัสดุ งานทางทะเล'), + ( + 13, + 'สคฉ.3-03', + 'ตรวจรับพัสดุ อาคารและระบบสาธารณูปโภค' + ), + ( + 14, + 'สคฉ.3-04', + 'ตรวจรับพัสดุ ตรวจสอบผลกระทบสิ่งแวดล้อม' + ), + (15, 'สคฉ.3-05', 'ตรวจรับพัสดุ เยียวยาการประมง'), + ( + 16, + 'สคฉ.3-06', + 'ตรวจรับพัสดุ งานก่อสร้าง ส่วนที่ 3' + ), + ( + 17, + 'สคฉ.3-07', + 'ตรวจรับพัสดุ งานก่อสร้าง ส่วนที่ 4' + ), + ( + 18, + 'สคฉ.3-xx', + 'ตรวจรับพัสดุ ที่ปรึกษาออกแบบ ส่วนที่ 4' + ), + (21, 'TEAM', 'Designer Consulting Ltd.'), + (22, 'คคง.', 'Construction Supervision Ltd.'), + (41, 'ผรม.1', 'Contractor งานทางทะเล'), + (42, 'ผรม.2', 'Contractor อาคารและระบบ'), + (43, 'ผรม.3', 'Contractor #3 Ltd.'), + (44, 'ผรม.4', 'Contractor #4 Ltd.'), + (31, 'EN', 'Third Party Environment'), + (32, 'CAR', 'Third Party Fishery Care'); -- Seed project -INSERT INTO projects (project_code, project_name) -VALUES ( - 'LCBP3', - 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)' - ), - ( - 'LCBP3C1', - 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1) งานก่อสร้างงานทางทะเล' - ), - ( - 'LCBP3C2', - 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 2) งานก่อสร้างอาคาร ท่าเทียบเรือ ระบบถนน และระบบสาธารณูปโภค' - ), - ( - 'LCBP3C3', - 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 3) งานก่อสร้าง' - ), - ( - 'LCBP3C4', - 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 4) งานก่อสร้าง' - ); +insert into projects (project_code, project_name) +values ( + 'LCBP3', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)' + ), + ( + 'LCBP3-C1', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1) งานก่อสร้างงานทางทะเล' + ), + ( + 'LCBP3-C2', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 2) งานก่อสร้างอาคาร ท่าเทียบเรือ ระบบถนน และระบบสาธารณูปโภค' + ), + ( + 'LCBP3-C3', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 3) งานก่อสร้าง' + ), + ( + 'LCBP3-C4', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 4) งานก่อสร้าง' + ), + ( + 'LCBP3-EN', + 'โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 4) งานก่อสร้าง' + ); -- Seed contract -- ใช้ Subquery เพื่อดึง project_id มาเชื่อมโยง ทำให้ไม่ต้องมานั่งจัดการ ID ด้วยตัวเอง -INSERT INTO contracts ( - contract_code, - contract_name, - project_id, - is_active - ) -VALUES ( - 'DSLCBP3', - 'งานจ้างที่ปรีกษาออกแบบ โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3' - ), - TRUE - ), +insert into contracts ( + contract_code, + contract_name, + project_id, + is_active + ) +values ( + 'LCBP3-DS', + 'งานจ้างที่ปรีกษาออกแบบ โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)', ( - 'PSLCBP3', - 'งานจ้างที่ปรีกษาควบคุมงาน โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3' - ), - TRUE + select id + from projects + where project_code = 'LCBP3' ), + true + ), + ( + 'LCBP3-PS', + 'งานจ้างที่ปรีกษาควบคุมงาน โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)', ( - 'LCBP3-C1', - 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1) งานก่อสร้างงานทางทะเล', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3C1' - ), - TRUE + select id + from projects + where project_code = 'LCBP3' ), + true + ), + ( + 'LCBP3-C1', + 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1) งานก่อสร้างงานทางทะเล', ( - 'LCBP3-C2', - 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 2) งานก่อสร้างอาคาร ท่าเทียบเรือ ระบบถนน และระบบสาธารณูปโภค', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3C2' - ), - TRUE + select id + from projects + where project_code = 'LCBP3-C1' ), + true + ), + ( + 'LCBP3-C2', + 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 2) งานก่อสร้างอาคาร ท่าเทียบเรือ ระบบถนน และระบบสาธารณูปโภค', ( - 'LCBP3-C3', - 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 3) งานก่อสร้าง', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3C3' - ), - TRUE + select id + from projects + where project_code = 'LCBP3-C2' ), + true + ), + ( + 'LCBP3-C3', + 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 3) งานก่อสร้าง', ( - 'LCBP3-C4', - 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 4) งานก่อสร้าง', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3C4' - ), - TRUE + select id + from projects + where project_code = 'LCBP3-C3' ), + true + ), + ( + 'LCBP3-C4', + 'งานก่อสร้าง โครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 4) งานก่อสร้าง', ( - 'ENLCBP3', - 'งานจ้างเหมาตรวจสอบผลกระทบสิ่งแวดล้อมนะหว่างงานก่อสร้างโครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)', - ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3' - ), - TRUE - ); + select id + from projects + where project_code = 'LCBP3-C4' + ), + true + ), + ( + 'LCBP3-EN', + 'งานจ้างเหมาตรวจสอบผลกระทบสิ่งแวดล้อมนะหว่างงานก่อสร้างโครงการพัฒนาท่าเรือแหลมฉบัง ระยะที่ 3 (ส่วนที่ 1-4)', + ( + select id + from projects + where project_code = 'LCBP3' + ), + true + ); -- Seed user -- Initial SUPER_ADMIN user -INSERT INTO `users` ( - `user_id`, - `username`, - `password_hash`, - `first_name`, - `last_name`, - `email`, - `line_id`, - `primary_organization_id` - ) -VALUES ( - 1, - 'superadmin', - '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', - 'Super', - 'Admin', - 'superadmin @example.com', - NULL, - NULL - ), - ( - 2, - 'admin', - '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', - 'Admin', - 'คคง.', - 'admin@example.com', - NULL, - 1 - ), - ( - 3, - 'editor01', - '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', - 'DC', - 'C1', - 'editor01 @example.com', - NULL, - 41 - ), - ( - 4, - 'viewer01', - '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', - 'Viewer', - 'สคฉ.03', - 'viewer01 @example.com', - NULL, - 10 - ); +insert into `users` ( + `user_id`, + `username`, + `password_hash`, + `first_name`, + `last_name`, + `email`, + `line_id`, + `primary_organization_id` + ) +values ( + 1, + 'superadmin', + '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', + 'Super', + 'Admin', + 'superadmin @example.com', + null, + null + ), + ( + 2, + 'admin', + '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', + 'Admin', + 'คคง.', + 'admin@example.com', + null, + 1 + ), + ( + 3, + 'editor01', + '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', + 'DC', + 'C1', + 'editor01 @example.com', + null, + 41 + ), + ( + 4, + 'viewer01', + '$2b$10$E6d5k.f46jr.POGWKHhiQ.X1ZsFrMpZox//sCxeOiLUULGuAHO0NW', + 'Viewer', + 'สคฉ.03', + 'viewer01 @example.com', + null, + 10 + ); -- ========================================================== -- Seed Roles (บทบาทพื้นฐาน 5 บทบาท ตาม Req 4.3) -- ========================================================== -- 1. Superadmin (Global) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 1, - 'Superadmin', - 'Global', - 'ผู้ดูแลระบบสูงสุด: สามารถทำทุกอย่างในระบบ, จัดการองค์กร, และจัดการข้อมูลหลักระดับ Global' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 1, + 'Superadmin', + 'Global', + 'ผู้ดูแลระบบสูงสุด: สามารถทำทุกอย่างในระบบ, จัดการองค์กร, และจัดการข้อมูลหลักระดับ Global' + ); -- 2. Org Admin (Organization) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 2, - 'Org Admin', - 'Organization', - 'ผู้ดูแลองค์กร: จัดการผู้ใช้ในองค์กร, จัดการบทบาท / สิทธิ์ภายในองค์กร, และดูรายงานขององค์กร' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 2, + 'Org Admin', + 'Organization', + 'ผู้ดูแลองค์กร: จัดการผู้ใช้ในองค์กร, จัดการบทบาท / สิทธิ์ภายในองค์กร, และดูรายงานขององค์กร' + ); -- 3. Document Control (Organization) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 3, - 'Document Control', - 'Organization', - 'ควบคุมเอกสารขององค์กร: เพิ่ม / แก้ไข / ลบเอกสาร, และกำหนดสิทธิ์เอกสารภายในองค์กร' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 3, + 'Document Control', + 'Organization', + 'ควบคุมเอกสารขององค์กร: เพิ่ม / แก้ไข / ลบเอกสาร, และกำหนดสิทธิ์เอกสารภายในองค์กร' + ); -- 4. Editor (Organization) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 4, - 'Editor', - 'Organization', - 'ผู้แก้ไขเอกสารขององค์กร: เพิ่ม / แก้ไขเอกสารที่ได้รับมอบหมาย' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 4, + 'Editor', + 'Organization', + 'ผู้แก้ไขเอกสารขององค์กร: เพิ่ม / แก้ไขเอกสารที่ได้รับมอบหมาย' + ); -- 5. Viewer (Organization) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 5, - 'Viewer', - 'Organization', - 'ผู้ดูเอกสารขององค์กร: ดูเอกสารที่มีสิทธิ์เข้าถึงเท่านั้น' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 5, + 'Viewer', + 'Organization', + 'ผู้ดูเอกสารขององค์กร: ดูเอกสารที่มีสิทธิ์เข้าถึงเท่านั้น' + ); -- 6. Project Manager (Project) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 6, - 'Project Manager', - 'Project', - 'ผู้จัดการโครงการ: จัดการสมาชิกในโครงการ, สร้าง / จัดการสัญญาในโครงการ, และดูรายงานโครงการ' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 6, + 'Project Manager', + 'Project', + 'ผู้จัดการโครงการ: จัดการสมาชิกในโครงการ, สร้าง / จัดการสัญญาในโครงการ, และดูรายงานโครงการ' + ); -- 7. Contract Admin (Contract) -INSERT INTO roles (role_id, role_name, scope, description) -VALUES ( - 7, - 'Contract Admin', - 'Contract', - 'ผู้ดูแลสัญญา: จัดการสมาชิกในสัญญา, สร้าง / จัดการข้อมูลหลักเฉพาะสัญญา, และอนุมัติเอกสารในสัญญา' - ); +insert into roles (role_id, role_name, scope, description) +values ( + 7, + 'Contract Admin', + 'Contract', + 'ผู้ดูแลสัญญา: จัดการสมาชิกในสัญญา, สร้าง / จัดการข้อมูลหลักเฉพาะสัญญา, และอนุมัติเอกสารในสัญญา' + ); -- ===================================================== -- 2. Seed Permissions (สิทธิ์การใช้งานทั้งหมด) -- สิทธิ์ระดับระบบและการจัดการหลัก (System & Master Data) -- ===================================================== -INSERT INTO permissions (permission_id, permission_name, description) -VALUES ( - 1, - 'system.manage_all', - 'ทำทุกอย่างในระบบ (Superadmin Power)' - ), - -- การจัดการองค์กร - (2, 'organization.create', 'สร้างองค์กรใหม่'), - (3, 'organization.edit', 'แก้ไขข้อมูลองค์กร'), - (4, 'organization.delete', 'ลบองค์กร'), - (5, 'organization.view', 'ดูรายการองค์กร'), - -- การจัดการโครงการ - (6, 'project.create', 'สร้างโครงการใหม่'), - (7, 'project.edit', 'แก้ไขข้อมูลโครงการ'), - (8, 'project.delete', 'ลบโครงการ'), - (9, 'project.view', 'ดูรายการโครงการ'), - -- การจัดการบทบาทและสิทธิ์ (Roles & Permissions) - (10, 'role.create', 'สร้างบทบาท (Role) ใหม่'), - (11, 'role.edit', 'แก้ไขบทบาท (Role)'), - (12, 'role.delete', 'ลบบทบาท (Role)'), - ( - 13, - 'permission.assign', - 'มอบสิทธิ์ให้กับบทบาท (Role)' - ), - -- การจัดการข้อมูลหลัก (Master Data) - ( - 14, - 'master_data.document_type.manage', - 'จัดการประเภทเอกสาร (Document Types)' - ), - ( - 15, - 'master_data.document_status.manage', - 'จัดการสถานะเอกสาร (Document Statuses)' - ), - ( - 16, - 'master_data.drawing_category.manage', - 'จัดการหมวดหมู่แบบ (Drawing Categories)' - ), - (17, 'master_data.tag.manage', 'จัดการ Tags'), - -- การจัดการผู้ใช้งาน - (18, 'user.create', 'สร้างผู้ใช้งานใหม่'), - (19, 'user.edit', 'แก้ไขข้อมูลผู้ใช้งาน'), - (20, 'user.delete', 'ลบ / ปิดการใช้งานผู้ใช้'), - (21, 'user.view', 'ดูข้อมูลผู้ใช้งาน'), - ( - 22, - 'user.assign_organization', - 'มอบผู้ใช้งานให้กับองค์กร' - ); +insert into permissions (permission_id, permission_name, description) +values ( + 1, + 'system.manage_all', + 'ทำทุกอย่างในระบบ (Superadmin Power)' + ), + -- การจัดการองค์กร + (2, 'organization.create', 'สร้างองค์กรใหม่'), + (3, 'organization.edit', 'แก้ไขข้อมูลองค์กร'), + (4, 'organization.delete', 'ลบองค์กร'), + (5, 'organization.view', 'ดูรายการองค์กร'), + -- การจัดการโครงการ + (6, 'project.create', 'สร้างโครงการใหม่'), + (7, 'project.edit', 'แก้ไขข้อมูลโครงการ'), + (8, 'project.delete', 'ลบโครงการ'), + (9, 'project.view', 'ดูรายการโครงการ'), + -- การจัดการบทบาทและสิทธิ์ (Roles & Permissions) + (10, 'role.create', 'สร้างบทบาท (Role) ใหม่'), + (11, 'role.edit', 'แก้ไขบทบาท (Role)'), + (12, 'role.delete', 'ลบบทบาท (Role)'), + ( + 13, + 'permission.assign', + 'มอบสิทธิ์ให้กับบทบาท (Role)' + ), + -- การจัดการข้อมูลหลัก (Master Data) + ( + 14, + 'master_data.document_type.manage', + 'จัดการประเภทเอกสาร (Document Types)' + ), + ( + 15, + 'master_data.document_status.manage', + 'จัดการสถานะเอกสาร (Document Statuses)' + ), + ( + 16, + 'master_data.drawing_category.manage', + 'จัดการหมวดหมู่แบบ (Drawing Categories)' + ), + (17, 'master_data.tag.manage', 'จัดการ Tags'), + -- การจัดการผู้ใช้งาน + (18, 'user.create', 'สร้างผู้ใช้งานใหม่'), + (19, 'user.edit', 'แก้ไขข้อมูลผู้ใช้งาน'), + (20, 'user.delete', 'ลบ / ปิดการใช้งานผู้ใช้'), + (21, 'user.view', 'ดูข้อมูลผู้ใช้งาน'), + ( + 22, + 'user.assign_organization', + 'มอบผู้ใช้งานให้กับองค์กร' + ); -- ===================================================== -- == 2. สิทธิ์การจัดการโครงการและสัญญา (Project & Contract) == -- ===================================================== -INSERT INTO permissions (permission_id, permission_name, description) -VALUES ( - 23, - 'project.manage_members', - 'จัดการสมาชิกในโครงการ (เชิญ / ถอดสมาชิก)' - ), - ( - 24, - 'project.create_contracts', - 'สร้างสัญญาในโครงการ' - ), - ( - 25, - 'project.manage_contracts', - 'จัดการสัญญาในโครงการ' - ), - ( - 26, - 'project.view_reports', - 'ดูรายงานระดับโครงการ' - ), - ( - 27, - 'contract.manage_members', - 'จัดการสมาชิกในสัญญา' - ), - (28, 'contract.view', 'ดูข้อมูลสัญญา'); +insert into permissions (permission_id, permission_name, description) +values ( + 23, + 'project.manage_members', + 'จัดการสมาชิกในโครงการ (เชิญ / ถอดสมาชิก)' + ), + ( + 24, + 'project.create_contracts', + 'สร้างสัญญาในโครงการ' + ), + ( + 25, + 'project.manage_contracts', + 'จัดการสัญญาในโครงการ' + ), + ( + 26, + 'project.view_reports', + 'ดูรายงานระดับโครงการ' + ), + ( + 27, + 'contract.manage_members', + 'จัดการสมาชิกในสัญญา' + ), + (28, 'contract.view', 'ดูข้อมูลสัญญา'); -- ===================================================== -- == 3. สิทธิ์การจัดการเอกสาร (Document Management) == -- ===================================================== -- สิทธิ์ทั่วไปสำหรับเอกสารทุกประเภท -INSERT INTO permissions (permission_id, permission_name, description) -VALUES ( - 29, - 'document.create_draft', - 'สร้างเอกสารในสถานะฉบับร่าง (Draft) ' - ), - (30, 'document.submit', 'ส่งเอกสาร (Submitted)'), - (31, 'document.view', 'ดูเอกสาร'), - (32, 'document.edit', 'แก้ไขเอกสาร (ทั่วไป)'), - ( - 33, - 'document.admin_edit', - 'แก้ไข / ถอน / ยกเลิกเอกสารที่ส่งแล้ว (Admin Power) ' - ), - (34, 'document.delete', 'ลบเอกสาร'), - ( - 35, - 'document.attach', - 'จัดการไฟล์แนบ (อัปโหลด / ลบ) ' - ), - -- สิทธิ์เฉพาะสำหรับ Correspondence - ( - 36, - 'correspondence.create', - 'สร้างเอกสารโต้ตอบ (Correspondence) ' - ), - -- สิทธิ์เฉพาะสำหรับ Request for Approval (RFA) - (37, 'rfa.create', 'สร้างเอกสารขออนุมัติ (RFA)'), - ( - 38, - 'rfa.manage_shop_drawings', - 'จัดการข้อมูล Shop Drawing และ Contract Drawing ที่เกี่ยวข้อง' - ), - -- สิทธิ์เฉพาะสำหรับ Shop Drawing & Contract Drawing - ( - 39, - 'drawing.create', - 'สร้าง / แก้ไขข้อมูลแบบ (Shop / Contract Drawing)' - ), - -- สิทธิ์เฉพาะสำหรับ Transmittal - ( - 40, - 'transmittal.create', - 'สร้างเอกสารนำส่ง (Transmittal)' - ), - -- สิทธิ์เฉพาะสำหรับ Circulation Sheet (ใบเวียน) - ( - 41, - 'circulation.create', - 'สร้างใบเวียนเอกสาร (Circulation)' - ), - ( - 42, - 'circulation.respond', - 'ตอบกลับใบเวียน (Main / Action)' - ), - ( - 43, - 'circulation.acknowledge', - 'รับทราบใบเวียน (Information)' - ), - (44, 'circulation.close', 'ปิดใบเวียน'); +insert into permissions (permission_id, permission_name, description) +values ( + 29, + 'document.create_draft', + 'สร้างเอกสารในสถานะฉบับร่าง (Draft) ' + ), + (30, 'document.submit', 'ส่งเอกสาร (Submitted)'), + (31, 'document.view', 'ดูเอกสาร'), + (32, 'document.edit', 'แก้ไขเอกสาร (ทั่วไป)'), + ( + 33, + 'document.admin_edit', + 'แก้ไข / ถอน / ยกเลิกเอกสารที่ส่งแล้ว (Admin Power) ' + ), + (34, 'document.delete', 'ลบเอกสาร'), + ( + 35, + 'document.attach', + 'จัดการไฟล์แนบ (อัปโหลด / ลบ) ' + ), + -- สิทธิ์เฉพาะสำหรับ Correspondence + ( + 36, + 'correspondence.create', + 'สร้างเอกสารโต้ตอบ (Correspondence) ' + ), + -- สิทธิ์เฉพาะสำหรับ Request for Approval (RFA) + (37, 'rfa.create', 'สร้างเอกสารขออนุมัติ (RFA)'), + ( + 38, + 'rfa.manage_shop_drawings', + 'จัดการข้อมูล Shop Drawing และ Contract Drawing ที่เกี่ยวข้อง' + ), + -- สิทธิ์เฉพาะสำหรับ Shop Drawing & Contract Drawing + ( + 39, + 'drawing.create', + 'สร้าง / แก้ไขข้อมูลแบบ (Shop / Contract Drawing)' + ), + -- สิทธิ์เฉพาะสำหรับ Transmittal + ( + 40, + 'transmittal.create', + 'สร้างเอกสารนำส่ง (Transmittal)' + ), + -- สิทธิ์เฉพาะสำหรับ Circulation Sheet (ใบเวียน) + ( + 41, + 'circulation.create', + 'สร้างใบเวียนเอกสาร (Circulation)' + ), + ( + 42, + 'circulation.respond', + 'ตอบกลับใบเวียน (Main / Action)' + ), + ( + 43, + 'circulation.acknowledge', + 'รับทราบใบเวียน (Information)' + ), + (44, 'circulation.close', 'ปิดใบเวียน'); -- ===================================================== -- == 4. สิทธิ์การจัดการ Workflow == -- ===================================================== -INSERT INTO permissions (permission_id, permission_name, description) -VALUES ( - 45, - 'workflow.action_review', - 'ดำเนินการในขั้นตอนปัจจุบัน (เช่น ตรวจสอบแล้ว)' - ), - ( - 46, - 'workflow.force_proceed', - 'บังคับไปยังขั้นตอนถัดไป (Document Control Power)' - ), - ( - 47, - 'workflow.revert', - 'ย้อนกลับไปยังขั้นตอนก่อนหน้า (Document Control Power)' - ); +insert into permissions (permission_id, permission_name, description) +values ( + 45, + 'workflow.action_review', + 'ดำเนินการในขั้นตอนปัจจุบัน (เช่น ตรวจสอบแล้ว)' + ), + ( + 46, + 'workflow.force_proceed', + 'บังคับไปยังขั้นตอนถัดไป (Document Control Power)' + ), + ( + 47, + 'workflow.revert', + 'ย้อนกลับไปยังขั้นตอนก่อนหน้า (Document Control Power)' + ); -- ===================================================== -- == 5. สิทธิ์ด้านการค้นหาและรายงาน (Search & Reporting) == -- ===================================================== -INSERT INTO permissions (permission_id, permission_name, description) -VALUES (48, 'search.advanced', 'ใช้งานการค้นหาขั้นสูง'), - ( - 49, - 'report.generate', - 'สร้างรายงานสรุป (รายวัน / สัปดาห์ / เดือน / ปี)' - ); +insert into permissions (permission_id, permission_name, description) +values (48, 'search.advanced', 'ใช้งานการค้นหาขั้นสูง'), + ( + 49, + 'report.generate', + 'สร้างรายงานสรุป (รายวัน / สัปดาห์ / เดือน / ปี)' + ); -- ========================================================== -- Seed Role-Permissions Mapping (จับคู่สิทธิ์เริ่มต้น) -- ========================================================== @@ -454,1674 +458,1676 @@ VALUES (48, 'search.advanced', 'ใช้งานการค้นหาขั -- ===================================================== -- Superadmin can do everything. We can dynamically link all permissions to this role. -- This is a robust way to ensure Superadmin always has full power. -INSERT INTO role_permissions (role_id, permission_id) -SELECT 1, - permission_id -FROM permissions; +insert into role_permissions (role_id, permission_id) +select 1, + permission_id +from permissions; -- ===================================================== -- == 2. Org Admin (role_id = 2) == -- ===================================================== -INSERT INTO role_permissions (role_id, permission_id) -VALUES -- จัดการผู้ใช้ในองค์กร - (2, 18), - -- user.create - (2, 19), - -- user.edit - (2, 20), - -- user.delete - (2, 21), - -- user.view - (2, 22), - -- user.assign_organization - -- จัดการองค์กร - (2, 3), - -- organization.edit - (2, 5), - -- organization.view - -- จัดการข้อมูลหลักที่อนุญาต (เฉพาะ Tags) - (2, 17), - -- master_data.tag.manage - -- ดูข้อมูลต่างๆ ในองค์กร - (2, 31), - -- document.view - (2, 9), - -- project.view - (2, 28), - -- contract.view - -- การค้นหาและรายงาน - (2, 48), - -- search.advanced - (2, 49); +insert into role_permissions (role_id, permission_id) +values -- จัดการผู้ใช้ในองค์กร + (2, 18), + -- user.create + (2, 19), + -- user.edit + (2, 20), + -- user.delete + (2, 21), + -- user.view + (2, 22), + -- user.assign_organization + -- จัดการองค์กร + (2, 3), + -- organization.edit + (2, 5), + -- organization.view + -- จัดการข้อมูลหลักที่อนุญาต (เฉพาะ Tags) + (2, 17), + -- master_data.tag.manage + -- ดูข้อมูลต่างๆ ในองค์กร + (2, 31), + -- document.view + (2, 9), + -- project.view + (2, 28), + -- contract.view + -- การค้นหาและรายงาน + (2, 48), + -- search.advanced + (2, 49); -- report.generate -- ===================================================== -- == 3. Document Control (role_id = 3) == -- ===================================================== -INSERT INTO role_permissions (role_id, permission_id) -VALUES -- สิทธิ์จัดการเอกสารทั้งหมด - (3, 29), - -- document.create_draft - (3, 30), - -- document.submit - (3, 31), - -- document.view - (3, 32), - -- document.edit - (3, 33), - -- document.admin_edit - (3, 34), - -- document.delete - (3, 35), - -- document.attach - -- สิทธิ์สร้างเอกสารแต่ละประเภท - (3, 36), - -- correspondence.create - (3, 37), - -- rfa.create - (3, 39), - -- drawing.create - (3, 40), - -- transmittal.create - (3, 41), - -- circulation.create - -- สิทธิ์จัดการ Workflow - (3, 45), - -- workflow.action_review - (3, 46), - -- workflow.force_proceed - (3, 47), - -- workflow.revert - -- สิทธิ์จัดการ Circulation - (3, 42), - -- circulation.respond - (3, 43), - -- circulation.acknowledge - (3, 44), - -- circulation.close - -- สิทธิ์อื่นๆ ที่จำเป็น - (3, 38), - -- rfa.manage_shop_drawings - (3, 48), - -- search.advanced - (3, 49); +insert into role_permissions (role_id, permission_id) +values -- สิทธิ์จัดการเอกสารทั้งหมด + (3, 29), + -- document.create_draft + (3, 30), + -- document.submit + (3, 31), + -- document.view + (3, 32), + -- document.edit + (3, 33), + -- document.admin_edit + (3, 34), + -- document.delete + (3, 35), + -- document.attach + -- สิทธิ์สร้างเอกสารแต่ละประเภท + (3, 36), + -- correspondence.create + (3, 37), + -- rfa.create + (3, 39), + -- drawing.create + (3, 40), + -- transmittal.create + (3, 41), + -- circulation.create + -- สิทธิ์จัดการ Workflow + (3, 45), + -- workflow.action_review + (3, 46), + -- workflow.force_proceed + (3, 47), + -- workflow.revert + -- สิทธิ์จัดการ Circulation + (3, 42), + -- circulation.respond + (3, 43), + -- circulation.acknowledge + (3, 44), + -- circulation.close + -- สิทธิ์อื่นๆ ที่จำเป็น + (3, 38), + -- rfa.manage_shop_drawings + (3, 48), + -- search.advanced + (3, 49); -- report.generate -- ===================================================== -- == 4. Editor (role_id = 4) == -- ===================================================== -INSERT INTO role_permissions (role_id, permission_id) -VALUES -- สิทธิ์แก้ไขเอกสาร (แต่ไม่ใช่สิทธิ์ Admin) - (4, 29), - -- document.create_draft - (4, 30), - -- document.submit - (4, 31), - -- document.view - (4, 32), - -- document.edit - (4, 35), - -- document.attach - -- สิทธิ์สร้างเอกสารแต่ละประเภท - (4, 36), - -- correspondence.create - (4, 37), - -- rfa.create - (4, 39), - -- drawing.create - (4, 40), - -- transmittal.create - (4, 41), - -- circulation.create - -- สิทธิ์อื่นๆ ที่จำเป็น - (4, 38), - -- rfa.manage_shop_drawings - (4, 48); +insert into role_permissions (role_id, permission_id) +values -- สิทธิ์แก้ไขเอกสาร (แต่ไม่ใช่สิทธิ์ Admin) + (4, 29), + -- document.create_draft + (4, 30), + -- document.submit + (4, 31), + -- document.view + (4, 32), + -- document.edit + (4, 35), + -- document.attach + -- สิทธิ์สร้างเอกสารแต่ละประเภท + (4, 36), + -- correspondence.create + (4, 37), + -- rfa.create + (4, 39), + -- drawing.create + (4, 40), + -- transmittal.create + (4, 41), + -- circulation.create + -- สิทธิ์อื่นๆ ที่จำเป็น + (4, 38), + -- rfa.manage_shop_drawings + (4, 48); -- search.advanced -- ===================================================== -- == 5. Viewer (role_id = 5) == -- ===================================================== -INSERT INTO role_permissions (role_id, permission_id) -VALUES -- สิทธิ์ดูเท่านั้น - (5, 31), - -- document.view - (5, 48); +insert into role_permissions (role_id, permission_id) +values -- สิทธิ์ดูเท่านั้น + (5, 31), + -- document.view + (5, 48); -- search.advanced -- ===================================================== -- == 6. Project Manager (role_id = 6) == -- ===================================================== -INSERT INTO role_permissions (role_id, permission_id) -VALUES -- สิทธิ์จัดการโครงการ - (6, 23), - -- project.manage_members - (6, 24), - -- project.create_contracts - (6, 25), - -- project.manage_contracts - (6, 26), - -- project.view_reports - (6, 9), - -- project.view - -- สิทธิ์จัดการข้อมูลหลักระดับโครงการ - (6, 16), - -- master_data.drawing_category.manage - -- สิทธิ์ดูข้อมูลในสัญญา - (6, 28), - -- contract.view - -- สิทธิ์ในการจัดการเอกสาร (ระดับ Editor) - (6, 29), - -- document.create_draft - (6, 30), - -- document.submit - (6, 31), - -- document.view - (6, 32), - -- document.edit - (6, 35), - -- document.attach - (6, 36), - -- correspondence.create - (6, 37), - -- rfa.create - (6, 39), - -- drawing.create - (6, 40), - -- transmittal.create - (6, 41), - -- circulation.create - (6, 38), - -- rfa.manage_shop_drawings - (6, 48), - -- search.advanced - (6, 49); +insert into role_permissions (role_id, permission_id) +values -- สิทธิ์จัดการโครงการ + (6, 23), + -- project.manage_members + (6, 24), + -- project.create_contracts + (6, 25), + -- project.manage_contracts + (6, 26), + -- project.view_reports + (6, 9), + -- project.view + -- สิทธิ์จัดการข้อมูลหลักระดับโครงการ + (6, 16), + -- master_data.drawing_category.manage + -- สิทธิ์ดูข้อมูลในสัญญา + (6, 28), + -- contract.view + -- สิทธิ์ในการจัดการเอกสาร (ระดับ Editor) + (6, 29), + -- document.create_draft + (6, 30), + -- document.submit + (6, 31), + -- document.view + (6, 32), + -- document.edit + (6, 35), + -- document.attach + (6, 36), + -- correspondence.create + (6, 37), + -- rfa.create + (6, 39), + -- drawing.create + (6, 40), + -- transmittal.create + (6, 41), + -- circulation.create + (6, 38), + -- rfa.manage_shop_drawings + (6, 48), + -- search.advanced + (6, 49); -- report.generate -- ===================================================== -- == 7. Contract Admin (role_id = 7) == -- ===================================================== -INSERT INTO role_permissions (role_id, permission_id) -VALUES -- สิทธิ์จัดการสัญญา - (7, 27), - -- contract.manage_members - (7, 28), - -- contract.view - -- สิทธิ์ในการอนุมัติ (ส่วนหนึ่งของ Workflow) - (7, 45), - -- workflow.action_review - -- สิทธิ์จัดการข้อมูลเฉพาะสัญญา - (7, 38), - -- rfa.manage_shop_drawings - (7, 39), - -- drawing.create - -- สิทธิ์ในการจัดการเอกสาร (ระดับ Editor) - (7, 29), - -- document.create_draft - (7, 30), - -- document.submit - (7, 31), - -- document.view - (7, 32), - -- document.edit - (7, 35), - -- document.attach - (7, 36), - -- correspondence.create - (7, 37), - -- rfa.create - (7, 40), - -- transmittal.create - (7, 41), - -- circulation.create - (7, 48); +insert into role_permissions (role_id, permission_id) +values -- สิทธิ์จัดการสัญญา + (7, 27), + -- contract.manage_members + (7, 28), + -- contract.view + -- สิทธิ์ในการอนุมัติ (ส่วนหนึ่งของ Workflow) + (7, 45), + -- workflow.action_review + -- สิทธิ์จัดการข้อมูลเฉพาะสัญญา + (7, 38), + -- rfa.manage_shop_drawings + (7, 39), + -- drawing.create + -- สิทธิ์ในการจัดการเอกสาร (ระดับ Editor) + (7, 29), + -- document.create_draft + (7, 30), + -- document.submit + (7, 31), + -- document.view + (7, 32), + -- document.edit + (7, 35), + -- document.attach + (7, 36), + -- correspondence.create + (7, 37), + -- rfa.create + (7, 40), + -- transmittal.create + (7, 41), + -- circulation.create + (7, 48); -- Seed data for the 'user_assignments' table -INSERT INTO `user_assignments` ( - `id`, - `user_id`, - `role_id`, - `organization_id`, - `project_id`, - `contract_id`, - `assigned_by_user_id` - ) -VALUES ( - 1, - 1, - 1, - NULL, - NULL, - NULL, - NULL - ), - ( - 2, - 2, - 2, - 1, - NULL, - NULL, - NULL - ); +insert into `user_assignments` ( + `id`, + `user_id`, + `role_id`, + `organization_id`, + `project_id`, + `contract_id`, + `assigned_by_user_id` + ) +values (1, 1, 1, null, null, null, null), + (2, 2, 2, 1, null, null, null); -- ===================================================== -- == 4. การเชื่อมโยงโครงการกับองค์กร (project_organizations) == -- ===================================================== -- โครงการหลัก (LCBP3) จะมีองค์กรหลักๆ เข้ามาเกี่ยวข้องทั้งหมด -INSERT INTO project_organizations (project_id, organization_id) -SELECT ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3 ' - ), - id -FROM organizations -WHERE organization_code IN ( - 'กทท.', - 'สคฉ.3', - 'TEAM', - 'คคง.', - 'ผรม.1', - 'ผรม.2', - 'ผรม.3', - 'ผรม.4', - 'EN', - 'CAR ' - ); +insert into project_organizations (project_id, organization_id) +select ( + select id + from projects + where project_code = 'LCBP3 ' + ), + id +from organizations +where organization_code in ( + 'กทท.', + 'สคฉ.3', + 'TEAM', + 'คคง.', + 'ผรม.1', + 'ผรม.2', + 'ผรม.3', + 'ผรม.4', + 'EN', + 'CAR ' + ); -- โครงการย่อย (LCBP3C1) จะมีเฉพาะองค์กรที่เกี่ยวข้อง -INSERT INTO project_organizations (project_id, organization_id) -SELECT ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3C1 ' - ), - id -FROM organizations -WHERE organization_code IN ('กทท.', 'สคฉ.3', 'สคฉ.3 -02', 'คคง.', 'ผรม.1 '); +insert into project_organizations (project_id, organization_id) +select ( + select id + from projects + where project_code = 'LCBP3-C1 ' + ), + id +from organizations +where organization_code in ('กทท.', 'สคฉ.3', 'สคฉ.3 -02', 'คคง.', 'ผรม.1 '); -- ทำเช่นเดียวกันสำหรับโครงการอื่นๆ (ตัวอย่าง) -INSERT INTO project_organizations (project_id, organization_id) -SELECT ( - SELECT id - FROM projects - WHERE project_code = 'LCBP3C2 ' - ), - id -FROM organizations -WHERE organization_code IN ('กทท.', 'สคฉ.3', 'สคฉ.3 -03', 'คคง.', 'ผรม.2 '); +insert into project_organizations (project_id, organization_id) +select ( + select id + from projects + where project_code = 'LCBP3-C2 ' + ), + id +from organizations +where organization_code in ('กทท.', 'สคฉ.3', 'สคฉ.3 -03', 'คคง.', 'ผรม.2 '); -- ===================================================== -- == 5. การเชื่อมโยงสัญญากับองค์กร (contract_organizations) == -- ===================================================== -- สัญญาที่ปรึกษาออกแบบ (DSLCBP3) -INSERT INTO contract_organizations (contract_id, organization_id, role_in_contract) -VALUES ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'DSLCBP3' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'กทท.' - ), - 'Owner' +insert into contract_organizations (contract_id, organization_id, role_in_contract) +values ( + ( + select id + from contracts + where contract_code = 'LCBP3-DS' ), ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'DSLCBP3' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'TEAM' - ), - 'Designer' - ); + select id + from organizations + where organization_code = 'กทท.' + ), + 'Owner' + ), + ( + ( + select id + from contracts + where contract_code = 'LCBP3-DS' + ), + ( + select id + from organizations + where organization_code = 'TEAM' + ), + 'Designer' + ); -- สัญญาที่ปรึกษาควบคุมงาน (PSLCBP3) -INSERT INTO contract_organizations (contract_id, organization_id, role_in_contract) -VALUES ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'PSLCBP3 ' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'กทท.' - ), - 'Owner' +insert into contract_organizations (contract_id, organization_id, role_in_contract) +values ( + ( + select id + from contracts + where contract_code = 'LCBP3-PS' ), ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'PSLCBP3 ' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'คคง.' - ), - 'Consultant' - ); + select id + from organizations + where organization_code = 'กทท.' + ), + 'Owner' + ), + ( + ( + select id + from contracts + where contract_code = 'LCBP3-PS' + ), + ( + select id + from organizations + where organization_code = 'คคง.' + ), + 'Consultant' + ); -- สัญญางานก่อสร้าง ส่วนที่ 1 (LCBP3-C1) -INSERT INTO contract_organizations (contract_id, organization_id, role_in_contract) -VALUES ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'LCBP3-C1' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'กทท.' - ), - 'Owner' +insert into contract_organizations (contract_id, organization_id, role_in_contract) +values ( + ( + select id + from contracts + where contract_code = 'LCBP3-C1' ), ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'LCBP3-C1 ' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'ผรม.1' - ), - 'Contractor' - ); + select id + from organizations + where organization_code = 'กทท.' + ), + 'Owner' + ), + ( + ( + select id + from contracts + where contract_code = 'LCBP3-C1' + ), + ( + select id + from organizations + where organization_code = 'ผรม.1' + ), + 'Contractor' + ); -- สัญญางานก่อสร้าง ส่วนที่ 2 (LCBP3-C2) -INSERT INTO contract_organizations (contract_id, organization_id, role_in_contract) -VALUES ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'LCBP3-C2' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'กทท.' - ), - 'Owner' +insert into contract_organizations (contract_id, organization_id, role_in_contract) +values ( + ( + select id + from contracts + where contract_code = 'LCBP3-C2' ), ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'LCBP3-C2' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'ผรม.2' - ), - 'Contractor' - ); --- สัญญาตรวจสอบสิ่งแวดล้อม (ENLCBP3) -INSERT INTO contract_organizations (contract_id, organization_id, role_in_contract) -VALUES ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'ENLCBP3' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'กทท.' - ), - 'Owner' + select id + from organizations + where organization_code = 'กทท.' + ), + 'Owner' + ), + ( + ( + select id + from contracts + where contract_code = 'LCBP3-C2' ), ( - ( - SELECT id - FROM contracts - WHERE contract_code = 'ENLCBP3' - ), - ( - SELECT id - FROM organizations - WHERE organization_code = 'EN' - ), - 'Consultant' - ); + select id + from organizations + where organization_code = 'ผรม.2' + ), + 'Contractor' + ); +-- สัญญาตรวจสอบสิ่งแวดล้อม (LCBP3-EN) +insert into contract_organizations (contract_id, organization_id, role_in_contract) +values ( + ( + select id + from contracts + where contract_code = 'LCBP3-EN' + ), + ( + select id + from organizations + where organization_code = 'กทท.' + ), + 'Owner' + ), + ( + ( + select id + from contracts + where contract_code = 'LCBP3-EN' + ), + ( + select id + from organizations + where organization_code = 'EN' + ), + 'Consultant' + ); -- Seed correspondence_status -INSERT INTO correspondence_status (status_code, status_name, sort_order, is_active) -VALUES ('DRAFT', 'Draft', 10, 1), - ('SUBOWN', 'Submitted to Owner', 21, 1), - ('SUBDSN', 'Submitted to Designer', 22, 1), - ('SUBCSC', 'Submitted to CSC', 23, 1), - ('SUBCON', 'Submitted to Contractor', 24, 1), - ('SUBOTH', 'Submitted to Others', 25, 1), - ('REPOWN', 'Reply by Owner', 31, 1), - ('REPDSN', 'Reply by Designer', 32, 1), - ('REPCSC', 'Reply by CSC', 33, 1), - ('REPCON', 'Reply by Contractor', 34, 1), - ('REPOTH', 'Reply by Others', 35, 1), - ('RSBOWN', 'Resubmited by Owner', 41, 1), - ('RSBDSN', 'Resubmited by Designer', 42, 1), - ('RSBCSC', 'Resubmited by CSC', 43, 1), - ('RSBCON', 'Resubmited by Contractor', 44, 1), - ('CLBOWN', 'Closed by Owner', 51, 1), - ('CLBDSN', 'Closed by Designer', 52, 1), - ('CLBCSC', 'Closed by CSC', 53, 1), - ('CLBCON', 'Closed by Contractor', 54, 1), - ('CCBOWN', 'Canceled by Owner', 91, 1), - ('CCBDSN', 'Canceled by Designer', 92, 1), - ('CCBCSC', 'Canceled by CSC', 93, 1), - ('CCBCON', 'Canceled by Contractor', 94, 1); +insert into correspondence_status (status_code, status_name, sort_order, is_active) +values ('DRAFT', 'Draft', 10, 1), + ('SUBOWN', 'Submitted to Owner', 21, 1), + ('SUBDSN', 'Submitted to Designer', 22, 1), + ('SUBCSC', 'Submitted to CSC', 23, 1), + ('SUBCON', 'Submitted to Contractor', 24, 1), + ('SUBOTH', 'Submitted to Others', 25, 1), + ('REPOWN', 'Reply by Owner', 31, 1), + ('REPDSN', 'Reply by Designer', 32, 1), + ('REPCSC', 'Reply by CSC', 33, 1), + ('REPCON', 'Reply by Contractor', 34, 1), + ('REPOTH', 'Reply by Others', 35, 1), + ('RSBOWN', 'Resubmited by Owner', 41, 1), + ('RSBDSN', 'Resubmited by Designer', 42, 1), + ('RSBCSC', 'Resubmited by CSC', 43, 1), + ('RSBCON', 'Resubmited by Contractor', 44, 1), + ('CLBOWN', 'Closed by Owner', 51, 1), + ('CLBDSN', 'Closed by Designer', 52, 1), + ('CLBCSC', 'Closed by CSC', 53, 1), + ('CLBCON', 'Closed by Contractor', 54, 1), + ('CCBOWN', 'Canceled by Owner', 91, 1), + ('CCBDSN', 'Canceled by Designer', 92, 1), + ('CCBCSC', 'Canceled by CSC', 93, 1), + ('CCBCON', 'Canceled by Contractor', 94, 1); +-- Seed correspondence_types +insert into correspondence_types (type_code, type_name, sort_order, is_active) +values ('RFA', 'Request for Approval', 1, 1), + ('RFI', 'Request for Information', 2, 1), + ('TRANSMITTAL', 'Transmittal', 3, 1), + ('EMAIL', 'Email', 4, 1), + ('INSTRUCTION', 'Instruction', 5, 1), + ('LETTER', 'Letter', 6, 1), + ('MEMO', 'Memorandum', 7, 1), + ('MOM', 'Minutes of Meeting', 8, 1), + ('NOTICE', 'Notice', 9, 1), + ('OTHER', 'Other', 10, 1); -- Seed rfa_types -INSERT INTO rfa_types ( - contract_id, - type_code, - type_name_en, - type_name_th - ) -SELECT id, - 'ADW', - 'As Built Drawing', - 'แบบร่างหลังการก่อสร้าง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'BC', - 'Box Culvert', - 'ท่อระบายน้ำรูปกล่อง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'BM', - 'Benchmark', - 'หมุดหลักฐาน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'CER', - 'Certificates', - 'ใบรับรอง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'CN', - 'Canal Drainage', - 'ระบบระบายน้ำในคลอง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'CON', - 'Contract', - 'สัญญา' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'DDS', - 'Design Data Submission', - 'นำส่งข้อมูลการออกแบบ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'DDW', - 'Draft Drawing', - 'แบบร่าง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'DRW', - 'Drawings (All Types)', - 'แบบก่อสร้าง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'DSN', - 'Design/Calculation/Manual (All Stages)', - 'ออกแบบ / คำนวณ / คู่มือ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'GEN', - 'General', - 'ทั่วไป' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'ICR', - 'Incident Report', - 'รายงานการเกิดอุบัติเหตุและการบาดเจ็บ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'INS', - 'Insurances/Bond/Guarantee', - 'การประกัน / พันธบัตร / การค้ำประกัน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'INR', - 'Inspection/Audit/Surveillance Report', - 'รายงานการตรวจสอบ / การตรวจสอบ / รายงานการเฝ้าระวัง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'ITP', - 'Inspection and Test Plan', - 'แผนการตรวจสอบและทดสอบ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'JSA', - 'Jobs Analysis', - 'รายงานการวิเคราะห์ความปลอดภัย' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'MAN', - 'Manual', - 'คู่มือ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'MAT', - 'Materials/Equipment/Plant', - 'วัสดุ / อุปกรณ์ / โรงงาน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'MOM', - 'Minutes of Meeting', - 'รายงานการประชุม' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'MPR', - 'Monthly Progress Report', - 'รายงานความคืบหน้าประจำเดือน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'MST', - 'Method Statement for Construction/Installation', - 'ขั้นตอนการก่อสร้าง / ติดตั้ง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'NDS', - 'Non-Design Data Submission', - 'นำส่งข้อมูลที่ไม่เกี่ยวข้องกับการออกแบบ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'PMA', - 'Payment/Invoice/Retention/Estimate', - 'การชำระเงิน / ใบแจ้งหนี้ / ประกันผลงาน / ประมาณการ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'PRD', - 'Procedure', - 'ระเบียบปฏิบัติ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'PRG', - 'Progress of Construction', - 'ความคืบหน้าของการก่อสร้าง / ภาพถ่าย / วิดีโอ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'QMS', - 'Quality Document (Plan/Work Instruction)', - 'เอกสารด้านคุณภาพ (แผนงาน / ข้อแนะนำในการทำงาน)' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'RPT', - 'Report', - 'รายงาน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SAR', - 'Semi Annual Report', - 'รายงานประจำหกเดือน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SCH', - 'Schedule and Program', - 'แผนงาน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SDW', - 'Shop Drawing', - 'แบบขยายรายละเอียด' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SI', - 'Soil Investigation', - 'การตรวจสอบดิน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SPE', - 'Specification', - 'ข้อกำหนด' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'TNR', - 'Training Report', - 'รายงานการฝึกปฏิบัติ' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'UC', - 'Underground Construction', - 'โครงสร้างใต้ดิน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'VEN', - 'Vendor', - 'ผู้ขาย' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'VRO', - 'Variation Request/Instruction/Order', - 'คำขอเปลี่ยนแปลง / ข้อเสนอแนะ / ข้อเรียกร้อง' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'WTY', - 'Warranty', - 'การประกัน' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'GEN', - 'General', - 'ทั่วไป' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'CON', - 'Contract', - 'สัญญา' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'INS', - 'Insurances/Bond/Guarantee', - 'การประกัน / พันธบัตร / การค้ำประกัน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SCH', - 'Schedule and Program', - 'แผนงาน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'PMA', - 'Payment/Invoice/Retention/Estimate', - 'การชำระเงิน / ใบแจ้งหนี้ / ประกันผลงาน / ประมาณการ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'VRO', - 'Variation Request/Instruction/Order', - 'คำขอเปลี่ยนแปลง / ข้อเสนอแนะ / ข้อเรียกร้อง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'VEN', - 'Vendor', - 'ผู้ขาย' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'WTY', - 'Warranty', - 'การประกัน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'DRW', - 'Drawings (All Types)', - 'แบบก่อสร้าง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'DDW', - 'Draft Drawing', - 'แบบร่าง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SDW', - 'Shop Drawing', - 'แบบขยายรายละเอียด' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ADW', - 'As Built Drawing', - 'แบบร่างหลังการก่อสร้าง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'DDS', - 'Design Data Submission', - 'นำส่งข้อมูลการออกแบบ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'DSN', - 'Design/Calculation/Manual (All Stages)', - 'ออกแบบ / คำนวณ / คู่มือ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'NDS', - 'Non-Design Data Submission', - 'นำส่งข้อมูลที่ไม่เกี่ยวข้องกับการออกแบบ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'PRD', - 'Procedure', - 'ระเบียบปฏิบัติ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MST', - 'Method Statement for Construction/Installation', - 'ขั้นตอนการก่อสร้าง / ติดตั้ง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'QMS', - 'Quality Document (Plan/Work Instruction)', - 'เอกสารด้านคุณภาพ (แผนงาน / ข้อแนะนำในการทำงาน)' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'INR', - 'Inspection/Audit/Surveillance Report', - 'รายงานการตรวจสอบ / การตรวจสอบ / รายงานการเฝ้าระวัง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ITP', - 'Inspection and Test Plan', - 'แผนการตรวจสอบและทดสอบ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MAT', - 'Materials/Equipment/Plant', - 'วัสดุ / อุปกรณ์ / โรงงาน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SPE', - 'Specification', - 'ข้อกำหนด' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MAN', - 'Manual', - 'คู่มือ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'CER', - 'Certificates', - 'ใบรับรอง' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SAR', - 'Semi Annual Report', - 'รายงานประจำหกเดือน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'JSA', - 'Jobs Analysis', - 'รายงานการวิเคราะห์ความปลอดภัย' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MOM', - 'Minutes of Meeting', - 'รายงานการประชุม' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MPR', - 'Monthly Progress Report', - 'รายงานความคืบหน้าประจำเดือน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ICR', - 'Incident Report', - 'รายงานการเกิดอุบัติเหตุและการบาดเจ็บ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'PRG', - 'Progress of Construction', - 'ความคืบหน้าของการก่อสร้าง / ภาพถ่าย / วิดีโอ' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'RPT', - 'Report', - 'รายงาน' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'TNR', - 'Training Report', - 'รายงานการฝึกปฏิบัติ' -FROM contracts -WHERE contract_code = 'LCBP3-C2'; +insert into rfa_types ( + contract_id, + type_code, + type_name_en, + type_name_th + ) +select id, + 'ADW', + 'As Built Drawing', + 'แบบร่างหลังการก่อสร้าง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'BC', + 'Box Culvert', + 'ท่อระบายน้ำรูปกล่อง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'BM', + 'Benchmark', + 'หมุดหลักฐาน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'CER', + 'Certificates', + 'ใบรับรอง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'CN', + 'Canal Drainage', + 'ระบบระบายน้ำในคลอง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'CON', + 'Contract', + 'สัญญา' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'DDS', + 'Design Data Submission', + 'นำส่งข้อมูลการออกแบบ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'DDW', + 'Draft Drawing', + 'แบบร่าง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'DRW', + 'Drawings (All Types)', + 'แบบก่อสร้าง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'DSN', + 'Design/Calculation/Manual (All Stages)', + 'ออกแบบ / คำนวณ / คู่มือ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'GEN', + 'General', + 'ทั่วไป' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'ICR', + 'Incident Report', + 'รายงานการเกิดอุบัติเหตุและการบาดเจ็บ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'INS', + 'Insurances/Bond/Guarantee', + 'การประกัน / พันธบัตร / การค้ำประกัน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'INR', + 'Inspection/Audit/Surveillance Report', + 'รายงานการตรวจสอบ / การตรวจสอบ / รายงานการเฝ้าระวัง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'ITP', + 'Inspection and Test Plan', + 'แผนการตรวจสอบและทดสอบ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'JSA', + 'Jobs Analysis', + 'รายงานการวิเคราะห์ความปลอดภัย' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'MAN', + 'Manual', + 'คู่มือ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'MAT', + 'Materials/Equipment/Plant', + 'วัสดุ / อุปกรณ์ / โรงงาน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'MOM', + 'Minutes of Meeting', + 'รายงานการประชุม' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'MPR', + 'Monthly Progress Report', + 'รายงานความคืบหน้าประจำเดือน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'MST', + 'Method Statement for Construction/Installation', + 'ขั้นตอนการก่อสร้าง / ติดตั้ง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'NDS', + 'Non-Design Data Submission', + 'นำส่งข้อมูลที่ไม่เกี่ยวข้องกับการออกแบบ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'PMA', + 'Payment/Invoice/Retention/Estimate', + 'การชำระเงิน / ใบแจ้งหนี้ / ประกันผลงาน / ประมาณการ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'PRD', + 'Procedure', + 'ระเบียบปฏิบัติ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'PRG', + 'Progress of Construction', + 'ความคืบหน้าของการก่อสร้าง / ภาพถ่าย / วิดีโอ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'QMS', + 'Quality Document (Plan/Work Instruction)', + 'เอกสารด้านคุณภาพ (แผนงาน / ข้อแนะนำในการทำงาน)' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'RPT', + 'Report', + 'รายงาน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SAR', + 'Semi Annual Report', + 'รายงานประจำหกเดือน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SCH', + 'Schedule and Program', + 'แผนงาน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SDW', + 'Shop Drawing', + 'แบบขยายรายละเอียด' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SI', + 'Soil Investigation', + 'การตรวจสอบดิน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SPE', + 'Specification', + 'ข้อกำหนด' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'TNR', + 'Training Report', + 'รายงานการฝึกปฏิบัติ' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'UC', + 'Underground Construction', + 'โครงสร้างใต้ดิน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'VEN', + 'Vendor', + 'ผู้ขาย' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'VRO', + 'Variation Request/Instruction/Order', + 'คำขอเปลี่ยนแปลง / ข้อเสนอแนะ / ข้อเรียกร้อง' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'WTY', + 'Warranty', + 'การประกัน' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'GEN', + 'General', + 'ทั่วไป' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'CON', + 'Contract', + 'สัญญา' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'INS', + 'Insurances/Bond/Guarantee', + 'การประกัน / พันธบัตร / การค้ำประกัน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SCH', + 'Schedule and Program', + 'แผนงาน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'PMA', + 'Payment/Invoice/Retention/Estimate', + 'การชำระเงิน / ใบแจ้งหนี้ / ประกันผลงาน / ประมาณการ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'VRO', + 'Variation Request/Instruction/Order', + 'คำขอเปลี่ยนแปลง / ข้อเสนอแนะ / ข้อเรียกร้อง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'VEN', + 'Vendor', + 'ผู้ขาย' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'WTY', + 'Warranty', + 'การประกัน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'DRW', + 'Drawings (All Types)', + 'แบบก่อสร้าง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'DDW', + 'Draft Drawing', + 'แบบร่าง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SDW', + 'Shop Drawing', + 'แบบขยายรายละเอียด' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ADW', + 'As Built Drawing', + 'แบบร่างหลังการก่อสร้าง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'DDS', + 'Design Data Submission', + 'นำส่งข้อมูลการออกแบบ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'DSN', + 'Design/Calculation/Manual (All Stages)', + 'ออกแบบ / คำนวณ / คู่มือ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'NDS', + 'Non-Design Data Submission', + 'นำส่งข้อมูลที่ไม่เกี่ยวข้องกับการออกแบบ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'PRD', + 'Procedure', + 'ระเบียบปฏิบัติ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MST', + 'Method Statement for Construction/Installation', + 'ขั้นตอนการก่อสร้าง / ติดตั้ง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'QMS', + 'Quality Document (Plan/Work Instruction)', + 'เอกสารด้านคุณภาพ (แผนงาน / ข้อแนะนำในการทำงาน)' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'INR', + 'Inspection/Audit/Surveillance Report', + 'รายงานการตรวจสอบ / การตรวจสอบ / รายงานการเฝ้าระวัง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ITP', + 'Inspection and Test Plan', + 'แผนการตรวจสอบและทดสอบ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MAT', + 'Materials/Equipment/Plant', + 'วัสดุ / อุปกรณ์ / โรงงาน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SPE', + 'Specification', + 'ข้อกำหนด' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MAN', + 'Manual', + 'คู่มือ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'CER', + 'Certificates', + 'ใบรับรอง' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SAR', + 'Semi Annual Report', + 'รายงานประจำหกเดือน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'JSA', + 'Jobs Analysis', + 'รายงานการวิเคราะห์ความปลอดภัย' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MOM', + 'Minutes of Meeting', + 'รายงานการประชุม' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MPR', + 'Monthly Progress Report', + 'รายงานความคืบหน้าประจำเดือน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ICR', + 'Incident Report', + 'รายงานการเกิดอุบัติเหตุและการบาดเจ็บ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'PRG', + 'Progress of Construction', + 'ความคืบหน้าของการก่อสร้าง / ภาพถ่าย / วิดีโอ' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'RPT', + 'Report', + 'รายงาน' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'TNR', + 'Training Report', + 'รายงานการฝึกปฏิบัติ' +from contracts +where contract_code = 'LCBP3-C2'; -- Seed rfa_status_codes -INSERT INTO rfa_status_codes ( - status_code, - status_name, - description, - sort_order - ) -VALUES ('DFT', 'Draft', 'ฉบับร่าง', 1), - ('FAP', 'For Approve', 'เพื่อขออนุมัติ', 11), - ('FRE', 'For Review', 'เพื่อตรวจสอบ', 12), - ('FCO', 'For Construction', 'เพื่อก่อสร้าง', 20), - ('ASB', 'AS - Built', 'แบบก่อสร้างจริง', 30), - ('OBS', 'Obsolete', 'ไม่ใช้งาน', 80), - ('CC', 'Canceled', 'ยกเลิก', 99); -INSERT INTO rfa_approve_codes ( - approve_code, - approve_name, - sort_order, - is_active - ) -VALUES ('1A', 'Approved by Authority', 10, 1), - ('1C', 'Approved by CSC', 11, 1), - ('1N', 'Approved As Note', 12, 1), - ('1R', 'Approved with Remarks', 13, 1), - ('3C', 'Consultant Comments', 31, 1), - ('3R', 'Revise +insert into rfa_status_codes ( + status_code, + status_name, + description, + sort_order + ) +values ('DFT', 'Draft', 'ฉบับร่าง', 1), + ('FAP', 'For Approve', 'เพื่อขออนุมัติ', 11), + ('FRE', 'For Review', 'เพื่อตรวจสอบ', 12), + ('FCO', 'For Construction', 'เพื่อก่อสร้าง', 20), + ('ASB', 'AS - Built', 'แบบก่อสร้างจริง', 30), + ('OBS', 'Obsolete', 'ไม่ใช้งาน', 80), + ('CC', 'Canceled', 'ยกเลิก', 99); +insert into rfa_approve_codes ( + approve_code, + approve_name, + sort_order, + is_active + ) +values ('1A', 'Approved by Authority', 10, 1), + ('1C', 'Approved by CSC', 11, 1), + ('1N', 'Approved As Note', 12, 1), + ('1R', 'Approved with Remarks', 13, 1), + ('3C', 'Consultant Comments', 31, 1), + ('3R', 'Revise and Resubmit', 32, 1), - ('4X', 'Reject', 40, 1), - ('5N', 'No Further Action', 50, 1); + ('4X', 'Reject', 40, 1), + ('5N', 'No Further Action', 50, 1); +-- Seed circulation_status_codes +insert into circulation_status_codes (code, description, sort_order) +values ('OPEN', 'Open', 1), + ('IN_REVIEW', 'In Review', 2), + ('COMPLETED', 'ปCompleted', 3), + ('CANCELLED', 'Cancelled / Withdrawn', 9); -- ตาราง "แม่" ของ RFA (มีความสัมพันธ์ 1:N กับ rfa_revisions) -- ========================================================== -- SEED DATA 6B.md (Disciplines, RFA Types, Sub Types) -- ========================================================== -- 1. Seed ข้อมูล Disciplines (สาขางาน) -- LCBP3-C1 -INSERT INTO disciplines ( - contract_id, - discipline_code, - code_name_th, - code_name_en - ) -SELECT id, - 'GEN', - 'งานบริหารโครงการ', - 'General Management' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'COD', - 'สัญญาและข้อโต้แย้ง', - 'Contracting' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'QSB', - 'สำรวจปริมาณและควบคุมงบประมาณ', - 'Quantity Survey and Budget Control' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'PPG', - 'บริหารแผนและความก้าวหน้า', - 'Plan and Progress Management' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'PRC', - 'งานจัดซื้อ', - 'Procurement' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SUB', - 'ผู้รับเหมาช่วง', - 'Subcontractor' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'ODC', - 'สำนักงาน-ควบคุมเอกสาร', - 'Operation Docment Control' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'LAW', - 'กฎหมาย', - 'Law' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'TRF', - 'จราจร', - 'Traffic' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'BIM', - 'BIM', - 'Building information modeling' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SRV', - 'งานสำรวจ', - 'Survey' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SFT', - 'ความปลอดภัย', - 'Safety' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'BST', - 'งานโครงสร้างอาคาร', - 'Building Structure Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'TEM', - 'งานชั่วคราว', - 'Temporary Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'UTL', - 'งานระบบสาธารณูปโภค', - 'Utility' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'EPW', - 'งานระบบไฟฟ้า', - 'Electrical Power Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'ECM', - 'งานระบบไฟฟ้าสื่อสาร', - 'Electrical Communication Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'ENV', - 'สิ่งแวดล้อม', - 'Environment' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'AQV', - 'คุณภาพอากาศและความสั่นสะเทือน', - 'Air quality and vibration' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'WAB', - 'คุณภาพน้ำและชีววิทยาทางน้ำ', - 'Water quality and Aquatic biology' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'ONS', - 'วิศวกรรมชายฝั่ง', - 'Onshore Engineer Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'PPR', - 'มวลชนสัมพันธ์และการประชาสัมพันธ์', - 'Public Relations' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'OSW', - 'งานก่อสร้างงานทางทะเล', - 'Offshore Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'DRE', - 'งานขุดและถมทะเล', - 'Dredging and Reclamation' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'REV', - 'งานคันหินล้อมพื้นที่ถมทะเล', - 'Revetment' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'BRW', - 'งานเขื่อนกันคลื่น', - 'Breakwater' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SOI', - 'ปรับปรุงคุณภาพดิน', - 'Soil Improvement' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'BLC', - 'งานปรับปรุงคลองบางละมุง', - 'Bang Lamung Canal Bank Protection' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'FUP', - 'งานประตูระบายน้ำและท่อลอด', - 'Floodgate & Under Ground Piping Works' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'SWP', - 'งานอาคารควบคุมสถานีสูบน้ำทะเล', - 'Sea Water Pumping Station Control BuilDing' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'NAV', - 'งานติดตั้งเครื่องหมายช่วงการเดินเรือ', - 'Navigations Aids' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'GEO', - 'งานด้านธรณีเทคนิค', - 'Geotechnical' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'CRW', - 'งานด้านโยธา - Rock Works', - 'Civil-Rock work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'DVR', - 'ทีมนักประดาน้ำ', - 'Dive Work' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'MTS', - 'งานทดสอบวัสดุและธรณีเทคนิค', - 'Materials and Geotechnical Testing' -FROM contracts -WHERE contract_code = 'LCBP3-C1' -UNION ALL -SELECT id, - 'OTH', - 'อื่นๆ', - 'Other' -FROM contracts -WHERE contract_code = 'LCBP3-C1'; +insert into disciplines ( + contract_id, + discipline_code, + code_name_th, + code_name_en + ) +select id, + 'GEN', + 'งานบริหารโครงการ', + 'General Management' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'COD', + 'สัญญาและข้อโต้แย้ง', + 'Contracting' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'QSB', + 'สำรวจปริมาณและควบคุมงบประมาณ', + 'Quantity Survey and Budget Control' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'PPG', + 'บริหารแผนและความก้าวหน้า', + 'Plan and Progress Management' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'PRC', + 'งานจัดซื้อ', + 'Procurement' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SUB', + 'ผู้รับเหมาช่วง', + 'Subcontractor' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'ODC', + 'สำนักงาน-ควบคุมเอกสาร', + 'Operation Docment Control' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'LAW', + 'กฎหมาย', + 'Law' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'TRF', + 'จราจร', + 'Traffic' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'BIM', + 'BIM', + 'Building information modeling' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SRV', + 'งานสำรวจ', + 'Survey' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SFT', + 'ความปลอดภัย', + 'Safety' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'BST', + 'งานโครงสร้างอาคาร', + 'Building Structure Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'TEM', + 'งานชั่วคราว', + 'Temporary Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'UTL', + 'งานระบบสาธารณูปโภค', + 'Utility' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'EPW', + 'งานระบบไฟฟ้า', + 'Electrical Power Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'ECM', + 'งานระบบไฟฟ้าสื่อสาร', + 'Electrical Communication Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'ENV', + 'สิ่งแวดล้อม', + 'Environment' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'AQV', + 'คุณภาพอากาศและความสั่นสะเทือน', + 'Air quality and vibration' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'WAB', + 'คุณภาพน้ำและชีววิทยาทางน้ำ', + 'Water quality and Aquatic biology' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'ONS', + 'วิศวกรรมชายฝั่ง', + 'Onshore Engineer Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'PPR', + 'มวลชนสัมพันธ์และการประชาสัมพันธ์', + 'Public Relations' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'OSW', + 'งานก่อสร้างงานทางทะเล', + 'Offshore Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'DRE', + 'งานขุดและถมทะเล', + 'Dredging and Reclamation' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'REV', + 'งานคันหินล้อมพื้นที่ถมทะเล', + 'Revetment' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'BRW', + 'งานเขื่อนกันคลื่น', + 'Breakwater' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SOI', + 'ปรับปรุงคุณภาพดิน', + 'Soil Improvement' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'BLC', + 'งานปรับปรุงคลองบางละมุง', + 'Bang Lamung Canal Bank Protection' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'FUP', + 'งานประตูระบายน้ำและท่อลอด', + 'Floodgate & Under Ground Piping Works' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'SWP', + 'งานอาคารควบคุมสถานีสูบน้ำทะเล', + 'Sea Water Pumping Station Control BuilDing' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'NAV', + 'งานติดตั้งเครื่องหมายช่วงการเดินเรือ', + 'Navigations Aids' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'GEO', + 'งานด้านธรณีเทคนิค', + 'Geotechnical' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'CRW', + 'งานด้านโยธา - Rock Works', + 'Civil-Rock work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'DVR', + 'ทีมนักประดาน้ำ', + 'Dive Work' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'MTS', + 'งานทดสอบวัสดุและธรณีเทคนิค', + 'Materials and Geotechnical Testing' +from contracts +where contract_code = 'LCBP3-C1' +union all +select id, + 'OTH', + 'อื่นๆ', + 'Other' +from contracts +where contract_code = 'LCBP3-C1'; -- LCBP3-C2 -INSERT INTO disciplines ( - contract_id, - discipline_code, - code_name_th, - code_name_en - ) -SELECT id, - 'GEN', - 'งานบริหารโครงการ', - 'Project Management' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'COD', - 'สัญญาและข้อโต้แย้ง', - 'Contracts and arguments' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'QSB', - 'สำรวจปริมาณและควบคุมงบประมาณ', - 'Survey the quantity and control the budget' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'PPM', - 'บริหารแผนและความก้าวหน้า', - 'Plan Management & Progress' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ODC', - 'สำนักงาน-ควบคุมเอกสาร', - 'Document Control Office' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'LAW', - 'กฎหมาย', - 'Law' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'TRF', - 'จราจร', - 'Traffic' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'BIM', - 'Building Information Modeling', - 'Building Information Modeling' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SRV', - 'งานสำรวจ', - 'Survey' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SFT', - 'ความปลอดภัย', - 'Safety' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'BST', - 'งานโครงสร้างอาคาร', - 'Building Structure' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'UTL', - 'งานะบบสาธารณูปโภค', - 'Public Utilities' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'EPW', - 'งานระบบไฟฟ้า', - 'Electrical Systems' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ECM', - 'งานระบบไฟฟ้าสื่อสาร', - 'Electrical Communication System' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ENV', - 'สิ่งแวดล้อม', - 'Environment' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'AQV', - 'คุณภาพอากาศและความสั่นสะเทือน', - 'Air Quality and Vibration' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'WAB', - 'คุณภาพน้ำและชีววิทยาทางน้ำ', - 'Water Quality and Aquatic Biology' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ONS', - 'วิศวกรรมชายฝั่ง', - 'Coastal Engineering' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'PPR', - 'มวลชนสัมพันธ์และประชาสัมพันธ์', - 'Mass Relations and Public Relations' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'OFW', - 'งานก่อสร้างทางทะเล', - 'Marine Construction' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'EXR', - 'งานขุดและถมทะเล', - 'Excavation and reclamation' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'GEO', - 'งานด้านธรณีเทคนิค', - 'Geotechnical work' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'CRW', - 'งานด้านโยธา - Rock Works', - 'Civil Works - Rock Works' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'DVW', - 'ทีมนักประดาน้ำ', - 'Team of Divers' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MTT', - 'งานทดสอบวัสดุ', - 'Materials Testing' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ARC', - 'งานสถาปัตยกรรม', - 'Architecture' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'STR', - 'งานโครงสร้าง', - 'Structural work' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'SAN', - 'งานระบบสุขาภิบาล', - 'Sanitation System' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'DRA', - 'งานระบบระบายน้ำ', - 'Drainage system work' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'TER', - 'งานท่าเทียบเรือ', - 'Terminal Work work' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'BUD', - 'งานอาคาร', - 'Building' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'ROW', - 'งานถนนและสะพาน', - 'Road and Bridge Work' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'MEC', - 'งานเคริองกล', - 'Mechanical work' -FROM contracts -WHERE contract_code = 'LCBP3-C2' -UNION ALL -SELECT id, - 'OTH', - 'อื่น ๆ', - 'Others' -FROM contracts -WHERE contract_code = 'LCBP3-C2'; +insert into disciplines ( + contract_id, + discipline_code, + code_name_th, + code_name_en + ) +select id, + 'GEN', + 'งานบริหารโครงการ', + 'Project Management' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'COD', + 'สัญญาและข้อโต้แย้ง', + 'Contracts and arguments' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'QSB', + 'สำรวจปริมาณและควบคุมงบประมาณ', + 'Survey the quantity and control the budget' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'PPM', + 'บริหารแผนและความก้าวหน้า', + 'Plan Management & Progress' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ODC', + 'สำนักงาน-ควบคุมเอกสาร', + 'Document Control Office' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'LAW', + 'กฎหมาย', + 'Law' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'TRF', + 'จราจร', + 'Traffic' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'BIM', + 'Building Information Modeling', + 'Building Information Modeling' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SRV', + 'งานสำรวจ', + 'Survey' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SFT', + 'ความปลอดภัย', + 'Safety' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'BST', + 'งานโครงสร้างอาคาร', + 'Building Structure' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'UTL', + 'งานะบบสาธารณูปโภค', + 'Public Utilities' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'EPW', + 'งานระบบไฟฟ้า', + 'Electrical Systems' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ECM', + 'งานระบบไฟฟ้าสื่อสาร', + 'Electrical Communication System' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ENV', + 'สิ่งแวดล้อม', + 'Environment' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'AQV', + 'คุณภาพอากาศและความสั่นสะเทือน', + 'Air Quality and Vibration' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'WAB', + 'คุณภาพน้ำและชีววิทยาทางน้ำ', + 'Water Quality and Aquatic Biology' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ONS', + 'วิศวกรรมชายฝั่ง', + 'Coastal Engineering' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'PPR', + 'มวลชนสัมพันธ์และประชาสัมพันธ์', + 'Mass Relations and Public Relations' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'OFW', + 'งานก่อสร้างทางทะเล', + 'Marine Construction' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'EXR', + 'งานขุดและถมทะเล', + 'Excavation and reclamation' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'GEO', + 'งานด้านธรณีเทคนิค', + 'Geotechnical work' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'CRW', + 'งานด้านโยธา - Rock Works', + 'Civil Works - Rock Works' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'DVW', + 'ทีมนักประดาน้ำ', + 'Team of Divers' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MTT', + 'งานทดสอบวัสดุ', + 'Materials Testing' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ARC', + 'งานสถาปัตยกรรม', + 'Architecture' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'STR', + 'งานโครงสร้าง', + 'Structural work' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'SAN', + 'งานระบบสุขาภิบาล', + 'Sanitation System' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'DRA', + 'งานระบบระบายน้ำ', + 'Drainage system work' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'TER', + 'งานท่าเทียบเรือ', + 'Terminal Work work' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'BUD', + 'งานอาคาร', + 'Building' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'ROW', + 'งานถนนและสะพาน', + 'Road and Bridge Work' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'MEC', + 'งานเคริองกล', + 'Mechanical work' +from contracts +where contract_code = 'LCBP3-C2' +union all +select id, + 'OTH', + 'อื่น ๆ', + 'Others' +from contracts +where contract_code = 'LCBP3-C2'; -- 2. Seed ข้อมูล Correspondence Sub Types (Mapping RFA Types กับ Number) -- เนื่องจาก sub_type_code ตรงกับ RFA Type Code แต่ Req ต้องการ Mapping เป็น Number -- LCBP3-C1 -INSERT INTO correspondence_sub_types ( - contract_id, - correspondence_type_id, - sub_type_code, - sub_type_name, - sub_type_number - ) -SELECT c.id, - ct.id, - 'MAT', - 'Material Approval', - '11' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C1' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'SHP', - 'Shop Drawing Submittal', - '12' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C1' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'DWG', - 'Document Approval', - '13' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C1' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'MET', - 'Engineering Document Submittal', - '14' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C1' - AND ct.type_code = 'RFA'; +insert into correspondence_sub_types ( + contract_id, + correspondence_type_id, + sub_type_code, + sub_type_name, + sub_type_number + ) +select c.id, + ct.id, + 'MAT', + 'Material Approval', + '11' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C1' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'SHP', + 'Shop Drawing Submittal', + '12' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C1' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'DWG', + 'Document Approval', + '13' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C1' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'MET', + 'Engineering Document Submittal', + '14' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C1' + and ct.type_code = 'RFA'; -- LCBP3-C2 -INSERT INTO correspondence_sub_types ( - contract_id, - correspondence_type_id, - sub_type_code, - sub_type_name, - sub_type_number - ) -SELECT c.id, - ct.id, - 'MAT', - 'Material Approval', - '21' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C2' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'SHP', - 'Shop Drawing Submittal', - '22' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C2' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'DWG', - 'Document Approval', - '23' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C2' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'MET', - 'Engineering Document Submittal', - '24' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C2' - AND ct.type_code = 'RFA'; +insert into correspondence_sub_types ( + contract_id, + correspondence_type_id, + sub_type_code, + sub_type_name, + sub_type_number + ) +select c.id, + ct.id, + 'MAT', + 'Material Approval', + '21' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C2' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'SHP', + 'Shop Drawing Submittal', + '22' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C2' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'DWG', + 'Document Approval', + '23' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C2' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'MET', + 'Engineering Document Submittal', + '24' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C2' + and ct.type_code = 'RFA'; -- LCBP3-C3 -INSERT INTO correspondence_sub_types ( - contract_id, - correspondence_type_id, - sub_type_code, - sub_type_name, - sub_type_number - ) -SELECT c.id, - ct.id, - 'MAT', - 'Material Approval', - '31' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C3' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'SHP', - 'Shop Drawing Submittal', - '32' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C3' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'DWG', - 'Document Approval', - '33' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C3' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'MET', - 'Engineering Document Submittal', - '34' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C4' - AND ct.type_code = 'RFA'; +insert into correspondence_sub_types ( + contract_id, + correspondence_type_id, + sub_type_code, + sub_type_name, + sub_type_number + ) +select c.id, + ct.id, + 'MAT', + 'Material Approval', + '31' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C3' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'SHP', + 'Shop Drawing Submittal', + '32' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C3' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'DWG', + 'Document Approval', + '33' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C3' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'MET', + 'Engineering Document Submittal', + '34' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C4' + and ct.type_code = 'RFA'; -- Note: 6B data has C4 on the right column for MET but C3 on left, checking logic... MD says C3 for first 3 rows, then C4 mixed. I will assume C4 starts at row 12 in the MD table. -- LCBP3-C4 -INSERT INTO correspondence_sub_types ( - contract_id, - correspondence_type_id, - sub_type_code, - sub_type_name, - sub_type_number - ) -SELECT c.id, - ct.id, - 'MAT', - 'Material Approval', - '41' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C4' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'SHP', - 'Shop Drawing Submittal', - '42' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C4' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'DWG', - 'Document Approval', - '43' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C4' - AND ct.type_code = 'RFA' -UNION ALL -SELECT c.id, - ct.id, - 'MET', - 'Engineering Document Submittal', - '44' -FROM contracts c, - correspondence_types ct -WHERE c.contract_code = 'LCBP3-C4' - AND ct.type_code = 'RFA'; +insert into correspondence_sub_types ( + contract_id, + correspondence_type_id, + sub_type_code, + sub_type_name, + sub_type_number + ) +select c.id, + ct.id, + 'MAT', + 'Material Approval', + '41' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C4' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'SHP', + 'Shop Drawing Submittal', + '42' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C4' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'DWG', + 'Document Approval', + '43' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C4' + and ct.type_code = 'RFA' +union all +select c.id, + ct.id, + 'MET', + 'Engineering Document Submittal', + '44' +from contracts c, + correspondence_types ct +where c.contract_code = 'LCBP3-C4' + and ct.type_code = 'RFA'; diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index cb8f1e7..adbcf89 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -28,7 +28,10 @@ "@public": ["public/*"], "@styles": ["styles/*"], "@types": ["types/*"], - "@api": ["app/api/*"] + "@api": ["app/api/*"], + // เพิ่มส่วนที่ขาดไปเพื่อให้ตรงกับ Workspace + "@hooks/*": ["app/hooks/*"], + "@utils/*": ["utils/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], diff --git a/nap-dms.lcbp3.code-workspace b/lcbp3.code-workspace similarity index 83% rename from nap-dms.lcbp3.code-workspace rename to lcbp3.code-workspace index 406f539..fd405a2 100644 --- a/nap-dms.lcbp3.code-workspace +++ b/lcbp3.code-workspace @@ -1,32 +1,17 @@ { - "folders": [+ - { - "name": "🎯 Root", - "path": "./" - }, - { - "name": "🗓️ docs", - "path": "./docs" - }, - { - "name": "🔗 specs", - "path": "./specs" - }, - { - "name": "🔧 Backend", - "path": "./backend" - }, - { - "name": "🎨 Frontend", - "path": "./frontend" - } + "folders": [ + { "name": "🎯 Root", "path": "./" }, + { "name": "🔧 Backend", "path": "./backend" }, + { "name": "🎨 Frontend", "path": "./frontend" }, + { "name": "🗓️ docs", "path": "./docs" }, + { "name": "🔗 specs", "path": "./specs" } ], "settings": { // ======================================== // EDITOR SETTINGS // ======================================== - "editor.fontSize": 14, + "editor.fontSize": 15, "editor.lineHeight": 1.6, "editor.rulers": [80, 120], "editor.minimap.enabled": true, @@ -85,34 +70,28 @@ "editor.defaultFormatter": "redhat.vscode-yaml" }, "[dockerfile]": { - "editor.defaultFormatter": "ms-azuretools.vscode-docker" + "editor.defaultFormatter": "dbaeumer.vscode-eslint" + }, + "[sql]": { + "editor.defaultFormatter": "inferrinizzard.prettier-sql-vscode", + "editor.tabSize": 2, + "editor.insertSpaces": true }, - // ======================================== // CODE ACTION ON SAVE // ======================================== "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit", + "source.fixAll": "explicit", + // "source.fixAll.eslint": "explicit" "source.organizeImports": "explicit", "source.addMissingImports": "explicit" }, // ======================================== - // PRETTIER SETTINGS + // PRETTIER SETTINGS .prettierrc // ======================================== - "prettier.singleQuote": true, - "prettier.semi": true, - "prettier.tabWidth": 2, - "prettier.useTabs": false, - "prettier.trailingComma": "es5", - "prettier.printWidth": 80, - "prettier.arrowParens": "always", - "prettier.endOfLine": "lf", - "prettier.bracketSpacing": true, - "prettier.jsxSingleQuote": false, - // ======================================== // ESLINT SETTINGS // ======================================== @@ -127,10 +106,7 @@ "eslint.alwaysShowStatus": true, "eslint.format.enable": false, "eslint.lintTask.enable": true, - "eslint.workingDirectories": [ - "./backend", - "./frontend" - ], + "eslint.workingDirectories": ["./backend", "./frontend"], // ======================================== // PATH INTELLISENSE - ไม่มี src folder // ======================================== @@ -170,7 +146,7 @@ "@public": "${workspaceFolder:🎨 Frontend (React/Next.js)}/public", "@styles": "${workspaceFolder:🎨 Frontend (React/Next.js)}/styles", "@types": "${workspaceFolder:🎨 Frontend (React/Next.js)}/types", - "@api": "${workspaceFolder:🎨 Frontend (React/Next.js)}/app/api", + "@api": "${workspaceFolder:🎨 Frontend (React/Next.js)}/app/api" }, "path-intellisense.autoSlashAfterDirectory": true, "path-intellisense.extensionOnImport": false, @@ -461,12 +437,18 @@ // TERMINAL // ======================================== - "terminal.integrated.fontSize": 14, + "terminal.integrated.fontSize": 15, "terminal.integrated.lineHeight": 1.2, "terminal.integrated.smoothScrolling": true, "terminal.integrated.cursorBlinking": true, "terminal.integrated.fontFamily": "MesloLGS NF, Consolas, monospace", - "terminal.integrated.defaultProfile.windows": "PowerShell", + "terminal.integrated.profiles.windows": { + "PowerShell-7": { + "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", + "icon": "terminal-powershell" + } + }, + "terminal.integrated.defaultProfile.windows": "PowerShell-7", "terminal.integrated.cwd": "${workspaceFolder}", // ======================================== @@ -513,7 +495,7 @@ "*.jsx": "${capture}.test.jsx, ${capture}.spec.jsx" }, - // ======================================== + // ======================================== // BREADCRUMBS // ======================================== @@ -525,9 +507,31 @@ // JEST // ======================================== - "jest.autoRun": "off", - "jest.showCoverageOnLoad": false, - "jest.rootPath": "backend", + // เปิดใช้งาน Jest extension + "jest.enable": true, + + // ปิดการเปิด Terminal ตอนเปิด VS Code + "jest.showTerminalOnLaunch": false, + + // ปิดการเปิด Terminal ตอนรันเทสต์ + "jest.showTerminalOnTestRun": false, + + // ให้รัน Jest ใน background โดยไม่ต้องเปิด terminal + "jest.runInWorkspace": true, + + // แสดงผลลัพธ์เทสต์ใน editor (inline) + "jest.showInlineError": true, + + // ใช้ watch mode สำหรับการรันเทสต์อัตโนมัติเมื่อไฟล์เปลี่ยน + "jest.runMode": "watch", + + // กำหนด path ของ Jest ถ้าใช้ local install + "jest.pathToJest": "node_modules/.bin/jest", + + // กำหนด config ของ Jest ถ้ามีไฟล์ jest.config.js + "jest.pathToConfig": "jest.config.js", + + "jest.disabledWorkspaceFolders": ["🎯 Root", "🗓️ docs", "🔗 specs"], // ======================================== // DOCKER @@ -535,6 +539,7 @@ "docker.languageserver.formatter.ignoreMultilineInstructions": true, "docker.showStartPage": false, + // ======================================== // YAML // ======================================== @@ -622,7 +627,7 @@ "telemetry.telemetryLevel": "off", "security.workspace.trust.untrustedFiles": "open", "extensions.ignoreRecommendations": false, - // ======================================== + // ======================================== // DEBUGGING // ======================================== @@ -790,6 +795,67 @@ "type": "shell", "command": "docker-compose down", "problemMatcher": [] + }, + { + "label": "Start Backend", + "type": "shell", + "command": "npm run start:dev", + "options": { + "cwd": "${workspaceFolder:🔧 Backend}" + }, + "presentation": { + "panel": "dedicated", + "group": "dev", + "reveal": "always" + } + }, + // 1. Task หลักที่จะรันอัตโนมัติเมื่อเปิดโปรแกรม + { + "label": "🚀 Setup Workspace", + "dependsOn": ["🔧 PS: Backend", "🎨 PS: Frontend"], // สั่งให้รัน 2 task ย่อย + "runOptions": { + "runOn": "folderOpen" // <--- คำสั่งศักดิ์สิทธิ์: รันทันทีที่เปิด VS Code + }, + "presentation": { + "reveal": "never" // ไม่ต้องโชว์หน้าต่างของตัวคุมหลัก + }, + "problemMatcher": [] + }, + + // 2. Task ย่อย: เปิด Terminal ที่ Backend + { + "label": "🔧 PS: Backend", + "type": "shell", + "command": "powershell", // สั่งเปิด PowerShell ค้างไว้ + "options": { + "cwd": "${workspaceFolder:🔧 Backend}" // cd เข้า folder นี้ + }, + "isBackground": true, // บอก VS Code ว่าไม่ต้องรอให้จบ (รันค้างไว้เลย) + "problemMatcher": [], + "presentation": { + "group": "workspace-terminals", // จัดกลุ่มเดียวกัน + "reveal": "always", + "panel": "dedicated", // แยก Tab ให้ชัดเจน + "focus": false // ไม่ต้องแย่ง Focus ทันที + } + }, + + // 3. Task ย่อย: เปิด Terminal ที่ Frontend + { + "label": "🎨 PS: Frontend", + "type": "shell", + "command": "powershell", + "options": { + "cwd": "${workspaceFolder:🎨 Frontend}" // cd เข้า folder นี้ + }, + "isBackground": true, + "problemMatcher": [], + "presentation": { + "group": "workspace-terminals", + "reveal": "always", + "panel": "dedicated", + "focus": true // ให้ Focus ที่อันนี้เป็นอันสุดท้าย (พร้อมพิมพ์) + } } ] }, @@ -832,7 +898,8 @@ "chakrounanas.turbo-console-log", "wallabyjs.console-ninja", "pkief.material-icon-theme", - "github.copilot" + "github.copilot", + "inferrinizzard.prettier-sql-vscode" ] } } diff --git a/specs/01-requirements/03.11-document-numbering.md b/specs/01-requirements/03.11-document-numbering.md index e57cff5..3cba5ad 100644 --- a/specs/01-requirements/03.11-document-numbering.md +++ b/specs/01-requirements/03.11-document-numbering.md @@ -18,17 +18,22 @@ related: ## 3.11.1. วัตถุประสงค์: - ระบบต้องสามารถสร้างเลขที่เอกสาร (Running Number) ได้โดยอัตโนมัติและยืดหยุ่นสูง +- ระบต้องสามารถกำหนด รูปแบบ(template) เลขที่เอกสารได้ สำหรับแต่ละโครงการ, ชนิดเอกสาร, ประเภทเอกสาร ## 3.11.2. Logic การนับเลข (Counter Logic): -- การนับเลขจะต้องรองรับการแยกตาม Key ที่ซับซ้อนขึ้น: -- Project + Originator + Type + Discipline (ถ้ามี) + Sub-Type (ถ้ามี) + Year +- การนับเลขจะต้องรองรับการแยกตาม Key ที่ซับซ้อนขึ้น ตามแต่ละ รูปแบบ(template) ได้ ## 3.11.3. Format Template: - รองรับการกำหนดรูปแบบด้วย Token Replacement เช่น: - - รองรับ Token: `{ORG}-{TYPE}-{DISCIPLINE}-{SEQ:4}-{REV}` -> `TEAM-RFA-STR-0001-A` - - รองรับ Token: `{PROJECT}`, `{ORG}`, `{TYPE}`, `{DISCIPLINE}`, `{SUBTYPE}`, `{SUBTYPE_NUM}`, `{YEAR}`, `{YEAR_SHORT}`, `{SEQ:n}` + - transmittal to owner: คคง.-สคฉ.3-03-21-0117-2568 + - other transmittal: ผรม.2-คคง.-0117-2568 + - LCBP3-C2-RFI-ROW-0029-A + - Correspondence type LETTEE คคง.-สคฉ.3-0985-2568 + - Correspondence รองรับ Token: {ORG}-{ORG}-{TYPE}-{SEQ:4}-{YEAR B.D.} -> คคง.-สคฉ.3-STR-0001-2568 + - RFA รองรับ Token: {PROJECT}-{ORG}-{TYPE}-{DISCIPLINE}-{SEQ:4}-{REV} -> TEAM-RFA-STR-0001-A + - Transmittal รองรับ Token: {PROJECT}-{ORG}-{TYPE}-{DISCIPLINE}-{SEQ:4}-{REV} -> TEAM-TR-STR-0001-A ## 3.11.4. Transmittal Logic: