

-- Insert missing report rights (starting from ID 27)
INSERT INTO `rights` (`id`, `name`, `description`, `category`) VALUES
(27, 'Daily Sales Report', 'View daily sales summary report', 'Reports'),
(28, 'Shift Report', 'View cashier shift reports', 'Reports'),
(29, 'Invoice Report', 'View detailed invoice reports', 'Reports'),
(30, 'Invoice Profit Report', 'View invoice profit analysis', 'Reports'),
(31, 'Itemwise Sales Report', 'View sales report by items', 'Reports'),
(32, 'Tax Wise Report', 'View tax summary reports', 'Reports'),
(33, 'Discount Report', 'View discount usage reports', 'Reports'),
(34, 'Void Orders Report', 'View voided orders report', 'Reports'),
(35, 'Sale Return Report', 'View sale returns report', 'Reports'),
(36, 'Purchase Return Report', 'View purchase returns report', 'Reports'),
(37, 'Order Taker Report', 'View order taker performance report', 'Reports'),
(38, 'Stock Balance Report', 'View current stock balance', 'Reports'),
(39, 'Stock Valuation Report', 'View stock valuation report', 'Reports'),
(40, 'Reorder Report', 'View items that need reordering', 'Reports'),
(41, 'Item Cost Report', 'View item cost analysis', 'Reports'),
(42, 'Item Ledger Report', 'View item transaction ledger', 'Reports'),
(43, 'Item Modifier Report', 'View item modifiers usage report', 'Reports'),
(44, 'KDS Order Report', 'View kitchen display orders report', 'Reports'),
(45, 'KPRA Sales Report', 'View KPRA integrated sales report', 'Reports'),
(46, 'Production Reports', 'View production and manufacturing reports', 'Reports'),
(47, 'Account Report', 'View account summary reports', 'Reports'),
(48, 'Financial Reports', 'View financial statements and reports', 'Reports');

-- Assign all new report rights to Admin role (role_id = 1)
INSERT INTO `role_rights` (`role_id`, `right_id`) VALUES
(1, 27),
(1, 28),
(1, 29),
(1, 30),
(1, 31),
(1, 32),
(1, 33),
(1, 34),
(1, 35),
(1, 36),
(1, 37),
(1, 38),
(1, 39),
(1, 40),
(1, 41),
(1, 42),
(1, 43),
(1, 44),
(1, 45),
(1, 46),
(1, 47),
(1, 48);





-- Add printer_id column to kds_stations table
ALTER TABLE `kds_stations` 
ADD COLUMN `printer_id` INT NULL AFTER `description`,
ADD COLUMN `enable_kot_print` TINYINT(1) DEFAULT '1' AFTER `printer_id`,
ADD INDEX `idx_printer_id` (`printer_id`);



ALTER TABLE `hold_orders` ADD COLUMN `discount_id` INT DEFAULT NULL AFTER `total_amount`;
ALTER TABLE `hold_orders` ADD INDEX `idx_discount_id` (`discount_id`);




-- Update KDS to KOT/KDS with proper translations for each language

-- English (ID: 127)
UPDATE `translations` 
SET `value` = 'KOT/KDS', `updated_at` = CURRENT_TIMESTAMP 
WHERE `id` = 127 AND `language_code` = 'en' AND `key` = 'kds';

-- Farsi (ID: 290) - Keep KOT/KDS or translate as needed
UPDATE `translations` 
SET `value` = 'KOT/KDS', `updated_at` = CURRENT_TIMESTAMP 
WHERE `id` = 290 AND `language_code` = 'fa' AND `key` = 'kds';

-- Urdu (ID: 453) - کچن آرڈر ٹکٹ/کچن ڈسپلے
UPDATE `translations` 
SET `value` = 'کچن آرڈر ٹکٹ/کچن ڈسپلے', `updated_at` = CURRENT_TIMESTAMP 
WHERE `id` = 453 AND `language_code` = 'ur' AND `key` = 'kds';

-- Arabic (ID: 624) - طلب المطبخ/شاشة المطبخ
UPDATE `translations` 
SET `value` = 'طلب المطبخ/شاشة المطبخ', `updated_at` = CURRENT_TIMESTAMP 
WHERE `id` = 624 AND `language_code` = 'ar' AND `key` = 'kds';


-- Add tip_amount column to sales table
ALTER TABLE `sales` ADD COLUMN `tip_amount` DECIMAL(10,2) DEFAULT '0.00' AFTER `delivery_charges`;
ALTER TABLE `sales` ADD INDEX `idx_tip_amount` (`tip_amount`);

-- Add tip_amount to account_transactions for tracking
ALTER TABLE `account_transactions` ADD COLUMN `tip_amount` DECIMAL(10,2) DEFAULT '0.00' AFTER `amount`;



ALTER TABLE `categories` 
ADD COLUMN `icon` VARCHAR(255) NULL DEFAULT 'assets/img/categories/category-01.png' AFTER `name`;

-- Add index for better performance
ALTER TABLE `categories` 
ADD KEY `idx_icon` (`icon`);




-- Add profile_picture column to users table
ALTER TABLE `users` 
ADD COLUMN `profile_picture` VARCHAR(255) NULL DEFAULT NULL AFTER `pin`;

-- Add index for better performance
ALTER TABLE `users` 
ADD KEY `idx_profile_picture` (`profile_picture`);
