-- Menu Permission Fix Script
-- Generated: 2025-11-29 14:10:15

UPDATE menu_items SET permission_required = 'dashboard.dashboard' WHERE id = 1; -- Dashboard
UPDATE menu_items SET permission_required = 'crm.dashboard' WHERE id = 4; -- Dashboard
UPDATE menu_items SET permission_required = 'crm.activities' WHERE id = 8; -- Activities
UPDATE menu_items SET permission_required = 'crm.contacts' WHERE id = 7; -- Contacts
UPDATE menu_items SET permission_required = 'crm.opportunities' WHERE id = 10; -- Opportunities
UPDATE menu_items SET permission_required = 'crm.reports' WHERE id = 14; -- Reports
UPDATE menu_items SET permission_required = 'settings.automation' WHERE id = 193; -- Automation
UPDATE menu_items SET permission_required = 'settings.company' WHERE id = 19; -- Company Info
UPDATE menu_items SET permission_required = 'settings.email' WHERE id = 20; -- Email Settings
UPDATE menu_items SET permission_required = 'settings.user_groups' WHERE id = 259; -- User Groups
UPDATE menu_items SET permission_required = 'settings.cost_allocation' WHERE id = 26; -- Cost Allocation
UPDATE menu_items SET permission_required = 'settings.fiscal_year' WHERE id = 24; -- Fiscal Year
UPDATE menu_items SET permission_required = 'settings.payment_terms' WHERE id = 25; -- Payment Terms
UPDATE menu_items SET permission_required = 'settings.ppe_parameters' WHERE id = 27; -- PP&E Parameters
UPDATE menu_items SET permission_required = 'settings.tax' WHERE id = 23; -- Tax Settings
UPDATE menu_items SET permission_required = 'settings.business_parameters' WHERE id = 29; -- Business Parameters
UPDATE menu_items SET permission_required = 'settings.facilities' WHERE id = 30; -- Facilities & Leasing
UPDATE menu_items SET permission_required = 'settings.payroll' WHERE id = 31; -- Payroll Settings
UPDATE menu_items SET permission_required = 'settings.action_menus' WHERE id = 277; -- Action Menu Editor
UPDATE menu_items SET permission_required = 'settings.dropdowns' WHERE id = 39; -- Operations
UPDATE menu_items SET permission_required = 'settings.dropdowns' WHERE id = 38; -- Sales & CRM
UPDATE menu_items SET permission_required = 'settings.nda_templates' WHERE id = 278; -- NDA Templates
UPDATE menu_items SET permission_required = 'settings.terms_conditions' WHERE id = 42; -- Terms & Conditions
UPDATE menu_items SET permission_required = 'accounting.accounts' WHERE id = 47; -- Chart of Accounts
UPDATE menu_items SET permission_required = 'accounting.journal' WHERE id = 48; -- Journal Entries
UPDATE menu_items SET permission_required = 'accounting.ledger' WHERE id = 49; -- General Ledger
UPDATE menu_items SET permission_required = 'accounting.bank_accounts' WHERE id = 51; -- Bank Accounts
UPDATE menu_items SET permission_required = 'accounting.reconciliation' WHERE id = 52; -- Bank Reconciliation
UPDATE menu_items SET permission_required = 'accounting.expenses' WHERE id = 54; -- Expenses
UPDATE menu_items SET permission_required = 'accounting.budgets' WHERE id = 55; -- Budgets
UPDATE menu_items SET permission_required = 'accounting.assets' WHERE id = 57; -- Fixed Assets
UPDATE menu_items SET permission_required = 'accounting.depreciation' WHERE id = 58; -- Depreciation
UPDATE menu_items SET permission_required = 'accounting.period' WHERE id = 60; -- Period Closing
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 45; -- All Report Package
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 62; -- Balance Sheet
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 63; -- Income Statement
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 253; -- Cash Flow Statement
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 65; -- Trial Balance
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 66; -- Aging Reports
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 251; -- A/P Aging Detail
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 252; -- A/R Aging Detail
UPDATE menu_items SET permission_required = 'accounting.reports' WHERE id = 254; -- Payment Terms List
UPDATE menu_items SET permission_required = 'hr.dashboard' WHERE id = 69; -- Dashboard
UPDATE menu_items SET permission_required = 'employees.view' WHERE id = 70; -- Employees
UPDATE menu_items SET permission_required = 'hr.recruitment' WHERE id = 72; -- Dashboard
UPDATE menu_items SET permission_required = 'hr.recruitment' WHERE id = 74; -- Applications
UPDATE menu_items SET permission_required = 'hr.recruitment' WHERE id = 75; -- Interviews
UPDATE menu_items SET permission_required = 'hr.recruitment' WHERE id = 76; -- Assessments
UPDATE menu_items SET permission_required = 'hr.recruitment' WHERE id = 77; -- Offers
UPDATE menu_items SET permission_required = 'hr.development' WHERE id = 79; -- Contracts
UPDATE menu_items SET permission_required = 'hr.development' WHERE id = 80; -- Training
UPDATE menu_items SET permission_required = 'hr.development' WHERE id = 81; -- Performance Reviews
UPDATE menu_items SET permission_required = 'hr.relations' WHERE id = 83; -- Issues & Challenges
UPDATE menu_items SET permission_required = 'hr.relations' WHERE id = 84; -- Separations
UPDATE menu_items SET permission_required = 'inventory.dashboard' WHERE id = 87; -- Dashboard
UPDATE menu_items SET permission_required = 'inventory.stock_levels' WHERE id = 91; -- Stock Levels
UPDATE menu_items SET permission_required = 'inventory.lots' WHERE id = 180; -- Lot/Serial Numbers
UPDATE menu_items SET permission_required = 'products.view' WHERE id = 89; -- Products
UPDATE menu_items SET permission_required = 'inventory.categories' WHERE id = 90; -- Categories
UPDATE menu_items SET permission_required = 'manufacturing.dashboard' WHERE id = 93; -- Dashboard
UPDATE menu_items SET permission_required = 'manufacturing.capacity' WHERE id = 95; -- Dashboard
UPDATE menu_items SET permission_required = 'manufacturing.capacity' WHERE id = 96; -- Real-time Status
UPDATE menu_items SET permission_required = 'manufacturing.capacity' WHERE id = 97; -- Analytics
UPDATE menu_items SET permission_required = 'manufacturing.capacity' WHERE id = 98; -- Availability
UPDATE menu_items SET permission_required = 'manufacturing.capacity' WHERE id = 99; -- Feasibility
UPDATE menu_items SET permission_required = 'manufacturing.boms' WHERE id = 101; -- Bill of Materials
UPDATE menu_items SET permission_required = 'manufacturing.mrp' WHERE id = 102; -- MRP
UPDATE menu_items SET permission_required = 'manufacturing.scheduling' WHERE id = 103; -- Production Scheduling
UPDATE menu_items SET permission_required = 'manufacturing.workorders' WHERE id = 105; -- Work Orders
UPDATE menu_items SET permission_required = 'manufacturing.shopfloor' WHERE id = 106; -- Shop Floor Control
UPDATE menu_items SET permission_required = 'manufacturing.business_lines' WHERE id = 108; -- Business Lines
UPDATE menu_items SET permission_required = 'manufacturing.equipment_lines' WHERE id = 109; -- Equipment Lines
UPDATE menu_items SET permission_required = 'manufacturing.equipment' WHERE id = 110; -- Equipment Units
UPDATE menu_items SET permission_required = 'manufacturing.quality' WHERE id = 112; -- Dashboard
UPDATE menu_items SET permission_required = 'manufacturing.quality' WHERE id = 113; -- Inspections
UPDATE menu_items SET permission_required = 'manufacturing.quality' WHERE id = 114; -- NCR
UPDATE menu_items SET permission_required = 'manufacturing.quality' WHERE id = 115; -- Metrics
UPDATE menu_items SET permission_required = 'manufacturing.quality' WHERE id = 116; -- Templates
UPDATE menu_items SET permission_required = 'manufacturing.maintenance' WHERE id = 118; -- Maintenance Schedules
UPDATE menu_items SET permission_required = 'manufacturing.maintenance' WHERE id = 119; -- Maintenance Work Orders
UPDATE menu_items SET permission_required = 'manufacturing.maintenance' WHERE id = 120; -- Downtime Tracking
UPDATE menu_items SET permission_required = 'manufacturing.costing' WHERE id = 122; -- Production Costing
UPDATE menu_items SET permission_required = 'manufacturing.costing' WHERE id = 123; -- Job Costing
UPDATE menu_items SET permission_required = 'manufacturing.reports' WHERE id = 125; -- Production Reports
UPDATE menu_items SET permission_required = 'manufacturing.reports' WHERE id = 126; -- OEE Reports
UPDATE menu_items SET permission_required = 'sales.dashboard' WHERE id = 128; -- Dashboard
UPDATE menu_items SET permission_required = 'sales.reports' WHERE id = 142; -- Reports
UPDATE menu_items SET permission_required = 'quotes.view' WHERE id = 130; -- Quotes
UPDATE menu_items SET permission_required = 'sales.orders' WHERE id = 131; -- Orders
UPDATE menu_items SET permission_required = 'creditnotes.view' WHERE id = 133; -- Credit Notes
UPDATE menu_items SET permission_required = 'shipments.view' WHERE id = 136; -- Shipments
UPDATE menu_items SET permission_required = 'sales.delivery_notes' WHERE id = 137; -- Delivery Notes
UPDATE menu_items SET permission_required = 'sales.returns' WHERE id = 138; -- Returns (RMA)
UPDATE menu_items SET permission_required = 'sales.pricing_rules' WHERE id = 140; -- Pricing Rules
UPDATE menu_items SET permission_required = 'sales.promotions' WHERE id = 141; -- Discounts & Promotions
UPDATE menu_items SET permission_required = 'purchases.dashboard' WHERE id = 144; -- Dashboard
UPDATE menu_items SET permission_required = 'suppliers.view' WHERE id = 145; -- Suppliers
UPDATE menu_items SET permission_required = 'purchases.reports' WHERE id = 157; -- Reports
UPDATE menu_items SET permission_required = 'purchases.requisitions' WHERE id = 147; -- Purchase Requisitions
UPDATE menu_items SET permission_required = 'purchases.rfqs' WHERE id = 148; -- RFQs (Quotes)
UPDATE menu_items SET permission_required = 'purchases.orders' WHERE id = 149; -- Purchase Orders
UPDATE menu_items SET permission_required = 'purchases.receiving' WHERE id = 150; -- Goods Receipt
UPDATE menu_items SET permission_required = 'purchases.bills' WHERE id = 152; -- Bills/Invoices
UPDATE menu_items SET permission_required = 'purchases.payments' WHERE id = 153; -- Payments Made (Legacy)
UPDATE menu_items SET permission_required = 'purchases.returns' WHERE id = 154; -- Purchase Returns
UPDATE menu_items SET permission_required = 'purchases.debit_notes' WHERE id = 155; -- Debit Notes
UPDATE menu_items SET permission_required = 'inventory.lots' WHERE id = 181; -- All Lots/Serials
UPDATE menu_items SET permission_required = 'inventory.lots' WHERE id = 182; -- Traceability
UPDATE menu_items SET permission_required = 'inventory.lots' WHERE id = 183; -- Expiration Dates
UPDATE menu_items SET permission_required = 'accounting.currency' WHERE id = 185; -- Currencies
UPDATE menu_items SET permission_required = 'accounting.currency' WHERE id = 186; -- Exchange Rates
UPDATE menu_items SET permission_required = 'projects.my_projects' WHERE id = 201; -- My Projects
UPDATE menu_items SET permission_required = 'projects.my_tasks' WHERE id = 202; -- My Tasks
UPDATE menu_items SET permission_required = 'file_manager.all_files' WHERE id = 208; -- All Files
UPDATE menu_items SET permission_required = 'file_manager.my_files' WHERE id = 209; -- My Files
UPDATE menu_items SET permission_required = 'file_manager.shared' WHERE id = 210; -- Shared With Me
UPDATE menu_items SET permission_required = 'product_forecast.proforma' WHERE id = 311; -- Pro Forma Stmts
UPDATE menu_items SET permission_required = 'product_forecast.sensitivity' WHERE id = 313; -- Sensitivity Analysis
UPDATE menu_items SET permission_required = 'product_forecast.compare' WHERE id = 312; -- Compare Scenarios
