-- Comprehensive Permissions Seed for All Modules
-- This adds all missing permissions for Dashboard, Employees, Attendance, Leave, Payroll, Overtime, Petty Cash, DFC, Transfer, Exit, Reports, MIS, Settings

-- Insert permissions only if they don't exist (using INSERT IGNORE or checking first)

-- DASHBOARD Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('DASHBOARD_VIEW', 'View Dashboard', 'dashboard', 'Access to view dashboard and statistics');

-- EMPLOYEE Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('EMPLOYEE_VIEW', 'View Employees', 'employee', 'View employee list and details'),
('EMPLOYEE_CREATE', 'Create Employee', 'employee', 'Create new employee records'),
('EMPLOYEE_EDIT', 'Edit Employee', 'employee', 'Edit existing employee records'),
('EMPLOYEE_DELETE', 'Delete Employee', 'employee', 'Delete employee records');

-- ATTENDANCE Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('ATTENDANCE_VIEW', 'View Attendance', 'attendance', 'View attendance records'),
('ATTENDANCE_CREATE', 'Create Attendance', 'attendance', 'Mark attendance for employees'),
('ATTENDANCE_EDIT', 'Edit Attendance', 'attendance', 'Edit attendance records'),
('ATTENDANCE_DELETE', 'Delete Attendance', 'attendance', 'Delete attendance records');

-- LEAVE Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('LEAVE_VIEW', 'View Leaves', 'leave', 'View leave applications'),
('LEAVE_CREATE', 'Create Leave', 'leave', 'Create leave applications'),
('LEAVE_APPROVE', 'Approve Leave', 'leave', 'Approve leave applications'),
('LEAVE_REJECT', 'Reject Leave', 'leave', 'Reject leave applications'),
('LEAVE_EDIT', 'Edit Leave', 'leave', 'Edit leave applications'),
('LEAVE_DELETE', 'Delete Leave', 'leave', 'Delete leave applications');

-- PAYROLL Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('PAYROLL_VIEW', 'View Payroll', 'payroll', 'View payroll records'),
('PAYROLL_CREATE', 'Create Payroll', 'payroll', 'Create payroll records'),
('PAYROLL_CALCULATE', 'Calculate Payroll', 'payroll', 'Calculate payroll for employees'),
('PAYROLL_APPROVE', 'Approve Payroll', 'payroll', 'Approve payroll records'),
('PAYROLL_LOCK', 'Lock Payroll', 'payroll', 'Lock payroll records'),
('PAYROLL_EDIT', 'Edit Payroll', 'payroll', 'Edit payroll records'),
('PAYROLL_DELETE', 'Delete Payroll', 'payroll', 'Delete payroll records'),
('PAYROLL_EXPORT', 'Export Payroll', 'payroll', 'Export payroll to Excel/PDF');

-- OVERTIME Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('OVERTIME_VIEW', 'View Overtime', 'overtime', 'View overtime records'),
('OVERTIME_CREATE', 'Create Overtime', 'overtime', 'Create overtime entries'),
('OVERTIME_EDIT', 'Edit Overtime', 'overtime', 'Edit overtime records'),
('OVERTIME_DELETE', 'Delete Overtime', 'overtime', 'Delete overtime records'),
('OVERTIME_RATES_MANAGE', 'Manage Overtime Rates', 'overtime', 'Manage overtime rates and configurations');

-- PETTY CASH Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('PETTY_CASH_VIEW', 'View Petty Cash', 'petty_cash', 'View petty cash transactions'),
('PETTY_CASH_CREATE', 'Create Petty Cash', 'petty_cash', 'Create petty cash transactions'),
('PETTY_CASH_EDIT', 'Edit Petty Cash', 'petty_cash', 'Edit petty cash transactions'),
('PETTY_CASH_DELETE', 'Delete Petty Cash', 'petty_cash', 'Delete petty cash transactions'),
('PETTY_CASH_CLOSE', 'Close Petty Cash', 'petty_cash', 'Close petty cash day/period'),
('PETTY_CASH_APPROVE', 'Approve Petty Cash', 'petty_cash', 'Approve petty cash transactions');

-- DFC (Daily Food Cost) Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('DFC_VIEW', 'View DFC', 'dfc', 'View DFC records'),
('DFC_CREATE', 'Create DFC', 'dfc', 'Create DFC entries'),
('DFC_EDIT', 'Edit DFC', 'dfc', 'Edit DFC records'),
('DFC_DELETE', 'Delete DFC', 'dfc', 'Delete DFC records');

