
-- Insert Customer Category right
-- Using ID 55
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (55, 'Customer Category', 'View and manage customer categories', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Customer Category right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 55)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Item Modifier Management right
-- Using ID 56
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (56, 'Item Modifier Management', 'View and manage item modifiers', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Item Modifier Management right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 56)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Void Reasons right
-- Using ID 57
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (57, 'Void Reasons', 'View and manage void reasons', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Void Reasons right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 57)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Quotations right
-- Using ID 58
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (58, 'Quotations', 'View and manage quotations', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Quotations right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 58)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Delivery Challan right
-- Using ID 59 (check if already exists without ID first)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (59, 'Delivery Challan', 'View and manage delivery challans', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Delivery Challan right to Admin role (role_id = 1)
-- First, get the right_id (whether it was just inserted or already exists)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
SELECT 1, id FROM `rights` WHERE `name` = 'Delivery Challan'
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Discount Management right
-- Using ID 60
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (60, 'Discount Management', 'View and manage discounts', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Discount Management right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 60)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Deal Management right
-- Using ID 61
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (61, 'Deal Management', 'View and manage deals', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Deal Management right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 61)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Order Takers right
-- Using ID 62
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (62, 'Order Takers', 'View and manage order takers', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Order Takers right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 62)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Tables right (for dine-in)
-- Using ID 63
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (63, 'Tables', 'View and manage tables for dine-in', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Tables right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 63)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Floors right (for dine-in)
-- Using ID 64
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (64, 'Floors', 'View and manage floors for dine-in', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Floors right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 64)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Riders right
-- Using ID 65
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (65, 'Riders', 'View and manage delivery riders', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Riders right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 65)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Delivery Orders right
-- Using ID 66
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (66, 'Delivery Orders', 'View and manage delivery orders', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Delivery Orders right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 66)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);





-- Insert Customer List right (ID 53)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (53, 'Customer List', 'View and manage customer list', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Customer List right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 53)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Customer Balance right (ID 54)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (54, 'Customer Balance', 'View customer balances and account statements', 'Sales')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Customer Balance right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 54)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);



-- Insert Items right (ID 67)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (67, 'Items', 'View and manage items', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Items right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 67)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Item Categories right (ID 68)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (68, 'Item Categories', 'View and manage item categories', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Item Categories right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 68)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert UOM Management right (ID 69)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (69, 'UOM Management', 'View and manage unit of measurement', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign UOM Management right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 69)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Purchases right (ID 70)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (70, 'Purchases', 'View and manage purchases', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Purchases right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 70)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Suppliers right (ID 71)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (71, 'Suppliers', 'View and manage suppliers', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Suppliers right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 71)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Supplier Balance right (ID 72)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (72, 'Supplier Balance', 'View supplier balances and account statements', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Supplier Balance right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 72)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Stock Transfer Request right (ID 73)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (73, 'Stock Transfer Request', 'Create and manage stock transfer requests', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Stock Transfer Request right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 73)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Stock Transfer Approval right (ID 74)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (74, 'Stock Transfer Approval', 'Approve stock transfer requests', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Stock Transfer Approval right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 74)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Stock Adjustment List right (ID 75)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (75, 'Stock Adjustment List', 'View stock adjustment list', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Stock Adjustment List right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 75)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Stock Adjustment right (ID 76)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (76, 'Stock Adjustment', 'Create new stock adjustments', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Stock Adjustment right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 76)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Production Orders right (ID 77)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (77, 'Production Orders', 'View and manage production orders', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Production Orders right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 77)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Opening Balance right (ID 78)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (78, 'Opening Balance', 'Manage opening balances', 'Inventory')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Opening Balance right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 78)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);




-- Insert Expenses right (ID 79)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (79, 'Expenses', 'View and manage expenses', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Expenses right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 79)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Expense Accounts right (ID 80)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (80, 'Expense Accounts', 'View and manage expense accounts', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Expense Accounts right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 80)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Expense Categories right (ID 81)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (81, 'Expense Categories', 'View and manage expense categories', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Expense Categories right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 81)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Bank Accounts right (ID 82)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (82, 'Bank Accounts', 'View and manage bank accounts', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Bank Accounts right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 82)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Payment Methods right (ID 83)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (83, 'Payment Methods', 'View and manage payment methods', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Payment Methods right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 83)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Card Types right (ID 84)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (84, 'Card Types', 'View and manage card types', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Card Types right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 84)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Customer Payments right (ID 85)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (85, 'Customer Payments', 'View and manage customer payments', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Customer Payments right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 85)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Supplier Payments right (ID 86)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (86, 'Supplier Payments', 'View and manage supplier payments', 'Accounts')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Supplier Payments right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 86)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);



