/*M!999999\- enable the sandbox mode */ 
-- MariaDB dump 10.19  Distrib 10.11.15-MariaDB, for Linux (x86_64)
--
-- Host: localhost    Database: italvettools_bdcrm
-- ------------------------------------------------------
-- Server version	10.11.15-MariaDB

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `audit_logs`
--

DROP TABLE IF EXISTS `audit_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `audit_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `action` varchar(100) NOT NULL,
  `entity_type` varchar(100) NOT NULL,
  `entity_id` int(11) DEFAULT NULL,
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_values`)),
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_values`)),
  `ip_address` varchar(45) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_audit_logs_entity` (`entity_type`,`entity_id`),
  KEY `idx_audit_logs_user_id` (`user_id`),
  KEY `idx_audit_logs_created_at` (`created_at`),
  CONSTRAINT `audit_logs_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `audit_logs`
--

LOCK TABLES `audit_logs` WRITE;
/*!40000 ALTER TABLE `audit_logs` DISABLE KEYS */;
INSERT INTO `audit_logs` VALUES
(1,1,'update','lead',28,'{\"id\":\"28\",\"event_id\":null,\"first_name\":\"Bryan Angel\",\"last_name\":\"De La Cruz Soto\",\"email\":\"bdelacruz654@gmail.com\",\"phone\":\"+51912538004\",\"company\":\"Next Boost Per\\u00fa\",\"position\":\"\",\"city\":\"Sunampe\",\"region\":\"Ica\",\"client_type\":[\"Distribuidor\",\"Veterinario\"],\"industry\":[\"Nutrici\\u00f3n Animal\",\"Sanidad Animal\"],\"classification\":\"tibio\",\"observations\":\"\",\"source\":\"manual\",\"status\":\"nuevo\",\"loss_reason_id\":null,\"is_duplicate\":\"1\",\"duplicate_of\":\"23\",\"created_by\":\"1\",\"updated_by\":\"1\",\"created_at\":\"2026-06-24 13:34:39\",\"updated_at\":\"2026-06-24 15:17:16\",\"created_by_name\":\"Super Administrador\",\"technical_profile\":{\"id\":\"3\",\"lead_id\":\"28\",\"animal_type\":null,\"herd_size\":null,\"current_supplier\":null,\"interest_area\":null,\"additional_data\":null,\"created_at\":\"2026-06-24 13:34:39\",\"updated_at\":\"2026-06-24 13:34:39\"}}','{\"id\":\"28\",\"event_id\":null,\"first_name\":\"Bryan Angel\",\"last_name\":\"De La Cruz Soto\",\"email\":\"bdelacruz654@gmail.com\",\"phone\":\"+51912538004\",\"company\":\"Next Boost Per\\u00fa\",\"position\":\"\",\"city\":\"Sunampe\",\"region\":\"Ica\",\"client_type\":[\"Distribuidor\",\"Veterinario\"],\"industry\":[\"Nutrici\\u00f3n Animal\",\"Sanidad Animal\"],\"classification\":\"frio\",\"observations\":\"\",\"source\":\"manual\",\"status\":\"nuevo\",\"loss_reason_id\":null,\"is_duplicate\":\"1\",\"duplicate_of\":\"23\",\"created_by\":\"1\",\"updated_by\":\"1\",\"created_at\":\"2026-06-24 13:34:39\",\"updated_at\":\"2026-06-24 15:29:03\",\"created_by_name\":\"Super Administrador\",\"technical_profile\":{\"id\":\"3\",\"lead_id\":\"28\",\"animal_type\":null,\"herd_size\":null,\"current_supplier\":null,\"interest_area\":null,\"additional_data\":null,\"created_at\":\"2026-06-24 13:34:39\",\"updated_at\":\"2026-06-24 13:34:39\"},\"status_history\":[],\"timeline\":[],\"products\":[]}','132.184.130.146','2026-06-24 19:29:03'),
(2,1,'login','user',1,NULL,NULL,'132.184.130.146','2026-06-24 19:48:51'),
(3,1,'login','user',1,NULL,NULL,'132.184.130.146','2026-06-24 19:53:00'),
(4,1,'login','user',1,NULL,NULL,'179.6.14.40','2026-06-24 19:53:11'),
(5,4,'login','user',4,NULL,NULL,'132.184.130.146','2026-06-24 19:53:29'),
(6,1,'login','user',1,NULL,NULL,'132.184.130.146','2026-06-24 20:02:49'),
(7,1,'update','lead',23,'{\"id\":\"23\",\"event_id\":\"7\",\"first_name\":\"Bryan\",\"last_name\":\"De la cruz\",\"email\":\"bdelacruz654@gmail.com\",\"phone\":\"+51947394676\",\"company\":\"Agromex\",\"position\":\"Gerente\",\"city\":\"chincha\",\"region\":\"Ica\",\"client_type\":[\"Distribuidor\"],\"industry\":[\"Nutrici\\u00f3n Animal\"],\"classification\":\"caliente\",\"observations\":\"ssssssssss\",\"source\":\"manual\",\"status\":\"contactado\",\"loss_reason_id\":null,\"is_duplicate\":\"1\",\"duplicate_of\":null,\"created_by\":\"4\",\"updated_by\":\"1\",\"created_at\":\"2026-06-22 23:43:40\",\"updated_at\":\"2026-06-24 12:53:06\",\"created_by_name\":\"Carlos Vendedor\",\"technical_profile\":{\"id\":\"2\",\"lead_id\":\"23\",\"animal_type\":\"Prueba\",\"herd_size\":\"100\",\"current_supplier\":\"Prueba\",\"interest_area\":\"Prueba\",\"additional_data\":null,\"created_at\":\"2026-06-22 23:43:40\",\"updated_at\":\"2026-06-23 00:44:20\"}}','{\"id\":\"23\",\"event_id\":\"7\",\"first_name\":\"Bryan\",\"last_name\":\"De la cruz\",\"email\":\"bdelacruz654@gmail.com\",\"phone\":\"+51947394676\",\"company\":\"Agromex\",\"position\":\"Gerente\",\"city\":\"chincha\",\"region\":\"Ica\",\"client_type\":[\"Distribuidor\"],\"industry\":[\"Nutrici\\u00f3n Animal\"],\"classification\":\"caliente\",\"observations\":\"12\\/05 \",\"source\":\"manual\",\"status\":\"contactado\",\"loss_reason_id\":null,\"is_duplicate\":\"1\",\"duplicate_of\":null,\"created_by\":\"4\",\"updated_by\":\"1\",\"created_at\":\"2026-06-22 23:43:40\",\"updated_at\":\"2026-06-24 16:07:30\",\"created_by_name\":\"Carlos Vendedor\",\"technical_profile\":{\"id\":\"2\",\"lead_id\":\"23\",\"animal_type\":\"Prueba\",\"herd_size\":\"100\",\"current_supplier\":\"Prueba\",\"interest_area\":\"Prueba\",\"additional_data\":null,\"created_at\":\"2026-06-22 23:43:40\",\"updated_at\":\"2026-06-23 00:44:20\"},\"status_history\":[{\"id\":\"9\",\"lead_id\":\"23\",\"previous_status\":\"nuevo\",\"new_status\":\"contactado\",\"loss_reason_id\":null,\"notes\":null,\"changed_by\":\"4\",\"created_at\":\"2026-06-23 00:37:21\",\"changed_by_name\":\"Carlos Vendedor\"}],\"timeline\":[{\"type\":\"status_change\",\"date\":\"2026-06-23 00:37:21\",\"data\":{\"from\":\"nuevo\",\"to\":\"contactado\",\"notes\":null,\"changed_by\":\"Carlos Vendedor\"}}],\"products\":[]}','179.6.14.40','2026-06-24 20:07:30'),
(8,4,'create','lead',29,NULL,NULL,'132.184.130.146','2026-06-24 20:27:39'),
(9,1,'login','user',1,NULL,NULL,'179.6.14.40','2026-06-24 20:37:17'),
(10,1,'login','user',1,NULL,NULL,'179.6.14.40','2026-06-24 20:38:03'),
(11,4,'login','user',4,NULL,NULL,'132.184.130.146','2026-06-24 20:41:51'),
(12,4,'login','user',4,NULL,NULL,'179.6.14.40','2026-06-24 20:53:13'),
(13,4,'login','user',4,NULL,NULL,'179.6.14.40','2026-06-24 20:55:00'),
(14,4,'login','user',4,NULL,NULL,'179.6.14.40','2026-06-24 21:33:07'),
(15,1,'login','user',1,NULL,NULL,'179.6.14.40','2026-06-24 21:41:16'),
(16,4,'login','user',4,NULL,NULL,'190.236.89.137','2026-06-24 22:00:33'),
(17,4,'update','lead',29,NULL,'{\"status\":\"calificado\"}','190.236.89.137','2026-06-24 22:01:15'),
(18,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-06-25 14:53:39'),
(19,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-06-25 15:19:51'),
(20,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-06-25 15:56:59'),
(21,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-06-25 16:58:24'),
(22,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-06-25 17:13:00'),
(23,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-06-25 18:08:59'),
(24,4,'login','user',4,NULL,NULL,'190.236.89.176','2026-06-25 19:31:47'),
(25,4,'login','user',4,NULL,NULL,'179.6.14.40','2026-06-25 21:24:39'),
(26,4,'login','user',4,NULL,NULL,'132.184.130.146','2026-06-25 22:13:02'),
(27,1,'login','user',1,NULL,NULL,'179.6.14.40','2026-06-26 14:42:36'),
(28,1,'login','user',1,NULL,NULL,'179.6.14.40','2026-07-01 20:27:45'),
(29,4,'login','user',4,NULL,NULL,'38.43.143.171','2026-07-01 20:28:42'),
(30,4,'login','user',4,NULL,NULL,'38.43.143.171','2026-07-01 20:29:43'),
(31,4,'create','lead',30,NULL,NULL,'38.43.143.171','2026-07-01 20:47:30'),
(32,1,'login','user',1,NULL,NULL,'38.43.143.171','2026-07-01 21:11:05'),
(33,4,'login','user',4,NULL,NULL,'179.6.14.40','2026-07-01 21:45:34'),
(34,4,'update','lead',29,NULL,'{\"status\":\"contactado\"}','179.6.14.40','2026-07-01 21:47:10'),
(35,4,'update','lead',29,NULL,'{\"status\":\"propuesta\"}','179.6.14.40','2026-07-01 21:47:11'),
(36,4,'login','user',4,NULL,NULL,'179.6.14.40','2026-07-01 23:45:22'),
(37,4,'login','user',4,NULL,NULL,'181.67.176.175','2026-07-03 17:47:22'),
(38,4,'login','user',4,NULL,NULL,'38.43.143.171','2026-07-03 19:11:47'),
(39,3,'login','user',3,NULL,NULL,'38.43.143.171','2026-07-04 02:47:05'),
(40,3,'login','user',3,NULL,NULL,'181.67.176.175','2026-07-07 13:59:15'),
(41,1,'login','user',1,NULL,NULL,'181.67.176.175','2026-07-08 15:05:39');
/*!40000 ALTER TABLE `audit_logs` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `backups`
--

DROP TABLE IF EXISTS `backups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `backups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `file_name` varchar(300) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `type` enum('completo','parcial') NOT NULL DEFAULT 'completo',
  `size_bytes` bigint(20) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `backups_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `backups`
--

LOCK TABLES `backups` WRITE;
/*!40000 ALTER TABLE `backups` DISABLE KEYS */;
INSERT INTO `backups` VALUES
(1,'backup_20260624_092138.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_092138.sql','completo',33103,1,'2026-06-24 15:21:40'),
(2,'backup_20260624_093213.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_093213.sql','completo',33310,1,'2026-06-24 15:32:14'),
(3,'backup_20260624_104312.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_104312.sql','completo',33729,1,'2026-06-24 16:43:14'),
(4,'backup_20260624_104318.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_104318.sql','completo',33890,1,'2026-06-24 16:43:18'),
(5,'backup_20260624_123502.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_123502.sql','completo',35104,1,'2026-06-24 18:35:03'),
(6,'backup_20260624_123750.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_123750.sql','completo',35265,1,'2026-06-24 18:37:50'),
(7,'backup_20260624_132930.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260624_132930.sql','completo',37632,1,'2026-06-24 19:29:31'),
(8,'backup_20260627_174023.sql','/home/italvettools/back.italvettools.com/storage/backups/backup_20260627_174023.sql','completo',41777,1,'2026-06-27 23:40:23');
/*!40000 ALTER TABLE `backups` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `configurations`
--

DROP TABLE IF EXISTS `configurations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `configurations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `key` varchar(100) NOT NULL,
  `value` text DEFAULT NULL,
  `description` varchar(300) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `key` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `configurations`
--

LOCK TABLES `configurations` WRITE;
/*!40000 ALTER TABLE `configurations` DISABLE KEYS */;
INSERT INTO `configurations` VALUES
(1,'smtp_host','smtp.test.qa',NULL,1,'2026-06-18 04:01:20'),
(2,'smtp_port','2525',NULL,1,'2026-06-18 04:01:21'),
(3,'google_vision_key','qa-123',NULL,1,'2026-06-18 04:01:22'),
(4,'nueva_key','val',NULL,1,'2026-06-18 04:01:26');
/*!40000 ALTER TABLE `configurations` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `event_users`
--

DROP TABLE IF EXISTS `event_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `event_users` (
  `event_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`event_id`,`user_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `event_users_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `event_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `event_users`
--

LOCK TABLES `event_users` WRITE;
/*!40000 ALTER TABLE `event_users` DISABLE KEYS */;
INSERT INTO `event_users` VALUES
(6,2),
(7,4);
/*!40000 ALTER TABLE `event_users` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `events`
--

DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `events` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `location` varchar(300) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `events`
--

LOCK TABLES `events` WRITE;
/*!40000 ALTER TABLE `events` DISABLE KEYS */;
INSERT INTO `events` VALUES
(1,'Feria QA Editada','Actualizado','2026-08-15','2026-08-20','Lima','active','2026-06-16 05:52:24','2026-06-16 05:52:33'),
(2,'Congreso QA',NULL,NULL,NULL,'Arequipa','active','2026-06-16 05:52:25','2026-06-16 05:52:25'),
(3,'Feria QA',NULL,NULL,NULL,NULL,'active','2026-06-17 02:59:38','2026-06-17 02:59:38'),
(4,'Test',NULL,NULL,NULL,NULL,'active','2026-06-17 03:01:14','2026-06-17 03:01:14'),
(6,'Evento Gestor',NULL,NULL,NULL,NULL,'active','2026-06-18 04:15:25','2026-06-18 04:15:25'),
(7,'APROHPERU 2026','Feria principal','2026-08-15','2026-08-20','Lima','active','2026-06-18 05:04:53','2026-06-18 05:04:53');
/*!40000 ALTER TABLE `events` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lead_products`
--

DROP TABLE IF EXISTS `lead_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lead_products` (
  `lead_id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`lead_id`,`product_id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `lead_products_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lead_products_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `lead_products`
--

LOCK TABLES `lead_products` WRITE;
/*!40000 ALTER TABLE `lead_products` DISABLE KEYS */;
/*!40000 ALTER TABLE `lead_products` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lead_representatives`
--

DROP TABLE IF EXISTS `lead_representatives`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lead_representatives` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `tipo_documento` varchar(20) DEFAULT NULL,
  `numero_documento` varchar(20) DEFAULT NULL,
  `nombre` varchar(250) NOT NULL,
  `cargo` varchar(200) DEFAULT NULL,
  `fecha_desde` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_lead_representatives_lead_id` (`lead_id`),
  CONSTRAINT `lead_representatives_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `lead_representatives`
--

LOCK TABLES `lead_representatives` WRITE;
/*!40000 ALTER TABLE `lead_representatives` DISABLE KEYS */;
/*!40000 ALTER TABLE `lead_representatives` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lead_status_history`
--

DROP TABLE IF EXISTS `lead_status_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lead_status_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `previous_status` varchar(30) DEFAULT NULL,
  `new_status` varchar(30) NOT NULL,
  `loss_reason_id` int(11) DEFAULT NULL,
  `notes` varchar(500) DEFAULT NULL,
  `changed_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `lead_id` (`lead_id`),
  KEY `loss_reason_id` (`loss_reason_id`),
  KEY `changed_by` (`changed_by`),
  CONSTRAINT `lead_status_history_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lead_status_history_ibfk_2` FOREIGN KEY (`loss_reason_id`) REFERENCES `loss_reasons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lead_status_history_ibfk_3` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `lead_status_history`
--

LOCK TABLES `lead_status_history` WRITE;
/*!40000 ALTER TABLE `lead_status_history` DISABLE KEYS */;
INSERT INTO `lead_status_history` VALUES
(1,1,'nuevo','contactado',NULL,'Primer contacto',1,'2026-06-17 02:59:56'),
(2,1,'contactado','calificado',NULL,NULL,1,'2026-06-17 02:59:58'),
(3,1,'calificado','ganado',NULL,'Cerrado!',1,'2026-06-17 03:00:00'),
(4,2,'nuevo','propuesta',NULL,NULL,1,'2026-06-17 03:00:02'),
(5,2,'propuesta','negociacion',NULL,NULL,1,'2026-06-17 03:00:04'),
(6,4,'nuevo','contactado',NULL,NULL,1,'2026-06-17 03:01:20'),
(9,23,'nuevo','contactado',NULL,NULL,4,'2026-06-23 04:37:21'),
(10,29,'nuevo','calificado',NULL,NULL,4,'2026-06-24 22:01:15'),
(11,29,'calificado','contactado',NULL,NULL,4,'2026-07-01 21:47:10'),
(12,29,'contactado','propuesta',NULL,NULL,4,'2026-07-01 21:47:11');
/*!40000 ALTER TABLE `lead_status_history` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lead_technical_problems`
--

DROP TABLE IF EXISTS `lead_technical_problems`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lead_technical_problems` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `description` text NOT NULL,
  `status` enum('pendiente','resuelto') NOT NULL DEFAULT 'pendiente',
  `resolved_at` timestamp NULL DEFAULT NULL,
  `created_by` int(11) NOT 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_lead_tech_problems_lead_id` (`lead_id`),
  CONSTRAINT `lead_technical_problems_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lead_technical_problems_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `lead_technical_problems`
--

LOCK TABLES `lead_technical_problems` WRITE;
/*!40000 ALTER TABLE `lead_technical_problems` DISABLE KEYS */;
/*!40000 ALTER TABLE `lead_technical_problems` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lead_technical_profiles`
--

DROP TABLE IF EXISTS `lead_technical_profiles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lead_technical_profiles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `animal_type` varchar(100) DEFAULT NULL,
  `herd_size` varchar(100) DEFAULT NULL,
  `current_supplier` varchar(200) DEFAULT NULL,
  `interest_area` varchar(200) DEFAULT NULL,
  `additional_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`additional_data`)),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `lead_id` (`lead_id`),
  CONSTRAINT `lead_technical_profiles_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `lead_technical_profiles`
--

LOCK TABLES `lead_technical_profiles` WRITE;
/*!40000 ALTER TABLE `lead_technical_profiles` DISABLE KEYS */;
INSERT INTO `lead_technical_profiles` VALUES
(2,23,'Prueba','100','Prueba','Prueba',NULL,'2026-06-23 03:43:40','2026-06-23 04:44:20'),
(3,28,NULL,NULL,NULL,NULL,NULL,'2026-06-24 17:34:39','2026-06-24 17:34:39'),
(4,29,NULL,NULL,NULL,NULL,NULL,'2026-06-24 20:27:39','2026-06-24 20:27:39'),
(5,30,NULL,NULL,NULL,NULL,NULL,'2026-07-01 20:47:30','2026-07-01 20:47:30');
/*!40000 ALTER TABLE `lead_technical_profiles` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `leads`
--

DROP TABLE IF EXISTS `leads`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `leads` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `event_id` int(11) DEFAULT NULL,
  `first_name` varchar(150) NOT NULL,
  `last_name` varchar(150) NOT NULL,
  `email` varchar(200) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `company` varchar(200) DEFAULT NULL,
  `position` varchar(200) DEFAULT NULL,
  `city` varchar(150) DEFAULT NULL,
  `region` varchar(150) DEFAULT NULL,
  `ruc` varchar(11) DEFAULT NULL,
  `business_name` varchar(250) DEFAULT NULL,
  `address` varchar(300) DEFAULT NULL,
  `audio_file_path` varchar(500) DEFAULT NULL,
  `photo_file_path` varchar(500) DEFAULT NULL,
  `client_type` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`client_type`)),
  `industry` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`industry`)),
  `classification` varchar(20) DEFAULT NULL,
  `observations` text DEFAULT NULL,
  `source` enum('manual','scan','voice') NOT NULL DEFAULT 'manual',
  `status` enum('nuevo','contactado','calificado','propuesta','negociacion','ganado','perdido') NOT NULL DEFAULT 'nuevo',
  `loss_reason_id` int(11) DEFAULT NULL,
  `is_duplicate` tinyint(1) NOT NULL DEFAULT 0,
  `duplicate_of` int(11) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `updated_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 `loss_reason_id` (`loss_reason_id`),
  KEY `duplicate_of` (`duplicate_of`),
  KEY `updated_by` (`updated_by`),
  KEY `idx_leads_event_id` (`event_id`),
  KEY `idx_leads_status` (`status`),
  KEY `idx_leads_created_by` (`created_by`),
  KEY `idx_leads_email` (`email`),
  KEY `idx_leads_phone` (`phone`),
  KEY `idx_leads_ruc` (`ruc`),
  CONSTRAINT `leads_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE,
  CONSTRAINT `leads_ibfk_2` FOREIGN KEY (`loss_reason_id`) REFERENCES `loss_reasons` (`id`) ON DELETE SET NULL,
  CONSTRAINT `leads_ibfk_3` FOREIGN KEY (`duplicate_of`) REFERENCES `leads` (`id`) ON DELETE SET NULL,
  CONSTRAINT `leads_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `leads_ibfk_5` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `leads`
--

LOCK TABLES `leads` WRITE;
/*!40000 ALTER TABLE `leads` DISABLE KEYS */;
INSERT INTO `leads` VALUES
(1,3,'Carlos Editado','Gomez','carlos@test.com','5550001','AgroMex 2.0','Gerente',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','ganado',NULL,0,NULL,1,1,'2026-06-17 02:59:42','2026-06-17 03:00:00'),
(2,3,'Maria','Lopez','maria@test.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','negociacion',NULL,0,NULL,1,1,'2026-06-17 02:59:44','2026-06-17 03:00:04'),
(3,3,'Copia','Gomez','carlos@test.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,1,1,1,NULL,'2026-06-17 02:59:45','2026-06-17 02:59:45'),
(4,4,'T','L',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','contactado',NULL,0,NULL,1,1,'2026-06-17 03:01:18','2026-06-17 03:01:20'),
(10,7,'Sin nombre','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:36:54','2026-06-18 05:36:54'),
(11,7,'Sin nombre','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:37:33','2026-06-18 05:37:33'),
(12,7,'Sin nombre','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:42:30','2026-06-18 05:42:30'),
(13,7,'Brad','Delacruz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:46:27','2026-06-18 05:46:27'),
(14,7,'Hola','Esto',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:48:26','2026-06-18 05:48:26'),
(15,7,'Brian','Por voz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:48:45','2026-06-18 05:48:45'),
(16,7,'Carlos','De',NULL,NULL,'Agromex',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:50:45','2026-06-18 05:50:45'),
(17,7,'Sin nombre','Por voz',NULL,'55 50 2320',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:51:05','2026-06-18 05:51:05'),
(18,7,'Brian','Trabaja',NULL,NULL,'Agromex Mi Teléfono Es Nueve Veinte Uno Tres Cuatro Cuatro Tres Ocho',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 05:53:16','2026-06-18 05:53:16'),
(19,7,'Brian','Trabajo',NULL,'940 123 4056','Cruz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 06:00:36','2026-06-18 06:00:36'),
(20,7,'Brian','Trabajador',NULL,'920 123456','Cruz',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-18 06:02:12','2026-06-18 06:02:12'),
(22,7,'Brian','De',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'manual','nuevo',NULL,0,NULL,4,NULL,'2026-06-19 20:10:08','2026-06-19 20:10:08'),
(23,7,'Bryan','De la cruz','bdelacruz654@gmail.com','+51947394676','Agromex','Gerente','chincha','Ica',NULL,NULL,NULL,NULL,NULL,'[\"Distribuidor\"]','[\"Nutrici\\u00f3n Animal\"]','caliente','12/05 ','manual','contactado',NULL,1,NULL,4,1,'2026-06-23 03:43:40','2026-06-24 20:07:30'),
(28,NULL,'Bryan Angel','De La Cruz Soto','bdelacruz654@gmail.com','+51912538004','Next Boost Perú','','Sunampe','Ica',NULL,NULL,NULL,NULL,NULL,'[\"Distribuidor\",\"Veterinario\"]','[\"Nutrici\\u00f3n Animal\",\"Sanidad Animal\"]','frio','','manual','nuevo',NULL,1,23,1,1,'2026-06-24 17:34:39','2026-06-24 19:29:03'),
(29,7,'Bryan Angel','De La Cruz Soto','bdelacruz654@gmail.com','+51912538004','Agromex',NULL,'Sunampe','Ica',NULL,NULL,NULL,NULL,NULL,'[\"Distribuidor\"]','[\"Nutrici\\u00f3n Animal\"]',NULL,NULL,'manual','propuesta',NULL,1,23,4,4,'2026-06-24 20:27:39','2026-07-01 21:47:11'),
(30,7,'Bryan Angel','De La Cruz Soto','bdelacruz654@gmail.com','+51912538004','ITALVET S.A.C.','Prueba','Prueba','Prueba','20513909382','ITALVET S.A.C.','MZ. H LT. 17 PRO VIV AYACUCHO',NULL,NULL,'[\"Distribuidor\"]','[\"Nutrici\\u00f3n Animal\"]','caliente','Prueba','manual','nuevo',NULL,1,23,4,NULL,'2026-07-01 20:47:30','2026-07-01 20:47:30');
/*!40000 ALTER TABLE `leads` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `loss_reasons`
--

DROP TABLE IF EXISTS `loss_reasons`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `loss_reasons` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `loss_reasons`
--

LOCK TABLES `loss_reasons` WRITE;
/*!40000 ALTER TABLE `loss_reasons` DISABLE KEYS */;
INSERT INTO `loss_reasons` VALUES
(1,'Precio','El lead considero que el precio era muy alto','active','2026-06-17 03:03:47'),
(2,'Competencia','El lead eligio un competidor','active','2026-06-17 03:03:47'),
(3,'Sin interes','El lead perdio interes','active','2026-06-17 03:03:47'),
(4,'No contactable','No fue posible contactar al lead','active','2026-06-17 03:03:47'),
(5,'Presupuesto','El lead no cuenta con presupuesto','active','2026-06-17 03:03:47'),
(6,'Otro','Otro motivo no especificado','active','2026-06-17 03:03:47'),
(7,'Precio','El lead consideró que el precio era muy alto','active','2026-06-24 15:17:26'),
(8,'Competencia','El lead eligió un competidor','active','2026-06-24 15:17:26'),
(9,'Sin interés','El lead perdió interés en el producto/servicio','active','2026-06-24 15:17:26'),
(10,'No contactable','No fue posible contactar al lead','active','2026-06-24 15:17:26'),
(11,'Presupuesto','El lead no cuenta con presupuesto','active','2026-06-24 15:17:26'),
(12,'Otro','Otro motivo no especificado','active','2026-06-24 15:17:26');
/*!40000 ALTER TABLE `loss_reasons` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `material_categories`
--

DROP TABLE IF EXISTS `material_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `material_categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `material_categories`
--

LOCK TABLES `material_categories` WRITE;
/*!40000 ALTER TABLE `material_categories` DISABLE KEYS */;
/*!40000 ALTER TABLE `material_categories` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `notes`
--

DROP TABLE IF EXISTS `notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `type` enum('texto','audio') NOT NULL DEFAULT 'texto',
  `content` text DEFAULT NULL,
  `audio_file_path` varchar(500) DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `lead_id` (`lead_id`),
  KEY `created_by` (`created_by`),
  CONSTRAINT `notes_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `notes_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `notes`
--

LOCK TABLES `notes` WRITE;
/*!40000 ALTER TABLE `notes` DISABLE KEYS */;
/*!40000 ALTER TABLE `notes` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `notifications`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `notifications` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `type` enum('tarea_proxima','tarea_vencida','nuevo_lead','invitacion','actividad') NOT NULL,
  `title` varchar(200) NOT NULL,
  `message` text DEFAULT NULL,
  `reference_type` varchar(100) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `is_read` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_notifications_user` (`user_id`,`is_read`),
  CONSTRAINT `notifications_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `notifications` WRITE;
/*!40000 ALTER TABLE `notifications` DISABLE KEYS */;
INSERT INTO `notifications` VALUES
(1,4,'tarea_proxima','Nueva tarea: Llamar cliente','Tarea programada para el 2026-07-08 a las 14:00','task',3,0,'2026-07-01 20:51:18'),
(2,4,'tarea_proxima','Nueva tarea: Seguimiento','Tarea programada para el 2026-07-03 a las 10:40','task',4,0,'2026-07-01 21:48:04'),
(3,4,'tarea_proxima','Nueva tarea: Visita técnica','Tarea programada para el 2026-07-09 a las 12:50','task',5,0,'2026-07-01 23:51:00'),
(4,1,'tarea_proxima','Nueva tarea: Llamar cliente','Tarea programada para el 2026-07-08','task',6,0,'2026-07-08 15:06:02');
/*!40000 ALTER TABLE `notifications` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `password_resets`
--

DROP TABLE IF EXISTS `password_resets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `password_resets` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `token` varchar(255) NOT NULL,
  `expires_at` timestamp NOT NULL,
  `used` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `password_resets_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `password_resets`
--

LOCK TABLES `password_resets` WRITE;
/*!40000 ALTER TABLE `password_resets` DISABLE KEYS */;
INSERT INTO `password_resets` VALUES
(1,1,'6f0cfaa28cc61fce548e6b46e7d9829f1ea3f1940d5994c28af44bfa6efb3ead','2026-06-24 00:42:37',1,'2026-06-23 23:42:37'),
(2,1,'d51a388dec1bd9194132eea1151c387c38fdf4d2b3d78c04b4d7eaa9817dd714','2026-06-24 00:42:38',1,'2026-06-23 23:42:38'),
(3,1,'7885e3af013f75501dbd4b1f69e6f50cd7dd27e37de41ae4d1af12d5a4ecee2a','2026-06-24 00:42:39',1,'2026-06-23 23:42:39'),
(4,1,'e982ea8f42745c4c45550a82a3a38c88f2e1f7d6473e7aaf589526f5a438bef7','2026-06-24 00:46:22',1,'2026-06-23 23:46:22'),
(5,1,'c63ba429baf6de0011ab5fe54e99c044f2261cd0e317a95f34763ffbc576a3b0','2026-06-24 00:46:23',1,'2026-06-23 23:46:23'),
(6,1,'8a1e0e03295f78a7198458c54934e7484f875a65cb93f64157d4681106ef1134','2026-06-24 00:46:24',1,'2026-06-23 23:46:24');
/*!40000 ALTER TABLE `password_resets` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `category` varchar(150) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `products` WRITE;
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
INSERT INTO `products` VALUES
(1,'v2','Upd','Nutricion','active','2026-06-17 03:14:40','2026-06-17 03:14:48');
/*!40000 ALTER TABLE `products` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `sessions`
--

DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `sessions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `token` varchar(500) NOT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `expires_at` timestamp NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`),
  KEY `idx_sessions_user_id` (`user_id`),
  KEY `idx_sessions_expires_at` (`expires_at`),
  CONSTRAINT `sessions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=125 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `sessions`
--

LOCK TABLES `sessions` WRITE;
/*!40000 ALTER TABLE `sessions` DISABLE KEYS */;
INSERT INTO `sessions` VALUES
(124,1,'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjUxNzMiLCJpYXQiOjE3ODM1MjMxMzksImV4cCI6MTc4MzUyNjczOSwic3ViIjoiMSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsImV2ZW50X2lkIjpudWxsfQ.JcmkZzS7mswbCanCAFfk5_WJbtYQTWOHV39HX73K0Z0','181.67.176.175','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36','2026-07-08 16:05:39','2026-07-08 15:05:39');
/*!40000 ALTER TABLE `sessions` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `tasks`
--

DROP TABLE IF EXISTS `tasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `tasks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lead_id` int(11) NOT NULL,
  `type` enum('llamada','reunion','correo','whatsapp','seguimiento','otro') NOT NULL,
  `scheduled_date` date NOT NULL,
  `scheduled_time` time DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `farm_lat` decimal(10,7) DEFAULT NULL,
  `farm_lng` decimal(10,7) DEFAULT NULL,
  `assigned_to` int(11) NOT NULL,
  `status` enum('pendiente','completada','cancelada') NOT NULL DEFAULT 'pendiente',
  `completed_at` timestamp NULL DEFAULT NULL,
  `created_by` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `lead_id` (`lead_id`),
  KEY `created_by` (`created_by`),
  KEY `idx_tasks_assigned_to` (`assigned_to`),
  KEY `idx_tasks_scheduled_date` (`scheduled_date`),
  KEY `idx_tasks_status` (`status`),
  CONSTRAINT `tasks_ibfk_1` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE,
  CONSTRAINT `tasks_ibfk_2` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`),
  CONSTRAINT `tasks_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `tasks`
--

LOCK TABLES `tasks` WRITE;
/*!40000 ALTER TABLE `tasks` DISABLE KEYS */;
INSERT INTO `tasks` VALUES
(1,23,'llamada','2026-06-23','00:00:00','ssssssss',NULL,NULL,4,'completada','2026-06-24 18:23:56',4,'2026-06-23 05:03:03','2026-06-24 20:23:56'),
(2,23,'llamada','2026-06-24','13:02:00','wdsfdsds',NULL,NULL,4,'completada','2026-07-01 18:59:28',4,'2026-06-24 18:02:12','2026-07-01 20:59:28'),
(3,30,'llamada','2026-07-08','14:00:00','Definir interes en espectorantes',NULL,NULL,4,'pendiente',NULL,4,'2026-07-01 20:51:18','2026-07-01 20:51:18'),
(4,29,'seguimiento','2026-07-03','10:40:00','pendiente respuesta cotizacion del 01/07',NULL,NULL,4,'pendiente',NULL,4,'2026-07-01 21:48:04','2026-07-01 21:48:04'),
(5,30,'reunion','2026-07-09','12:50:00','visita ',NULL,NULL,4,'pendiente',NULL,4,'2026-07-01 23:51:00','2026-07-01 23:51:00'),
(6,2,'llamada','2026-07-08',NULL,'',NULL,NULL,1,'pendiente',NULL,1,'2026-07-08 15:06:02','2026-07-08 15:06:02');
/*!40000 ALTER TABLE `tasks` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `technical_materials`
--

DROP TABLE IF EXISTS `technical_materials`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `technical_materials` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `type` enum('pdf','video') NOT NULL,
  `file_path` varchar(500) DEFAULT NULL,
  `external_url` varchar(500) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_by` int(11) NOT 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_materials_category` (`category_id`),
  CONSTRAINT `technical_materials_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `technical_materials_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `material_categories` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `technical_materials`
--

LOCK TABLES `technical_materials` WRITE;
/*!40000 ALTER TABLE `technical_materials` DISABLE KEYS */;
INSERT INTO `technical_materials` VALUES
(3,'Prueba','',NULL,'pdf','/home/italvettools/back.italvettools.com/storage/materials/material_pdf_6a3c29b9eaf35.pdf',NULL,'active',1,'2026-06-24 19:02:17','2026-06-24 19:02:17');
/*!40000 ALTER TABLE `technical_materials` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user_invitations`
--

DROP TABLE IF EXISTS `user_invitations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_invitations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(200) NOT NULL,
  `token` varchar(255) NOT NULL,
  `role` enum('super_admin','comercial_manager') NOT NULL,
  `invited_by` int(11) NOT NULL,
  `status` enum('pendiente','aceptada','expirada') NOT NULL DEFAULT 'pendiente',
  `expires_at` timestamp NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`),
  KEY `invited_by` (`invited_by`),
  CONSTRAINT `user_invitations_ibfk_1` FOREIGN KEY (`invited_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user_invitations`
--

LOCK TABLES `user_invitations` WRITE;
/*!40000 ALTER TABLE `user_invitations` DISABLE KEYS */;
/*!40000 ALTER TABLE `user_invitations` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `users`
--

DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `email` varchar(200) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('super_admin','comercial_manager') NOT NULL DEFAULT 'comercial_manager',
  `status` enum('pending_activation','active','inactive') NOT NULL DEFAULT 'pending_activation',
  `current_event_id` 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`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `users`
--

LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES
(1,'Super Administrador','admin@italvet.com','$2y$10$XTmLzR1.cSKQp0mOFH7gLOTSsQHF2BlMYZGaWst608rjvPMGEf0NG','super_admin','active',NULL,'2026-06-16 05:28:14','2026-06-24 20:02:49'),
(2,'Gestor QA','gq@t.com','$2y$10$uZx7lHW/qeNkdrc6dnqrNOOV4Mbw0X1hscCRROgeVhD0jlXCkiQte','comercial_manager','active',6,'2026-06-16 05:56:05','2026-06-18 04:15:27'),
(3,'Bryan Angel De La Cruz Soto','bdelacruz654@gmail.com','$2y$10$rQG63gpd.9DDQ.o24wQITOQB9GJB4eBX6o3ToHYS7052IOY7ByDrW','super_admin','active',NULL,'2026-06-17 02:41:36','2026-06-17 02:41:36'),
(4,'Carlos Vendedor','vendedor@italvet.com','$2y$10$jtNOIARnXIYsYwpkC8x0iempgK62xzlxdV1U1kOmomqhJPPPCiGZi','comercial_manager','active',7,'2026-06-18 04:43:48','2026-07-03 19:11:53'),
(5,'Test','test@test.com','$2y$10$zi059NQSEzzhh6RM/PS87eIQ71jN/hNg/r.H/9HSNkdqaawg.bFWa','super_admin','active',NULL,'2026-06-24 15:43:36','2026-06-24 15:43:36');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `whatsapp_templates`
--

DROP TABLE IF EXISTS `whatsapp_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `whatsapp_templates` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `content` text NOT NULL,
  `variables` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`variables`)),
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_by` int(11) NOT 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`),
  CONSTRAINT `whatsapp_templates_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `whatsapp_templates`
--

LOCK TABLES `whatsapp_templates` WRITE;
/*!40000 ALTER TABLE `whatsapp_templates` DISABLE KEYS */;
INSERT INTO `whatsapp_templates` VALUES
(1,'Saludo v2','Hola {nombre}!','[\"nombre\"]','active',1,'2026-06-17 04:36:04','2026-06-17 04:36:08');
/*!40000 ALTER TABLE `whatsapp_templates` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-07-08 11:11:49