-- TRANSFER Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('TRANSFER_VIEW', 'View Transfer', 'transfer', 'View employee transfer records'),
('TRANSFER_CREATE', 'Create Transfer', 'transfer', 'Create employee transfers'),
('TRANSFER_EDIT', 'Edit Transfer', 'transfer', 'Edit transfer records'),
('TRANSFER_DELETE', 'Delete Transfer', 'transfer', 'Delete transfer records'),
('TRANSFER_APPROVE', 'Approve Transfer', 'transfer', 'Approve employee transfers');

-- EXIT Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('EXIT_VIEW', 'View Exit', 'exit', 'View employee exit records'),
('EXIT_CREATE', 'Create Exit', 'exit', 'Create employee exit records'),
('EXIT_EDIT', 'Edit Exit', 'exit', 'Edit exit records'),
('EXIT_DELETE', 'Delete Exit', 'exit', 'Delete exit records'),
('EXIT_APPROVE', 'Approve Exit', 'exit', 'Approve employee exit');

-- REPORTS Module (already exists, but adding more)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('REPORTS_VIEW', 'View Reports', 'reports', 'View all reports'),
('REPORTS_EXPORT', 'Export Reports', 'reports', 'Export reports to Excel/PDF'),
('REPORTS_ANALYTICS', 'View Analytics', 'reports', 'Access analytics and insights');

-- MIS REPORTS Module
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('MIS_VIEW', 'MIS - View', 'mis', 'View MIS reports'),
('MIS_CREATE', 'MIS - Create', 'mis', 'Create new MIS reports'),
('MIS_EDIT', 'MIS - Edit', 'mis', 'Edit MIS reports'),
('MIS_EXPORT', 'MIS - Export', 'mis', 'Export MIS reports to Excel/PDF'),
('MIS_DELETE', 'MIS - Delete', 'mis', 'Delete MIS reports'),
('MIS_LOCK', 'MIS - Lock', 'mis', 'Lock MIS reports');

-- SETTINGS Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('SETTINGS_VIEW', 'View Settings', 'settings', 'View system settings'),
('SETTINGS_EDIT', 'Edit Settings', 'settings', 'Edit system settings'),
('SETTINGS_DEPARTMENTS_MANAGE', 'Manage Departments', 'settings', 'Manage departments and designations'),
('SETTINGS_LEAVE_TYPES_MANAGE', 'Manage Leave Types', 'settings', 'Manage leave types'),
('SETTINGS_SALARY_COMPONENTS_MANAGE', 'Manage Salary Components', 'settings', 'Manage salary components'),
('SETTINGS_INVENTORY_MANAGE', 'Manage Inventory Items', 'settings', 'Manage inventory items'),
('SETTINGS_EXPENSE_HEADS_MANAGE', 'Manage Expense Heads', 'settings', 'Manage expense heads');

-- USER Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('USER_MANAGE', 'Manage Users', 'user', 'Create, edit, and manage users'),
('USER_VIEW', 'View Users', 'user', 'View user list'),
('USER_CREATE', 'Create User', 'user', 'Create new users'),
('USER_EDIT', 'Edit User', 'user', 'Edit user details'),
('USER_DELETE', 'Delete User', 'user', 'Delete users');

-- SITE Module (already exists, but ensuring all are present)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('SITE_MANAGE', 'Manage Sites', 'site', 'Create, edit, and manage sites'),
('SITE_VIEW', 'View Sites', 'site', 'View site list'),
('SITE_CREATE', 'Create Site', 'site', 'Create new sites'),
('SITE_EDIT', 'Edit Site', 'site', 'Edit site details'),
('SITE_DELETE', 'Delete Site', 'site', 'Delete sites');

-- ROLE Module (for role management)
INSERT IGNORE INTO `permissions` (`permission_code`, `permission_name`, `permission_module`, `permission_description`) VALUES
('ROLE_VIEW', 'View Roles', 'role', 'View roles and permissions'),
('ROLE_CREATE', 'Create Role', 'role', 'Create custom roles'),
('ROLE_EDIT', 'Edit Role', 'role', 'Edit roles and permissions'),
('ROLE_DELETE', 'Delete Role', 'role', 'Delete custom roles'),
('ROLE_ASSIGN', 'Assign Role', 'role', 'Assign roles to users');

