-- Pacific Logistics · slice 34 · Customer statements
--
-- Grants only. Reads from customer_invoices, customer_receipts, and
-- customers — no new tables.

INSERT IGNORE INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on) VALUES
-- Executive (1) — read
(1,  'CustomerStatements', 'index', 1, NOW()),
(1,  'CustomerStatements', 'pdf',   1, NOW()),
-- Finance Manager (2)
(2,  'CustomerStatements', 'index', 1, NOW()),
(2,  'CustomerStatements', 'pdf',   1, NOW()),
-- Accountant (3)
(3,  'CustomerStatements', 'index', 1, NOW()),
(3,  'CustomerStatements', 'pdf',   1, NOW()),
-- CRM (9)
(9,  'CustomerStatements', 'index', 1, NOW()),
(9,  'CustomerStatements', 'pdf',   1, NOW()),
-- Administrator (10)
(10, 'CustomerStatements', 'index', 1, NOW()),
(10, 'CustomerStatements', 'pdf',   1, NOW());

SELECT ug.user_group_name, GROUP_CONCAT(ugp.action_allowed ORDER BY ugp.action_allowed) AS actions
  FROM user_groups_perms ugp
  JOIN user_groups ug ON ug.c0d = ugp.user_group_id
 WHERE ugp.controller_allowed = 'CustomerStatements'
 GROUP BY ug.c0d, ug.user_group_name;