-- Insert Quick Transaction right (ID 87)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (87, 'Quick Transaction', 'Create quick financial transactions', 'Financials')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Quick Transaction right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 87)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Journal Entries right (ID 88)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (88, 'Journal Entries', 'View and manage journal entries', 'Financials')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Journal Entries right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 88)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Chart of Accounts right (ID 89)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (89, 'Chart of Accounts', 'View and manage chart of accounts', 'Financials')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Chart of Accounts right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 89)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Account Mappings right (ID 90)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (90, 'Account Mappings', 'View and manage account mappings', 'Financials')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Account Mappings right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 90)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Period Management right (ID 91)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (91, 'Period Management', 'View and manage accounting periods', 'Financials')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Period Management right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 91)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);



-- Insert Terminals right (ID 92)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (92, 'Terminals', 'View and manage terminals', 'Hardware')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Terminals right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 92)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Print Devices right (ID 93)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (93, 'Print Devices', 'View and manage print devices', 'Hardware')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Print Devices right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 93)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert KOT/KDS right (ID 94)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (94, 'KOT/KDS', 'View and manage KOT/KDS management', 'Hardware')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign KOT/KDS right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 94)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Tablet Orders right (ID 95)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (95, 'Tablet Orders', 'View and manage tablet orders', 'Hardware')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Tablet Orders right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 95)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Backup Tool right (ID 96)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (96, 'Backup Tool', 'Access backup tool for database operations', 'Hardware')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Backup Tool right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 96)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);



-- Insert General Settings right (ID 97)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (97, 'General Settings', 'Access general system settings', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign General Settings right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 97)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Branches right (ID 98)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (98, 'Branches', 'View and manage branches', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Branches right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 98)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Stores right (ID 99)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (99, 'Stores', 'View and manage stores', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Stores right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 99)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Sync Settings right (ID 100)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (100, 'Sync Settings', 'Manage sync settings', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Sync Settings right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 100)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Languages right (ID 101)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (101, 'Languages', 'Manage language settings', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Languages right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 101)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Tax Rates right (ID 102)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (102, 'Tax Rates', 'View and manage tax rates', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Tax Rates right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 102)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert DB Operations right (ID 103)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (103, 'DB Operations', 'Access database operations panel', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign DB Operations right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 103)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);

-- Insert Users & Permissions right (ID 104)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) 
VALUES (104, 'Users & Permissions', 'Manage users and permissions', 'Settings')
ON DUPLICATE KEY UPDATE 
    `name` = VALUES(`name`),
    `description` = VALUES(`description`),
    `category` = VALUES(`category`);

-- Assign Users & Permissions right to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) 
VALUES (1, 104)
ON DUPLICATE KEY UPDATE 
    `role_id` = VALUES(`role_id`), 
    `right_id` = VALUES(`right_id`);




INSERT INTO `settings` (`store_id`, `category_id`, `name`, `code`, `type`, `value`, `default_value`, `description`, `is_active`) 
SELECT NULL, 4, 'Catering', 'catering', 'boolean', '1', '1', 'Enable Catering orders', 1
WHERE NOT EXISTS (SELECT 1 FROM settings WHERE code = 'catering');





-- Add number_of_guests column to sales table
ALTER TABLE `sales` 
ADD COLUMN `number_of_guests` INT NULL DEFAULT NULL 
AFTER `order_taker_id`;

-- Add number_of_guests column to hold_orders table
ALTER TABLE `hold_orders` 
ADD COLUMN `number_of_guests` INT NULL DEFAULT NULL 
AFTER `order_taker_id`;

-- Add index for better query performance (optional)
ALTER TABLE `sales` 
ADD INDEX `idx_number_of_guests` (`number_of_guests`);


ALTER TABLE `items` 
ADD COLUMN `supplier_id` INT NULL DEFAULT NULL AFTER `is_third_schedule`;

-- Add index for better performance
CREATE INDEX `idx_items_supplier_id` ON `items` (`supplier_id`);

INSERT INTO `rights` (`id`, `name`, `description`, `category`) VALUES (NULL, 'Customer List', 'Manage customer', 'Sales');




-- Add POS Screen Type setting
INSERT INTO `settings` (`store_id`, `category_id`, `name`, `code`, `type`, `value`, `default_value`, `description`, `is_active`) 
SELECT 
    NULL,
    6,
    'POS Screen Type',
    'pos_screen_type',
    'select',
    'touch_screen',
    'touch_screen',
    'Select POS interface type: Touch Screen (restaurant) shows categories/subcategories, Desktop shows search bar',
    1
