- PermissionSeeder: 29 permissions with role mapping (admin/manager/staff) - Policies updated to use hasPermissionTo() instead of hasRole() - ExportBackup command: JSON per-table backup with chunk processing - UserResource: CRUD users with role assignment (admin only) - RoleResource: CRUD roles with permission assignment (admin only) - UserPolicy + RolePolicy: admin-only access control - ImportCskh: detailed skip logging with color in dry-run mode - Widgets: permission-based visibility checks - Tests: 8/8 pass (21 assertions)
6.5 KiB
6.5 KiB
TASKS_ROADMAP.md — AfterSales CRM
Mục đích: Theo dõi tất cả các công việc: đã hoàn thành, đang làm, sẽ làm. Cập nhật: Mỗi khi hoàn thành hoặc thêm task mới.
✅ ĐÃ HOÀN THÀNH (SOP Phase 1–8)
Giai đoạn 1: Mở rộng CSDL
- Bảng
departments(id, name, manager_id → users) - Bổ sung
feedback: current_department_id, is_escalated - Bảng
ticket_transfer_logs - Nâng cấp
feedback_attachments: uuid, disk, collection - Cài Spatie laravel-permission
Giai đoạn 2: Services & Logic
FileService: upload, validation (jpg/png/pdf/mp4/mov ≤20MB), collection query, temporary URLTransferService: transfer department + reason required + notificationClosingService: role-gated close + proof_of_resolution check- Policies dùng Spatie
hasRole() - Custom Rule
RequireProofOfResolution
Giai đoạn 3: Notifications
TicketTransferred(Database + Mail)TicketClosed(Database + Mail)
Giai đoạn 4: Filament UI
TransferDepartmentAction trên EditFeedbackCloseTicketAction- InteractionsRelationManager: role-aware status options
- FeedbackForm: current_department_id, is_escalated
Giai đoạn 5: Dashboard Widgets
ResolvedTicketsWidgetAvgProcessingTimeWidgetHandlerPerformanceWidget
Giai đoạn 6: Testing
- Pest: 8 tests (21 assertions)
Giai đoạn 7: Seeder
- 4 departments, 5 channels, 5 products, 4 customers, 5 feedbacks, 5 tags, 5 interactions, 1 transfer log, 3 attachments
Giai đoạn 8: Polish & Bug Fix
- Dashboard widget filter Manager theo department
- Migration disk default fix
- File upload pattern fix
- Department + Escalated columns trên FeedbackTable
- Validation proof_of_resolution khi close từ form
- Manager chỉ đóng ticket phòng mình
- View Attachments trong Interaction History
- Docker deployment
- Migration notifications table
Giai đoạn 9: Granular Permissions + Export Backup + User/Role Management
- PermissionSeeder: 29 granular permissions (admin/manager/staff mapping)
- Policies updated to
hasPermissionTo()(5 policies) - ExportBackup command:
app:export-backup(JSON, per-table, chunk 500) - UserResource: CRUD users + assign role (admin only)
- RoleResource: CRUD roles + assign permissions via CheckboxList (admin only)
- UserPolicy + RolePolicy (admin-only access)
🔴 CHƯA LÀM — Theo AI Instructions
A: Module Hợp đồng (Contract) — từ AI_01, AI_02
- Tạo migration bảng
contracts:product_idFK,customer_idFKtype(LEASE/BCC/SALE)start_date,end_datestatus(Active/Expired/Liquidated)printed_at,signed_status
- Tạo Model
Contract+ EnumContractType - Relationships:
product(),customer(),feedbacks() - Tạo ContractResource Filament + ContractPolicy
- Tạo ContractsRelationManager trên ProductResource
B: Cơ chế Snapshot Hợp đồng — từ AI_01
- Tạo migration thêm
contract_id(FK->contracts, nullable) vào bảngfeedback - Cập nhật Model
Feedback: fillable + relationshipcontract() - Logic auto-select active contract khi tạo Feedback mới (FeedbackForm)
- Hiển thị contract info trên Feedback list (FeedbackTable column)
- Gán contract_id cho feedback mẫu trong Seeder
C: Module Bàn giao (Handover) — từ AI_01, AI_02
- Tạo migration bảng
handovers:product_idFK,customer_idFKhandover_date(date)status(Chưa đủ điều kiện/Đủ ĐK/Đã lên lịch/Đã BG)remark(text nullable)
- Tạo Model
Handover+ EnumHandoverStatus - Relationships:
product(),customer() - Tạo
HandoversRelationManagergắn vàoProductResource - Cập nhật Product model: thêm
handovers()HasMany
D: Module Dịch vụ phụ trợ (ProductService) — từ AI_02
- Tạo migration bảng
product_services:product_idFKservice_type(MANAGEMENT_FEE/GRATITUDE/SELF_BUSINESS)statusactual_collection_date(date nullable)remark(text nullable)
- Tạo Model
ProductService+ EnumServiceType - Relationship:
product() - Tạo
ProductServicesRelationManagergắn vàoProductResource - Cập nhật Product model: thêm
productServices()HasMany
E: Enhancement ProductResource — từ AI_02
- Thêm RelationManagers vào
ProductResource::getRelations()- ContractsRelationManager ✅
- HandoversRelationManager ✅
- ProductServicesRelationManager ✅
- Product detail page có 3 tabs: Contracts + Handovers + Services
F: Tự động gợi ý transfer — từ AI_01 (optional)
- Hiển thị badge gợi ý: "Ticket BCC → khuyến nghị chuyển Pháp lý"
- Logic detect contract type → suggest department
G: Data Import Pipeline — từ AI_03
- Cài package
spatie/simple-excel - Tạo Command
app:import-cskh {file_path} --dry-run - Logic: Lazy Collection, chunk 100 rows, DB::transaction, ProgressBar
- Pipeline per row: Product/Customer firstOrCreate → Contract/Handover/Service → Feedback + Interactions
- Tạo customer_product pivot record
- Xử lý DateTimeImmutable từ Excel
- Skip header/meta rows
- Đã test thành công với CSKH.xlsx (3658 rows → 3299 products, 2089 customers, 2637 contracts, 2077 handovers, 159 services, 71 feedbacks, 226 interactions)
📋 Ưu tiên phát triển
| Ưu tiên | Task | Phụ thuộc |
|---|---|---|
| 1 | Không | |
| 2 | A | |
| 3 | Không | |
| 4 | Không | |
| 5 | A, C, D | |
| 6 | A, B, C, D | |
| 7 | F: Tự động gợi ý transfer (nice-to-have) | A |
📊 Tiến độ tổng quan
SOP Phase 1-8: ████████████████████████ 100% (Hoàn thành)
AI Instructions Core: ███████████████████████░ 85% (6/7 — Còn: auto-suggest transfer)
Data Import Tested: ████████████████████████ 100% (3658 rows real data imported successfully)