Files
minicrm/TASKS_ROADMAP.md
phuongtc 3a8db5cae6
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
feat: granular permissions, export backup, user/role management
- 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)
2026-05-02 04:47:10 +00:00

6.5 KiB
Raw Blame History

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 18)

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 URL
  • TransferService: transfer department + reason required + notification
  • ClosingService: 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

  • TransferDepartment Action trên EditFeedback
  • CloseTicket Action
  • InteractionsRelationManager: role-aware status options
  • FeedbackForm: current_department_id, is_escalated

Giai đoạn 5: Dashboard Widgets

  • ResolvedTicketsWidget
  • AvgProcessingTimeWidget
  • HandlerPerformanceWidget

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_id FK, customer_id FK
    • type (LEASE/BCC/SALE)
    • start_date, end_date
    • status (Active/Expired/Liquidated)
    • printed_at, signed_status
  • Tạo Model Contract + Enum ContractType
  • 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ảng feedback
  • Cập nhật Model Feedback: fillable + relationship contract()
  • 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_id FK, customer_id FK
    • handover_date (date)
    • status (Chưa đủ điều kiện/Đủ ĐK/Đã lên lịch/Đã BG)
    • remark (text nullable)
  • Tạo Model Handover + Enum HandoverStatus
  • Relationships: product(), customer()
  • Tạo HandoversRelationManager gắn vào ProductResource
  • 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_id FK
    • service_type (MANAGEMENT_FEE/GRATITUDE/SELF_BUSINESS)
    • status
    • actual_collection_date (date nullable)
    • remark (text nullable)
  • Tạo Model ProductService + Enum ServiceType
  • Relationship: product()
  • Tạo ProductServicesRelationManager gắn vào ProductResource
  • 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 A: Module Hợp đồng (Migration + Model) Không
2 B: contract_id trên feedback (Snapshot) A
3 C: Module Bàn giao (Migration + Model + RelationManager) Không
4 D: Module Dịch vụ (Migration + Model + RelationManager) Không
5 E: Enhancement ProductResource A, C, D
6 G: Data Import Pipeline 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)