WHERE NOT EXISTS (SELECT 1 FROM settings WHERE code = 'pos_screen_type');

-- Get the setting ID for adding options
SET @setting_id = (SELECT id FROM settings WHERE code = 'pos_screen_type' LIMIT 1);

-- Add setting options for POS Screen Type
INSERT INTO `setting_options` (`setting_id`, `option_label`, `option_value`) 
SELECT @setting_id, 'Touch Screen (Restaurant)', 'touch_screen'
WHERE NOT EXISTS (
    SELECT 1 FROM setting_options 
    WHERE setting_id = @setting_id AND option_value = 'touch_screen'
);

INSERT INTO `setting_options` (`setting_id`, `option_label`, `option_value`) 
SELECT @setting_id, 'Desktop', 'desktop'
WHERE NOT EXISTS (
    SELECT 1 FROM setting_options 
    WHERE setting_id = @setting_id AND option_value = 'desktop'
);


-- Add POS Order Taker Display setting
INSERT INTO `settings` (`store_id`, `category_id`, `name`, `code`, `type`, `value`, `default_value`, `description`, `is_active`) 
SELECT 
    NULL,
    6,
    'Display Order Taker Selection',
    'pos_display_order_taker',
    'boolean',
    '0',
    '0',
    'Enable to show order taker selection dropdown on POS (appears next to customer selection)',
    1
WHERE NOT EXISTS (SELECT 1 FROM settings WHERE code = 'pos_display_order_taker');


INSERT INTO `video_help` (`page_name`, `page_title`, `video_url`, `video_title`, `description`, `is_active`, `created_at`, `updated_at`) 
VALUES ('backup_tool', 'Backup Tool', 'https://youtu.be/j-TWDFgPMME?si=WmrijzPYtVOr4fg3', 'ITR POS Backup Tool Tutorial', 'Learn how to download, install, configure, and use the ITR POS Backup Tool for automated database backups.', 1, NOW(), NOW());




ALTER TABLE `items` ADD COLUMN `wholesale_price` DECIMAL(10,2) NULL DEFAULT NULL AFTER `retail_price`;

ALTER TABLE `customers` ADD COLUMN `customer_type` ENUM('retail', 'wholesale') NOT NULL DEFAULT 'retail' AFTER `category_id`;




INSERT INTO video_help (page_name, page_title, video_url, video_title, description, is_active) 
VALUES (
    'fbr_integration',
    'FBR Integration',
    'https://youtu.be/pEUirdhePdA?si=kmk7xb1t0F_KloUS',
    'FBR Integration Tutorial',
    'Learn how to configure and use FBR integration, read item list, and manage FBR settings.',
    1
)
ON DUPLICATE KEY UPDATE
    page_title = 'FBR Integration',
    video_url = 'https://youtu.be/pEUirdhePdA?si=kmk7xb1t0F_KloUS',
    video_title = 'FBR Integration Tutorial',
    description = 'Learn how to configure and use FBR integration, read item list, and manage FBR settings.',
    is_active = 1;


-- Add login authentication method setting to system_settings category
INSERT INTO `settings` (`category_id`, `name`, `code`, `type`, `value`, `default_value`, `description`, `is_active`) 
SELECT 
    (SELECT id FROM setting_categories WHERE code = 'system_settings' LIMIT 1),
    'Login Authentication Method',
    'login_authentication_method',
    'select',
    'username_password',
    'username_password',
    'Choose the authentication method for user login: Username/Password or PIN',
    1
WHERE NOT EXISTS (SELECT 1 FROM settings WHERE code = 'login_authentication_method');

-- Add login method options
INSERT INTO `setting_options` (`setting_id`, `option_label`, `option_value`) 
SELECT 
    (SELECT id FROM settings WHERE code = 'login_authentication_method' LIMIT 1),
    'Username & Password',
    'username_password'
WHERE NOT EXISTS (SELECT 1 FROM setting_options WHERE setting_id = (SELECT id FROM settings WHERE code = 'login_authentication_method') AND option_value = 'username_password');

INSERT INTO `setting_options` (`setting_id`, `option_label`, `option_value`) 
SELECT 
    (SELECT id FROM settings WHERE code = 'login_authentication_method' LIMIT 1),
    'PIN',
    'pin'
WHERE NOT EXISTS (SELECT 1 FROM setting_options WHERE setting_id = (SELECT id FROM settings WHERE code = 'login_authentication_method') AND option_value = 'pin');


