commit;

--
-- Table structure for table `journal_entry_lines_backup_20250111`
--

CREATE TABLE `journal_entry_lines_backup_20250111` (
  `id` int(10) unsigned NOT NULL DEFAULT 0,
  `entry_id` int(10) unsigned NOT NULL,
  `account_id` int(10) unsigned NOT NULL,
  `debit` decimal(15,2) DEFAULT 0.00,
  `credit` decimal(15,2) DEFAULT 0.00,
  `description` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `journal_entry_lines_backup_20250111`
--

set autocommit=0;
INSERT INTO `journal_entry_lines_backup_20250111` VALUES
(1,3,21,308025.00,0.00,'Invoice #INV-20251031-8225','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(2,3,12,0.00,308025.00,'Sales revenue for Invoice #INV-20251031-8225','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(3,7,2,1936.00,0.00,'Payment for Invoice #INV-20251031-7461','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(4,7,21,0.00,1936.00,'Payment for Invoice #INV-20251031-7461','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(5,8,21,999.00,0.00,'Invoice #INV-20251031-3380','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(6,8,12,0.00,999.00,'Sales revenue for Invoice #INV-20251031-3380','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(7,9,2,999.00,0.00,'Payment for Invoice #INV-20251031-3380','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(8,9,21,0.00,999.00,'Payment for Invoice #INV-20251031-3380','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(9,10,92,500000.00,0.00,'Initial cash investment - operating','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(10,10,94,250000.00,0.00,'Initial cash investment - savings','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(11,10,11,0.00,750000.00,'Capital stock - initial investment','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(12,12,2,1000000.00,0.00,'Opening balance - Bank account','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(13,12,10,0.00,1000000.00,'Opening balance - Equity','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(14,13,2,10000000.00,0.00,'Opening balance - Bank account','2025-11-11 00:33:35','2025-11-11 00:33:35'),
(15,13,10,0.00,10000000.00,'Opening balance - Equity','2025-11-11 00:33:35','2025-11-11 00:33:35');
commit;

--
-- Table structure for table `location_asset_overrides`
--

CREATE TABLE `location_asset_overrides` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `location_id` int(10) unsigned NOT NULL,
  `asset_category_id` int(10) unsigned NOT NULL,
  `useful_life_years` decimal(5,1) DEFAULT NULL COMMENT 'Override global value',
  `maintenance_capex_rate` decimal(5,2) DEFAULT NULL,
  `replacement_period_years` decimal(5,1) DEFAULT NULL,
  `capitalization_threshold` decimal(5,2) DEFAULT NULL,
  `depreciation_method` enum('straight_line','declining_balance','units_of_production') DEFAULT NULL,
  `salvage_value_percent` decimal(5,2) DEFAULT NULL,
  `notes` text DEFAULT NULL COMMENT 'Location-specific notes',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `location_category` (`location_id`,`asset_category_id`),
  KEY `asset_category_id` (`asset_category_id`),
  CONSTRAINT `location_asset_overrides_ibfk_1` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `location_asset_overrides_ibfk_2` FOREIGN KEY (`asset_category_id`) REFERENCES `asset_categories` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `location_asset_overrides`
--

set autocommit=0;
commit;

--
-- Table structure for table `location_capacity_forecast`
--

CREATE TABLE `location_capacity_forecast` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `assumption_set_id` int(11) NOT NULL,
  `location_id` int(10) unsigned NOT NULL,
  `equipment_line_id` int(10) unsigned DEFAULT NULL,
  `projection_date` date NOT NULL,
  `period_type` enum('monthly','quarterly','annual') DEFAULT 'monthly',
  `available_hours` decimal(12,2) NOT NULL,
  `planned_production_hours` decimal(12,2) NOT NULL,
  `utilization_pct` decimal(5,2) NOT NULL,
  `bottleneck` tinyint(1) DEFAULT 0 COMMENT 'Is this a capacity bottleneck?',
  `fixed_costs` decimal(15,2) DEFAULT 0.00 COMMENT 'Facility rent, utilities, etc',
  `variable_costs` decimal(15,2) DEFAULT 0.00 COMMENT 'Based on actual production',
  `labor_costs` decimal(15,2) DEFAULT 0.00,
  `overhead_costs` decimal(15,2) DEFAULT 0.00,
  `generated_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_set` (`assumption_set_id`),
  KEY `idx_location` (`location_id`),
  KEY `idx_equipment` (`equipment_line_id`),
  KEY `idx_date` (`projection_date`),
  CONSTRAINT `location_capacity_forecast_ibfk_1` FOREIGN KEY (`assumption_set_id`) REFERENCES `forecast_assumption_sets` (`id`) ON DELETE CASCADE,
  CONSTRAINT `location_capacity_forecast_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `location_capacity_forecast_ibfk_3` FOREIGN KEY (`equipment_line_id`) REFERENCES `equipment_lines` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `location_capacity_forecast`
--

set autocommit=0;
commit;

--
-- Table structure for table `locations`
--

CREATE TABLE `locations` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `code` varchar(50) NOT NULL,
  `address` text DEFAULT NULL,
  `city` varchar(100) DEFAULT NULL,
  `state` varchar(100) DEFAULT NULL,
  `zip` varchar(20) DEFAULT NULL,
  `country` varchar(100) DEFAULT NULL,
  `square_footage` decimal(10,2) DEFAULT NULL COMMENT 'Square footage of the location',
  `phone` varchar(20) DEFAULT NULL,
  `manager_id` int(10) unsigned DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `description` text DEFAULT NULL,
  `work_days_per_week` decimal(3,1) DEFAULT NULL COMMENT 'Override global - work days per week',
  `work_hours_per_shift` decimal(4,1) DEFAULT NULL COMMENT 'Override global - hours per shift',
  `shifts_per_day` int(11) DEFAULT NULL COMMENT 'Override global - number of shifts',
  `working_weeks_per_year` int(11) DEFAULT NULL COMMENT 'Override global - working weeks per year',
  `labor_utilization_rate` decimal(5,2) DEFAULT NULL COMMENT 'Override global - labor utilization %',
  `hours_per_day` decimal(5,1) DEFAULT NULL COMMENT 'Override global - total hours per day',
  `facility_size_sqft` decimal(12,2) DEFAULT NULL COMMENT 'Location facility size in square feet',
  `capitalization_limit` decimal(12,2) DEFAULT NULL COMMENT 'Override global - capitalization threshold',
  `cpi_increase_rate` decimal(5,2) DEFAULT NULL COMMENT 'Override global - CPI increase rate',
  `project_start_date` date DEFAULT NULL COMMENT 'Override global - project start date',
  `base_year` int(11) DEFAULT NULL COMMENT 'Override global - base year',
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`),
  KEY `manager_id` (`manager_id`),
  KEY `idx_deleted_at` (`deleted_at`),
  CONSTRAINT `locations_ibfk_1` FOREIGN KEY (`manager_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `locations`
--

set autocommit=0;
INSERT INTO `locations` VALUES
(2,'Garage','GAR','123 Garage St','Garage','ST','11123','USA',85000.00,'',NULL,'active','2025-10-27 16:13:22',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-11 00:36:45',NULL),
(3,'Farm','FARM','123 Farm Road','Place','ST','11111','USA',6500000.00,'',NULL,'active','2025-10-27 16:13:38',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-11 00:36:45',NULL);
commit;

--
-- Table structure for table `lot_serial_movements`
--

CREATE TABLE `lot_serial_movements` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `lot_serial_id` int(10) unsigned NOT NULL,
  `movement_type` enum('receipt','shipment','transfer','adjustment','return','production','consumption') NOT NULL,
  `from_location_id` int(10) unsigned DEFAULT NULL,
  `to_location_id` int(10) unsigned DEFAULT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `reference_type` varchar(50) DEFAULT NULL,
  `reference_id` int(10) unsigned DEFAULT NULL,
  `movement_date` datetime DEFAULT current_timestamp(),
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `from_location_id` (`from_location_id`),
  KEY `to_location_id` (`to_location_id`),
  KEY `created_by` (`created_by`),
  KEY `idx_lot_serial` (`lot_serial_id`),
  KEY `idx_movement_date` (`movement_date`),
  KEY `idx_reference` (`reference_type`,`reference_id`),
  CONSTRAINT `lot_serial_movements_ibfk_1` FOREIGN KEY (`lot_serial_id`) REFERENCES `lot_serial_numbers` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lot_serial_movements_ibfk_2` FOREIGN KEY (`from_location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lot_serial_movements_ibfk_3` FOREIGN KEY (`to_location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lot_serial_movements_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lot_serial_movements`
--

set autocommit=0;
commit;

--
-- Table structure for table `lot_serial_numbers`
--

CREATE TABLE `lot_serial_numbers` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` int(10) unsigned NOT NULL,
  `lot_number` varchar(100) DEFAULT NULL,
  `serial_number` varchar(100) DEFAULT NULL,
  `manufacture_date` date DEFAULT NULL,
  `expiration_date` date DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT 1.00,
  `location_id` int(10) unsigned DEFAULT NULL,
  `status` enum('active','reserved','sold','expired','returned') DEFAULT 'active',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_by` int(10) unsigned DEFAULT NULL,
  `last_notified_at` datetime DEFAULT NULL COMMENT 'Last expiry reminder sent',
  `notification_level` varchar(20) DEFAULT NULL COMMENT 'Current notification level: 30day, 7day, expired',
  PRIMARY KEY (`id`),
  KEY `location_id` (`location_id`),
  KEY `created_by` (`created_by`),
  KEY `idx_lot_number` (`lot_number`),
  KEY `idx_serial_number` (`serial_number`),
  KEY `idx_product` (`product_id`),
  KEY `idx_expiration` (`expiration_date`),
  KEY `idx_status` (`status`),
  KEY `idx_lot_expiry_notification` (`expiration_date`,`status`,`last_notified_at`),
  CONSTRAINT `lot_serial_numbers_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
  CONSTRAINT `lot_serial_numbers_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lot_serial_numbers_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lot_serial_numbers`
--

set autocommit=0;
commit;

--
-- Table structure for table `machine_events`
--

CREATE TABLE `machine_events` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `equipment_id` int(10) unsigned NOT NULL,
  `event_type` varchar(50) NOT NULL COMMENT 'e.g., status_change, production_update, utilization_update, alert',
  `event_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Event details in JSON format' CHECK (json_valid(`event_data`)),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `equipment_id` (`equipment_id`),
  KEY `event_type` (`event_type`),
  KEY `created_at` (`created_at`),
  CONSTRAINT `machine_events_ibfk_1` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Logs machine automation events and data integration';

--
-- Dumping data for table `machine_events`
--

set autocommit=0;
commit;

--
-- Table structure for table `material_requirements`
--

CREATE TABLE `material_requirements` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `work_order_id` int(10) unsigned DEFAULT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `total_required` decimal(15,3) NOT NULL DEFAULT 0.000,
  `on_hand` decimal(15,3) NOT NULL DEFAULT 0.000,
  `on_order` decimal(15,3) NOT NULL DEFAULT 0.000,
  `allocated` decimal(15,3) NOT NULL DEFAULT 0.000,
  `net_required` decimal(15,3) NOT NULL DEFAULT 0.000,
  `suggested_order_date` date DEFAULT NULL,
  `requisition_created` tinyint(1) DEFAULT 0,
  `requisition_id` int(10) unsigned DEFAULT NULL,
  `calculated_at` datetime DEFAULT current_timestamp(),
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_work_order` (`work_order_id`),
  KEY `idx_product` (`product_id`),
  KEY `idx_calculated_at` (`calculated_at`),
  KEY `idx_net_required` (`net_required`),
  KEY `idx_material_req_product_calculated` (`product_id`,`calculated_at`),
  CONSTRAINT `material_requirements_ibfk_1` FOREIGN KEY (`work_order_id`) REFERENCES `work_orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `material_requirements_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `material_requirements`
--

set autocommit=0;
commit;

--
-- Temporary table structure for view `mention_stats`
--

/*!50001 DROP VIEW IF EXISTS `mention_stats`*/;
/*!50001 CREATE VIEW `mention_stats` AS SELECT
 1 AS `user_id`,
  1 AS `user_name`,
  1 AS `total_mentions`,
  1 AS `unread_mentions`,
  1 AS `last_mention_at` */;

--
-- Table structure for table `mentions`
--

CREATE TABLE `mentions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `mentioned_by` int(10) unsigned NOT NULL,
  `entity_type` varchar(50) NOT NULL COMMENT 'Comment, Note, Message, etc.',
  `entity_id` int(11) NOT NULL COMMENT 'ID of the comment/note/message',
  `related_type` varchar(50) DEFAULT NULL COMMENT 'Invoice, Quote, Task, etc.',
  `related_id` int(11) DEFAULT NULL COMMENT 'ID of the invoice/quote/task',
  `content_snippet` varchar(500) DEFAULT NULL COMMENT 'Snippet of text where mention occurred',
  `is_read` tinyint(1) DEFAULT 0,
  `read_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_user_id` (`user_id`,`is_read`),
  KEY `idx_mentioned_by` (`mentioned_by`),
  KEY `idx_entity` (`entity_type`,`entity_id`),
  KEY `idx_related` (`related_type`,`related_id`),
  CONSTRAINT `mentions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `mentions_ibfk_2` FOREIGN KEY (`mentioned_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Track @mentions across the system';

--
-- Dumping data for table `mentions`
--

set autocommit=0;
commit;

--
-- Table structure for table `menu_items`
--

CREATE TABLE `menu_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) DEFAULT NULL,
  `label` varchar(100) NOT NULL,
  `icon` varchar(50) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `target` varchar(20) DEFAULT '_self',
  `permission_required` varchar(100) DEFAULT NULL COMMENT 'Permission key to check (e.g., users.view)',
  `display_order` int(11) DEFAULT 0,
  `is_active` tinyint(1) DEFAULT 1,
  `is_header` tinyint(1) DEFAULT 0 COMMENT 'Is this a section header?',
  `is_app_grid` tinyint(1) DEFAULT 0,
  `badge_query` text DEFAULT NULL COMMENT 'SQL query to get badge count',
  `badge_color` varchar(20) DEFAULT NULL COMMENT 'Badge color: primary, danger, warning, etc.',
  `urgent_threshold` int(11) DEFAULT NULL COMMENT 'If badge count > this, show as urgent',
  `urgent_color` varchar(20) DEFAULT NULL COMMENT 'Color when urgent',
  `description` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_parent` (`parent_id`),
  KEY `idx_order` (`display_order`),
  KEY `idx_active` (`is_active`),
  KEY `idx_permission` (`permission_required`),
  CONSTRAINT `menu_items_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `menu_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=364 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `menu_items`
--

set autocommit=0;
INSERT INTO `menu_items` VALUES
(1,NULL,'Dashboard','bi bi-cpu','dashboard','_self','dashboard.view',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:43:45','2025-11-30 01:23:31'),
(2,NULL,'DEPARTMENTS',NULL,NULL,'_self',NULL,100,1,1,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:43:45','2025-11-01 17:43:45'),
(3,2,'CRM','bi bi-person-badge','#','_self','crm.view',20,1,0,0,'','',NULL,'','','2025-11-01 17:44:23','2025-11-11 11:44:58'),
(4,3,'Dashboard','','crm/dashboard','_self','crm.dashboard',10,1,0,0,'','',NULL,'','','2025-11-01 17:44:23','2025-11-29 19:13:00'),
(5,3,'Companies','','companies','_self','companies.view',25,1,0,0,'SELECT COUNT(*) FROM customers WHERE status = \'active\'','',NULL,'','','2025-11-01 17:44:23','2025-11-28 22:27:00'),
(7,3,'Contacts','','crm/contacts','_self','crm.contacts',20,1,0,0,'SELECT ((SELECT COUNT(*) FROM client_contacts) + (SELECT COUNT(*) FROM customer_contacts))','primary',NULL,'','','2025-11-01 17:44:23','2025-11-29 19:13:00'),
(8,3,'Activities','','crm/activities','_self','crm.activities',15,1,0,0,'SELECT COUNT(*) as count FROM activities WHERE assigned_to = {user_id} AND activity_date = CURDATE() AND status != \'completed\'','info',3,'warning','','2025-11-01 17:44:23','2025-11-29 19:13:00'),
(10,3,'Opportunities','','crm/opportunities','_self','crm.opportunities',60,1,0,0,'SELECT COUNT(*) as count FROM opportunities WHERE status NOT IN (\'won\', \'lost\', \'closed\')','success',5,'warning','','2025-11-01 17:44:23','2025-11-29 19:13:00'),
(11,3,'Support','','#','_self','crm.view',80,1,0,0,'SELECT COUNT(*) as count FROM crm_support_tickets WHERE status NOT IN (\'closed\', \'resolved\')','danger',2,'warning','','2025-11-01 17:44:23','2025-11-11 12:23:42'),
(12,11,'Tickets',NULL,'crm/support','_self','crm.view',1,1,0,0,'SELECT COUNT(*) as count FROM crm_support_tickets WHERE status NOT IN (\'closed\', \'resolved\')','danger',2,'warning',NULL,'2025-11-01 17:44:23','2025-11-11 11:15:46'),
(14,3,'Reports','','crm/reports','_self','crm.reports',90,1,0,0,'','',NULL,'','','2025-11-01 17:44:23','2025-11-29 19:13:00'),
(15,NULL,'ADMIN','','','_self','admin',400,1,1,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-08 15:02:09'),
(16,15,'Announcements','bi bi-megaphone-fill','announcements','_self','announcements.view',1,1,0,0,'SELECT COUNT(*) as count FROM announcements WHERE status = \'active\' AND start_date <= CURDATE() AND (end_date IS NULL OR end_date >= CURDATE())','info',NULL,'','','2025-11-01 17:44:54','2025-11-28 22:27:00'),
(17,15,'Settings','bi bi-gear-wide-connected','#','_self','admin',2,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-08 15:02:28'),
(18,17,'Company Settings','','#','_self','admin',50,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-17 11:28:18'),
(19,18,'Company Info',NULL,'settings/company','_self','settings.company',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(20,18,'Email Settings',NULL,'settings/email','_self','settings.email',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(21,18,'Locations',NULL,'locations','_self','locations.view',3,1,0,0,'SELECT COUNT(*) FROM locations WHERE is_active = 1','primary',NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-28 22:27:00'),
(22,17,'Financial Settings','','#','_self','admin',60,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-17 11:29:22'),
(23,22,'Tax Settings','','settings/tax','_self','settings.tax',5,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-29 19:13:00'),
(24,22,'Fiscal Year',NULL,'settings/fiscal-year','_self','settings.fiscal_year',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(25,22,'Payment Terms',NULL,'settings/payment-terms','_self','settings.payment_terms',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(26,22,'Cost Allocation','','settings/cost-allocation','_self','settings.cost_allocation',1,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-29 19:13:00'),
(27,22,'PP&E Parameters','','settings/ppe-parameters','_self','settings.ppe_parameters',4,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-29 19:13:00'),
(28,17,'Location Settings','','#','_self','admin',80,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-17 11:29:38'),
(29,28,'Business Parameters',NULL,'settings/business-parameters','_self','settings.business_parameters',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(30,28,'Facilities & Leasing',NULL,'settings/facilities','_self','settings.facilities',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(31,28,'Payroll Settings',NULL,'settings/payroll','_self','settings.payroll',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(32,17,'Security Settings','','#','_self','admin',140,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-29 12:46:27'),
(33,32,'Users','','users','_self','users.view',5,1,0,0,'SELECT COUNT(*) as count FROM users WHERE status != \'active\'','',NULL,'','','2025-11-01 17:44:54','2025-11-30 13:39:08'),
(35,17,'System Configuration','','#','_self','admin',150,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-24 19:17:51'),
(36,281,'Menu Mgmt','','menus','_self','menus.view',20,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-28 22:27:00'),
(37,35,'Dropdowns',NULL,'#','_self','admin',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-08 15:04:07'),
(38,37,'Sales & CRM','','settings/dropdowns/sales','_self','settings.sales__crm',3,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-29 19:15:36'),
(39,37,'Operations',NULL,'settings/dropdowns/operations','_self','settings.operations',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:15:36'),
(40,35,'Templates','','#','_self','admin',6,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-24 19:17:08'),
(42,40,'Terms & Conditions',NULL,'settings/terms-conditions','_self','settings.terms_conditions',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:44:54','2025-11-29 19:13:00'),
(43,35,'QuickBooks Mgmt','','quickbooks','_self','quickbooks.view',3,1,0,0,'','',NULL,'','','2025-11-01 17:44:54','2025-11-28 22:27:00'),
(44,2,'Accounting','bi bi-calculator','#','_self','accounting.view',10,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-11-11 11:44:58'),
(45,61,'All Report Package','','accounting/reports/package','_self','accounting.all_report_package',0,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-11-29 19:15:36'),
(46,44,'Core Accounting','','#','_self','accounting.view',30,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-11-15 19:19:45'),
(47,46,'Chart of Accounts',NULL,'accounting/accounts','_self','accounting.accounts',1,1,0,0,'SELECT COUNT(*) FROM chart_of_accounts WHERE status = \'active\'','primary',NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(48,46,'Journal Entries',NULL,'accounting/journal','_self','accounting.journal',2,1,0,0,'SELECT COUNT(*) as count FROM journal_entries WHERE status = \'draft\'','primary',0,'warning',NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(49,46,'General Ledger',NULL,'accounting/ledger','_self','accounting.ledger',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(50,44,'Banking/Cash','','#','_self','accounting.banking_cash',20,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-12-02 13:56:09'),
(51,50,'Bank Accounts',NULL,'accounting/bank-accounts','_self','accounting.bank_accounts',1,1,0,0,'SELECT COUNT(*) FROM bank_accounts WHERE is_active = 1','primary',NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(52,50,'Bank Reconciliation',NULL,'accounting/reconciliation','_self','accounting.reconciliation',2,1,0,0,'SELECT COUNT(*) as count FROM bank_accounts WHERE last_reconciliation_date < DATE_SUB(CURDATE(), INTERVAL 30 DAY) OR last_reconciliation_date IS NULL','danger',1,'danger',NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(53,44,'Operations','','#','_self','accounting.operations',60,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-12-02 13:56:09'),
(54,53,'Expenses',NULL,'accounting/expenses','_self','accounting.expenses',1,1,0,0,'SELECT COUNT(*) as count FROM expenses WHERE status = \'pending_approval\'','info',10,'warning',NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(55,53,'Budgets',NULL,'accounting/budgets','_self','accounting.budgets',2,1,0,0,'SELECT COUNT(*) FROM budgets WHERE status = \'active\'','primary',NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(56,44,'Assets/Compliance','','#','_self','accounting.assets_compliance',10,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-12-02 13:56:09'),
(57,56,'Fixed Assets',NULL,'accounting/assets','_self','accounting.assets',1,1,0,0,'SELECT COUNT(*) as count FROM fixed_assets WHERE status = \'active\' AND depreciation_method != \'none\'','primary',NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(58,56,'Depreciation',NULL,'accounting/depreciation','_self','accounting.depreciation',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(60,56,'Period Closing',NULL,'accounting/period','_self','accounting.period',4,1,0,0,'SELECT COUNT(*) as count FROM accounting_periods WHERE status = \'open\'','warning',1,'warning',NULL,'2025-11-01 17:45:12','2025-11-29 19:13:00'),
(61,44,'Reports','','#','_self','accounting.reports',90,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-12-02 13:56:09'),
(62,61,'Balance Sheet',NULL,'accounting/reports/balance-sheet','_self','accounting.balance_sheet',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:15:36'),
(63,61,'Income Statement',NULL,'accounting/reports/income-statement','_self','accounting.income_statement',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:15:36'),
(65,61,'Trial Balance','','accounting/reports/trial-balance','_self','accounting.trial_balance',5,1,0,0,'','',NULL,'','','2025-11-01 17:45:12','2025-11-29 19:15:36'),
(66,61,'Aging Reports',NULL,'accounting/reports/aging','_self','accounting.aging_reports',6,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:12','2025-11-29 19:15:36'),
(68,2,'HR','bi bi-people','#','_self','hr.view',30,1,0,0,'','',NULL,'','','2025-11-01 17:45:27','2025-11-11 12:23:42'),
(69,68,'Dashboard',NULL,'hr/dashboard','_self','hr.dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:13:00'),
(70,68,'Employees',NULL,'employees','_self','employees.view',2,1,0,0,'SELECT COUNT(*) FROM employees WHERE status = \'active\'','primary',NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:13:00'),
(71,68,'Recruitment',NULL,'#','_self','hr.view',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-11 11:41:06'),
(72,71,'Dashboard',NULL,'hr/recruitment/dashboard','_self','hr.dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(73,71,'Job Positions',NULL,'hr/recruitment/positions','_self','positions.view',2,1,0,0,'SELECT COUNT(*) FROM job_positions WHERE status = \'open\'','primary',NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-11 12:46:12'),
(74,71,'Applications',NULL,'hr/recruitment/applications','_self','hr.applications',3,1,0,0,'SELECT COUNT(*) as count FROM applications WHERE status = \'pending_review\'','info',5,'warning',NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(75,71,'Interviews',NULL,'hr/recruitment/interviews','_self','hr.interviews',4,1,0,0,'SELECT COUNT(*) as count FROM interviews WHERE status = \'scheduled\'','info',0,'warning',NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(76,71,'Assessments',NULL,'hr/recruitment/assessments','_self','hr.assessments',5,1,0,0,'SELECT COUNT(*) FROM qualification_assessments WHERE status = \'pending\'',NULL,NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(77,71,'Offers',NULL,'hr/recruitment/offers','_self','hr.offers',6,1,0,0,'SELECT COUNT(*) as count FROM offers WHERE status = \'pending\'','success',0,'warning',NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(78,68,'Development',NULL,'#','_self','hr.view',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-11 11:41:06'),
(79,78,'Contracts',NULL,'hr/development/contracts','_self','hr.contracts',1,1,0,0,'SELECT COUNT(*) as count FROM contracts WHERE status IN (\'draft\', \'pending_signature\', \'pending_approval\')','warning',3,'warning',NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(80,78,'Training',NULL,'hr/development/training','_self','hr.training',2,1,0,0,'SELECT COUNT(*) as count FROM training_programs WHERE status = \'in_progress\'','secondary',NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(81,78,'Performance Reviews',NULL,'hr/development/reviews','_self','hr.performance_reviews',3,1,0,0,'SELECT COUNT(*) as count FROM performance_reviews WHERE status IN (\'pending\', \'in_progress\')','info',3,'warning',NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(82,68,'Relations',NULL,'#','_self','hr.view',5,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-11 11:41:06'),
(83,82,'Issues & Challenges',NULL,'hr/relations/issues','_self','hr.issues__challenges',1,1,0,0,'SELECT COUNT(*) FROM employee_issues WHERE status IN (\'reported\', \'investigating\', \'in-progress\')','warning',NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(84,82,'Separations',NULL,'hr/relations/separations','_self','hr.separations',2,1,0,0,'SELECT COUNT(*) as count FROM separations WHERE status = \'pending\'','warning',NULL,NULL,NULL,'2025-11-01 17:45:27','2025-11-29 19:15:36'),
(85,68,'Attendance',NULL,'hr/attendance','_self','hr.view',6,1,0,0,'SELECT COUNT(*) as count FROM attendance WHERE date = CURDATE() AND clock_out IS NULL','danger',0,'danger',NULL,'2025-11-01 17:45:27','2025-11-30 00:54:34'),
(86,2,'Inventory','bi bi-box-seam','#','_self','inventory.view',40,1,0,0,'','',NULL,'','','2025-11-01 17:45:41','2025-11-11 12:23:42'),
(87,86,'Dashboard',NULL,'inventory/dashboard','_self','inventory.dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:41','2025-11-29 19:13:00'),
(88,86,'Product Management',NULL,'#','_self','inventory.view',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:41','2025-11-11 11:41:06'),
(89,88,'Products',NULL,'products','_self','products.view',1,1,0,0,'SELECT COUNT(DISTINCT p.id) as count FROM products p LEFT JOIN inventory_levels il ON p.id = il.product_id WHERE COALESCE(il.quantity, 0) <= COALESCE(p.reorder_level, 0) AND p.reorder_level > 0','danger',3,'danger',NULL,'2025-11-01 17:45:41','2025-11-29 19:13:00'),
(90,88,'Categories',NULL,'inventory/categories','_self','inventory.categories',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:41','2025-11-29 19:13:00'),
(91,86,'Stock Levels',NULL,'/inventory/stock-levels','_self','inventory.stock_levels',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:45:41','2025-11-29 19:13:00'),
(92,2,'Manufacturing','bi bi-gear','#','_self','manufacturing.view',50,1,0,0,'','',NULL,'','','2025-11-01 17:46:13','2025-11-11 12:23:42'),
(93,92,'Dashboard',NULL,'manufacturing','_self','manufacturing.dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(94,92,'Capacity Planning',NULL,'#','_self','manufacturing.capacity_planning',2,1,0,0,'SELECT COUNT(*) as count FROM capacity_plans WHERE utilization_percentage > 100 AND period_date >= CURDATE()',NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(95,94,'Dashboard',NULL,'manufacturing/capacity','_self','manufacturing.capacity_dashboard',1,1,0,0,'SELECT COUNT(*) as count FROM capacity_plans WHERE utilization_percentage > 100 AND period_date >= CURDATE()',NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(96,94,'Real-time Status',NULL,'manufacturing/capacity/machineStatus','_self','manufacturing.real_time_status',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(97,94,'Analytics',NULL,'manufacturing/capacity/analytics','_self','manufacturing.analytics',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(98,94,'Availability',NULL,'manufacturing/capacity/availability','_self','manufacturing.availability',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(99,94,'Feasibility',NULL,'manufacturing/capacity/feasibility','_self','manufacturing.feasibility',5,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(100,92,'Planning & Materials',NULL,'#','_self','manufacturing.planning_materials',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(101,100,'Bill of Materials',NULL,'manufacturing/boms','_self','manufacturing.boms',1,1,0,0,'SELECT COUNT(DISTINCT b.id) as count FROM boms b INNER JOIN bom_components bc ON b.id = bc.bom_id INNER JOIN products p ON bc.component_id = p.id LEFT JOIN inventory_levels il ON p.id = il.product_id WHERE COALESCE(il.quantity, 0) < COALESCE(bc.quantity_required * 2, 0)','primary',NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(102,100,'MRP',NULL,'manufacturing/mrp','_self','manufacturing.mrp',2,1,0,0,'SELECT COUNT(*) as count FROM mrp_requirements WHERE status = \'required\' AND required_date <= DATE_ADD(CURDATE(), INTERVAL 7 DAY)','info',NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(103,100,'Production Scheduling',NULL,'manufacturing/scheduling','_self','manufacturing.scheduling',3,1,0,0,'SELECT COUNT(*) as count FROM work_orders WHERE status = \'pending\'',NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(104,92,'Production',NULL,'#','_self','manufacturing.production',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(105,104,'Work Orders',NULL,'manufacturing/workorders','_self','manufacturing.workorders',1,1,0,0,'SELECT COUNT(*) as count FROM work_orders WHERE status NOT IN (\'completed\', \'cancelled\')','primary',10,'warning',NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(106,104,'Shop Floor Control',NULL,'manufacturing/shopfloor','_self','manufacturing.shopfloor',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(107,92,'Resources',NULL,'#','_self','manufacturing.resources',5,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(108,107,'Business Lines',NULL,'manufacturing/business-lines','_self','manufacturing.business_lines',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(109,107,'Equipment Lines',NULL,'manufacturing/equipment-lines','_self','manufacturing.equipment_lines',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(110,107,'Equipment Units',NULL,'manufacturing/equipment','_self','manufacturing.equipment',3,1,0,0,'SELECT COUNT(*) as count FROM equipment WHERE status = \'maintenance_required\'',NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:13:00'),
(111,92,'Quality Control',NULL,'#','_self','manufacturing.quality_control',6,1,0,0,'SELECT COUNT(*) FROM quality_inspections WHERE status = \'pending\'','warning',NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(112,111,'Dashboard',NULL,'manufacturing/quality','_self','manufacturing.quality_dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(113,111,'Inspections',NULL,'manufacturing/quality/inspections','_self','manufacturing.inspections',2,1,0,0,'SELECT COUNT(*) as count FROM quality_inspections WHERE status IN (\'pending\', \'in_progress\')','warning',0,'danger',NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(114,111,'NCR',NULL,'manufacturing/quality/ncr','_self','manufacturing.ncr',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(115,111,'Metrics',NULL,'manufacturing/quality/metrics','_self','manufacturing.metrics',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(116,111,'Templates',NULL,'manufacturing/quality/templates','_self','manufacturing.templates',5,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(117,92,'Maintenance',NULL,'#','_self','manufacturing.maintenance',7,1,0,0,'SELECT COUNT(*) as count FROM maintenance_work_orders WHERE status IN (\'pending\', \'scheduled\')',NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(118,117,'Maintenance Schedules',NULL,'manufacturing/maintenance/schedules','_self','manufacturing.maintenance_schedules',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(119,117,'Maintenance Work Orders',NULL,'manufacturing/maintenance/work-orders','_self','manufacturing.maintenance_work_orders',2,1,0,0,'SELECT COUNT(*) as count FROM maintenance_work_orders WHERE status IN (\'pending\', \'scheduled\')','warning',3,'danger',NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(120,117,'Downtime Tracking',NULL,'manufacturing/maintenance/downtime','_self','manufacturing.downtime_tracking',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(121,92,'Costing',NULL,'#','_self','manufacturing.costing',8,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(122,121,'Production Costing',NULL,'manufacturing/costing/production','_self','manufacturing.production_costing',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(123,121,'Job Costing',NULL,'manufacturing/costing/jobs','_self','manufacturing.job_costing',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(124,92,'Reports',NULL,'#','_self','manufacturing.reports',9,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-12-02 13:56:09'),
(125,124,'Production Reports',NULL,'manufacturing/reports/production','_self','manufacturing.production_reports',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(126,124,'OEE Reports',NULL,'manufacturing/reports/oee','_self','manufacturing.oee_reports',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:13','2025-11-29 19:15:36'),
(127,2,'Sales','bi bi-cart','#','_self','sales.view',70,1,0,0,'','',NULL,'','','2025-11-01 17:46:33','2025-11-11 12:23:42'),
(128,127,'Dashboard',NULL,'sales/dashboard','_self','sales.dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(129,127,'Sales Documents',NULL,'#','_self','sales.view',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-11-11 11:41:06'),
(130,129,'Quotes','bi bi-1-square','quotes','_self','quotes.view',1,1,0,0,'SELECT COUNT(*) as count FROM quotes WHERE status NOT IN (\'converted\', \'rejected\', \'expired\')','info',5,'warning','','2025-11-01 17:46:33','2025-11-29 19:13:00'),
(131,129,'Orders','bi bi-3-square','sales/orders','_self','sales.orders',3,1,0,0,'SELECT COUNT(*) as count FROM sales_orders WHERE status NOT IN (\'delivered\', \'cancelled\')','primary',5,'warning','','2025-11-01 17:46:33','2025-11-29 19:13:00'),
(132,129,'Invoices','bi bi-4-square','invoices','_self','invoices.view',4,1,0,0,'SELECT COUNT(*) as count FROM invoices WHERE status NOT IN (\'paid\', \'cancelled\')','warning',5,'danger','','2025-11-01 17:46:33','2025-11-24 14:54:27'),
(133,129,'Credit Notes','','creditnotes','_self','creditnotes.view',10,1,0,0,'SELECT COUNT(*) as count FROM credit_notes WHERE status NOT IN (\'applied\', \'cancelled\')','',NULL,'','','2025-11-01 17:46:33','2025-11-29 19:13:00'),
(135,127,'Fulfillment',NULL,'#','_self','sales.fulfillment',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-12-02 14:03:43'),
(136,135,'Shipments',NULL,'shipments','_self','shipments.view',1,1,0,0,'SELECT COUNT(*) as count FROM shipments WHERE status NOT IN (\'delivered\', \'cancelled\')','primary',5,'warning',NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(137,135,'Delivery Notes',NULL,'sales/delivery_notes','_self','sales.delivery_notes',2,1,0,0,'SELECT COUNT(*) as count FROM delivery_notes WHERE status IN (\'draft\', \'pending\', \'in_transit\')','info',5,'warning',NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(138,135,'Returns (RMA)',NULL,'sales/returns','_self','sales.returns',3,1,0,0,'SELECT COUNT(*) as count FROM returns WHERE status IN (\'pending\', \'approved\', \'received\')','warning',10,'danger',NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(139,127,'Configuration',NULL,'#','_self','sales.configuration',5,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-12-02 14:03:43'),
(140,139,'Pricing Rules',NULL,'sales/pricing_rules','_self','sales.pricing_rules',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(141,139,'Discounts & Promotions',NULL,'sales/promotions','_self','sales.promotions',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(142,127,'Reports',NULL,'sales/reports','_self','sales.reports',6,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:33','2025-11-29 19:13:00'),
(143,2,'Purchases','bi bi-bag','#','_self','purchases.view',60,1,0,0,'','',NULL,'','','2025-11-01 17:46:47','2025-11-11 12:23:42'),
(144,143,'Dashboard',NULL,'purchases/dashboard','_self','purchases.dashboard',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(145,143,'Suppliers',NULL,'suppliers','_self','suppliers.view',2,1,0,0,'SELECT COUNT(*) FROM suppliers','primary',NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(146,143,'Procurement Process',NULL,'#','_self','purchases.procurement_process',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-12-02 13:59:43'),
(147,146,'Purchase Requisitions',NULL,'purchases/requisitions','_self','purchases.requisitions',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(148,146,'RFQs (Quotes)',NULL,'purchases/rfqs','_self','purchases.rfqs',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(149,146,'Purchase Orders',NULL,'purchases/orders','_self','purchases.orders',3,1,0,0,'SELECT COUNT(*) as count FROM purchase_orders WHERE status NOT IN (\'completed\', \'cancelled\')','primary',5,'warning',NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(150,146,'Goods Receipt',NULL,'purchases/receiving','_self','purchases.receiving',4,1,0,0,'SELECT COUNT(*) as count FROM goods_receipts WHERE status IN (\'pending\', \'received\')','info',5,'warning',NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(151,143,'Payments & Documents',NULL,'#','_self','purchases.payments_documents',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-12-02 13:59:43'),
(152,151,'Bills/Invoices',NULL,'purchases/bills','_self','purchases.bills',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(153,151,'Payments Made (Legacy)',NULL,'purchases/payments','_self','purchases.payments',2,1,0,0,NULL,NULL,NULL,NULL,'DEPRECATED: Use Accounting > Vendor Payments instead','2025-11-01 17:46:47','2025-11-29 19:13:00'),
(154,151,'Purchase Returns',NULL,'purchases/returns','_self','purchases.returns',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(155,151,'Debit Notes',NULL,'purchases/debit-notes','_self','purchases.debit_notes',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(156,143,'Supplier Contracts','','purchases/contracts','_self','purchases.view',5,1,0,0,'','',NULL,'','','2025-11-01 17:46:47','2025-12-02 19:36:11'),
(157,143,'Reports',NULL,'purchases/reports','_self','purchases.reports',6,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:46:47','2025-11-29 19:13:00'),
(161,11,'FAQs',NULL,'crm/faqs','_self','crm.view',2,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-01 17:57:10','2025-11-11 11:15:46'),
(162,NULL,'QUICK LINKS','','','_self','dashboard.view',300,1,1,0,'','',NULL,'','','2025-11-01 18:11:31','2025-11-11 11:15:46'),
(164,68,'Time Off',NULL,'hr/timeoff','_self','hr.view',50,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 00:54:34'),
(165,164,'My Time Off',NULL,'hr/timeoff/my','_self','hr.view',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(166,164,'All Requests',NULL,'hr/timeoff/all','_self','hr.view',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(167,164,'Approve Requests',NULL,'hr/timeoff/approve','_self','hr.view',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(168,164,'Time Off Types',NULL,'hr/timeoff/types','_self','admin',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(169,164,'Accrual Rules',NULL,'hr/timeoff/accruals','_self','admin',5,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(170,68,'Timesheets',NULL,'hr/timesheets','_self','hr.view',51,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 00:54:34'),
(171,170,'My Timesheet',NULL,'hr/timesheets/my','_self','hr.view',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(172,170,'All Timesheets',NULL,'hr/timesheets/all','_self','hr.view',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(173,170,'Approve Timesheets',NULL,'hr/timesheets/approve','_self','hr.view',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(174,170,'Timesheet Reports',NULL,'hr/timesheets/reports','_self','hr.view',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-30 01:00:47'),
(180,86,'Lot/Serial Numbers','','inventory/lots','_self','inventory.lots',40,1,0,0,'SELECT COUNT(*) as count FROM lot_serial_numbers WHERE expiration_date IS NOT NULL AND expiration_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 30 DAY) AND status = \'active\'','warning',5,'danger','','2025-11-03 19:25:34','2025-11-29 19:13:00'),
(181,180,'All Lots/Serials',NULL,'inventory/lots/all','_self','inventory.all_lotsserials',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-29 19:15:36'),
(182,180,'Traceability',NULL,'inventory/lots/traceability','_self','inventory.traceability',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-29 19:15:36'),
(183,180,'Expiration Dates',NULL,'inventory/lots/expiration','_self','inventory.expiration_dates',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:34','2025-11-29 19:15:36'),
(184,44,'Multi-Currency','','accounting/currency','_self','accounting.multicurrency',50,1,0,0,'','',NULL,'','','2025-11-03 19:25:34','2025-12-02 13:56:09'),
(185,184,'Currencies','','accounting/currency/list','_self','accounting.currencies',1,1,0,0,'','',NULL,'','','2025-11-03 19:25:34','2025-11-29 19:15:36'),
(186,184,'Exchange Rates','','accounting/currency/rates','_self','accounting.exchange_rates',2,1,0,0,'','',NULL,'','','2025-11-03 19:25:34','2025-11-29 19:15:36'),
(187,184,'Currency Gains/Losses','','accounting/currency/revaluation','_self','accounting.view',3,1,0,0,'','',NULL,'','','2025-11-03 19:25:34','2025-11-12 17:45:06'),
(188,32,'Audit Log','','audit-logs','_self','audit_log.view',2,1,0,0,'','',NULL,'','','2025-11-03 19:25:34','2025-11-30 13:42:36'),
(193,17,'Automation','','settings/automation','_self','settings.automation',30,1,0,0,'','',NULL,'','','2025-11-03 19:25:34','2025-11-29 19:13:00'),
(194,193,'Workflows','','settings/automation/workflows','_self','admin',5,0,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-16 21:19:23'),
(195,193,'Approval Rules','','settings/automation/approvals','_self','admin',1,0,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-16 21:20:03'),
(196,193,'Templates','','automation/email-templates','_self','admin',2,1,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-16 21:47:57'),
(197,193,'Scheduled Actions',NULL,'settings/automation/scheduled','_self','admin',4,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-05 16:19:55'),
(198,241,'Projects','bi bi-kanban','projects','_self','projects.view',300,1,0,0,'SELECT COUNT(*) as count FROM projects WHERE status IN (\'active\', \'on_hold\')','',NULL,'','','2025-11-03 19:25:35','2025-11-11 14:34:18'),
(199,198,'Dashboard','','projects/dashboard','_self','projects.dashboard',1,1,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:05:45'),
(201,198,'My Projects','','projects/?my_projects=1','_self','projects.my_projects',11,1,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:13:00'),
(202,198,'My Tasks','','projects/my-tasks','_self','projects.my_tasks',20,1,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:13:00'),
(203,198,'Gantt Chart','','projects/gantt','_self','projects.gantt',30,0,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:26:50'),
(204,198,'Time Tracking','','projects/time','_self','projects.time_tracking',40,0,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:26:50'),
(205,198,'Resource Planning','','projects/resources','_self','projects.resource_planning',50,0,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:26:50'),
(206,198,'Project Profitability','','projects/profitability','_self','projects.profitability',60,0,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:26:50'),
(207,241,'Files','bi bi-file-earmark-text','/files','_self','files.manage',100,1,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-21 21:48:10'),
(208,207,'All Files','','/files','_self','file_manager.all_files',10,1,0,0,'SELECT COUNT(*) FROM files WHERE 1=1','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:13:00'),
(209,207,'My Files','','/files?context=user','_self','file_manager.my_files',11,1,0,0,'SELECT COUNT(*) FROM files WHERE uploaded_by = {user_id}','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:13:00'),
(210,207,'Shared With Me','','files/shared','_self','file_manager.shared',12,1,0,0,'SELECT COUNT(DISTINCT f.id) FROM files f \r\n                 INNER JOIN file_shares fs ON f.id = fs.file_id \r\n                 WHERE (fs.shared_with_user_id = {user_id} OR fs.shared_with_role_id = {role_id})\r\n                 AND (fs.expires_at IS NULL OR fs.expires_at > NOW())\r\n                 AND f.uploaded_by != {user_id}','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:13:00'),
(213,241,'Reports','bi bi-clipboard-data','reports/custom','_self','reports.view',400,1,0,0,'SELECT COUNT(*) FROM custom_reports WHERE created_by = {user_id}','',NULL,'','','2025-11-03 19:25:35','2025-11-11 14:33:34'),
(214,213,'Report Builder',NULL,'reports/custom/builder','_self','custom_reports.builder',1,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:05:45'),
(215,213,'My Reports',NULL,'reports/custom/my','_self','custom_reports.my',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:05:45'),
(216,213,'Shared Reports',NULL,'reports/custom/shared','_self','custom_reports.shared',3,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:05:45'),
(217,213,'Scheduled Reports',NULL,'reports/custom/scheduled','_self','custom_reports.scheduled',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:05:45'),
(218,3,'Email Marketing','','email-marketing','_self','marketing.view',40,1,0,0,'','',NULL,'','','2025-11-03 19:25:35','2025-11-15 19:18:10'),
(219,218,'Dashboard',NULL,'email-marketing/dashboard','_self','marketing.view',1,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-11 11:15:46'),
(220,218,'Campaigns',NULL,'email-marketing/campaigns','_self','marketing.view',10,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-11 11:15:46'),
(221,218,'Email Templates',NULL,'email-marketing/templates','_self','marketing.view',20,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-11 11:15:46'),
(222,218,'Mailing Lists',NULL,'email-marketing/lists','_self','marketing.view',30,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-11 11:15:46'),
(223,218,'Automation',NULL,'email-marketing/automation','_self','marketing.view',40,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-11 11:15:46'),
(224,218,'Analytics',NULL,'email-marketing/analytics','_self','marketing.view',50,0,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-11 11:15:46'),
(225,241,'Helpdesk','bi bi-headset','helpdesk','_self','help_desk.view',200,1,0,0,'SELECT COUNT(*) as count FROM crm_support_tickets WHERE status NOT IN (\'closed\', \'resolved\')','',NULL,'','','2025-11-03 19:25:35','2025-11-29 19:01:02'),
(226,225,'Dashboard',NULL,'helpdesk/dashboard','_self','help_desk.dashboard',1,1,0,0,'SELECT COUNT(*) as count FROM crm_support_tickets WHERE status NOT IN (\'closed\', \'resolved\')',NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(227,225,'Tickets',NULL,'helpdesk/tickets','_self','help_desk.tickets',10,1,0,0,'SELECT COUNT(*) as count FROM crm_support_tickets WHERE status NOT IN (\'closed\', \'resolved\')','danger',2,'warning',NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(228,225,'My Tickets',NULL,'helpdesk/my-tickets','_self','help_desk.myTickets',11,1,0,0,'SELECT COUNT(*) as count FROM crm_support_tickets WHERE created_by = {user_id} AND status NOT IN (\'closed\', \'resolved\')','danger',0,'danger',NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(229,225,'SLA Management',NULL,'helpdesk/sla','_self','help_desk.sla',20,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(230,225,'Knowledge Base',NULL,'helpdesk/kb','_self','help_desk.knowledgeBase',30,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(231,225,'Live Chat',NULL,'helpdesk/chat','_self','help_desk.chat',40,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(232,225,'Reports',NULL,'helpdesk/reports','_self','help_desk.reports',50,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-03 19:25:35','2025-11-29 19:01:02'),
(234,NULL,'APP GRID',NULL,NULL,'_self','admin',999,1,1,0,NULL,NULL,NULL,NULL,'Container for app grid shortcuts','2025-11-03 21:45:59','2025-11-08 15:05:40'),
(235,234,'DASHBOARD','bi bi-speedometer2','dashboard','_self','dashboard.view',1,1,0,1,'','',NULL,'','Quick access to dashboard','2025-11-03 21:45:59','2025-11-18 18:40:34'),
(236,234,'CALENDAR','bi bi-calendar4','calendar','_self','calendar.view',2,1,0,1,NULL,NULL,NULL,NULL,'Quick access to calendar','2025-11-03 21:45:59','2025-11-11 11:15:46'),
(237,234,'EMPLOYEES','bi bi-people','employees/directory','_self','employees.directory',3,1,0,1,'','',NULL,'','Quick access to customers','2025-11-03 21:45:59','2025-11-28 22:18:52'),
(238,234,'SALES','bi bi-cart','salesorders','_self','sales.view',200,0,0,1,'','',NULL,'','Quick access to sales orders','2025-11-03 21:45:59','2025-11-18 18:40:41'),
(239,234,'PRODUCTS','bi bi-box-seam','products','_self','inventory.view',100,0,0,1,'SELECT COUNT(DISTINCT p.id) as count FROM products p LEFT JOIN inventory_levels il ON p.id = il.product_id WHERE COALESCE(il.quantity, 0) <= COALESCE(p.reorder_level, 0) AND p.reorder_level > 0','danger',3,'danger','Quick access to products','2025-11-03 21:45:59','2025-11-18 18:40:40'),
(240,234,'SETTINGS','bi bi-sliders','settings','_self','settings.view',300,0,0,1,'','',NULL,'','Quick access to settings','2025-11-03 21:45:59','2025-11-18 18:40:42'),
(241,NULL,'TOOLS','','','_self',NULL,200,1,1,0,'','',NULL,'','','2025-11-03 23:09:44','2025-11-11 12:43:15'),
(250,18,'Positions','','hr/positions','_self','positions.view',4,1,0,0,'','',NULL,'','','2025-11-08 15:00:54','2025-11-11 13:13:12'),
(251,61,'A/P Aging Detail',NULL,'accounting/reports/ap-aging-detail','_self','accounting.ap_aging_detail',7,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-09 13:34:09','2025-11-29 19:15:36'),
(252,61,'A/R Aging Detail',NULL,'accounting/reports/ar-aging-detail','_self','accounting.ar_aging_detail',8,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-09 13:34:09','2025-11-29 19:15:36'),
(253,61,'Cash Flow Statement','','accounting/reports/cash-flow-statement','_self','accounting.cash_flow_statement',4,1,0,0,'','',NULL,'','','2025-11-09 13:34:09','2025-11-29 19:15:36'),
(254,61,'Payment Terms List',NULL,'accounting/reports/payment-terms-list','_self','accounting.payment_terms_list',10,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-09 13:34:09','2025-11-29 19:15:36'),
(255,281,'PHPmyadmin','','/phpmyadmin','_self','admin',30,1,0,0,'','',NULL,'','Admin access to PHPmyadmin','2025-11-11 13:25:37','2025-12-02 13:44:42'),
(257,86,'Visual Audits','','/camera-audit','_self','inventory.view',100,1,0,0,'','',NULL,'','Visual inventory audit logs with camera imagery','2025-11-13 18:23:41','2025-12-02 13:44:42'),
(259,18,'User Groups','','settings/user-groups','_self','settings.user_groups',10,1,0,0,'','',NULL,'','','2025-11-14 13:14:30','2025-11-29 19:13:00'),
(264,274,'Vendor Payments','','/accounting/vendor-payments','_self','accounting.vendor_payments',30,1,0,0,'','',NULL,'','','2025-11-15 18:53:41','2025-12-02 13:44:42'),
(265,44,'Tax Management','','#','_self','accounting.view',80,1,0,0,'','',NULL,'','','2025-11-15 18:53:41','2025-12-02 13:44:42'),
(266,265,'Tax Jurisdictions','','/tax/jurisdictions','_self','tax_jurisdictions.view',1,1,0,0,'','',NULL,'','','2025-11-15 18:53:41','2025-11-15 19:20:47'),
(267,265,'Tax Payments','','/tax/payments','_self','tax_payments.view',2,1,0,0,'','',NULL,'','','2025-11-15 18:53:41','2025-11-15 19:20:58'),
(268,265,'Tax Reports','','/tax/reports/liability','_self','tax_reports.view',3,1,0,0,'','',NULL,'','','2025-11-15 18:53:41','2025-11-15 19:21:09'),
(269,145,'1099 Contractors','','/suppliers?filter=1099','_self','1099_contractors.view',15,1,0,0,'','',NULL,'','','2025-11-15 18:53:41','2025-11-15 18:55:44'),
(270,145,'Suppliers','','suppliers','_self','purchases.view',10,1,0,0,'','',NULL,'','','2025-11-15 18:56:26','2025-12-02 13:44:42'),
(272,274,'Customer Payments','','/accounting/customer-payments','_self','accounting.customer_payments.view',10,1,0,0,'','',NULL,'','','2025-11-15 19:51:04','2025-11-15 19:57:01'),
(274,44,'Payments','','','_self','accounting.view',70,1,0,0,'','',NULL,'','','2025-11-15 19:56:44','2025-12-02 13:44:42'),
(276,44,'Recurring Transactions','','/recurring','_self','accounting.view',75,1,0,0,'','',NULL,'','','2025-11-15 21:52:32','2025-12-02 13:44:42'),
(277,35,'Action Menu Editor','','settings/action-menus','_self','settings.action_menus',1,1,0,0,'','',NULL,'','','2025-11-16 20:47:28','2025-11-29 19:13:00'),
(278,40,'NDA Templates','','settings/nda-templates','_self','settings.nda_templates',1,1,0,0,'','',NULL,'','','2025-11-16 21:54:23','2025-11-29 19:13:00'),
(279,3,'NDAs','','ndas','_self','ndas.view',70,1,0,0,'','',NULL,'','','2025-11-16 22:28:51','2025-11-28 22:27:00'),
(280,281,'System Backup','','backup','_self','admin',40,1,0,0,'','',NULL,'','','2025-11-17 11:21:31','2025-12-02 13:44:42'),
(281,17,'Administrative','','','_self','admin',0,1,0,0,'','',NULL,'','','2025-11-17 11:23:09','2025-12-02 13:44:42'),
(282,225,'Documentation','','documentation','_self','help_desk.view',5,1,0,0,'','',NULL,'','','2025-11-17 14:24:20','2025-12-02 13:44:42'),
(283,281,'Document Mgmt','','#','_self','admin',10,1,0,0,'','',NULL,'','Cloud document storage and collaborative editing via Nextcloud','2025-11-18 01:03:28','2025-12-02 13:44:42'),
(301,193,'AI Testing','','ai-test','_self','admin',0,1,0,0,'','',NULL,'','','2025-11-19 12:52:34','2025-12-02 13:44:42'),
(303,2,'Forecaster','bi bi-graph-up-arrow','','_self','forecasting.view',22,1,0,0,'','',NULL,'','Daily forecasting and assumptions management','2025-11-19 17:30:35','2025-11-20 03:03:23'),
(304,303,'Daily Update','bi bi-1-square','assumptions','_self','forecasting.update_daily',2,1,0,0,'','',NULL,'','Quick daily updates for key assumptions','2025-11-19 17:30:35','2025-11-20 03:08:49'),
(305,303,'Variance Report','','assumptions/variance','_self','forecasting.view_actuals',10,1,0,0,'','',NULL,'','Compare forecast vs actual performance','2025-11-19 17:30:35','2025-11-20 03:11:34'),
(306,303,'Assumption Sets','bi bi-2-square','assumptions/sets','_self','forecasting.manage_assumptions',3,1,0,0,'','',NULL,'','Manage multiple assumption scenarios','2025-11-19 17:30:35','2025-11-20 03:09:17'),
(307,303,'Advanced Tools','','','_self','',98,1,1,0,'','',NULL,'','','2025-11-19 17:30:35','2025-11-20 03:11:56'),
(308,303,'Scenario Modeler','','forecaster','_self','forecasting.view',99,1,0,0,'','',NULL,'','Advanced scenario modeling with financing','2025-11-19 17:30:35','2025-11-20 03:13:02'),
(309,303,'Product Configs','bi bi-3-square','product-forecast','_self','forecasting.manage_products',4,1,0,0,'','',NULL,'','Configure product-level forecasts with capacity constraints','2025-11-19 18:02:33','2025-11-20 13:03:51'),
(310,303,'Generate Projections','bi bi-4-square','product-forecast/generate','_self','forecasting.generate_projections',5,1,0,0,'','',NULL,'','Run projection engine for all configured products','2025-11-19 18:02:33','2025-11-20 03:10:05'),
(311,303,'Pro Forma Stmts','bi bi-5-square','product-forecast/proforma','_self','product_forecast.proforma',6,1,0,0,'','',NULL,'','View consolidated financial statements','2025-11-19 18:02:33','2025-11-29 19:13:00'),
(312,303,'Compare Scenarios','','product-forecast/compare','_self','product_forecast.compare',9,1,0,0,'','',NULL,'','Side-by-side scenario comparison','2025-11-19 18:02:33','2025-11-29 19:13:00'),
(313,303,'Sensitivity Analysis','','product-forecast/sensitivity','_self','product_forecast.sensitivity',8,1,0,0,'','',NULL,'','Interactive what-if scenario analysis','2025-11-19 18:57:32','2025-11-29 19:13:00'),
(314,303,'Variance Tracking','bi bi-6-square','/product-forecast/variance','_self','manufacturing.view',7,1,0,0,'','',NULL,'','','2025-11-19 19:05:49','2025-12-02 13:44:42'),
(315,303,'Command Center','','/product-forecast/command-center','_self','manufacturing.view',1,1,0,0,'','',NULL,'','','2025-11-19 19:29:24','2025-12-02 13:44:42'),
(316,303,'Getting Started','','/product-forecast/getting-started','_self','manufacturing.view',0,1,0,0,'','',NULL,'','Learn the forecasting workflow','2025-11-19 19:57:51','2025-12-02 13:44:42'),
(317,207,'Company Files','bi bi-people','/files?context=company','_self','customers.documents',15,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'customer\'','',NULL,'','','2025-11-21 14:40:15','2025-11-24 19:17:29'),
(319,207,'Accounting Files','bi bi-calculator','/files?context=accounting','_self','accounting.view',14,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'accounting\'','',NULL,'','','2025-11-21 14:40:15','2025-11-21 17:11:02'),
(320,207,'Project Files','bi bi-kanban','/files?context=project','_self','projects.view',77,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'project\'','',NULL,'','','2025-11-21 14:40:15','2025-11-21 19:07:54'),
(321,207,'HR Documents','bi bi-people','/files?context=hr','_self','hr.view',65,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'hr\'',NULL,NULL,NULL,NULL,'2025-11-21 17:05:14','2025-11-29 01:04:03'),
(322,207,'Inventory Documents','bi bi-box-seam','/files?context=inventory','_self','inventory.view',70,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'inventory\'',NULL,NULL,NULL,NULL,'2025-11-21 17:05:14','2025-11-29 01:04:03'),
(323,207,'Manufacturing Documents','bi bi-gear','/files?context=manufacturing','_self','manufacturing.view',75,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'manufacturing\'',NULL,NULL,NULL,NULL,'2025-11-21 17:05:14','2025-11-29 01:04:03'),
(324,207,'Purchases Documents','bi bi-cart','/files?context=purchases','_self','purchases.view',80,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'purchases\'',NULL,NULL,NULL,NULL,'2025-11-21 17:05:14','2025-11-29 01:04:03'),
(325,207,'Sales Documents','bi bi-cart-check','/files?context=sales','_self','sales.view',85,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'sales\'',NULL,NULL,NULL,NULL,'2025-11-21 17:05:14','2025-11-29 01:04:03'),
(326,129,'Agreements','bi bi-2-square','agreements','_self','sales.create',2,1,0,0,'','',NULL,'','','2025-11-24 14:53:27','2025-11-25 23:44:54'),
(327,281,'System Scripts','','admin/system-scripts','_self','admin.system_scripts',250,1,0,0,'','',NULL,'','','2025-11-24 19:14:40','2025-11-25 12:55:37'),
(328,44,'Dashboard','','accounting','_self','',0,1,0,0,'','',NULL,'','','2025-11-24 19:27:52','2025-11-24 19:27:52'),
(330,NULL,'Email','bi-envelope','/email','_self','email.view',2,1,0,0,'SELECT COUNT(*) FROM emails e INNER JOIN email_folder_map efm ON e.id = efm.email_id INNER JOIN email_folders f ON efm.folder_id = f.id WHERE e.user_id = {user_id} AND e.is_read = 0 AND f.folder_type = \'inbox\'','primary',NULL,'','','2025-11-26 15:55:28','2025-12-04 16:08:20'),
(331,330,'Inbox','bi-inbox','/email','_self','email.view',1,1,0,0,'SELECT COUNT(DISTINCT e.id) FROM emails e INNER JOIN email_folder_map efm ON e.id = efm.email_id INNER JOIN email_folders f ON efm.folder_id = f.id WHERE e.user_id = {user_id} AND f.folder_type = \'inbox\' AND e.is_read = 0','primary',10,'warning',NULL,'2025-11-26 16:10:07','2025-12-04 16:08:20'),
(334,330,'Starred','bi-star','/email/folder/starred','_self','email.view',3,1,0,0,'SELECT COUNT(*) FROM emails WHERE user_id = {user_id} AND is_starred = 1','warning',NULL,'','','2025-11-26 16:10:07','2025-12-04 16:08:20'),
(335,330,'Compose','bi-pencil-square','/email/compose','_self','email.view',2,1,0,0,'','',NULL,'','','2025-11-26 16:10:07','2025-12-02 13:44:42'),
(339,330,'Sent','bi bi-send','/email/folder/sent','_self','email.view',2,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-27 13:24:34','2025-12-02 13:44:42'),
(340,330,'Drafts','bi bi-file-earmark','/email/folder/drafts','_self','email.view',3,1,0,0,'SELECT COUNT(DISTINCT e.id) FROM emails e INNER JOIN email_folder_map efm ON e.id = efm.email_id INNER JOIN email_folders f ON efm.folder_id = f.id WHERE e.user_id = {user_id} AND f.folder_type = \'drafts\'','info',NULL,NULL,NULL,'2025-11-27 13:24:34','2025-12-04 16:08:20'),
(341,330,'Archive','bi bi-archive','/email/folder/archive','_self','email.view',4,1,0,0,NULL,NULL,NULL,NULL,NULL,'2025-11-27 13:24:34','2025-12-02 13:44:42'),
(342,330,'Trash','bi bi-trash','/email/folder/trash','_self','email.view',10,1,0,0,'SELECT COUNT(DISTINCT e.id) FROM emails e INNER JOIN email_folder_map efm ON e.id = efm.email_id INNER JOIN email_folders f ON efm.folder_id = f.id WHERE e.user_id = {user_id} AND f.folder_type = \'trash\'','secondary',NULL,'','','2025-11-27 13:24:34','2025-12-04 16:08:20'),
(343,330,'Spam','bi bi-exclamation-triangle','/email/folder/spam','_self','email.view',6,1,0,0,'SELECT COUNT(DISTINCT e.id) FROM emails e INNER JOIN email_folder_map efm ON e.id = efm.email_id INNER JOIN email_folders f ON efm.folder_id = f.id WHERE e.user_id = {user_id} AND f.folder_type = \'spam\' AND e.is_read = 0','danger',0,'danger',NULL,'2025-11-27 13:24:34','2025-12-04 16:08:20'),
(347,32,'Access Management','','/security/roles','_self','roles.view',1,1,0,0,'','',NULL,'','','2025-11-30 13:38:35','2025-11-30 13:42:13'),
(348,207,'CRM Documents','bi bi-briefcase','/files?context=activity','_self','customers.view',62,1,0,0,'SELECT COUNT(*) FROM files WHERE entity_type = \'activity\'','',NULL,'','','2025-12-02 02:47:48','2025-12-02 13:44:42'),
(349,241,'Diagrams','fas fa-draw-polygon','/diagrams','_self','diagrams.view',95,1,0,0,'','',NULL,'','','2025-12-02 03:48:20','2025-12-02 13:12:58'),
(352,362,'Equipment Research','','/manufacturing/equipment-research','_self','equipment.view',85,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:31:05'),
(353,352,'Dashboard','','/manufacturing/equipment-research','_self','equipment.view',1,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:31:58'),
(354,352,'Vendors','','/manufacturing/equipment-research/vendors','_self','equipment.view',2,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:32:06'),
(355,352,'Market Research','','/manufacturing/equipment-research/market-research','_self','equipment.view',3,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:32:18'),
(356,352,'ROI Analysis','','/manufacturing/equipment-research/roi-analyses','_self','equipment.view',4,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:32:22'),
(357,352,'Benchmarking','','/manufacturing/equipment-research/benchmarking','_self','equipment.view',5,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:32:26'),
(358,352,'Technology Trends','','/manufacturing/equipment-research/technology-trends','_self','equipment.view',6,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:32:29'),
(359,352,'Competitor Intel','','/manufacturing/equipment-research/competitor-snapshots','_self','equipment.view',7,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:32:32'),
(360,303,'Profit Optimizer','','/manufacturing/profit-optimizer','_self','equipment.view',999,1,0,0,'','',NULL,'','','2025-12-05 14:40:59','2025-12-05 22:31:31'),
(362,NULL,'DEV','fas fa-code','#','_self','admin',999,1,0,0,'','',NULL,'','','2025-12-05 18:06:31','2025-12-05 22:31:43');
commit;

--
-- Table structure for table `message_attachments`
--

CREATE TABLE `message_attachments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `message_id` int(10) unsigned NOT NULL,
  `filename` varchar(255) NOT NULL,
  `original_filename` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `file_size` int(10) unsigned NOT NULL,
  `mime_type` varchar(100) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_message_id` (`message_id`),
  CONSTRAINT `message_attachments_ibfk_1` FOREIGN KEY (`message_id`) REFERENCES `messages` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `message_attachments`
--

set autocommit=0;
INSERT INTO `message_attachments` VALUES
(1,6,'691650a6c7230_1763070118.png','1984 Apple Macintosh 128k.png','/Users/rpmbbu/LocalPHPStorm/m1_erp_web/uploads/messaging/691650a6c7230_1763070118.png',13052,'image/png','2025-11-13 21:41:58','2025-11-13 21:41:58'),
(2,7,'691655cb26b0d_1763071435.png','fsociety.png','/Users/rpmbbu/LocalPHPStorm/m1_erp_web/uploads/messaging/691655cb26b0d_1763071435.png',36485,'image/png','2025-11-13 22:03:55','2025-11-13 22:03:55');
commit;

--
-- Table structure for table `message_reactions`
--

CREATE TABLE `message_reactions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `message_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `emoji` varchar(50) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `message_user_emoji` (`message_id`,`user_id`,`emoji`),
  KEY `idx_message_id` (`message_id`),
  KEY `idx_user_id` (`user_id`),
  CONSTRAINT `message_reactions_ibfk_1` FOREIGN KEY (`message_id`) REFERENCES `messages` (`id`) ON DELETE CASCADE,
  CONSTRAINT `message_reactions_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `message_reactions`
--

set autocommit=0;
INSERT INTO `message_reactions` VALUES
(8,5,1,'❤️','2025-11-13 21:40:50','2025-11-13 21:40:50'),
(14,6,1,'🤜','2025-11-14 19:43:44','2025-11-14 19:43:44');
commit;

--
-- Table structure for table `messages`
--

CREATE TABLE `messages` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `channel_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `parent_id` int(10) unsigned DEFAULT NULL COMMENT 'For threaded replies',
  `message` text NOT NULL,
  `is_edited` tinyint(4) DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `mentions` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Array of mentioned user IDs' CHECK (json_valid(`mentions`)),
  PRIMARY KEY (`id`),
  KEY `idx_channel_id` (`channel_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_parent_id` (`parent_id`),
  KEY `idx_created_at` (`created_at`),
  CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`channel_id`) REFERENCES `channels` (`id`) ON DELETE CASCADE,
  CONSTRAINT `messages_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `messages_ibfk_3` FOREIGN KEY (`parent_id`) REFERENCES `messages` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `messages`
--

set autocommit=0;
INSERT INTO `messages` VALUES
(5,1,1,NULL,'Hey @admin does this work?',0,'2025-11-13 21:40:46','2025-11-13 21:40:46',NULL),
(6,1,1,NULL,'Shared a file: 1984 Apple Macintosh 128k.png',0,'2025-11-13 21:41:58','2025-11-13 21:41:58',NULL),
(7,1,1,NULL,'Shared a file: fsociety.png',0,'2025-11-13 22:03:55','2025-11-13 22:03:55',NULL);
commit;

--
-- Table structure for table `mrp_requirements`
--

CREATE TABLE `mrp_requirements` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` int(10) unsigned NOT NULL,
  `total_required` decimal(15,3) NOT NULL DEFAULT 0.000,
  `on_hand` decimal(15,3) NOT NULL DEFAULT 0.000,
  `on_order` decimal(15,3) NOT NULL DEFAULT 0.000,
  `allocated` decimal(15,3) NOT NULL DEFAULT 0.000,
  `net_required` decimal(15,3) NOT NULL DEFAULT 0.000,
  `suggested_order_date` date DEFAULT NULL,
  `lead_time_days` int(11) DEFAULT 7,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_product` (`product_id`),
  KEY `idx_net_required` (`net_required`),
  KEY `idx_created_at` (`created_at`),
  CONSTRAINT `mrp_requirements_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `mrp_requirements`
--

set autocommit=0;
commit;

--
-- Table structure for table `ncr_actions`
--

CREATE TABLE `ncr_actions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ncr_id` int(10) unsigned NOT NULL,
  `action_type` enum('investigation','corrective','preventive','follow_up') NOT NULL,
  `description` text NOT NULL,
  `assigned_to` int(10) unsigned DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `status` enum('pending','in_progress','completed') DEFAULT 'pending',
  `completed_by` int(10) unsigned DEFAULT NULL,
  `completed_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_ncr` (`ncr_id`),
  KEY `idx_status` (`status`),
  KEY `assigned_to` (`assigned_to`),
  KEY `completed_by` (`completed_by`),
  CONSTRAINT `ncr_actions_ibfk_1` FOREIGN KEY (`ncr_id`) REFERENCES `non_conformance_reports` (`id`) ON DELETE CASCADE,
  CONSTRAINT `ncr_actions_ibfk_2` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `ncr_actions_ibfk_3` FOREIGN KEY (`completed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `ncr_actions`
--

set autocommit=0;
commit;

--
-- Table structure for table `nda_signatures`
--

CREATE TABLE `nda_signatures` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nda_id` int(11) NOT NULL,
  `signer_role` enum('customer','company_representative') NOT NULL DEFAULT 'customer',
  `signer_name` varchar(255) NOT NULL,
  `signer_email` varchar(255) NOT NULL,
  `signer_title` varchar(255) DEFAULT NULL,
  `signer_company` varchar(255) DEFAULT NULL,
  `signature_data` text DEFAULT NULL,
  `signed_at` datetime NOT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `acceptance_text` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_nda_id` (`nda_id`),
  KEY `idx_signed_at` (`signed_at`),
  KEY `idx_signer_role` (`signer_role`),
  CONSTRAINT `nda_signatures_ibfk_1` FOREIGN KEY (`nda_id`) REFERENCES `ndas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `nda_signatures`
--

set autocommit=0;
commit;

--
-- Table structure for table `nda_templates`
--

CREATE TABLE `nda_templates` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `template_name` varchar(255) NOT NULL,
  `template_type` enum('mutual','unilateral','custom') NOT NULL,
  `template_content` longtext NOT NULL,
  `merge_fields` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`merge_fields`)),
  `is_active` tinyint(1) DEFAULT 1,
  `is_default` tinyint(1) DEFAULT 0,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_is_active` (`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `nda_templates`
--

set autocommit=0;
INSERT INTO `nda_templates` VALUES
(1,'Mavrix 1 Unilateral NDA','unilateral','\n<div style=\"text-align: center; margin-bottom: 30px;\">\n    <h1 style=\"font-size: 18pt; margin: 20px 0;\">NON-DISCLOSURE AGREEMENT</h1>\n</div>\n\n<p>This Agreement is dated as of the date of the last signature below (the \"Effective Date\") by and between <strong>{your_company_name}</strong>, having its principal legal mailing address at: <strong>{your_company_address}</strong></p>\n\n<p style=\"text-align: center; margin: 20px 0;\"><strong>AND</strong></p>\n\n<p>(individual/Company/LLC): <strong>{company_name}</strong>, with its principal address at: <strong>{contact_address}</strong>.</p>\n\n<p>The parties wish to assure the confidentiality of certain trade secrets, information, and other materials, which have been or may be disclosed by one party (\"Discloser\") to the other party (\"Recipient\") during the review and consideration of a possible business relationship (the \"Purpose\").</p>\n\n<h2 style=\"margin-top: 30px;\">1. NO JOINT VENTURE</h2>\n<p>The parties hereto agree that this Agreement is for the purposes of protecting confidential information disclosed in furtherance of the Purpose only. This Agreement is not a joint venture or other such business arrangement; and any agreement between the parties as to a joint business activities will be, or already is, set forth in other written agreements.</p>\n\n<h2 style=\"margin-top: 30px;\">2. NO LICENSES</h2>\n<p>No license to Recipient under any trademark, patent, copyright or any other intellectual property right is either granted or implied by the disclosure of Confidential Information to Recipient. None of the Confidential Information which may be disclosed to Recipient shall constitute any representation, warranty, assurance, guarantee or inducement by either party to the other of any kind including but not limited to representations, warranties, assurances, guarantees or inducements with respect to the non-infringement of trademarks, patents, copyrights, or any other intellectual property rights, or other rights of either party or of third parties.</p>\n\n<h2 style=\"margin-top: 30px;\">3. CONFIDENTIAL INFORMATION</h2>\n<p>\"Confidential Information\" shall mean any information, field technical guide, technical data, or know-how including, but not limited to, that which relates to a party\'s hardware, software, screens, specifications, designs, plans, site plans, site drawings, general drawings, data, prototypes, discoveries, research, developments, processes, procedures, and/or technical information and materials, in oral, demonstrative, written, electronic, graphic, or machine-readable form and any analyses, compilations, studies, or documents prepared by Recipient, its representatives, or employees, which summarize any such information of Discloser.</p>\n\n<p>This Agreement also encompasses 3rd Party members of contributions/information to {your_company_name}, {your_company_name} perspective DBA\'s and subordinate companies in design, engineering diagrams, unique business model, network(s) whether marked or unmarked confidential and any other originating content, as proprietary, and not to be disclosed outside of the recipient party or used in any form.</p>\n\n<h2 style=\"margin-top: 30px;\">4. EXCEPTIONS</h2>\n<p><strong>a)</strong> Notwithstanding anything to the contrary contained herein, Recipient shall have no obligation with respect to any Confidential Information of Discloser which, as evidenced by tangible records kept in the ordinary course of business: (i) is or becomes generally known to companies engaged in the same or similar business as the parties hereto on a nonconfidential basis, through no wrongful act of Recipient; (ii) is lawfully obtained by Recipient from a third party without any obligation by Recipient to maintain the information proprietary or confidential; (iii) is known by Recipient prior to disclosure hereunder without any obligation to keep it confidential and such information was not disclosed by Discloser under this Agreement; (iv) is independently developed by Recipient without reference to or use of the other\'s Confidential Information; or (v) is the subject of a written agreement whereby Discloser consents to the disclosure of such Confidential Information.</p>\n\n<p><strong>b)</strong> If Recipient or any of its representatives shall be under a legal obligation in any administrative or judicial circumstance to disclose any Confidential Information, Recipient shall give Discloser prompt notice thereof so that Discloser may seek a protective order and/or waive the duty of non-disclosure; provided that in the absence of such order or waiver, if Recipient or any such representative shall, in the opinion of its counsel, stand liable for contempt or be likely to suffer other censure or penalty for failure to disclose, disclosure pursuant to the order of such tribunal may be made Recipient or its representatives without liability hereunder.</p>\n\n<h2 style=\"margin-top: 30px; page-break-before: always;\">5. PROTECTION OF CONFIDENTIAL INFORMATION</h2>\n<p><strong>a)</strong> Recipient agrees not to disclose the Confidential Information of Discloser or to use Confidential Information for any purpose other than the Purpose specified in paragraph 1 above. Recipient agrees to protect the Confidential Information of Discloser from disclosure to anyone other than its directors, officers, and employees who have a business-related need to have access to such Confidential Information in connection with the purposes of this Agreement, and who have entered into the agreements with such party pursuant to which they are bound by the confidentiality provisions of this Agreement to the same extent that Recipient is bound. Recipient further agrees promptly to advise Discloser in writing of any unauthorized misappropriation, disclosure or use by any person of the Confidential Information of Discloser which may come to its attention and to take all steps reasonably requested by Discloser to limit, stop or otherwise remedy such misappropriation, disclosure or use.</p>\n\n<p><strong>b)</strong> Recipient will only make as many copies of Confidential Information as are necessary for its use under the terms hereof, and each such copy will be marked with the same proprietary notices that appear on the originals.</p>\n\n<p><strong>c)</strong> The rights and obligations of the parties under this Agreement expire <strong>FIVE (5) years</strong> after the Effective Date, provided that with respect to Confidential Information that constitutes a trade secret under applicable law, such rights and obligations will survive such expiration until, if ever, such Confidential Information loses its trade secret protection other than due to an act or omission of Recipient or its representatives.</p>\n\n<p><strong>d)</strong> The rights and obligations of the parties under this Agreement as to the confidence obligations of sensitive classified and unclassified information pertaining to national security shall continue forever and shall survive the expiration and/or termination of this Agreement.</p>\n\n<p><strong>e)</strong> The Parties acknowledge and agree that any Controlled Unclassified Information (CUI) exchanged or accessed in the course of this Agreement, whether oral, written, or electronic, shall be handled, protected, and secured in accordance with all applicable laws, regulations, and policies governing the handling of CUI. The receiving party agrees to protect the CUI from unauthorized access, disclosure, or use, and will implement appropriate and reasonable security measures in compliance with federal, state, and local laws, as well as any specific requirements outlined by the Disclosing Party. The receiving Party agrees that CUI disclosed under this Agreement shall be used solely for the purpose of the business relationship between the Parties and will not be used for any unauthorized or non-business-related purposes. Upon termination of this Agreement, or upon request of the Disclosing Party, the Receiving Party shall promptly return or take reasonable measures to destroy all copies of CUI, as instructed by the Disclosing Party.</p>\n\n<p><strong>f)</strong> In the event of a suspected or actual breach of CUI, the Receiving Party shall immediately notify the Disclosing Party and cooperate in any investigation or remedial actions necessary to address and mitigate any such breach. The obligations of this section shall survive the termination of this Agreement for as long as the information qualifies under CUI applicable laws and regulations.</p>\n\n<p><strong>g)</strong> Protection of confidentiality and other sensitive data under this Agreement must also adhere to the standard as provided by Department of Defense directive Operations Security (OPSEC) Program § 5205.02-M.</p>\n\n<p style=\"margin-left: 30px; font-style: italic;\">The Department of Defense policy, outlined in Department of Defense Manual (\"DoDM\") §5205.02-M mandates the establishment and maintenance of Operational Security (\"OPSEC\") programs to ensure national security-related missions and functions are protected. OPSEC is a risk management strategy designed to safeguard sensitive information and prevent unauthorized access or exploitation of information, communications, and data in the interest of the National Security of the United States.</p>\n\n<p style=\"margin-left: 30px; font-style: italic;\">Examples of OPSEC include avoiding sharing specific dates, locations, or casualty details to third parties, social media, or to anyone privately or in the public sphere; maintaining caution with regard to discussing unit specifics and capabilities. OPSEC involves a systematic approach that includes identifying critical information by evaluating potential adversaries and their capabilities to exploit vulnerabilities; vulnerability analysis by identifying weaknesses in security measures that could be exploited by adversaries; risk assessment by evaluating the likelihood and potential impact of vulnerabilities being exploited; and adherence to countermeasures by implementing measures to mitigate identified risks and protecting critical information.</p>\n\n<p style=\"margin-left: 30px; font-style: italic;\"><strong>OPSEC is a continuing process that requires ongoing assessment and adaptation to evolving threats and vulnerabilities. OPSEC also applies to unclassified information that could reveal sensitive details or information.</strong></p>\n\n<h2 style=\"margin-top: 30px; page-break-before: always;\">6. GENERAL PROVISIONS</h2>\n\n<p><strong>a. SEVERABILITY.</strong> If any term, provision, covenant or condition of this Agreement, or the application thereof to any person, place or circumstance, shall be held to be invalid, unenforceable or void, the remainder of this Agreement and such term, provision, covenant or condition as applied to other persons, places and circumstances shall remain in full force and effect.</p>\n\n<p><strong>b. RIGHTS CUMULATIVE.</strong> The rights and remedies provided by this Agreement are cumulative, and the exercise of any right or remedy by either party hereto (or by its successor), whether pursuant to this Agreement, to any other agreement, or to law, shall not preclude or waive its right to exercise any or all other rights and remedies.</p>\n\n<p>No failure or neglect of either party hereto in any instance to exercise any right, power, or privilege hereunder or under law shall constitute a waiver of any other right, power, or privilege or of the same right, power or privilege in any other instance. All waivers by either party hereto must be contained in a written instrument signed by the party to be charged and, in the case of the Company, by an officer of the Company or other person duly authorized by the Company.</p>\n\n<p><strong>c. REMEDY FOR BREACH.</strong> The parties hereto agree that, in the event of breach or threatened breach of any covenants of this Agreement, the damage or imminent damage to the other Party shall be inestimable, and that therefore any remedy at law or in damages shall be inadequate. Accordingly, the parties hereto agree that the aggrieved party shall be entitled to injunctive relief against the other Party in the event of any breach or threatened breach of this Agreement, in addition to any other relief (including damages) available to the Company under this Agreement or under law.</p>\n\n<p><strong>d. CHOICE OF LAW.</strong> Client consents to personal jurisdiction of the State and Federal courts located in the State of Florida, County of Manatee or closest thereof in connection with any controversy relating in any way to this Agreement or to any transaction. Client agrees to hold harmless {your_company_name} in any litigation, arbitration or any other choses or claim of action the Client may commence against Lender, Investor, Funding Source or Guarantor, or any other subcontracted party of the {your_company_name}.</p>\n\n<p>It is further agreed that any dispute, whether taking place in an international jurisdiction or in the USA shall be governed under the Laws of the United States of America and under the State and Federal courts named above.</p>\n\n<p><strong>e. NOTICES.</strong> Any notice, request, consent or approval required or permitted to be given under this Agreement or pursuant to law shall be sufficient if in writing, and if and when sent by certified or registered mail with postage prepaid and/or electronic mail, to {your_company_name}\'s address (as noted above) or to the Company\'s principal office, as the case may be.</p>\n\n<p><strong>f. MISCELLANEOUS.</strong></p>\n<p style=\"margin-left: 30px;\">(a) Should this Agreement be transmitted by facsimile, email, or electronic signature, the document shall be considered as an original document, and if signed and transmitted separately each section becoming both legally binding and enforceable.</p>\n<p style=\"margin-left: 30px;\">(b) This Agreement may only be modified or changed in writing and signed by both parties.</p>\n<p style=\"margin-left: 30px;\">(c) If any person or provision of this Agreement or its application is held to be invalid, illegal, or unenforceable in any respect, the validity, legality, or enforceability of any of the other provisions and applications therein shall not in any way be affected or impaired.</p>\n','{\"your_company_name\": \"Your company name\", \"your_company_address\": \"Your company address\", \"company_name\": \"Customer company name\", \"contact_name\": \"Customer contact name\", \"contact_title\": \"Customer contact title\", \"contact_email\": \"Customer contact email\", \"contact_address\": \"Customer company address\", \"effective_date\": \"Agreement effective date\", \"term_months\": \"Term duration in months\"}',1,1,NULL,'2025-11-16 11:44:05','2025-11-16 22:17:58');
commit;
set autocommit=0;
commit;

--
-- Table structure for table `network_monitor_logs`
--

CREATE TABLE `network_monitor_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL,
  `url` varchar(1000) NOT NULL,
  `host` varchar(255) NOT NULL,
  `port` int(11) DEFAULT 80,
  `method` varchar(10) DEFAULT 'GET',
  `context` varchar(255) DEFAULT '',
  `is_local` tinyint(1) DEFAULT 1,
  `status` enum('attempted','success','blocked','failed') DEFAULT 'attempted',
  `request_data` text DEFAULT NULL,
  `response_data` text DEFAULT NULL,
  `user_id` int(10) unsigned DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_timestamp` (`timestamp`),
  KEY `idx_host` (`host`),
  KEY `idx_status` (`status`),
  KEY `idx_is_local` (`is_local`),
  KEY `idx_user_id` (`user_id`),
  CONSTRAINT `network_monitor_logs_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;

--
-- Dumping data for table `network_monitor_logs`
--

set autocommit=0;
INSERT INTO `network_monitor_logs` VALUES
(1,'2025-11-19 09:49:46','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18305}','{\"status\":\"success\",\"response_size\":3527,\"tokens\":661}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(2,'2025-11-19 09:50:16','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18276}','{\"status\":\"success\",\"response_size\":1102,\"tokens\":174}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(3,'2025-11-19 09:50:34','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18229}','{\"status\":\"success\",\"response_size\":1583,\"tokens\":305}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(4,'2025-11-19 10:43:07','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18229}','{\"status\":\"success\",\"response_size\":1220,\"tokens\":230}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(5,'2025-11-19 10:45:11','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18370}','{\"status\":\"success\",\"response_size\":1713,\"tokens\":354}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(6,'2025-11-19 10:47:12','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18370}','{\"status\":\"success\",\"response_size\":1371,\"tokens\":286}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(7,'2025-11-19 10:47:53','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18410}','{\"status\":\"success\",\"response_size\":2999,\"tokens\":590}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(8,'2025-11-19 10:49:15','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18410}','{\"status\":\"success\",\"response_size\":3383,\"tokens\":662}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(9,'2025-11-19 10:49:46','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18372}','{\"status\":\"success\",\"response_size\":1447,\"tokens\":271}',NULL,'unknown','unknown'),
(10,'2025-11-19 10:56:58','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":145}','{\"status\":\"success\",\"response_size\":1351,\"tokens\":213}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(11,'2025-11-19 10:58:44','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":18842}','{\"status\":\"success\",\"response_size\":1570,\"tokens\":315}',NULL,'unknown','unknown'),
(12,'2025-11-19 10:59:49','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/generate\",\"payload_size\":18371}','{\"status\":\"success\",\"response_size\":23417,\"tokens\":72}',NULL,'unknown','unknown'),
(13,'2025-11-19 11:00:28','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/generate\",\"payload_size\":18405}','{\"status\":\"success\",\"response_size\":23835,\"tokens\":109}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(14,'2025-11-19 11:29:13','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/generate\",\"payload_size\":18408}','{\"status\":\"success\",\"response_size\":24825,\"tokens\":234}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(15,'2025-11-19 11:29:18','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.2:3b\",\"endpoint\":\"\\/chat\",\"payload_size\":448}','{\"status\":\"success\",\"response_size\":1221,\"tokens\":195}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(16,'2025-11-19 11:44:43','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(17,'2025-11-19 11:44:43','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(18,'2025-11-19 11:44:43','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(19,'2025-11-19 12:55:18','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":237}','{\"status\":\"success\",\"response_size\":760,\"tokens\":27}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(20,'2025-11-19 12:58:00','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":8466}','{\"status\":\"success\",\"response_size\":10545,\"tokens\":9}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(21,'2025-11-19 12:59:07','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":8456}','{\"status\":\"success\",\"response_size\":10607,\"tokens\":16}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(22,'2025-11-19 12:59:20','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/chat\",\"payload_size\":432}','{\"status\":\"success\",\"response_size\":1284,\"tokens\":213}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(23,'2025-11-19 13:45:57','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":966}','{\"status\":\"success\",\"response_size\":1663,\"tokens\":37}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(24,'2025-11-19 13:48:07','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":5356}','{\"status\":\"success\",\"response_size\":6805,\"tokens\":14}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(25,'2025-11-19 13:57:37','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":5356}','{\"status\":\"success\",\"response_size\":6976,\"tokens\":32}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(26,'2025-11-19 14:07:02','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":5341}','{\"status\":\"success\",\"response_size\":6877,\"tokens\":24}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(27,'2025-11-19 14:07:46','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":5341}','{\"status\":\"success\",\"response_size\":6818,\"tokens\":17}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(28,'2025-11-19 14:09:27','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":5341}','{\"status\":\"success\",\"response_size\":6843,\"tokens\":20}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(29,'2025-11-19 14:09:43','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/chat\",\"payload_size\":786}','{\"status\":\"success\",\"response_size\":1430,\"tokens\":279}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(30,'2025-11-19 14:26:33','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":5348}','{\"status\":\"success\",\"response_size\":6836,\"tokens\":19}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(31,'2025-11-21 09:02:08','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(32,'2025-11-21 09:02:09','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(33,'2025-11-21 09:02:11','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(34,'2025-11-21 09:02:11','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(35,'2025-11-21 09:02:12','google.com','unknown',80,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(36,'2025-11-21 09:02:17','https://google.com','google.com',443,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(37,'2025-11-21 09:02:21','https://google.com','google.com',443,'BLOCKED','Manual Test',0,'blocked','[]','External connection blocked by NetworkMonitor',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(38,'2025-12-03 09:29:28','http://localhost:11434/api/chat','localhost',11434,'POST','AI Chat',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/chat\",\"payload_size\":115}','{\"status\":\"success\",\"response_size\":411,\"tokens\":23}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'),
(39,'2025-12-04 09:50:43','http://localhost:11434/api/generate','localhost',11434,'POST','AI Generate',1,'success','{\"model\":\"llama3.1:8b\",\"endpoint\":\"\\/generate\",\"payload_size\":6457}','{\"status\":\"success\",\"response_size\":8113,\"tokens\":20}',1,'::1','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15');
commit;

--
-- Table structure for table `non_conformance_reports`
--

CREATE TABLE `non_conformance_reports` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ncr_number` varchar(50) NOT NULL,
  `inspection_id` int(10) unsigned DEFAULT NULL,
  `work_order_id` int(10) unsigned DEFAULT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `defect_type` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `quantity_affected` int(11) DEFAULT 0,
  `severity` enum('minor','major','critical') DEFAULT 'minor',
  `root_cause` text DEFAULT NULL,
  `corrective_action` text DEFAULT NULL,
  `preventive_action` text DEFAULT NULL,
  `disposition` enum('rework','scrap','use_as_is','return_to_supplier') DEFAULT NULL,
  `status` enum('open','in_review','resolved','closed') DEFAULT 'open',
  `reported_by` int(10) unsigned NOT NULL,
  `reported_at` datetime DEFAULT current_timestamp(),
  `resolved_by` int(10) unsigned DEFAULT NULL,
  `resolved_at` datetime DEFAULT NULL,
  `closed_by` int(10) unsigned DEFAULT NULL,
  `closed_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `ncr_number` (`ncr_number`),
  KEY `idx_status` (`status`),
  KEY `idx_severity` (`severity`),
  KEY `idx_product` (`product_id`),
  KEY `idx_reported_at` (`reported_at`),
  KEY `inspection_id` (`inspection_id`),
  KEY `work_order_id` (`work_order_id`),
  KEY `reported_by` (`reported_by`),
  KEY `resolved_by` (`resolved_by`),
  KEY `closed_by` (`closed_by`),
  KEY `idx_ncr_status_severity` (`status`,`severity`),
  CONSTRAINT `non_conformance_reports_ibfk_1` FOREIGN KEY (`inspection_id`) REFERENCES `quality_inspections` (`id`) ON DELETE SET NULL,
  CONSTRAINT `non_conformance_reports_ibfk_2` FOREIGN KEY (`work_order_id`) REFERENCES `work_orders` (`id`) ON DELETE SET NULL,
  CONSTRAINT `non_conformance_reports_ibfk_3` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `non_conformance_reports_ibfk_4` FOREIGN KEY (`reported_by`) REFERENCES `users` (`id`),
  CONSTRAINT `non_conformance_reports_ibfk_5` FOREIGN KEY (`resolved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `non_conformance_reports_ibfk_6` FOREIGN KEY (`closed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `non_conformance_reports`
--

set autocommit=0;
commit;

--
-- Table structure for table `notification_digest_queue`
--

CREATE TABLE `notification_digest_queue` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `notification_id` int(10) unsigned NOT NULL,
  `digest_type` enum('hourly','daily','weekly') NOT NULL,
  `status` enum('pending','sent','failed') DEFAULT 'pending',
  `sent_at` timestamp NULL DEFAULT NULL,
  `error_message` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_user_digest` (`user_id`,`digest_type`,`status`),
  KEY `idx_status` (`status`,`created_at`),
  KEY `notification_id` (`notification_id`),
  CONSTRAINT `notification_digest_queue_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `notification_digest_queue_ibfk_2` FOREIGN KEY (`notification_id`) REFERENCES `notifications` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Queue for digest email notifications';

--
-- Dumping data for table `notification_digest_queue`
--

set autocommit=0;
commit;

--
-- Table structure for table `notification_preferences`
--

CREATE TABLE `notification_preferences` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `notification_type` varchar(50) NOT NULL,
  `in_app_enabled` tinyint(1) DEFAULT 1 COMMENT 'Show in-app notifications',
  `email_enabled` tinyint(1) DEFAULT 1 COMMENT 'Send email notifications',
  `sms_enabled` tinyint(1) DEFAULT 0 COMMENT 'Send SMS notifications (future)',
  `frequency` enum('immediate','hourly','daily','weekly') DEFAULT 'immediate',
  `digest_time` time DEFAULT NULL COMMENT 'Preferred time for digest emails (e.g., 09:00:00)',
  `digest_day` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') DEFAULT NULL COMMENT 'Day for weekly digest',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_user_type` (`user_id`,`notification_type`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_notification_type` (`notification_type`),
  CONSTRAINT `notification_preferences_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='User notification preferences';

--
-- Dumping data for table `notification_preferences`
--

set autocommit=0;
INSERT INTO `notification_preferences` VALUES
(1,1,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(2,2,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(3,3,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(4,4,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(5,5,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(6,6,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(7,7,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(8,8,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26'),
(9,21,'all',1,1,0,'immediate',NULL,NULL,'2025-11-26 14:13:26','2025-11-26 14:13:26');
commit;

--
-- Temporary table structure for view `notification_stats_by_user`
--

/*!50001 DROP VIEW IF EXISTS `notification_stats_by_user`*/;
/*!50001 CREATE VIEW `notification_stats_by_user` AS SELECT
 1 AS `user_id`,
  1 AS `user_name`,
  1 AS `total_notifications`,
  1 AS `unread_count`,
  1 AS `emails_sent`,
  1 AS `last_notification_at` */;

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `type` varchar(50) NOT NULL COMMENT 'message, mention, system, alert, etc',
  `title` varchar(255) NOT NULL,
  `message` text DEFAULT NULL,
  `link` varchar(500) DEFAULT NULL,
  `icon` varchar(50) DEFAULT 'bi-bell',
  `is_read` tinyint(1) DEFAULT 0,
  `email_sent` tinyint(1) DEFAULT 0 COMMENT 'Whether email notification was sent',
  `email_sent_at` timestamp NULL DEFAULT NULL COMMENT 'When email was sent',
  `mentioned_users` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Array of user IDs mentioned in notification' CHECK (json_valid(`mentioned_users`)),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `read_at` timestamp NULL DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Additional data like channel_id, message_id, etc' CHECK (json_valid(`metadata`)),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_user_read` (`user_id`,`is_read`),
  KEY `idx_created` (`created_at` DESC),
  KEY `idx_email_sent` (`email_sent`,`created_at`),
  CONSTRAINT `notifications_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `notifications`
--

set autocommit=0;
INSERT INTO `notifications` VALUES
(16,4,'file_share','Admin User shared a file with you','You now have Download permission to \"IMG_5218.JPG\"','/files/shared','bi-share',0,0,NULL,NULL,'2025-11-27 18:34:31',NULL,'{\"item_type\":\"file\",\"item_id\":\"8\",\"item_name\":\"IMG_5218.JPG\",\"permission\":\"download\",\"sharer_name\":\"Admin User\"}','2025-11-27 18:34:31'),
(17,4,'file_share','Admin User shared a file with you','You now have Download permission to \"archive_1764262879453.zip\"','/files/shared','bi-share',0,0,NULL,NULL,'2025-11-27 19:20:30',NULL,'{\"item_type\":\"file\",\"item_id\":\"9\",\"item_name\":\"archive_1764262879453.zip\",\"permission\":\"download\",\"sharer_name\":\"Admin User\"}','2025-11-27 19:20:30'),
(18,4,'file_share','Admin User shared a file with you','You now have Download permission to \"archive_1764262879453.zip\"','/files/shared','bi-share',0,0,NULL,NULL,'2025-11-27 19:30:41',NULL,'{\"item_type\":\"file\",\"item_id\":\"9\",\"item_name\":\"archive_1764262879453.zip\",\"permission\":\"download\",\"sharer_name\":\"Admin User\"}','2025-11-27 19:30:41'),
(19,4,'file_share','Admin User shared a file with you','You now have Download permission to \"IMG_5218.JPG\"','/files/shared','bi-share',0,0,NULL,NULL,'2025-11-27 19:32:39',NULL,'{\"item_type\":\"file\",\"item_id\":\"8\",\"item_name\":\"IMG_5218.JPG\",\"permission\":\"download\",\"sharer_name\":\"Admin User\"}','2025-11-27 19:32:39'),
(20,4,'file_share','Admin User shared a file with you','You now have Download permission to \"IMG_5218.JPG\"','/files/shared','bi-share',0,0,NULL,NULL,'2025-11-27 19:58:09',NULL,'{\"item_type\":\"file\",\"item_id\":\"8\",\"item_name\":\"IMG_5218.JPG\",\"permission\":\"download\",\"sharer_name\":\"Admin User\"}','2025-11-27 19:58:09'),
(21,4,'file_share','Admin User shared a file with you','You now have Download permission to \"IMG_5218.JPG\"','/files/shared','bi-share',0,0,NULL,NULL,'2025-11-27 20:22:35',NULL,'{\"item_type\":\"file\",\"item_id\":\"8\",\"item_name\":\"IMG_5218.JPG\",\"permission\":\"download\",\"sharer_name\":\"Admin User\"}','2025-11-27 20:22:35'),
(22,4,'calendar_event','Admin User invited you to a calendar event','<strong>Event:</strong> Test6<br><strong>Start:</strong> Nov 27, 2025 4:00 PM<br><strong>End:</strong> Nov 27, 2025 4:30 PM<br><strong>Location:</strong> Not specified<br>','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:53:37',NULL,NULL,'2025-11-27 20:53:37'),
(23,4,'calendar_event','Admin User invited you to a calendar event','<strong>Event:</strong> Test6<br><strong>Start:</strong> Nov 27, 2025 4:00 PM<br><strong>End:</strong> Nov 27, 2025 4:30 PM<br><strong>Location:</strong> Not specified<br>','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:53:40',NULL,NULL,'2025-11-27 20:53:40'),
(24,4,'calendar_event','Admin User invited you to a calendar event','<strong>Event:</strong> Test6<br><strong>Start:</strong> Nov 27, 2025 4:00 PM<br><strong>End:</strong> Nov 27, 2025 4:30 PM<br><strong>Location:</strong> Not specified<br>','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:53:46',NULL,NULL,'2025-11-27 20:53:46'),
(25,4,'calendar_event','Admin User invited you to a calendar event','<strong>Event:</strong> Test6<br><strong>Start:</strong> Nov 27, 2025 4:00 PM<br><strong>End:</strong> Nov 27, 2025 4:30 PM<br><strong>Location:</strong> Not specified<br>','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:53:49',NULL,NULL,'2025-11-27 20:53:49'),
(26,4,'calendar_event','Admin User invited you to a calendar event','Event: ricks mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:57:37',NULL,NULL,'2025-11-27 20:57:37'),
(27,4,'calendar_event','Admin User invited you to a calendar event','Event: ricks mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:57:40',NULL,NULL,'2025-11-27 20:57:40'),
(28,4,'calendar_event','Admin User invited you to a calendar event','Event: ricks mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:57:42',NULL,NULL,'2025-11-27 20:57:42'),
(29,4,'calendar_event','Admin User invited you to a calendar event','Event: test7','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:58:28',NULL,NULL,'2025-11-27 20:58:28'),
(30,4,'calendar_event','Admin User invited you to a calendar event','Event: test7','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 20:59:40',NULL,NULL,'2025-11-27 20:59:40'),
(31,4,'calendar_event','Admin User invited you to a calendar event','Event: test','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 21:00:33',NULL,NULL,'2025-11-27 21:00:33'),
(32,4,'calendar_event','Admin User invited you to a calendar event','Event: test','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 21:00:56',NULL,NULL,'2025-11-27 21:00:56'),
(33,4,'calendar_event','Admin User invited you to a calendar event','Event: test','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 21:02:07',NULL,NULL,'2025-11-27 21:02:07'),
(34,4,'calendar_event','Admin User invited you to a calendar event','Event: tester','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 21:03:26',NULL,NULL,'2025-11-27 21:03:26'),
(35,4,'calendar_event','Admin User invited you to a calendar event','Event: tester','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-11-27 21:04:37',NULL,NULL,'2025-11-27 21:04:37'),
(36,4,'calendar_event','Admin User invited you to a calendar event','Event: Demo','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 18:07:29',NULL,NULL,'2025-12-04 18:07:29'),
(37,4,'calendar_event','Admin User updated a calendar event','Event: Demo','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 19:32:41',NULL,NULL,'2025-12-04 19:32:41'),
(38,5,'diagram_shared','Diagram Shared With You','Admin User shared a diagram \"Untitled Diagram\" with you','http://localhost:8080/diagrams/editor/6','bi-diagram-3',0,0,NULL,NULL,'2025-12-04 23:07:12',NULL,'{\"diagram_id\":\"6\",\"diagram_title\":\"Untitled Diagram\"}','2025-12-04 23:07:12'),
(39,4,'calendar_event','Admin User invited you to a calendar event','Event: Rick Mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 23:15:38',NULL,NULL,'2025-12-04 23:15:38'),
(40,3,'calendar_event','Admin User invited you to a calendar event','Event: Rick Mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 23:15:38',NULL,NULL,'2025-12-04 23:15:38'),
(41,5,'calendar_event','Admin User invited you to a calendar event','Event: Rick Mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 23:15:38',NULL,NULL,'2025-12-04 23:15:38'),
(42,6,'calendar_event','Admin User invited you to a calendar event','Event: Rick Mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 23:15:38',NULL,NULL,'2025-12-04 23:15:38'),
(43,7,'calendar_event','Admin User invited you to a calendar event','Event: Rick Mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 23:15:39',NULL,NULL,'2025-12-04 23:15:39'),
(44,8,'calendar_event','Admin User invited you to a calendar event','Event: Rick Mtg','http://localhost:8080/calendar','bi-calendar-event',0,0,NULL,NULL,'2025-12-04 23:15:39',NULL,NULL,'2025-12-04 23:15:39');
commit;

--
-- Table structure for table `opportunity_assignments`
--

CREATE TABLE `opportunity_assignments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `opportunity_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `role` varchar(50) DEFAULT 'contributor' COMMENT 'owner, contributor, viewer',
  `assigned_at` timestamp NULL DEFAULT current_timestamp(),
  `assigned_by` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_assignment` (`opportunity_id`,`user_id`),
  KEY `assigned_by` (`assigned_by`),
  KEY `idx_opportunity_assignments_opportunity` (`opportunity_id`),
  KEY `idx_opportunity_assignments_user` (`user_id`),
  CONSTRAINT `opportunity_assignments_ibfk_1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`id`) ON DELETE CASCADE,
  CONSTRAINT `opportunity_assignments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `opportunity_assignments_ibfk_3` FOREIGN KEY (`assigned_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `opportunity_assignments`
--

set autocommit=0;
INSERT INTO `opportunity_assignments` VALUES
(1,24,5,'owner','2025-12-03 19:44:15',1),
(3,24,1,'contributor','2025-12-03 20:40:13',1);
commit;

--
-- Table structure for table `opportunity_competitors`
--

CREATE TABLE `opportunity_competitors` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `opportunity_id` int(10) unsigned NOT NULL,
  `competitor_name` varchar(255) NOT NULL,
  `product_service` varchar(255) DEFAULT NULL COMMENT 'What product/service they are offering',
  `pricing` decimal(15,2) DEFAULT NULL COMMENT 'Their pricing',
  `strengths` text DEFAULT NULL COMMENT 'Competitor strengths',
  `weaknesses` text DEFAULT NULL COMMENT 'Competitor weaknesses',
  `notes` text DEFAULT NULL COMMENT 'Additional notes',
  `created_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_opportunity_id` (`opportunity_id`),
  KEY `idx_created_by` (`created_by`),
  CONSTRAINT `fk_opp_comp_opportunity` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_opp_comp_user` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `opportunity_competitors`
--

set autocommit=0;
commit;

--
-- Table structure for table `opportunity_documents`
--

CREATE TABLE `opportunity_documents` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `opportunity_id` int(10) unsigned NOT NULL,
  `document_name` varchar(255) NOT NULL,
  `original_filename` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `file_size` bigint(20) NOT NULL COMMENT 'Size in bytes',
  `file_type` varchar(100) DEFAULT NULL COMMENT 'MIME type',
  `document_type` enum('proposal','contract','presentation','other') DEFAULT 'other',
  `description` text DEFAULT NULL,
  `uploaded_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_opportunity_id` (`opportunity_id`),
  KEY `idx_uploaded_by` (`uploaded_by`),
  CONSTRAINT `fk_opp_docs_opportunity` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_opp_docs_user` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `opportunity_documents`
--

set autocommit=0;
commit;

--
-- Table structure for table `opportunity_stage_history`
--

CREATE TABLE `opportunity_stage_history` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `opportunity_id` int(10) unsigned NOT NULL,
  `from_stage` enum('lead','qualified','proposal','negotiation','closed_won','closed_lost') DEFAULT NULL,
  `to_stage` enum('lead','qualified','proposal','negotiation','closed_won','closed_lost') NOT NULL,
  `changed_by` int(10) unsigned NOT NULL,
  `changed_at` timestamp NULL DEFAULT current_timestamp(),
  `duration_days` int(11) DEFAULT NULL COMMENT 'Days spent in previous stage',
  `notes` text DEFAULT NULL COMMENT 'Optional notes about the stage change',
  PRIMARY KEY (`id`),
  KEY `idx_opportunity_id` (`opportunity_id`),
  KEY `idx_changed_by` (`changed_by`),
  KEY `idx_changed_at` (`changed_at`),
  CONSTRAINT `fk_stage_hist_opportunity` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_stage_hist_user` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `opportunity_stage_history`
--

set autocommit=0;
INSERT INTO `opportunity_stage_history` VALUES
(1,35,'proposal','negotiation',1,'2025-11-14 19:42:53',1,NULL),
(2,35,'negotiation','proposal',1,'2025-11-14 19:42:59',0,NULL),
(3,25,'proposal','qualified',1,'2025-11-24 13:25:17',10,NULL),
(4,25,'qualified','lead',1,'2025-11-24 13:25:26',0,NULL),
(5,26,'proposal','qualified',1,'2025-11-24 13:25:28',10,NULL),
(6,26,'qualified','lead',1,'2025-11-25 23:09:03',1,NULL),
(7,26,'lead','qualified',1,'2025-11-25 23:09:08',0,NULL),
(8,27,'proposal','qualified',1,'2025-11-26 00:15:41',12,NULL);
commit;

--
-- Table structure for table `opportunity_tasks`
--

CREATE TABLE `opportunity_tasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `opportunity_id` int(10) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `priority` enum('low','medium','high') DEFAULT 'medium',
  `status` enum('pending','completed','cancelled') DEFAULT 'pending',
  `assigned_to` int(10) unsigned DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `completed_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_opportunity_id` (`opportunity_id`),
  KEY `idx_status` (`status`),
  KEY `idx_due_date` (`due_date`),
  KEY `idx_assigned_to` (`assigned_to`),
  CONSTRAINT `opportunity_tasks_ibfk_1` FOREIGN KEY (`opportunity_id`) REFERENCES `crm_opportunities` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;

--
-- Dumping data for table `opportunity_tasks`
--

set autocommit=0;
INSERT INTO `opportunity_tasks` VALUES
(1,23,'Test','',NULL,'medium','completed',1,1,'2025-11-13 16:49:12',1,'2025-11-13 16:48:57','2025-11-13 16:49:12');
commit;

--
-- Table structure for table `page_actions`
--

CREATE TABLE `page_actions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `page_identifier` varchar(100) NOT NULL COMMENT 'e.g., quote_detail, customer_detail, invoice_detail',
  `action_name` varchar(100) DEFAULT NULL COMMENT 'Display name for the action (NULL for dividers)',
  `icon` varchar(50) DEFAULT NULL COMMENT 'Bootstrap icon class, e.g., bi-pen, bi-envelope',
  `action_type` enum('javascript','link','form_submit','modal','divider') NOT NULL DEFAULT 'link',
  `action_target` varchar(255) DEFAULT NULL COMMENT 'JS function name, route, or form ID depending on action_type',
  `action_method` varchar(10) DEFAULT NULL COMMENT 'For form_submit: GET, POST, etc.',
  `permission_required` varchar(100) DEFAULT NULL COMMENT 'Permission needed to see this action',
  `css_class` varchar(100) DEFAULT NULL COMMENT 'Additional CSS classes for styling',
  `display_order` int(11) NOT NULL DEFAULT 0 COMMENT 'Order in which actions appear',
  `group_name` varchar(50) DEFAULT NULL COMMENT 'Group actions together with dividers',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_page_identifier` (`page_identifier`),
  KEY `idx_is_active` (`is_active`),
  KEY `idx_display_order` (`display_order`)
) ENGINE=InnoDB AUTO_INCREMENT=300 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `page_actions`
--

set autocommit=0;
INSERT INTO `page_actions` VALUES
(1,'quote_detail','Send for E-Signature','bi-pen','javascript','sendForSignature',NULL,'sales.edit',NULL,10,'signature',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(2,'quote_detail','Email Quote Link','bi-envelope','javascript','showEmailModal',NULL,NULL,NULL,20,'signature',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(3,'quote_detail','Copy Signature Link','bi-link-45deg','javascript','copySignatureLink',NULL,NULL,NULL,30,'signature',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(4,'quote_detail','Convert to Order','bi-arrow-right-circle','form_submit','convertForm',NULL,'sales.create',NULL,40,'order',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(5,'quote_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,50,NULL,1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(6,'quote_detail','Notes','bi-sticky','javascript','openNotes',NULL,NULL,NULL,60,'standard',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(7,'quote_detail','Print Quote','bi-printer','link','quotes/general/{id}/print',NULL,NULL,NULL,70,'standard',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(8,'quote_detail','Edit Quote','bi-pencil','link','quotes/general/{id}/edit',NULL,'sales.edit',NULL,80,'standard',1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(9,'quote_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,90,NULL,1,'2025-11-16 15:34:57','2025-11-16 15:34:57'),
(10,'quote_detail','Back','bi-arrow-left','link','quotes/general',NULL,NULL,NULL,100,'navigation',1,'2025-11-16 15:34:57','2025-11-16 15:54:16'),
(11,'invoice_detail','Notes','bi-sticky','javascript','openNotes',NULL,NULL,NULL,10,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(12,'invoice_detail','Print Invoice','bi-printer','link','invoices/{id}/print',NULL,NULL,NULL,20,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(13,'invoice_detail','Edit Invoice','bi-pencil','link','invoices/{id}/edit',NULL,'sales.edit',NULL,30,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(14,'invoice_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,40,NULL,1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(15,'invoice_detail','Back','bi-arrow-left','link','invoices',NULL,NULL,NULL,50,'navigation',1,'2025-11-16 15:43:35','2025-11-16 15:54:16'),
(16,'salesorder_detail','Notes','bi-sticky','javascript','openNotes',NULL,NULL,NULL,10,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(17,'salesorder_detail','Print Order','bi-printer','link','sales/orders/{id}/print',NULL,NULL,NULL,20,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(18,'salesorder_detail','Edit Order','bi-pencil','link','sales/orders/{id}/edit',NULL,'sales.edit',NULL,30,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(19,'salesorder_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,40,NULL,1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(20,'salesorder_detail','Back','bi-arrow-left','link','sales/orders',NULL,NULL,NULL,50,'navigation',1,'2025-11-16 15:43:35','2025-11-16 15:54:16'),
(21,'purchaseorder_detail','Print PO','bi-printer','javascript','window.print()',NULL,NULL,NULL,10,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(22,'purchaseorder_detail','Edit Order','bi-pencil','link','purchases/orders/{id}/edit',NULL,'procurement.edit',NULL,20,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(23,'purchaseorder_detail','Delete Order','bi-trash','form_submit','deletePOForm',NULL,'procurement.delete',NULL,30,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(24,'purchaseorder_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,40,NULL,1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(25,'purchaseorder_detail','Back','bi-arrow-left','link','purchases/orders',NULL,NULL,NULL,50,'navigation',1,'2025-11-16 15:43:35','2025-11-16 15:54:16'),
(26,'customer_detail','Edit Customer','bi-pencil','link','customers/{id}/edit',NULL,'crm.edit',NULL,10,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(27,'customer_detail','Delete Customer','bi-trash','javascript','confirmDelete',NULL,'crm.delete',NULL,20,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(28,'customer_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,NULL,1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(29,'customer_detail','Back','bi-arrow-left','link','customers',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 15:43:35','2025-11-16 15:54:16'),
(30,'product_detail','Edit Product','bi-pencil','link','products/{id}/edit',NULL,'inventory.edit',NULL,10,'standard',1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(31,'product_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,20,NULL,1,'2025-11-16 15:43:35','2025-11-16 15:43:35'),
(32,'product_detail','Back','bi-arrow-left','link','products',NULL,NULL,NULL,30,'navigation',1,'2025-11-16 15:43:35','2025-11-16 15:54:16'),
(33,'workorder_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(34,'workorder_detail','Print WO','bi bi-printer','javascript','window.print()',NULL,NULL,'btn-outline-theme',20,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(35,'workorder_detail','Start Work Order','fas fa-play','javascript','changeStatus(\'in_progress\')',NULL,'manufacturing.manage','btn-outline-success',30,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(36,'workorder_detail','Mark Complete','fas fa-check','javascript','changeStatus(\'completed\')',NULL,'manufacturing.manage','btn-outline-success',40,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(37,'workorder_detail','Cancel','fas fa-times','javascript','changeStatus(\'cancelled\')',NULL,'manufacturing.manage','btn-outline-danger',50,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(38,'workorder_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,55,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(39,'workorder_detail','Open in Shop Floor','fas fa-industry','link','manufacturing/shopfloor/workorder/{id}',NULL,'manufacturing.view','btn-outline-info',60,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(40,'workorder_detail','Back','fas fa-arrow-left','link','manufacturing/workorders',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(41,'bom_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(42,'bom_detail','Print BOM','bi bi-printer','javascript','window.print()',NULL,NULL,'btn-outline-theme',20,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(43,'bom_detail','Back','bi bi-arrow-left','link','manufacturing/boms',NULL,NULL,'btn-outline-theme',100,'back',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(44,'movement_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(45,'movement_detail','View Stock Levels','fas fa-boxes','link','inventory/stock-levels?product_id={product_id}',NULL,NULL,'btn-outline-primary',20,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(46,'movement_detail','Product Movement History','fas fa-history','link','inventory/movements?product_id={product_id}',NULL,NULL,'btn-outline-secondary',30,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(47,'movement_detail','Location Movements','fas fa-warehouse','link','inventory/movements?location_id={location_id}',NULL,NULL,'btn-outline-info',40,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(48,'movement_detail','Record New Movement','fas fa-plus','link','inventory/movements/create',NULL,'inventory.manage','btn-outline-success',50,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(49,'movement_detail','Back','fas fa-arrow-left','link','inventory/movements',NULL,NULL,'btn-cancel',100,'back',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(50,'employee_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(51,'employee_detail','Edit','bi bi-pencil','link','employees/{id}/edit',NULL,'hr.edit','btn-outline-warning',20,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(52,'employee_detail','Back','bi bi-arrow-left','link','employees',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(53,'opportunity_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(54,'opportunity_detail','Edit','bi bi-pencil','link','crm/opportunities/{id}/edit',NULL,'crm.edit','btn-outline-theme',20,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(55,'opportunity_detail','Send Email','bi bi-envelope','modal','emailModal',NULL,NULL,'btn-outline-primary',30,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(56,'opportunity_detail','Log Received Email','bi bi-envelope-check','modal','logEmailModal',NULL,NULL,'btn-outline-secondary',40,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(57,'opportunity_detail','Clone','bi bi-files','link','crm/opportunities/{id}/clone',NULL,'crm.create','btn-outline-secondary',50,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(58,'opportunity_detail','Back','bi bi-arrow-left','link','crm/opportunities',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(59,'ticket_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(60,'ticket_detail','Edit','bi bi-pencil','link','crm/support/{id}/edit',NULL,'crm.edit','btn-outline-theme',20,'main',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(61,'ticket_detail','Back','bi bi-arrow-left','link','crm/support',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:04:37','2025-11-16 16:04:37'),
(62,'project_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(63,'project_detail','Edit','bi bi-pencil','link','projects/{id}/edit',NULL,'projects.edit','btn-save',20,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(64,'project_detail','Delete','bi bi-trash','form_submit','deleteForm','POST','projects.delete','btn-outline-danger',30,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(65,'project_detail','Back','bi bi-arrow-left','link','projects',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(66,'helpdesk_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(67,'helpdesk_detail','Edit','bi bi-pencil','link','helpdesk/tickets/{id}/edit',NULL,'helpdesk.edit','btn-outline-warning',20,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(68,'helpdesk_detail','Change Status','bi bi-arrow-repeat','javascript','showStatusModal()',NULL,'helpdesk.manage','btn-outline-info',30,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(69,'helpdesk_detail','Back','bi bi-arrow-left','link','helpdesk/tickets',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(70,'asset_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(71,'asset_detail','Edit','bi bi-pencil','link','accounting/assets/{id}/edit',NULL,'accounting.edit','btn-outline-warning',20,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(72,'asset_detail','Depreciation Schedule','bi bi-calendar3','link','accounting/depreciation/{id}/schedule',NULL,'accounting.view','btn-outline-theme',30,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(73,'asset_detail','Back','bi bi-arrow-left','link','accounting/assets',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(74,'deliverynote_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(75,'deliverynote_detail','Print','bi bi-printer','javascript','window.print()',NULL,NULL,'btn-outline-secondary',20,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(76,'deliverynote_detail','Edit','bi bi-pencil','link','sales/delivery_notes/{id}/edit',NULL,'sales.edit','btn-outline-warning',30,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(77,'deliverynote_detail','Delete','bi bi-trash','form_submit','deleteForm','POST','sales.delete','btn-outline-danger',40,'main',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(78,'deliverynote_detail','Back','bi bi-arrow-left','link','sales/delivery_notes',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:20:48','2025-11-16 16:20:48'),
(79,'creditnote_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(80,'creditnote_detail','Print Credit Note','bi bi-printer','javascript','window.print()',NULL,NULL,'btn-outline-secondary',20,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(81,'creditnote_detail','Edit','bi bi-pencil','link','creditnotes/{id}/edit',NULL,'sales.edit','btn-outline-warning',30,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(82,'creditnote_detail','Back','bi bi-arrow-left','link','creditnotes',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(83,'debitnote_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(84,'debitnote_detail','Edit','bi bi-pencil','link','purchases/debit-notes/{id}/edit',NULL,'purchases.edit','btn-primary',20,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(85,'debitnote_detail','Delete','bi bi-trash','form_submit','deleteForm','POST','purchases.delete','btn-outline-danger',30,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(86,'debitnote_detail','Back','bi bi-arrow-left','link','purchases/debit-notes',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(87,'purchasebill_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(88,'purchasebill_detail','Edit','bi bi-pencil','link','purchases/bills/{id}/edit',NULL,'purchases.edit','btn-primary',20,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(89,'purchasebill_detail','Delete','bi bi-trash','form_submit','deleteForm','POST','purchases.delete','btn-outline-danger',30,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(90,'purchasebill_detail','Back','bi bi-arrow-left','link','purchases/bills',NULL,NULL,'btn-outline-secondary',100,'back',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(91,'goodsreceipt_detail','Notes','bi bi-chat-left-text','modal','notesModal',NULL,NULL,'btn-outline-primary',10,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(92,'goodsreceipt_detail','Print GRN','bi bi-printer','javascript','window.print()',NULL,NULL,'btn-outline-theme',20,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(93,'goodsreceipt_detail','Delete Receipt','bi bi-trash','form_submit','deleteForm','POST','procurement.delete','btn-outline-danger',30,'main',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(94,'goodsreceipt_detail','Back','bi bi-arrow-left','link','purchases/receiving',NULL,NULL,'btn-default',100,'back',1,'2025-11-16 16:34:53','2025-11-16 16:34:53'),
(95,'lots_index','Add Lot/Serial','bi-plus-lg','link','inventory/lots/create',NULL,'inventory.create','btn-theme',10,'primary',1,'2025-11-16 17:56:06','2025-11-16 17:56:06'),
(96,'lots_index',NULL,NULL,'divider',NULL,NULL,NULL,NULL,20,NULL,1,'2025-11-16 17:56:06','2025-11-16 17:56:06'),
(97,'lots_index','Traceability','bi-diagram-3','link','inventory/lots/traceability',NULL,NULL,'btn-outline-theme',30,'utility',1,'2025-11-16 17:56:06','2025-11-16 17:56:06'),
(98,'lots_index','Expiration Dates','bi-calendar-x','link','inventory/lots/expiration',NULL,NULL,'btn-outline-warning',40,'utility',1,'2025-11-16 17:56:06','2025-11-16 17:56:06'),
(99,'lots_index',NULL,NULL,'divider',NULL,NULL,NULL,NULL,50,NULL,1,'2025-11-16 17:56:06','2025-11-16 17:56:06'),
(100,'lots_index','Back','bi-arrow-left','link','inventory',NULL,NULL,NULL,60,'navigation',1,'2025-11-16 17:56:06','2025-11-16 17:56:06'),
(101,'quotes_index','Create General Quote','bi bi-plus-lg','link','quotes/general/create',NULL,'sales.create','btn-create',10,'primary',1,'2025-11-16 18:06:13','2025-11-20 13:34:27'),
(102,'quotes_index','Create Battery Quote','bi-battery-charging','link','quotes/battery/create',NULL,'sales.create','btn-create',20,'primary',1,'2025-11-16 18:06:13','2025-11-16 18:06:13'),
(105,'quotes_index',NULL,NULL,'divider',NULL,NULL,NULL,NULL,50,NULL,0,'2025-11-16 18:06:13','2025-11-26 02:21:47'),
(106,'quotes_index','Back','bi-arrow-left','link','sales/dashboard',NULL,NULL,NULL,60,'navigation',0,'2025-11-16 18:06:13','2025-11-26 02:21:50'),
(107,'quotes_index','Export CSV','bi-download','javascript','exportQuotes',NULL,NULL,NULL,30,'utility',1,'2025-11-16 18:09:07','2025-11-16 18:09:07'),
(108,'expense_detail','Approve','bi-check-lg','form_submit','accounting/expenses/{id}/approve','POST',NULL,'btn-success',10,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(109,'expense_detail','Reject','bi-x-lg','modal','#rejectModal',NULL,NULL,'btn-danger',20,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(110,'expense_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(111,'expense_detail','Back','bi-arrow-left','link','accounting/expenses',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(112,'return_detail','Print','bi-printer','javascript','window.print()',NULL,NULL,NULL,10,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(113,'return_detail','Edit','bi-pencil','link','sales/returns/{id}/edit',NULL,'sales.edit','btn-edit',20,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(114,'return_detail','Approve','bi-check-circle','form_submit','sales/returns/{id}/approve','POST','sales.approve','btn-success',30,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(115,'return_detail','Reject','bi-x-circle','form_submit','sales/returns/{id}/reject','POST','sales.approve','btn-danger',40,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(116,'return_detail','Complete','bi-check-circle-fill','form_submit','sales/returns/{id}/complete','POST','sales.edit','btn-success',50,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(117,'return_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,60,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(118,'return_detail','Back','bi-arrow-left','link','sales/returns',NULL,NULL,NULL,70,'navigation',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(119,'camera_audit_detail','Verify','bi-check-circle','form_submit','camera-audit/verify/{id}','POST','camera_audit.verify','btn-success',10,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(120,'camera_audit_detail','Delete','bi-trash','form_submit','camera-audit/delete/{id}','POST','camera_audit.delete','btn-delete',20,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(121,'camera_audit_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(122,'camera_audit_detail','Back','bi-arrow-left','link','camera-audit',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(123,'pipedrive_import','Run All Phases','fas fa-play','javascript','importAll(false)',NULL,NULL,'btn-success',10,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(124,'pipedrive_import','Dry Run All','fas fa-check-circle','javascript','importAll(true)',NULL,NULL,NULL,20,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(125,'pipedrive_import',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(126,'pipedrive_import','Back','bi-arrow-left','link','pipedrive',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(127,'application_detail','Edit','bi-pencil','link','hr/recruitment/applications/{id}/edit',NULL,'hr.edit',NULL,10,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:37:09'),
(128,'application_detail','Delete','bi-trash','javascript','deleteApplication({id})',NULL,'hr.delete',NULL,20,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:37:09'),
(129,'application_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(130,'application_detail','Back','bi-arrow-left','link','hr/recruitment/applications',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 18:28:39','2025-11-16 18:28:39'),
(131,'interview_detail','Edit','bi-pencil','link','hr/recruitment/interviews/{id}/edit',NULL,NULL,NULL,10,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(132,'interview_detail','Delete','bi-trash','form_submit','hr/recruitment/interviews/{id}/delete',NULL,NULL,NULL,20,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(133,'interview_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(134,'interview_detail','View Application','bi-file-earmark','link','hr/recruitment/applications/{application_id}',NULL,NULL,NULL,40,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(135,'interview_detail','View Position','bi-briefcase','link','hr/recruitment/positions/{position_id}',NULL,NULL,NULL,50,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(136,'interview_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,60,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(137,'interview_detail','Back','bi-arrow-left','link','hr/recruitment/interviews',NULL,NULL,NULL,70,NULL,1,'2025-11-16 18:46:12','2025-11-16 18:46:12'),
(138,'assessment_detail','Edit','bi-pencil','link','hr/recruitment/assessments/{id}/edit',NULL,NULL,NULL,10,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(139,'assessment_detail','Delete','bi-trash','form_submit','hr/recruitment/assessments/{id}/delete',NULL,NULL,NULL,20,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(140,'assessment_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(141,'assessment_detail','View Application','bi-file-earmark','link','hr/recruitment/applications/{application_id}',NULL,NULL,NULL,40,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(142,'assessment_detail','View Position','bi-briefcase','link','hr/recruitment/positions/{position_id}',NULL,NULL,NULL,50,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(143,'assessment_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,60,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(144,'assessment_detail','Back','bi-arrow-left','link','hr/recruitment/assessments',NULL,NULL,NULL,70,NULL,1,'2025-11-16 18:55:26','2025-11-16 18:55:26'),
(145,'offer_detail','Edit','bi-pencil','link','hr/recruitment/offers/{id}/edit',NULL,NULL,NULL,10,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(146,'offer_detail','Print Offer Letter','bi-printer','link','hr/recruitment/offers/{id}/print',NULL,NULL,NULL,15,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(147,'offer_detail','Delete','bi-trash','form_submit','hr/recruitment/offers/{id}/delete',NULL,NULL,NULL,20,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(148,'offer_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(149,'offer_detail','View Application','bi-file-earmark','link','hr/recruitment/applications/{application_id}',NULL,NULL,NULL,40,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(150,'offer_detail','View Position','bi-briefcase','link','hr/recruitment/positions/{position_id}',NULL,NULL,NULL,50,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(151,'offer_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,60,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(152,'offer_detail','Back','bi-arrow-left','link','hr/recruitment/offers',NULL,NULL,NULL,70,NULL,1,'2025-11-16 19:00:39','2025-11-16 19:00:39'),
(153,'document_view','Download','bi-download','link','documents/download/{id}',NULL,NULL,'btn-create',10,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(154,'document_view','Delete','bi-trash','javascript','deleteDocument()',NULL,NULL,'btn-outline-danger',20,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(155,'document_view',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(156,'document_view','Back','bi-arrow-left','link','documents',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(157,'crm_document_detail','Download','bi-download','link','crm/documents/{id}/download',NULL,NULL,'btn-create',10,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(158,'crm_document_detail','Edit','bi-pencil','link','crm/documents/{id}/edit',NULL,NULL,'btn-outline-theme',20,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(159,'crm_document_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(160,'crm_document_detail','Back','bi-arrow-left','link','crm/documents',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(161,'recurring_template_detail','Execute Now','bi-play-fill','javascript','executeTemplate()',NULL,'recurring_templates.execute','btn-success',10,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(162,'recurring_template_detail','Edit','bi-pencil','link','recurring/{id}/edit',NULL,'recurring_templates.edit','btn-primary',20,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(163,'recurring_template_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,30,'actions',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(164,'recurring_template_detail','Back','bi-arrow-left','link','recurring',NULL,NULL,NULL,40,'navigation',1,'2025-11-16 19:09:22','2025-11-16 19:09:22'),
(165,'project_board','List View','bi-list-ul','link','projects/{id}/list',NULL,NULL,NULL,10,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(166,'project_board','Financials','bi-cash-stack','link','projects/{id}/financials',NULL,NULL,NULL,20,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(167,'project_board','Edit','bi-pencil','link','projects/{id}/edit',NULL,NULL,NULL,30,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(168,'project_board','Delete','bi-trash','javascript','deleteProject({id})',NULL,NULL,'btn-outline-danger',40,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(169,'project_board',NULL,NULL,'divider',NULL,NULL,NULL,NULL,50,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(170,'project_board','Back','bi-arrow-left','link','projects',NULL,NULL,NULL,60,'navigation',1,'2025-11-16 20:29:08','2025-11-16 20:31:37'),
(171,'project_list','Board View','bi-kanban','link','projects/{id}',NULL,NULL,NULL,10,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(172,'project_list','Financials','bi-cash-stack','link','projects/{id}/financials',NULL,NULL,NULL,20,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(173,'project_list','Export CSV','bi-file-earmark-spreadsheet','link','projects/{id}/export',NULL,NULL,NULL,30,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(174,'project_list','Edit','bi-pencil','link','projects/{id}/edit',NULL,NULL,NULL,40,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(175,'project_list',NULL,NULL,'divider',NULL,NULL,NULL,NULL,50,'actions',1,'2025-11-16 20:29:08','2025-11-16 20:29:08'),
(176,'project_list','Back','bi-arrow-left','link','projects',NULL,NULL,NULL,60,'navigation',1,'2025-11-16 20:29:08','2025-11-16 20:31:37'),
(177,'nda_detail','Preview','bi-eye','link','ndas/{id}/preview',NULL,'ndas.view',NULL,10,'view',1,'2025-11-16 22:55:50','2025-11-16 22:55:50'),
(178,'nda_detail','Edit','bi-pencil','link','ndas/{id}/edit',NULL,'ndas.edit',NULL,20,'edit',1,'2025-11-16 22:55:50','2025-11-16 22:55:50'),
(179,'nda_detail','Send for Signature','bi-send','modal','sendEmailModal',NULL,'ndas.send',NULL,30,'send',1,'2025-11-16 22:55:50','2025-11-16 22:55:50'),
(180,'nda_detail',NULL,NULL,'divider',NULL,NULL,NULL,NULL,35,NULL,1,'2025-11-16 22:55:50','2025-11-16 22:55:50'),
(181,'nda_detail','Delete','bi-trash','form_submit','deleteForm',NULL,'ndas.delete',NULL,40,'delete',1,'2025-11-16 22:55:50','2025-11-16 22:55:50'),
(182,'nda_detail','Counter-Sign','bi-pen','link','ndas/{id}/countersign',NULL,'ndas.countersign','btn-success',15,NULL,1,'2025-11-16 23:44:17','2025-11-16 23:47:47'),
(183,'nda_detail','Email NDA','bi-envelope','modal','emailNDAModal',NULL,'ndas.view','btn-primary',20,NULL,1,'2025-11-16 23:52:27','2025-11-16 23:52:27'),
(184,'journal_entries_index','Import CSV','bi bi-file-earmark-arrow-up','link','accounting/journal/import',NULL,'accounting.create',NULL,10,'actions',1,'2025-11-17 17:29:12','2025-11-17 17:29:12'),
(185,'journal_entries_index','New Entry','bi bi-plus-lg','link','accounting/journal/create',NULL,'accounting.create',NULL,20,'actions',1,'2025-11-17 17:29:12','2025-11-20 13:34:27'),
(186,'journal_entries_index','Back','bi bi-arrow-left','link','accounting/dashboard',NULL,NULL,NULL,30,'navigation',1,'2025-11-17 17:29:12','2025-11-17 17:29:12'),
(231,'product_forecast_index','Command Center','fas fa-tachometer-alt','link','product-forecast/command-center',NULL,NULL,NULL,10,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(232,'product_forecast_index','Generate','fas fa-calculator','link','product-forecast/generate',NULL,NULL,NULL,20,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(233,'product_forecast_index','Pro Forma','fas fa-chart-line','link','product-forecast/proforma',NULL,NULL,NULL,30,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(234,'product_forecast_index','Back','bi bi-arrow-left','link','assumptions',NULL,NULL,NULL,40,'navigation',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(235,'product_forecast_generate','Command Center','fas fa-tachometer-alt','link','product-forecast/command-center',NULL,NULL,NULL,10,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(236,'product_forecast_generate','Configure','fas fa-cog','link','product-forecast',NULL,NULL,NULL,20,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(237,'product_forecast_generate','Pro Forma','fas fa-chart-line','link','product-forecast/proforma',NULL,NULL,NULL,30,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(238,'product_forecast_generate','Back','bi bi-arrow-left','link','product-forecast',NULL,NULL,NULL,40,'navigation',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(239,'product_forecast_proforma','Configure','fas fa-cog','link','product-forecast',NULL,NULL,NULL,10,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(240,'product_forecast_proforma','Variance','fas fa-chart-bar','link','product-forecast/variance?set_id={set_id}&start_date={start_date}&end_date={end_date}',NULL,NULL,NULL,20,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(241,'product_forecast_proforma','Export Excel','fas fa-file-excel','link','product-forecast/export-excel?set_id={set_id}&start_date={start_date}&end_date={end_date}&period_type={period_type}',NULL,NULL,NULL,30,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(242,'product_forecast_proforma','Sensitivity','fas fa-sliders-h','link','product-forecast/sensitivity?set_id={set_id}',NULL,NULL,NULL,40,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(243,'product_forecast_proforma','Compare','fas fa-exchange-alt','link','product-forecast/compare',NULL,NULL,NULL,50,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(244,'product_forecast_proforma','Back','bi bi-arrow-left','link','assumptions',NULL,NULL,NULL,60,'navigation',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(245,'product_forecast_sensitivity','Command Center','fas fa-tachometer-alt','link','product-forecast/command-center?set_id={set_id}',NULL,NULL,NULL,10,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(246,'product_forecast_sensitivity','Pro Forma','fas fa-chart-line','link','product-forecast/proforma?set_id={set_id}',NULL,NULL,NULL,20,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(247,'product_forecast_sensitivity','Variance','fas fa-chart-bar','link','product-forecast/variance?set_id={set_id}',NULL,NULL,NULL,30,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(248,'product_forecast_sensitivity','Back','bi bi-arrow-left','link','assumptions',NULL,NULL,NULL,40,'navigation',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(249,'product_forecast_variance','Command Center','fas fa-tachometer-alt','link','product-forecast/command-center?set_id={set_id}',NULL,NULL,NULL,10,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(250,'product_forecast_variance','Pro Forma','fas fa-chart-line','link','product-forecast/proforma?set_id={set_id}',NULL,NULL,NULL,20,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(251,'product_forecast_variance','Sensitivity','fas fa-sliders-h','link','product-forecast/sensitivity?set_id={set_id}',NULL,NULL,NULL,30,'actions',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(252,'product_forecast_variance','Back','bi bi-arrow-left','link','assumptions',NULL,NULL,NULL,40,'navigation',1,'2025-11-20 13:26:58','2025-11-20 13:26:58'),
(253,'mrp_index','Run MRP Calculation','bi bi-calculator','form_submit','mrpCalculateForm',NULL,NULL,NULL,1,'actions',1,'2025-11-20 21:08:46','2025-11-20 21:09:42'),
(254,'mrp_index','Safety Stock','bi bi-building','link','manufacturing/mrp/safetyStock',NULL,NULL,NULL,2,'actions',1,'2025-11-20 21:08:46','2025-11-20 21:08:46'),
(255,'mrp_index','Requisitions','bi bi-receipt','link','manufacturing/mrp/requisitions',NULL,NULL,NULL,3,'actions',1,'2025-11-20 21:08:46','2025-11-20 21:08:46'),
(256,'mrp_index','Back','bi bi-arrow-left','link','manufacturing/dashboard',NULL,NULL,NULL,4,'navigation',0,'2025-11-20 21:08:46','2025-11-26 02:11:45'),
(257,'shopfloor_index','Refresh','bi bi-arrow-repeat','javascript','refreshDashboard()',NULL,NULL,NULL,1,'actions',1,'2025-11-20 21:19:25','2025-11-20 21:19:25'),
(258,'shopfloor_index','All Work Orders','bi bi-clipboard-check','link','manufacturing/workorders',NULL,NULL,NULL,2,'actions',1,'2025-11-20 21:19:25','2025-11-20 21:19:25'),
(259,'shopfloor_index','Back','bi bi-arrow-left','link','manufacturing',NULL,NULL,NULL,3,'navigation',0,'2025-11-20 21:19:25','2025-11-26 02:20:11'),
(260,'crm_document_detail','Delete','bi-trash','form_submit','deleteDocumentForm','POST',NULL,'btn-delete',25,'actions',1,'2025-11-21 03:32:23','2025-11-21 03:33:16'),
(261,'crm_document_detail','Preview','bi-file-earmark-text','modal','documentPreviewModal',NULL,NULL,'btn-outline-theme',5,'actions',1,'2025-11-21 03:46:56','2025-11-21 03:46:56'),
(262,'agreements_index','Create Agreement','fas fa-plus','link','/agreements/create',NULL,NULL,NULL,1,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(263,'agreements_index','Export CSV','fas fa-download','link','/agreements/export',NULL,NULL,NULL,2,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(264,'agreements_index','View Trash','fas fa-trash','link','/agreements/trash',NULL,NULL,NULL,3,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(265,'agreements_index','Back','bi bi-arrow-left','link','/dashboard','GET','','btn-outline-theme',10,'navigation',0,'2025-11-25 23:30:52','2025-11-26 02:10:21'),
(266,'agreements_show','Edit','fas fa-edit','link','/agreements/{id}/edit',NULL,NULL,NULL,1,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(267,'agreements_show','Print','fas fa-print','link','/agreements/{id}/print',NULL,NULL,NULL,2,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(268,'agreements_show','Send for Signature','fas fa-paper-plane','modal','#sendSignatureModal',NULL,NULL,NULL,3,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(269,'agreements_show','Convert to Order','fas fa-exchange-alt','form_submit','/agreements/{id}/convert-order',NULL,NULL,NULL,4,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(270,'agreements_show','Delete','fas fa-trash','form_submit','/agreements/{id}/delete',NULL,NULL,NULL,5,'actions',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(271,'agreements_show','Back','bi bi-arrow-left','link','/agreements',NULL,NULL,NULL,10,'navigation',1,'2025-11-25 23:30:52','2025-11-25 23:30:52'),
(272,'diagrams_index','New Diagram','fas fa-plus','link','/diagrams/create',NULL,NULL,NULL,1,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(273,'diagrams_index','Templates','fas fa-clone','link','/diagrams/templates',NULL,NULL,NULL,2,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(274,'diagrams_index','Import','fas fa-file-import','javascript','importDiagram()',NULL,NULL,NULL,3,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(276,'diagrams_editor','Export PNG','fas fa-image','javascript','exportPNG()',NULL,NULL,NULL,2,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(277,'diagrams_editor','Export SVG','fas fa-file-code','javascript','exportSVG()',NULL,NULL,NULL,3,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(278,'diagrams_editor','Share','fas fa-share-alt','javascript','shareDiagram()',NULL,NULL,NULL,4,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(279,'diagrams_editor','Save as Template','fas fa-clone','javascript','saveAsTemplate()',NULL,NULL,NULL,5,'actions',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(280,'diagrams_editor','Back','bi bi-arrow-left me-1','link','/diagrams',NULL,NULL,NULL,10,'navigation',1,'2025-12-02 03:48:20','2025-12-02 03:48:20'),
(299,'product_detail','Delete Product','bi bi-trash','form_submit','products/{id}/delete',NULL,'inventory.delete',NULL,15,'actions',1,'2025-12-04 22:30:06','2025-12-04 22:30:06');
commit;

--
-- Table structure for table `password_reset_requests`
--

CREATE TABLE `password_reset_requests` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned DEFAULT NULL,
  `email` varchar(255) NOT NULL,
  `token_hash` varchar(255) NOT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `requested_at` timestamp NULL DEFAULT current_timestamp(),
  `expires_at` datetime NOT NULL,
  `used_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_email` (`email`),
  KEY `idx_expires` (`expires_at`),
  CONSTRAINT `password_reset_requests_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `password_reset_requests`
--

set autocommit=0;
commit;

--
-- Table structure for table `payment_batches`
--

CREATE TABLE `payment_batches` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `batch_number` varchar(50) NOT NULL,
  `batch_date` date NOT NULL,
  `batch_name` varchar(200) DEFAULT NULL,
  `payment_method` enum('check','ach','wire') NOT NULL,
  `bank_account_id` int(10) unsigned DEFAULT NULL,
  `total_amount` decimal(15,2) DEFAULT 0.00,
  `payment_count` int(11) DEFAULT 0,
  `status` enum('draft','processed','cancelled') DEFAULT 'draft',
  `processed_at` timestamp NULL DEFAULT NULL,
  `processed_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `created_by` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `batch_number` (`batch_number`),
  KEY `bank_account_id` (`bank_account_id`),
  KEY `created_by` (`created_by`),
  KEY `processed_by` (`processed_by`),
  KEY `idx_batch_date` (`batch_date`),
  KEY `idx_status` (`status`),
  CONSTRAINT `payment_batches_ibfk_1` FOREIGN KEY (`bank_account_id`) REFERENCES `bank_accounts` (`id`),
  CONSTRAINT `payment_batches_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `payment_batches_ibfk_3` FOREIGN KEY (`processed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payment_batches`
--

set autocommit=0;
commit;

--
-- Table structure for table `payment_terms`
--

CREATE TABLE `payment_terms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `term_name` varchar(50) NOT NULL COMMENT 'Display name (e.g., Net 30)',
  `term_code` varchar(20) NOT NULL COMMENT 'Short code (e.g., NET30)',
  `net_days` int(11) NOT NULL DEFAULT 30 COMMENT 'Payment due in days',
  `discount_percentage` decimal(5,2) DEFAULT 0.00 COMMENT 'Early payment discount %',
  `discount_days` int(11) DEFAULT 0 COMMENT 'Days to qualify for discount',
  `late_fee_percentage` decimal(5,2) DEFAULT 0.00 COMMENT 'Late payment fee %',
  `late_fee_grace_days` int(11) DEFAULT 0 COMMENT 'Grace period before late fees',
  `is_default` tinyint(1) DEFAULT 0 COMMENT 'Default payment term',
  `is_active` tinyint(1) DEFAULT 1,
  `description` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `term_code` (`term_code`),
  UNIQUE KEY `unique_term_code` (`term_code`),
  KEY `idx_active` (`is_active`),
  KEY `idx_default` (`is_default`),
  KEY `idx_payment_net_days` (`net_days`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Standard payment terms for invoices and bills';

--
-- Dumping data for table `payment_terms`
--

set autocommit=0;
INSERT INTO `payment_terms` VALUES
(1,'Due on Receipt','DUE_ON_RECEIPT',0,0.00,0,0.00,0,0,1,'Payment due immediately upon receipt','2025-11-01 12:32:09','2025-11-01 12:32:09'),
(2,'Net 15','NET15',15,0.00,0,0.00,0,0,1,'Payment due within 15 days','2025-11-01 12:32:09','2025-11-01 12:32:09'),
(3,'Net 30','NET30',30,0.00,0,0.00,0,1,1,'Payment due within 30 days','2025-11-01 12:32:09','2025-11-01 12:32:09'),
(4,'Net 45','NET45',45,0.00,0,0.00,0,0,1,'Payment due within 45 days','2025-11-01 12:32:09','2025-11-01 12:32:09'),
(5,'Net 60','NET60',60,0.00,0,0.00,0,0,1,'Payment due within 60 days','2025-11-01 12:32:09','2025-11-01 12:32:09'),
(6,'Net 90','NET90',90,0.00,0,0.00,0,0,1,'Payment due within 90 days','2025-11-01 12:32:09','2025-11-01 12:32:09'),
(7,'2/10 Net 30','2_10_NET30',30,2.00,10,0.00,0,0,1,'2% discount if paid within 10 days, net 30','2025-11-01 12:32:09','2025-11-01 12:32:09');
commit;

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `payment_number` varchar(50) NOT NULL,
  `invoice_id` int(10) unsigned NOT NULL,
  `customer_id` int(10) unsigned NOT NULL,
  `payment_date` date NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `payment_method` enum('cash','check','credit_card','bank_transfer','other') NOT NULL,
  `reference` varchar(100) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `payment_number` (`payment_number`),
  KEY `invoice_id` (`invoice_id`),
  KEY `customer_id` (`customer_id`),
  KEY `created_by` (`created_by`),
  KEY `idx_payments_deleted_at` (`deleted_at`),
  CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`),
  CONSTRAINT `payments_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`),
  CONSTRAINT `payments_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payments`
--

set autocommit=0;
commit;

--
-- Table structure for table `payroll`
--

CREATE TABLE `payroll` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` int(10) unsigned NOT NULL,
  `pay_period_start` date NOT NULL,
  `pay_period_end` date NOT NULL,
  `pay_date` date NOT NULL,
  `basic_salary` decimal(15,2) NOT NULL,
  `allowances` decimal(15,2) DEFAULT 0.00,
  `deductions` decimal(15,2) DEFAULT 0.00,
  `net_pay` decimal(15,2) NOT NULL,
  `status` enum('draft','processed','paid') DEFAULT 'draft',
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `employee_id` (`employee_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `payroll_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payroll_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payroll`
--

set autocommit=0;
commit;

--
-- Table structure for table `performance_reviews`
--

CREATE TABLE `performance_reviews` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` int(10) unsigned NOT NULL,
  `review_period_start` date NOT NULL,
  `review_period_end` date NOT NULL,
  `review_date` date DEFAULT NULL,
  `reviewer_id` int(10) unsigned DEFAULT NULL,
  `review_type` enum('probation','quarterly','annual','project','other') DEFAULT 'annual',
  `overall_rating` decimal(3,2) DEFAULT NULL COMMENT 'Rating out of 5.00',
  `performance_rating` decimal(3,2) DEFAULT NULL,
  `attendance_rating` decimal(3,2) DEFAULT NULL,
  `teamwork_rating` decimal(3,2) DEFAULT NULL,
  `communication_rating` decimal(3,2) DEFAULT NULL,
  `strengths` text DEFAULT NULL,
  `areas_for_improvement` text DEFAULT NULL,
  `goals` text DEFAULT NULL,
  `achievements` text DEFAULT NULL,
  `comments` text DEFAULT NULL,
  `employee_comments` text DEFAULT NULL,
  `status` enum('scheduled','in-progress','completed','acknowledged') DEFAULT 'scheduled',
  `acknowledged_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_employee` (`employee_id`),
  KEY `idx_review_date` (`review_date`),
  KEY `idx_status` (`status`),
  CONSTRAINT `performance_reviews_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `performance_reviews`
--

set autocommit=0;
commit;

--
-- Table structure for table `permission_groups`
--

CREATE TABLE `permission_groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL COMMENT 'Display name of the group',
  `parent_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent group for hierarchy',
  `display_order` int(11) DEFAULT 0 COMMENT 'Order within parent group',
  `icon` varchar(50) DEFAULT NULL COMMENT 'Icon class (e.g., bi-grid-3x3-gap)',
  `color` varchar(20) DEFAULT NULL COMMENT 'Color for visual distinction (e.g., success, danger, primary)',
  `description` text DEFAULT NULL COMMENT 'Description of this permission group',
  `is_system` tinyint(1) DEFAULT 0 COMMENT 'System groups cannot be deleted',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_parent` (`parent_id`),
  KEY `idx_order` (`parent_id`,`display_order`),
  CONSTRAINT `permission_groups_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `permission_groups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Hierarchical grouping of permissions for better organization';

--
-- Dumping data for table `permission_groups`
--

set autocommit=0;
INSERT INTO `permission_groups` VALUES
(1,'App Grid (Quick Access)',NULL,0,'bi-grid-3x3-gap-fill','success','Essential quick-access items for all users',1,'2025-11-24 18:37:49','2025-11-28 23:18:59'),
(2,'Departments',NULL,1,'bi-building','primary','Core business department modules',1,'2025-11-24 18:37:49','2025-11-28 23:18:48'),
(3,'Tools',NULL,3,'bi-tools','info','Productivity and utility tools',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(4,'Administration',NULL,4,'bi-shield-lock-fill','danger','System administration and settings',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(5,'Accounting',2,1,'bi-calculator',NULL,'Financial accounting, invoicing, and reporting',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(6,'CRM',2,2,'bi-people',NULL,'Customer relationship management and sales',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(7,'HR',2,3,'bi-person-badge',NULL,'Human resources and employee management',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(8,'Inventory',2,4,'bi-box-seam',NULL,'Inventory and stock management',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(9,'Manufacturing',2,5,'bi-gear-wide-connected',NULL,'Manufacturing and production',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(10,'Purchases',2,6,'bi-cart',NULL,'Procurement and supplier management',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(11,'Sales',2,7,'bi-graph-up',NULL,'Sales orders and fulfillment',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(12,'Documents',3,1,'bi-file-earmark-text',NULL,'Document management and storage',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(13,'Help Desk',3,2,'bi-headset',NULL,'Support ticketing system',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(14,'Projects',3,3,'bi-kanban',NULL,'Project management',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(15,'Reports',3,4,'bi-bar-chart',NULL,'Reporting and analytics',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(16,'Settings & System',4,1,'bi-gear',NULL,'System configuration and settings',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(17,'Security',4,2,'bi-shield-check',NULL,'User, role, and permission management',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(18,'Announcements',4,3,'bi-megaphone',NULL,'System announcements',1,'2025-11-24 18:37:49','2025-11-24 18:37:49'),
(19,'Forecasting',NULL,2,'','','Financial forecasting and planning',0,'2025-11-28 22:58:33','2025-11-28 23:18:38');
commit;

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `module` varchar(50) NOT NULL,
  `group_id` int(10) unsigned DEFAULT NULL COMMENT 'Permission group this belongs to',
  `description` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `idx_group` (`group_id`),
  CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `permission_groups` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=1489 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `permissions`
--

set autocommit=0;

commit;

--
-- Temporary table structure for view `popular_searches_30d`
--

/*!50001 DROP VIEW IF EXISTS `popular_searches_30d`*/;
/*!50001 CREATE VIEW `popular_searches_30d` AS SELECT
 1 AS `query`,
  1 AS `category`,
  1 AS `search_count`,
  1 AS `avg_results`,
  1 AS `avg_execution_time_ms`,
  1 AS `last_searched_at` */;

--
-- Table structure for table `positions`
--

CREATE TABLE `positions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `department` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `level` varchar(50) DEFAULT NULL COMMENT 'Entry, Junior, Mid, Senior, Lead, Manager, Director, Executive',
  `reports_to_position_id` int(11) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `role_id` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_title` (`title`),
  KEY `idx_department` (`department`),
  KEY `idx_is_active` (`is_active`),
  KEY `reports_to_position_id` (`reports_to_position_id`),
  CONSTRAINT `positions_ibfk_1` FOREIGN KEY (`reports_to_position_id`) REFERENCES `positions` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `positions`
--

set autocommit=0;
INSERT INTO `positions` VALUES
(1,'Chief Executive Officer','Executive','CEO - Top executive position','Executive',NULL,1,108,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(2,'Chief Financial Officer','Finance','CFO - Financial oversight','Executive',1,1,110,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(3,'Chief Operating Officer','Operations','COO - Operations oversight','Executive',1,1,112,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(4,'Chief Technology Officer','IT','CTO - Technology oversight','Executive',1,1,111,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(5,'VP of Sales','Sales','Sales leadership','Executive',1,1,76,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(6,'VP of Human Resources','HR','HR leadership','Executive',1,1,116,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(7,'VP of Manufacturing','Manufacturing','Manufacturing leadership','Executive',3,1,88,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(8,'VP of Finance','Finance','Finance leadership','Executive',2,1,110,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(9,'Director of Accounting','Finance','Accounting operations director','Director',8,1,121,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(10,'Director of Financial Planning','Finance','FP&A director','Director',8,1,87,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(11,'Director of Sales Operations','Sales','Sales operations director','Director',5,1,76,'2025-11-08 17:16:14','2025-11-15 12:14:48'),
(12,'Director of Customer Success','Sales','Customer success director','Director',5,1,80,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(13,'Director of Manufacturing','Manufacturing','Manufacturing operations director','Director',7,1,81,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(14,'Director of Supply Chain','Operations','Supply chain director','Director',3,1,87,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(15,'Director of Quality Assurance','Manufacturing','Quality director','Director',7,1,87,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(16,'Director of HR Operations','HR','HR operations director','Director',6,1,116,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(17,'Director of Talent Acquisition','HR','Recruitment director','Director',6,1,97,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(18,'Director of IT','IT','IT infrastructure director','Director',4,1,101,'2025-11-08 17:16:14','2025-11-15 12:03:34'),
(19,'Accounting Manager','Finance','Manages accounting team','Manager',9,1,121,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(28,'Quality Control Manager','Manufacturing','QC team manager','Manager',15,1,92,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(31,'Inventory Control Manager','Operations','Inventory management','Manager',14,1,87,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(33,'Recruiting Manager','HR','Recruitment team manager','Manager',17,1,97,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(36,'Accounting Supervisor','Finance','Supervises accounting staff','Lead',19,1,121,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(37,'AP Supervisor','Finance','Supervises AP staff','Lead',NULL,1,70,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(38,'AR Supervisor','Finance','Supervises AR staff','Lead',NULL,1,72,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(39,'Sales Team Lead - East','Sales','East team lead','Lead',NULL,1,78,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(40,'Sales Team Lead - West','Sales','West team lead','Lead',NULL,1,78,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(41,'Sales Team Lead - Central','Sales','Central team lead','Lead',NULL,1,78,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(42,'Customer Service Lead','Sales','CS team lead','Lead',NULL,1,79,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(44,'Quality Inspector Lead','Manufacturing','QC lead','Lead',28,1,93,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(46,'Shipping Supervisor','Operations','Shipping supervisor','Lead',NULL,1,82,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(47,'Receiving Supervisor','Operations','Receiving supervisor','Lead',NULL,1,82,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(48,'Purchasing Agent Lead','Operations','Lead buyer','Lead',NULL,1,85,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(49,'HR Coordinator Lead','HR','HR team lead','Lead',NULL,1,96,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(50,'Recruiter Lead','HR','Recruitment team lead','Lead',33,1,97,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(51,'IT Support Lead','IT','IT support lead','Lead',NULL,1,101,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(55,'AP Clerk','Finance','Accounts payable clerk','Mid',37,1,70,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(56,'AR Clerk','Finance','Accounts receivable clerk','Mid',38,1,72,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(57,'Payroll Specialist','Finance','Payroll processing','Mid',NULL,1,99,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(58,'Senior Sales Representative','Sales','Senior sales position','Senior',NULL,1,77,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(71,'HR Assistant','HR','HR support','Entry',50,1,96,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(74,'Systems Administrator','IT','System administration','Senior',NULL,1,100,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(75,'Database Administrator','IT','Database management','Senior',NULL,1,100,'2025-11-08 17:16:14','2025-11-15 12:03:48'),
(77,'Senior Software Engineer','Engineering',NULL,'Senior',NULL,1,126,'2025-11-10 17:33:43','2025-11-15 12:03:48'),
(80,'Senior Product Manager','Product',NULL,'Senior',NULL,1,127,'2025-11-10 17:33:43','2025-11-15 12:03:48'),
(91,'Customer Support Specialist','Support',NULL,'Mid',NULL,1,80,'2025-11-10 17:33:43','2025-11-15 12:03:48'),
(92,'Customer Support Manager','Support',NULL,'Manager',NULL,1,79,'2025-11-10 17:33:43','2025-11-15 12:03:48'),
(110,'President','Battery & Energy Technologies','','Director',4,1,130,'2025-11-15 00:03:04','2025-11-15 12:17:39'),
(111,'Director of Operations','Operations','','Director',1,1,81,'2025-11-15 00:23:53','2025-11-15 12:03:34'),
(112,'Administrator','Admin',NULL,'Executive',NULL,1,1,'2025-11-15 11:49:26','2025-11-15 11:49:26'),
(114,'VP of Production','Manufacturing','','Executive',1,1,131,'2025-11-15 12:35:43','2025-11-15 12:36:55'),
(115,'VP of Business Development','Business Development',NULL,'Executive',NULL,1,132,'2025-11-15 12:35:43','2025-11-15 12:35:43'),
(116,'VP of Autonomous Systems','Autonomous Systems',NULL,'Executive',NULL,1,133,'2025-11-15 12:35:43','2025-11-15 12:35:43'),
(117,'President, Batteries & Tech',NULL,NULL,'Executive',NULL,1,NULL,'2025-11-15 18:23:48','2025-11-15 18:23:48');
commit;

--
-- Table structure for table `ppe_parameters`
--

CREATE TABLE `ppe_parameters` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `location_id` int(11) NOT NULL,
  `asset_type` enum('tangible','intangible') NOT NULL DEFAULT 'tangible',
  `asset_category` varchar(100) NOT NULL,
  `useful_life_years` decimal(10,1) NOT NULL DEFAULT 10.0,
  `maintenance_capex_pct` decimal(5,2) NOT NULL DEFAULT 0.00,
  `replacement_period_years` decimal(10,1) NOT NULL DEFAULT 10.0,
  `capitalization_threshold_pct` decimal(5,2) NOT NULL DEFAULT 15.00,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_by` int(11) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_location_category` (`location_id`,`asset_category`),
  KEY `idx_location` (`location_id`),
  KEY `idx_active` (`is_active`),
  KEY `idx_asset_type` (`asset_type`)
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `ppe_parameters`
--

set autocommit=0;
INSERT INTO `ppe_parameters` VALUES
(1,3,'tangible','Land / Property',20.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(2,2,'tangible','Land / Property',20.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(3,3,'tangible','Plant / Building',15.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(4,2,'tangible','Plant / Building',15.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(5,3,'tangible','Manufacturing Equipment',15.0,2.00,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(6,2,'tangible','Manufacturing Equipment',15.0,2.00,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(7,3,'tangible','Tooling Machinery',15.0,2.00,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(8,2,'tangible','Tooling Machinery',15.0,2.00,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(9,3,'tangible','Office Furniture',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(10,2,'tangible','Office Furniture',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(11,3,'tangible','Office Fixtures',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(12,2,'tangible','Office Fixtures',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(13,3,'tangible','Vehicles',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(14,2,'tangible','Vehicles',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(15,3,'tangible','IT Equipment',5.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(16,2,'tangible','IT Equipment',5.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(17,3,'tangible','Construction Fees & Expenses',5.0,0.00,0.0,0.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(18,2,'tangible','Construction Fees & Expenses',5.0,0.00,0.0,0.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(19,3,'tangible','Battery Module Assembly Equipment',10.0,5.00,7.0,0.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(20,2,'tangible','Battery Module Assembly Equipment',10.0,5.00,7.0,0.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(21,3,'tangible','Battery Module T&A Equipment',12.0,2.00,10.0,0.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(22,2,'tangible','Battery Module T&A Equipment',12.0,2.00,10.0,0.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(23,3,'tangible','Physical Security',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(24,2,'tangible','Physical Security',10.0,6.20,10.0,15.00,1,'2025-11-01 12:53:08','2025-11-01 12:53:08',NULL,NULL),
(25,3,'intangible','Software Licenses',3.0,0.00,3.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(26,2,'intangible','Software Licenses',3.0,0.00,3.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(27,3,'intangible','Patents',17.0,0.00,20.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(28,2,'intangible','Patents',17.0,0.00,20.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(29,3,'intangible','Trademarks',10.0,0.00,10.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(30,2,'intangible','Trademarks',10.0,0.00,10.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(31,3,'intangible','Customer Relationships',15.0,0.00,0.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(32,2,'intangible','Customer Relationships',15.0,0.00,0.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(33,3,'intangible','Non-Compete Agreements',5.0,0.00,0.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(34,2,'intangible','Non-Compete Agreements',5.0,0.00,0.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(35,3,'intangible','Technology / IP Rights',10.0,0.00,15.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(36,2,'intangible','Technology / IP Rights',10.0,0.00,15.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(37,3,'intangible','Website & Domain Names',5.0,0.00,5.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(38,2,'intangible','Website & Domain Names',5.0,0.00,5.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(39,3,'intangible','Proprietary Processes',10.0,0.00,0.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL),
(40,2,'intangible','Proprietary Processes',10.0,0.00,0.0,0.00,1,'2025-11-01 12:57:23','2025-11-01 14:30:09',NULL,NULL);
commit;

--
-- Table structure for table `pricing_rules`
--

CREATE TABLE `pricing_rules` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `rule_name` varchar(100) NOT NULL,
  `rule_type` enum('customer_specific','volume_discount','product_bundle','tiered_pricing') NOT NULL,
  `customer_id` int(10) unsigned DEFAULT NULL,
  `product_id` int(10) unsigned DEFAULT NULL,
  `min_quantity` decimal(10,2) DEFAULT 0.00,
  `max_quantity` decimal(10,2) DEFAULT NULL,
  `discount_type` enum('percentage','fixed_amount','fixed_price') NOT NULL,
  `discount_value` decimal(10,2) NOT NULL,
  `priority` int(11) DEFAULT 0,
  `valid_from` date DEFAULT NULL,
  `valid_to` date DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  KEY `idx_customer` (`customer_id`),
  KEY `idx_product` (`product_id`),
  KEY `idx_active` (`is_active`),
  KEY `idx_dates` (`valid_from`,`valid_to`),
  CONSTRAINT `pricing_rules_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pricing_rules_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pricing_rules_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pricing_rules`
--

set autocommit=0;
INSERT INTO `pricing_rules` VALUES
(1,'test','customer_specific',NULL,NULL,NULL,NULL,'percentage',5.00,0,NULL,NULL,1,NULL,1,'2025-10-31 01:12:38','2025-10-31 01:12:38'),
(2,'','customer_specific',NULL,NULL,NULL,NULL,'',0.00,0,NULL,NULL,1,NULL,1,'2025-10-31 01:17:39','2025-10-31 01:19:42');
commit;

--
-- Table structure for table `product_categories`
--

CREATE TABLE `product_categories` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `parent_id` int(10) unsigned DEFAULT NULL,
  `description` text DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `parent_id` (`parent_id`),
  KEY `idx_product_categories_deleted_at` (`deleted_at`),
  CONSTRAINT `product_categories_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `product_categories` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_categories`
--

set autocommit=0;
INSERT INTO `product_categories` VALUES
(1,'Electronics',NULL,'Electronic devices and components',1,'2025-10-26 14:24:24','2025-12-05 11:23:06',NULL),
(2,'Office Supplies',NULL,'Office equipment and supplies',1,'2025-10-26 14:24:24','2025-10-29 19:06:46',NULL),
(4,'Finished Goods',NULL,'Completed products ready for sale',1,'2025-10-26 14:24:24','2025-10-29 19:06:46',NULL),
(7,'Work in Progress',NULL,'Items currently in production',1,'2025-10-29 19:03:12','2025-10-29 19:06:46',NULL),
(8,'Components',NULL,'Parts and components used in assembly',1,'2025-10-29 19:03:12','2025-10-29 19:06:46',NULL),
(9,'Packaging Materials',NULL,'Materials used for packaging',1,'2025-10-29 19:03:12','2025-10-29 19:06:46',NULL),
(10,'Battery Modules',NULL,'',1,'2025-10-29 19:07:08','2025-10-29 19:07:08',NULL),
(12,'Hardware',NULL,'Mechanical and hardware components',1,'2025-11-04 19:45:22','2025-11-04 19:45:22',NULL),
(13,'Software',NULL,'Software products and licenses',1,'2025-11-04 19:45:22','2025-11-04 19:45:22',NULL),
(14,'Services',NULL,'Professional services',1,'2025-11-04 19:45:22','2025-11-04 19:45:22',NULL),
(15,'Raw Materials',NULL,'Basic manufacturing materials',1,'2025-11-04 19:45:22','2025-11-04 19:45:22',NULL),
(17,'Hardware',NULL,'Mechanical and hardware components',1,'2025-11-04 19:46:54','2025-11-04 19:46:54',NULL);
commit;

--
-- Table structure for table `product_forecast_config`
--

CREATE TABLE `product_forecast_config` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` int(10) unsigned NOT NULL,
  `assumption_set_id` int(11) NOT NULL COMMENT 'Which assumption set drives this product',
  `revenue_growth_rate` decimal(5,2) DEFAULT NULL COMMENT 'Override global growth rate for this product',
  `gross_margin_pct` decimal(5,2) DEFAULT NULL COMMENT 'Target gross margin %',
  `price_increase_pct` decimal(5,2) DEFAULT NULL COMMENT 'Annual price increase %',
  `volume_growth_pct` decimal(5,2) DEFAULT NULL COMMENT 'Unit volume growth %',
  `launch_date` date DEFAULT NULL COMMENT 'When product launches (for new products)',
  `discontinue_date` date DEFAULT NULL COMMENT 'When product is discontinued',
  `lifecycle_stage` enum('development','launch','growth','maturity','decline') DEFAULT 'maturity',
  `production_hours_per_unit` decimal(8,4) DEFAULT NULL COMMENT 'How long to make one unit',
  `production_rate_per_hour` decimal(10,2) DEFAULT NULL COMMENT 'Units per hour production rate',
  `equipment_labor_cost_per_unit` decimal(10,4) DEFAULT NULL COMMENT 'Labor cost per unit based on equipment',
  `equipment_energy_cost_per_unit` decimal(10,4) DEFAULT NULL COMMENT 'Energy cost per unit',
  `equipment_operating_cost_per_unit` decimal(10,4) DEFAULT NULL COMMENT 'Total equipment operating cost per unit',
  `capacity_constraint_flag` tinyint(1) DEFAULT 0 COMMENT 'Flag if capacity is a constraint for growth',
  `machines_required` decimal(6,2) DEFAULT 1.00 COMMENT 'Number of machines needed for forecast volume',
  `capital_investment_required` decimal(15,2) DEFAULT 0.00 COMMENT 'Capital needed for additional equipment',
  `primary_equipment_line_id` int(10) unsigned DEFAULT NULL COMMENT 'Which equipment line produces this',
  `primary_equipment_id` int(10) unsigned DEFAULT NULL COMMENT 'Primary equipment for this product',
  `location_id` int(10) unsigned DEFAULT NULL COMMENT 'Primary production location',
  `jan_factor` decimal(4,2) DEFAULT 1.00,
  `feb_factor` decimal(4,2) DEFAULT 1.00,
  `mar_factor` decimal(4,2) DEFAULT 1.00,
  `apr_factor` decimal(4,2) DEFAULT 1.00,
  `may_factor` decimal(4,2) DEFAULT 1.00,
  `jun_factor` decimal(4,2) DEFAULT 1.00,
  `jul_factor` decimal(4,2) DEFAULT 1.00,
  `aug_factor` decimal(4,2) DEFAULT 1.00,
  `sep_factor` decimal(4,2) DEFAULT 1.00,
  `oct_factor` decimal(4,2) DEFAULT 1.00,
  `nov_factor` decimal(4,2) DEFAULT 1.00,
  `dec_factor` decimal(4,2) DEFAULT 1.00,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_product_set` (`product_id`,`assumption_set_id`),
  KEY `idx_product` (`product_id`),
  KEY `idx_assumption_set` (`assumption_set_id`),
  KEY `idx_equipment` (`primary_equipment_line_id`),
  KEY `idx_location` (`location_id`),
  KEY `idx_lifecycle` (`lifecycle_stage`),
  KEY `idx_config_equipment` (`primary_equipment_id`),
  CONSTRAINT `fk_product_forecast_equipment` FOREIGN KEY (`primary_equipment_id`) REFERENCES `equipment` (`id`) ON DELETE SET NULL,
  CONSTRAINT `product_forecast_config_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_forecast_config_ibfk_2` FOREIGN KEY (`assumption_set_id`) REFERENCES `forecast_assumption_sets` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_forecast_config_ibfk_3` FOREIGN KEY (`primary_equipment_line_id`) REFERENCES `equipment_lines` (`id`) ON DELETE SET NULL,
  CONSTRAINT `product_forecast_config_ibfk_4` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_forecast_config`
--

set autocommit=0;
commit;

--
-- Table structure for table `product_line_projections`
--

CREATE TABLE `product_line_projections` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `assumption_set_id` int(11) NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `location_id` int(10) unsigned DEFAULT NULL,
  `projection_date` date NOT NULL COMMENT 'First day of period',
  `period_type` enum('monthly','quarterly','annual') DEFAULT 'monthly',
  `projected_units` decimal(15,2) NOT NULL DEFAULT 0.00,
  `avg_unit_price` decimal(15,2) NOT NULL DEFAULT 0.00,
  `revenue` decimal(15,2) NOT NULL DEFAULT 0.00,
  `unit_cost` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_cogs` decimal(15,2) NOT NULL DEFAULT 0.00,
  `gross_profit` decimal(15,2) NOT NULL DEFAULT 0.00,
  `gross_margin_pct` decimal(5,2) NOT NULL DEFAULT 0.00,
  `required_production_hours` decimal(12,2) DEFAULT NULL,
  `available_capacity_hours` decimal(12,2) DEFAULT NULL,
  `capacity_utilization_pct` decimal(5,2) DEFAULT NULL,
  `capacity_constrained` tinyint(1) DEFAULT 0 COMMENT 'Could not meet demand due to capacity',
  `allocated_fixed_costs` decimal(15,2) DEFAULT 0.00 COMMENT 'Share of location fixed costs',
  `allocated_overhead` decimal(15,2) DEFAULT 0.00 COMMENT 'Manufacturing overhead allocation',
  `generated_at` timestamp NULL DEFAULT current_timestamp(),
  `calculation_notes` text DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_set_product_date` (`assumption_set_id`,`product_id`,`projection_date`,`period_type`),
  KEY `idx_set` (`assumption_set_id`),
  KEY `idx_product` (`product_id`),
  KEY `idx_location` (`location_id`),
  KEY `idx_date` (`projection_date`),
  KEY `idx_period_type` (`period_type`),
  CONSTRAINT `product_line_projections_ibfk_1` FOREIGN KEY (`assumption_set_id`) REFERENCES `forecast_assumption_sets` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_line_projections_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_line_projections_ibfk_3` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_line_projections`
--

set autocommit=0;
commit;

--
-- Table structure for table `product_tax_categories`
--

CREATE TABLE `product_tax_categories` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `category_code` varchar(50) NOT NULL,
  `category_name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `is_taxable` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `category_code` (`category_code`),
  KEY `idx_code` (`category_code`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_tax_categories`
--

set autocommit=0;
INSERT INTO `product_tax_categories` VALUES
(1,'STANDARD','Standard Taxable Goods','Normal taxable products and services',1,'2025-11-15 18:08:20','2025-11-15 18:08:20'),
(2,'EXEMPT','Tax Exempt','Non-taxable items (e.g., prescription drugs, groceries in some states)',0,'2025-11-15 18:08:20','2025-11-15 18:08:20'),
(3,'REDUCED','Reduced Rate','Items with reduced tax rate (e.g., food, clothing in some states)',1,'2025-11-15 18:08:20','2025-11-15 18:08:20'),
(4,'DIGITAL','Digital Goods','Software, downloads, streaming services',1,'2025-11-15 18:08:20','2025-11-15 18:08:20'),
(5,'SERVICES','Services','Professional and personal services',1,'2025-11-15 18:08:20','2025-11-15 18:08:20'),
(6,'SHIPPING','Shipping & Handling','Freight and delivery charges',1,'2025-11-15 18:08:20','2025-11-15 18:08:20');
commit;

--
-- Table structure for table `product_tax_rules`
--

CREATE TABLE `product_tax_rules` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tax_category_id` int(10) unsigned NOT NULL,
  `jurisdiction_id` int(10) unsigned NOT NULL,
  `is_taxable` tinyint(1) DEFAULT 1,
  `override_rate` decimal(8,5) DEFAULT NULL COMMENT 'Custom rate for this category in this jurisdiction',
  `effective_date` date NOT NULL,
  `expiration_date` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_rule` (`tax_category_id`,`jurisdiction_id`,`effective_date`),
  KEY `idx_category` (`tax_category_id`),
  KEY `idx_jurisdiction` (`jurisdiction_id`),
  CONSTRAINT `product_tax_rules_ibfk_1` FOREIGN KEY (`tax_category_id`) REFERENCES `product_tax_categories` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_tax_rules_ibfk_2` FOREIGN KEY (`jurisdiction_id`) REFERENCES `tax_jurisdictions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_tax_rules`
--

set autocommit=0;
commit;

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `category_id` int(10) unsigned DEFAULT NULL,
  `sku` varchar(100) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `product_type` enum('goods','service','digital','raw_material','finished_goods') DEFAULT 'goods',
  `unit_of_measure` varchar(50) DEFAULT NULL,
  `cost_price` decimal(15,2) DEFAULT 0.00,
  `selling_price` decimal(15,2) DEFAULT 0.00,
  `tax_rate` decimal(5,2) DEFAULT 0.00,
  `reorder_level` int(11) DEFAULT 0,
  `safety_stock` decimal(15,3) DEFAULT 0.000,
  `reorder_point` decimal(15,3) DEFAULT 0.000,
  `lead_time_days` int(11) DEFAULT 7,
  `min_order_quantity` decimal(15,3) DEFAULT 1.000,
  `preferred_supplier_id` int(10) unsigned DEFAULT NULL,
  `requires_inspection` tinyint(1) DEFAULT 0,
  `inspection_template_id` int(10) unsigned DEFAULT NULL,
  `reorder_quantity` int(11) DEFAULT 0,
  `image` varchar(255) DEFAULT NULL,
  `barcode` varchar(100) DEFAULT NULL,
  `status` enum('active','inactive','discontinued') DEFAULT 'active',
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `deleted_at` timestamp NULL DEFAULT NULL,
  `tax_category_id` int(10) unsigned DEFAULT NULL COMMENT 'Tax category for this product',
  PRIMARY KEY (`id`),
  UNIQUE KEY `sku` (`sku`),
  KEY `category_id` (`category_id`),
  KEY `products_ibfk_created_by` (`created_by`),
  KEY `fk_products_preferred_supplier` (`preferred_supplier_id`),
  KEY `fk_products_inspection_template` (`inspection_template_id`),
  KEY `idx_tax_category` (`tax_category_id`),
  KEY `idx_deleted_at` (`deleted_at`),
  KEY `idx_search_active` (`status`,`name`),
  FULLTEXT KEY `ft_product_search` (`name`,`description`,`sku`,`barcode`),
  CONSTRAINT `fk_products_inspection_template` FOREIGN KEY (`inspection_template_id`) REFERENCES `inspection_templates` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_products_preferred_supplier` FOREIGN KEY (`preferred_supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `product_categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `products_ibfk_created_by` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--

set autocommit=0;
INSERT INTO `products` VALUES
(70,10,'BATT-PACK-001','16 KwH Battery','','finished_goods','',0.00,0.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,'','active',NULL,'2025-12-04 20:30:05','2025-12-05 10:47:48',NULL,NULL),
(71,10,'BATT-LIFEPO4-314AH','LiFePO4 battery cell,3.2V 314ah,REPT','LiFePO4 battery cell, 3.2V 314ah, REPT brand','goods',NULL,60.00,75.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(72,8,'BATT-BMS-001','BMS','Battery Management System','goods',NULL,127.00,160.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(73,8,'BATT-SHELL-001','Shell box','Battery shell box enclosure','goods',NULL,200.00,250.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(74,8,'BATT-SPACER-001','Spacers/brackets','Spacers and mounting brackets','goods',NULL,45.00,60.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(75,8,'BATT-INSUL-001','Insulating materials','Insulating materials for battery cells','goods',NULL,75.00,95.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(76,8,'BATT-BUSBAR-001','Busbars/connecting pieces','Busbars and connecting pieces','goods',NULL,85.00,110.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(77,8,'BATT-WIRE-001','Wiring harnesses','Wiring harnesses for battery connections','goods',NULL,20.00,30.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(78,8,'BATT-FUSE-001','Fuse & Fuse holder','Fuse and fuse holder assembly','goods',NULL,12.00,18.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(79,8,'BATT-CONN-001','Connector(Ports)','Battery connector ports','goods',NULL,12.00,18.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(80,1,'BATT-DISP-001','Display/touch screen','Display and touch screen interface','goods','',27.00,40.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,'','active',NULL,'2025-12-04 22:26:53','2025-12-05 11:25:15',NULL,NULL),
(81,8,'BATT-LED-001','LED light','LED indicator light','goods',NULL,5.00,10.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(82,8,'BATT-BREAK-001','Breaker','Circuit breaker','goods',NULL,15.00,25.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(83,8,'BATT-COOL-001','Cooling system','Battery cooling system','goods',NULL,57.00,80.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(84,8,'BATT-BOLT-001','Fastening Bolts and Nuts','Fastening bolts and nuts hardware','goods',NULL,0.40,0.60,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL),
(85,8,'BATT-SWITCH-001','Switch','Power switch','goods',NULL,5.00,10.00,0.00,0,0.000,0.000,7,1.000,NULL,0,NULL,0,NULL,NULL,'active',NULL,'2025-12-04 22:26:53','2025-12-04 22:26:53',NULL,NULL);
commit;

--
-- Table structure for table `project_activity_log`
--

CREATE TABLE `project_activity_log` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `task_id` int(10) unsigned DEFAULT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `activity_type` varchar(50) NOT NULL COMMENT 'created, updated, moved, commented, etc.',
  `description` text DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Additional context data' CHECK (json_valid(`metadata`)),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_project` (`project_id`),
  KEY `idx_task` (`task_id`),
  KEY `idx_user` (`user_id`),
  KEY `idx_created` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='Project and task activity timeline';

--
-- Dumping data for table `project_activity_log`
--

set autocommit=0;
INSERT INTO `project_activity_log` VALUES
(19,3,NULL,1,'created','Battery Production Line Setup project created with 66 tasks across 8 phases',NULL,'2025-11-14 19:29:43'),
(20,3,16,1,'task_moved','Moved task \'Internet Installation\' to In Progress',NULL,'2025-11-14 20:51:11'),
(21,3,2,1,'task_moved','Moved task \'Facility Walkthrough\' to In Progress',NULL,'2025-11-14 20:51:26'),
(22,3,2,1,'task_moved','Moved task \'Facility Walkthrough\' to Review',NULL,'2025-11-14 20:52:11'),
(23,3,2,1,'task_moved','Moved task \'Facility Walkthrough\' to Testing',NULL,'2025-11-14 20:52:15'),
(24,3,2,8,'task_moved','Moved task \'Facility Walkthrough\' to Review',NULL,'2025-11-14 22:11:13'),
(25,4,NULL,1,'updated','Project updated',NULL,'2025-11-15 13:50:15'),
(26,4,68,1,'task_moved','Moved task \'Review and Sign Facility Lease Agreement\' to In Progress',NULL,'2025-11-15 13:53:27'),
(27,4,70,1,'task_moved','Moved task \'Setup Business Insurance Coverage\' to To Do',NULL,'2025-11-15 13:53:43'),
(28,4,69,1,'task_moved','Moved task \'Obtain Business Permits and Licenses\' to To Do',NULL,'2025-11-15 13:53:48'),
(29,4,90,1,'task_moved','Moved task \'Establish Banking Relationships\' to To Do',NULL,'2025-11-15 13:54:20'),
(30,4,69,1,'task_moved','Moved task \'Obtain Business Permits and Licenses\' to In Progress',NULL,'2025-11-15 13:54:37'),
(31,4,90,1,'task_moved','Moved task \'Establish Banking Relationships\' to In Progress',NULL,'2025-11-15 13:54:42'),
(32,4,73,1,'task_moved','Moved task \'Setup Utilities and Internet\' to In Progress',NULL,'2025-11-15 13:54:52'),
(33,4,76,1,'task_moved','Moved task \'Setup Office Furniture and IT Equipment\' to In Progress',NULL,'2025-11-15 13:55:02'),
(34,4,88,1,'task_moved','Moved task \'Setup Accounting and Payroll Systems\' to In Progress',NULL,'2025-11-15 13:55:17'),
(35,4,70,1,'task_moved','Moved task \'Setup Business Insurance Coverage\' to In Progress',NULL,'2025-11-15 13:59:05'),
(36,4,89,1,'task_moved','Moved task \'Create Budget and Financial Projections\' to To Do',NULL,'2025-11-15 13:59:39'),
(37,4,81,1,'task_moved','Moved task \'Setup Inventory Management System\' to To Do',NULL,'2025-11-15 13:59:48'),
(38,4,86,1,'task_moved','Moved task \'Setup Receiving and Shipping Procedures\' to To Do',NULL,'2025-11-15 13:59:56'),
(39,4,79,1,'task_moved','Moved task \'Develop Standard Operating Procedures (SOPs)\' to To Do',NULL,'2025-11-15 14:00:11'),
(40,3,NULL,1,'team_member_added','Team member added',NULL,'2025-11-15 14:47:16'),
(41,3,NULL,1,'team_member_added','Team member added',NULL,'2025-11-15 14:47:22'),
(42,3,NULL,1,'team_member_added','Team member added',NULL,'2025-11-15 14:47:29'),
(43,4,NULL,1,'team_member_added','Team member added',NULL,'2025-11-15 15:20:36'),
(44,4,NULL,1,'team_member_added','Team member added',NULL,'2025-11-15 15:20:41'),
(45,4,NULL,1,'updated','Project updated',NULL,'2025-11-15 15:42:37'),
(46,4,68,1,'task_moved','Moved task \'Review and Sign Facility Lease Agreement\' to Review',NULL,'2025-11-15 15:44:35'),
(47,4,68,1,'task_moved','Moved task \'Review and Sign Facility Lease Agreement\' to In Progress',NULL,'2025-11-15 16:39:29'),
(48,3,13,1,'task_updated','Updated task: HVAC Installation',NULL,'2025-11-16 11:56:30'),
(49,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:02:20'),
(50,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:02:22'),
(51,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:10:01'),
(52,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:10:03'),
(53,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:11:26'),
(54,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:11:29'),
(55,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:12:37'),
(56,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:12:45'),
(57,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:45:27'),
(58,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 12:46:54'),
(59,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:06:07'),
(60,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:06:10'),
(61,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:06:13'),
(62,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:07:37'),
(63,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:07:41'),
(64,3,3,1,'task_updated','Updated task: Mark Equipment Positions',NULL,'2025-11-16 13:25:26'),
(65,3,3,1,'task_updated','Updated task: Mark Equipment Positions',NULL,'2025-11-16 13:25:33'),
(66,3,3,1,'task_updated','Updated task: Mark Equipment Positions',NULL,'2025-11-16 13:25:33'),
(67,3,4,1,'task_updated','Updated task: Mark Workflow Zones',NULL,'2025-11-16 13:25:35'),
(68,3,4,1,'task_updated','Updated task: Mark Workflow Zones',NULL,'2025-11-16 13:25:35'),
(69,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:25:37'),
(70,3,2,1,'task_updated','Updated task: Facility Walkthrough',NULL,'2025-11-16 13:25:37'),
(71,3,5,1,'task_updated','Updated task: Mark Safety Aisles',NULL,'2025-11-16 13:25:38'),
(72,3,5,1,'task_updated','Updated task: Mark Safety Aisles',NULL,'2025-11-16 13:25:38'),
(73,3,6,1,'task_updated','Updated task: Determine Offices',NULL,'2025-11-16 13:25:40'),
(74,3,6,1,'task_updated','Updated task: Determine Offices',NULL,'2025-11-16 13:25:40'),
(75,3,6,1,'task_updated','Updated task: Determine Offices',NULL,'2025-11-16 13:25:41'),
(76,3,6,1,'task_updated','Updated task: Determine Offices',NULL,'2025-11-16 13:25:41'),
(77,3,7,1,'task_updated','Updated task: Determine Network Closet',NULL,'2025-11-16 13:25:42'),
(78,3,7,1,'task_updated','Updated task: Determine Network Closet',NULL,'2025-11-16 13:25:42'),
(79,3,8,1,'task_updated','Updated task: Power Assessment',NULL,'2025-11-16 13:25:44'),
(80,3,8,1,'task_updated','Updated task: Power Assessment',NULL,'2025-11-16 13:25:44'),
(81,3,9,1,'task_updated','Updated task: Power Drops Installation',NULL,'2025-11-16 13:25:45'),
(82,3,9,1,'task_updated','Updated task: Power Drops Installation',NULL,'2025-11-16 13:25:45'),
(83,3,26,1,'task_updated','Updated task: Dockside Inspection',NULL,'2025-11-19 18:22:05'),
(84,3,26,1,'task_moved','Moved task \'Dockside Inspection\' to To Do',NULL,'2025-11-24 13:26:33'),
(85,4,76,1,'task_moved','Moved task \'Setup Office Furniture and IT Equipment\' to Review',NULL,'2025-12-04 23:10:07');
commit;

--
-- Table structure for table `project_attachments`
--

CREATE TABLE `project_attachments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `task_id` int(10) unsigned DEFAULT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `file_size` int(11) DEFAULT NULL,
  `uploaded_by` int(10) unsigned NOT NULL,
  `uploaded_at` timestamp NULL DEFAULT current_timestamp(),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `uploaded_by` (`uploaded_by`),
  KEY `idx_project` (`project_id`),
  KEY `idx_task` (`task_id`),
  CONSTRAINT `project_attachments_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_attachments_ibfk_2` FOREIGN KEY (`task_id`) REFERENCES `project_tasks` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_attachments_ibfk_3` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `project_attachments`
--

set autocommit=0;
commit;

--
-- Table structure for table `project_baselines`
--

CREATE TABLE `project_baselines` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `baseline_name` varchar(255) NOT NULL,
  `baseline_date` date NOT NULL,
  `snapshot_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'Stores task dates, durations, and dependencies at baseline time' CHECK (json_valid(`snapshot_data`)),
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  KEY `idx_project_baseline` (`project_id`,`baseline_date`),
  CONSTRAINT `project_baselines_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_baselines_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `project_baselines`
--

set autocommit=0;
commit;

--
-- Table structure for table `project_budget_categories`
--

CREATE TABLE `project_budget_categories` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `category_name` varchar(100) NOT NULL,
  `budgeted_amount` decimal(15,2) DEFAULT 0.00,
  `committed_amount` decimal(15,2) DEFAULT 0.00 COMMENT 'POs issued but not paid',
  `actual_amount` decimal(15,2) DEFAULT 0.00 COMMENT 'Actually spent',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_project_category` (`project_id`,`category_name`),
  KEY `idx_project_category` (`project_id`),
  CONSTRAINT `project_budget_categories_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `project_budget_categories`
--

set autocommit=0;
commit;

--
-- Table structure for table `project_cash_flow_forecast`
--

CREATE TABLE `project_cash_flow_forecast` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `forecast_date` date NOT NULL,
  `expected_revenue` decimal(15,2) DEFAULT 0.00,
  `expected_expenses` decimal(15,2) DEFAULT 0.00,
  `forecasted_balance` decimal(15,2) DEFAULT 0.00,
  `actual_revenue` decimal(15,2) DEFAULT 0.00,
  `actual_expenses` decimal(15,2) DEFAULT 0.00,
  `actual_balance` decimal(15,2) DEFAULT 0.00,
  `variance` decimal(15,2) DEFAULT 0.00 COMMENT 'Difference between forecast and actual',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_project_forecast_date` (`project_id`,`forecast_date`),
  KEY `idx_project_forecast_date` (`project_id`,`forecast_date`),
  CONSTRAINT `project_cash_flow_forecast_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `project_cash_flow_forecast`
--

set autocommit=0;
commit;

--
-- Table structure for table `project_documents`
--

CREATE TABLE `project_documents` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `document_id` int(10) unsigned NOT NULL,
  `document_type` enum('contract','invoice','po','receipt','report','other') DEFAULT 'other',
  `linked_transaction_id` int(10) unsigned DEFAULT NULL COMMENT 'Link to specific financial transaction',
  `notes` varchar(500) DEFAULT NULL,
  `linked_by` int(10) unsigned DEFAULT NULL,
  `linked_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_project_document` (`project_id`,`document_id`),
  KEY `document_id` (`document_id`),
  KEY `linked_transaction_id` (`linked_transaction_id`),
  KEY `linked_by` (`linked_by`),
  KEY `idx_project_docs` (`project_id`),
  KEY `idx_doc_type` (`project_id`,`document_type`),
  CONSTRAINT `project_documents_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_documents_ibfk_2` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_documents_ibfk_3` FOREIGN KEY (`linked_transaction_id`) REFERENCES `project_financial_transactions` (`id`) ON DELETE SET NULL,
  CONSTRAINT `project_documents_ibfk_4` FOREIGN KEY (`linked_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `project_documents`
--

set autocommit=0;
commit;

--
-- Table structure for table `project_financial_transactions`
--

CREATE TABLE `project_financial_transactions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` int(10) unsigned NOT NULL,
  `transaction_date` date NOT NULL,
  `description` varchar(500) NOT NULL,
  `category` varchar(100) DEFAULT NULL COMMENT 'Expense/Revenue category (e.g., Construction, Shipping, Payroll)',
  `amount` decimal(15,2) NOT NULL DEFAULT 0.00,
  `transaction_type` enum('revenue','expense') NOT NULL,
  `status` enum('planned','committed','paid') DEFAULT 'planned',
  `journal_entry_id` int(10) unsigned DEFAULT NULL COMMENT 'Link to actual JE when paid',
  `account_id` int(10) unsigned DEFAULT NULL COMMENT 'Chart of accounts reference',
  `document_id` int(10) unsigned DEFAULT NULL COMMENT 'Supporting document (invoice, PO, etc)',
  `reference_type` varchar(50) DEFAULT NULL COMMENT 'Type of reference (PO, Invoice, Contract, etc)',
  `reference_id` int(10) unsigned DEFAULT NULL COMMENT 'ID of referenced record',
  `assigned_to` int(10) unsigned DEFAULT NULL COMMENT 'User responsible',
  `due_date` date DEFAULT NULL COMMENT 'When payment is due',
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `journal_entry_id` (`journal_entry_id`),
  KEY `account_id` (`account_id`),
  KEY `document_id` (`document_id`),
  KEY `assigned_to` (`assigned_to`),
  KEY `created_by` (`created_by`),
  KEY `idx_project_trans_date` (`project_id`,`transaction_date`),
  KEY `idx_project_trans_category` (`project_id`,`category`),
  KEY `idx_project_trans_type` (`project_id`,`transaction_type`),
  KEY `idx_project_trans_status` (`status`),
  KEY `idx_reference` (`reference_type`,`reference_id`),
  CONSTRAINT `project_financial_transactions_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_financial_transactions_ibfk_2` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE SET NULL,
  CONSTRAINT `project_financial_transactions_ibfk_3` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `project_financial_transactions_ibfk_4` FOREIGN KEY (`document_id`) REFERENCES `documents` (`id`) ON DELETE SET NULL,
  CONSTRAINT `project_financial_transactions_ibfk_5` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `project_financial_transactions_ibfk_6` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `project_financial_transactions`
--

set autocommit=0;
INSERT INTO `project_financial_transactions` VALUES
(1,3,'2025-11-30','CLIMATE FIRST BANK','Financing',1225000.00,'revenue','paid',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Initial loan funding',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(2,3,'2025-11-25','AR Advance','Accounts Receivable',200384.00,'revenue','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-25','Accounts receivable advance payment',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(3,3,'2025-12-16','PO Advance','Purchase Orders',700000.00,'revenue','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-12-16','Purchase order advance',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(4,3,'2025-12-15','Rent Owed Sept - Dec 2025','Landlord',375905.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-12-15','Assigned: Brian and Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(5,4,'2025-10-15','Utilities (estimate)','Utilities',20000.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-10-15','Assigned: KD',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(6,3,'2025-11-30','Shenzhen Cleva Power Co.,Ltd','PO Final Payments',6118.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: KD',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(7,3,'2025-11-30','Shenzhen SunFiD New Energy Co., Ltd.','PO Final Payments',59879.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: KD',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(8,3,'2025-11-30','FINAL PAYMENT For Large Cylindrical','EQ Factory',342126.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: Nathan and KD',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(9,3,'2025-11-30','Repower Aging Testing cabinets 60v200A (qty 5) 30% down','EQ Factory',30000.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(10,3,'2025-12-30','Repower Aging Testing cabinets 60v200A (qty 5) 70% remaining owed','EQ Factory',70000.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-12-30','Assigned: Nathan and JB',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(11,4,'2025-11-15','AMEX CC 23003 - B (Outstanding balance: $15,437.64)','Credit Cards',1500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-15','Payment Plan - Assigned: KD',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(12,4,'2025-11-15','AMEX CC 14007 - P (Outstanding balance: $7,654.17)','Credit Cards',1500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-15','Payment Plan - Assigned: KD',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(13,4,'2025-09-18','Loan Packaging Fee','Transaction Fees',2500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-09-18','CFB - Assigned: KD',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(14,4,'2025-09-18','Equity Injection','Transaction Fees',7500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-09-18','CFB - Assigned: KD',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(15,3,'2026-02-01','Repower - Shipping','Shipping',3000.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-02-01','Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(16,3,'2026-02-01','Repower - 301 Tariffs','301 Tariffs',2500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-02-01','Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(17,3,'2025-11-30','Section 301 Tariffs on Shipment - With 301 Exclusion','301 Tariffs',21783.00,'expense','committed',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','301 Exclusion Applied / Allianz Trade - Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(18,3,'2025-11-30','Cargo Brokers - Container Shipping Charges','Shipping',70840.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(19,3,'2025-11-30','Cosco Vietnam Storage Charges Through 12/1','Port Charges',22897.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Sent Demurrage Dispute - Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(20,3,'2025-11-30','Cosco Southampton Storage Charges Through 12/1','Port Charges',10854.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Sent Demurrage Dispute - Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(21,3,'2025-11-30','Floor Painting 1/3 Deposit - Suite 3 Only','Construction',26212.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Original: $78,635 - Construction Team',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(22,3,'2025-12-15','Floor Painting remaining 2/3 Owed - Suite 3 Only','Construction',17474.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-12-15','Original: $52,423 - Construction Team',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(23,3,'2025-11-30','Transformers w/ electrical','Construction',46080.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','2/5 Transformers with Electrical - Construction Team',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(24,3,'2025-11-30','Compressed Air & Nitrogen','Construction',40500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','2/5 Compressed Air & Nitrogen - Construction Team',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(25,3,'2025-11-30','Building Binding Policy','Insurance',34833.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: JB, Nathan, Paxton',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(26,4,'2025-10-15','General Liability - 10/1/2025','Insurance',933.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-10-15','Assigned: JB, Nathan, Paxton',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(27,4,'2025-11-15','General Liability - 11/1/2025','Insurance',933.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-15','Assigned: JB, Nathan, Paxton',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(28,4,'2025-12-15','General Liability - 12/1/2025','Insurance',933.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-12-15','Assigned: JB, Nathan, Paxton',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(29,3,'2025-11-30','Perimeter Fencing','Security',69951.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Assigned: Tony, Jordan, Tanner',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(30,3,'2025-11-30','Phase 1 Security','Security',85886.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30','Applied Cost Savings - Assigned: Tony, Tanner, John Kennerly',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(31,3,'2026-02-01','Section 301 Tariffs on Shipment - Large Cylindrical','301 Tariffs',8553.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-02-01','Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(32,3,'2026-02-01','Container Shipping - Large Cylindrical','Shipping',20660.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-02-01','Assigned: Nathan',1,'2025-11-14 19:57:45','2025-11-14 20:00:48'),
(33,4,'2026-01-31','R.R. Simmons (Final Payment #5/5)','Professional Services',15052.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-01-31','Related to 5201 Property litigation',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(34,4,'2026-01-31','LDD Blueline Invoice 50570','Professional Services',12500.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-01-31','Related to 5201 Property litigation',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(35,4,'2026-01-31','LDD Blueline Invoice 50452','Professional Services',9250.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2026-01-31','Related to 5201 Property litigation',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(36,4,'2025-09-19','Carlton Fields (Legal)','Professional Services',66311.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-09-19','Related to 5201 Property litigation',1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(37,4,'2025-11-30','BayFront Capital (JDCA Reimbursement)','Transaction Fees',6000.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30',NULL,1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(38,4,'2025-10-01','Mavrix1 Payroll Estimate','Payroll',50552.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-10-01',NULL,1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(39,4,'2025-10-01','Mavrix 1 Worker\'s Comp','Payroll',740.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-10-01',NULL,1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(40,4,'2025-10-01','LBC Payroll Estimate','Payroll',38682.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-10-01',NULL,1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(41,4,'2025-10-01','LBC Worker\'s Comp','Payroll',518.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-10-01',NULL,1,'2025-11-14 19:57:45','2025-11-15 13:49:46'),
(42,3,'2025-11-30','Sol Ark Prep Order','Equipment',5000.00,'expense','planned',NULL,NULL,NULL,NULL,NULL,NULL,'2025-11-30',NULL,1,'2025-11-14 19:57:45','2025-11-14 20:00:48');
commit;

--
