-- Pacific Logistics · slice 37 · Admin & Settings grants (retrofix)
--
-- Audit turned up FOUR sidebar entries with zero grants — links invisible
-- to every user.
--
--   Users            — controller MISSING (dead link)
--   UserGroups       — controller MISSING (dead link)
--   CompanyProfile   — controller exists (index + saveAj), no grants
--   DocNumbers       — controller exists (index + saveAj), no grants
--
-- This slice fixes the two that have real controllers. The two dead links
-- are removed from the sidebar in the same commit (view change).

INSERT IGNORE INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on) VALUES
-- Executive (1) — read-only-ish, gets to see the settings but not necessarily save
(1,  'CompanyProfile', 'index',   1, NOW()),
(1,  'DocNumbers',     'index',   1, NOW()),
-- Administrator (10) — full
(10, 'CompanyProfile', 'index',   1, NOW()),
(10, 'CompanyProfile', 'saveAj',  1, NOW()),
(10, 'DocNumbers',     'index',   1, NOW()),
(10, 'DocNumbers',     'saveAj',  1, NOW());

SELECT ug.user_group_name, ugp.controller_allowed,
       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 IN ('CompanyProfile','DocNumbers')
 GROUP BY ug.c0d, ug.user_group_name, ugp.controller_allowed
 ORDER BY ug.c0d, ugp.controller_allowed;
