-- Pacific Logistics · slice 02 · Pacific-specific roles + Trucks & Drivers grants
--
-- rsflow's seed already gives us: 1=Executive, 2=Finance Manager, 3=Accountant,
-- 4=Project Manager, 5=Projects Coordinator, 6=Field Supervisor, 7=Procurement,
-- 8=Stores, 9=CRM, 10=Administrator. Reuse the ones that map cleanly; add the
-- fleet-specific roles at id 20+ to leave a gap for future rsflow additions.

INSERT IGNORE INTO user_groups (c0d, user_group_name) VALUES
  (20, 'Ops Manager'),
  (21, 'Dispatcher'),
  (22, 'Fleet Manager'),
  (23, 'Fuel Officer'),
  (24, 'HR Officer'),
  (25, 'Driver');

-- ---- Trucks perms per role (Admin already granted in pacific_01_trucks.sql) ----
-- Executive: read only.  Ops Manager & Fleet Manager: full.  Dispatcher/HR/Accountant/FM: read only.
INSERT IGNORE INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on) VALUES
-- Executive (id 1) — read only
(1,  'Trucks', 'index',     1, NOW()),
(1,  'Trucks', 'view',      1, NOW()),
-- Ops Manager (20) — full
(20, 'Trucks', 'index',     1, NOW()),
(20, 'Trucks', 'add',       1, NOW()),
(20, 'Trucks', 'view',      1, NOW()),
(20, 'Trucks', 'edit',      1, NOW()),
(20, 'Trucks', 'delete',    1, NOW()),
(20, 'Trucks', 'uploadDoc', 1, NOW()),
(20, 'Trucks', 'deleteDoc', 1, NOW()),
(20, 'Trucks', 'viewDoc',   1, NOW()),
-- Dispatcher (21) — read
(21, 'Trucks', 'index',     1, NOW()),
(21, 'Trucks', 'view',      1, NOW()),
-- Fleet Manager (22) — full
(22, 'Trucks', 'index',     1, NOW()),
(22, 'Trucks', 'add',       1, NOW()),
(22, 'Trucks', 'view',      1, NOW()),
(22, 'Trucks', 'edit',      1, NOW()),
(22, 'Trucks', 'delete',    1, NOW()),
(22, 'Trucks', 'uploadDoc', 1, NOW()),
(22, 'Trucks', 'deleteDoc', 1, NOW()),
(22, 'Trucks', 'viewDoc',   1, NOW()),
-- HR Officer (24) — read
(24, 'Trucks', 'index',     1, NOW()),
(24, 'Trucks', 'view',      1, NOW()),
-- Accountant (3) — read
(3,  'Trucks', 'index',     1, NOW()),
(3,  'Trucks', 'view',      1, NOW()),
-- Finance Manager (2) — read
(2,  'Trucks', 'index',     1, NOW()),
(2,  'Trucks', 'view',      1, NOW());


-- ---- Drivers perms per role ----
INSERT IGNORE INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on) VALUES
-- Administrator (10) — full
(10, 'Drivers', 'index',     1, NOW()),
(10, 'Drivers', 'add',       1, NOW()),
(10, 'Drivers', 'view',      1, NOW()),
(10, 'Drivers', 'edit',      1, NOW()),
(10, 'Drivers', 'delete',    1, NOW()),
(10, 'Drivers', 'uploadDoc', 1, NOW()),
(10, 'Drivers', 'deleteDoc', 1, NOW()),
(10, 'Drivers', 'viewDoc',   1, NOW()),
-- Executive (1) — read
(1,  'Drivers', 'index',     1, NOW()),
(1,  'Drivers', 'view',      1, NOW()),
-- Ops Manager (20) — read + edit (assigns drivers to trucks/trips, not owner of driver identity data)
(20, 'Drivers', 'index',     1, NOW()),
(20, 'Drivers', 'view',      1, NOW()),
(20, 'Drivers', 'edit',      1, NOW()),
-- Dispatcher (21) — read
(21, 'Drivers', 'index',     1, NOW()),
(21, 'Drivers', 'view',      1, NOW()),
-- Fleet Manager (22) — read
(22, 'Drivers', 'index',     1, NOW()),
(22, 'Drivers', 'view',      1, NOW()),
-- HR Officer (24) — full (owns the driver identity + document lifecycle)
(24, 'Drivers', 'index',     1, NOW()),
(24, 'Drivers', 'add',       1, NOW()),
(24, 'Drivers', 'view',      1, NOW()),
(24, 'Drivers', 'edit',      1, NOW()),
(24, 'Drivers', 'delete',    1, NOW()),
(24, 'Drivers', 'uploadDoc', 1, NOW()),
(24, 'Drivers', 'deleteDoc', 1, NOW()),
(24, 'Drivers', 'viewDoc',   1, NOW()),
-- Accountant (3) — read
(3,  'Drivers', 'index',     1, NOW()),
(3,  'Drivers', 'view',      1, NOW()),
-- Finance Manager (2) — read
(2,  'Drivers', 'index',     1, NOW()),
(2,  'Drivers', 'view',      1, NOW());
