/*M!999999\- enable the sandbox mode */ 
-- MariaDB dump 10.19  Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost    Database: trimape_db
-- ------------------------------------------------------
-- Server version	10.11.14-MariaDB-0ubuntu0.24.04.1

/*!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 */;

--
-- Sequence structure for `folio_seq`
--

DROP SEQUENCE IF EXISTS `folio_seq`;
CREATE SEQUENCE `folio_seq` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=InnoDB;
DO SETVAL(`folio_seq`, 10, 0);

--
-- Table structure for table `OSFirmas`
--

DROP TABLE IF EXISTS `OSFirmas`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `OSFirmas` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `firma_ruta` text DEFAULT NULL,
  `nombre_responsable` varchar(255) DEFAULT NULL,
  `puesto` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `id_service_order` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `OSFirmas`
--

LOCK TABLES `OSFirmas` WRITE;
/*!40000 ALTER TABLE `OSFirmas` DISABLE KEYS */;
INSERT INTO `OSFirmas` VALUES
(1,'uploads/signatures/signature_0_1773336337465.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-12 17:25:37',2),
(2,'uploads/signatures/signature_1_1773336337466.png','JUAN LOPEZ','RESPONSABLE DE ÁREA','2026-03-12 17:25:37',2),
(7,'uploads/signatures/signature_0_1773337756296.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-12 17:50:46',1),
(8,'uploads/signatures/signature_1_1773337756296.png','PEDRO PEREZ','RESPONSABLE DE ÁREA','2026-03-12 17:50:46',1),
(13,'uploads/signatures/signature_0_1773725490016.png','JUAN PEREZ','INGENIERO DE SERVICIO','2026-03-17 05:32:10',3),
(14,'uploads/signatures/signature_1_1773725490017.png','MARIO BONOLA','RESPONSABLE DE ÁREA','2026-03-17 05:32:10',3),
(16,'uploads/signatures/signature_0_1773727150499.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-17 05:59:10',4),
(17,'uploads/signatures/signature_1_1773727150500.png','MARIO PEREZ','RESPONSABLE DE ÁREA','2026-03-17 05:59:10',4),
(19,'uploads/signatures/signature_0_1773729192394.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-17 06:33:12',5),
(20,'uploads/signatures/signature_1_1773729192394.png','ROBERTO VASQUEZ','RESPONSABLE DE ÁREA','2026-03-17 06:33:12',5),
(22,'uploads/signatures/signature_0_1773729591917.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-17 06:39:51',6),
(23,'uploads/signatures/signature_1_1773729591918.png','PEDRO VELEZ','RESPONSABLE DE ÁREA','2026-03-17 06:39:51',6),
(25,'uploads/signatures/signature_0_1773730146241.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-17 06:49:06',7),
(26,'uploads/signatures/signature_1_1773730146241.png','PABLO PEREZ','RESPONSABLE DE ÁREA','2026-03-17 06:49:06',7),
(27,'uploads/signatures/signature_0_1773965880157.png','DOMINIC VALDES','INGENIERO DE SERVICIO','2026-03-20 00:18:00',9),
(28,'uploads/signatures/signature_1_1773965880157.png','MANUEL GONZALES','RESPONSABLE DE ÁREA','2026-03-20 00:18:00',9);
/*!40000 ALTER TABLE `OSFirmas` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `OSrefacciones`
--

DROP TABLE IF EXISTS `OSrefacciones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `OSrefacciones` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `OS_id` bigint(20) unsigned NOT NULL,
  `codigo` varchar(255) NOT NULL,
  `descripcion` text DEFAULT NULL,
  `cantidad` int(11) NOT NULL,
  `tipo` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_sheet_tipo` (`OS_id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `OSrefacciones`
--

LOCK TABLES `OSrefacciones` WRITE;
/*!40000 ALTER TABLE `OSrefacciones` DISABLE KEYS */;
INSERT INTO `OSrefacciones` VALUES
(1,2,'1','TORNILLOS',12,'DIAGNOSTIC_SHEET'),
(2,2,'2','TALADRO',3,'DIAGNOSTIC_SHEET'),
(3,2,'3','MANGUERAS',1,'DIAGNOSTIC_SHEET'),
(13,1,'65','87',56,'SERVICE_ORDER'),
(14,1,'89','676',6,'SERVICE_ORDER'),
(15,1,'877654','567',86,'SERVICE_ORDER'),
(17,3,'54','654',654,'DIAGNOSTIC_SHEET'),
(18,4,'576','576',5,'DIAGNOSTIC_SHEET'),
(19,5,'76','8767',68,'DIAGNOSTIC_SHEET'),
(20,6,'67','876',76,'DIAGNOSTIC_SHEET'),
(21,7,'68','68',76,'DIAGNOSTIC_SHEET'),
(22,1,'656','765',65,'WARRANTY_SHEET'),
(23,9,'6765','765',675,'DIAGNOSTIC_SHEET');
/*!40000 ALTER TABLE `OSrefacciones` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `OsPhotos`
--

DROP TABLE IF EXISTS `OsPhotos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `OsPhotos` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `OS_id` int(10) unsigned NOT NULL,
  `ruta_foto` varchar(255) NOT NULL,
  `tipo` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `OsPhotos`
--

LOCK TABLES `OsPhotos` WRITE;
/*!40000 ALTER TABLE `OsPhotos` DISABLE KEYS */;
INSERT INTO `OsPhotos` VALUES
(1,2,'/uploads/photo-1773336337462-467260244.jpg','DIAGNOSTIC_SHEET','2026-03-12 17:25:37'),
(2,2,'/uploads/photo-1773336337463-755903050.jpg','DIAGNOSTIC_SHEET','2026-03-12 17:25:37'),
(3,2,'/uploads/photo-1773336337463-866035631.jpg','DIAGNOSTIC_SHEET','2026-03-12 17:25:37'),
(4,2,'/uploads/photo-1773336337464-551825949.jpg','DIAGNOSTIC_SHEET','2026-03-12 17:25:37'),
(8,3,'/uploads/photo-1773725490013-294004423.jpg','DIAGNOSTIC_SHEET','2026-03-17 05:31:30'),
(9,4,'/uploads/photo-1773727150497-985487998.jpg','DIAGNOSTIC_SHEET','2026-03-17 05:59:10'),
(10,5,'/uploads/photo-1773729192392-779700747.jpg','DIAGNOSTIC_SHEET','2026-03-17 06:33:12'),
(11,6,'/uploads/photo-1773729591917-57185875.jpg','DIAGNOSTIC_SHEET','2026-03-17 06:39:51'),
(12,7,'/uploads/photo-1773730146239-223144524.jpg','DIAGNOSTIC_SHEET','2026-03-17 06:49:06'),
(13,1,'/uploads/photo-1773731135101-13745451.jpg','WARRANTY_SHEET','2026-03-17 07:05:35'),
(14,9,'/uploads/photo-1773965880155-290854041.jpg','DIAGNOSTIC_SHEET','2026-03-20 00:18:00');
/*!40000 ALTER TABLE `OsPhotos` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `adminBudgets`
--

DROP TABLE IF EXISTS `adminBudgets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `adminBudgets` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_admin` int(10) unsigned NOT NULL,
  `initial_amount` decimal(12,2) NOT NULL,
  `current_amount` decimal(12,2) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `adminBudgets`
--

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

--
-- Table structure for table `adminVouchers`
--

DROP TABLE IF EXISTS `adminVouchers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `adminVouchers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `admin_expense_id` int(11) NOT NULL,
  `ruta_voucher` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `admin_expense_id` (`admin_expense_id`),
  CONSTRAINT `adminVouchers_ibfk_1` FOREIGN KEY (`admin_expense_id`) REFERENCES `admin_expenses` (`expense_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `adminVouchers`
--

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

--
-- Table structure for table `admin_expenses`
--

DROP TABLE IF EXISTS `admin_expenses`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `admin_expenses` (
  `expense_id` int(11) NOT NULL AUTO_INCREMENT,
  `admin_user_id` int(11) NOT NULL,
  `concepto` varchar(100) NOT NULL,
  `descripcion` text DEFAULT NULL,
  `monto` decimal(12,2) NOT NULL,
  `ruta_voucher` text DEFAULT NULL,
  `fecha` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`expense_id`),
  KEY `admin_user_id` (`admin_user_id`),
  CONSTRAINT `admin_expenses_ibfk_1` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `admin_expenses`
--

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

--
-- Table structure for table `budgetVouchers`
--

DROP TABLE IF EXISTS `budgetVouchers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `budgetVouchers` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `budget_id` int(10) unsigned DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `budgetVouchers`
--

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

--
-- Table structure for table `check_ins`
--

DROP TABLE IF EXISTS `check_ins`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `check_ins` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `service_order_id` int(11) DEFAULT NULL,
  `contract_id` int(11) DEFAULT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `check_out_at` datetime DEFAULT NULL,
  `latitude` decimal(10,8) DEFAULT NULL,
  `longitude` decimal(11,8) DEFAULT NULL,
  `photo` text NOT NULL,
  `check_out_lat` decimal(10,8) DEFAULT NULL,
  `check_out_lng` decimal(11,8) DEFAULT NULL,
  `check_out_photo` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `ix_checkins_user_date` (`user_id`,`timestamp`),
  KEY `ix_checkins_date` (`timestamp`),
  CONSTRAINT `check_ins_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `check_ins_ibfk_2` FOREIGN KEY (`service_order_id`) REFERENCES `service_orders` (`id_service_order`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `check_ins`
--

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

--
-- Table structure for table `clients`
--

DROP TABLE IF EXISTS `clients`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `clients` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `rfc` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `phone` varchar(15) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `company` varchar(100) DEFAULT NULL,
  `unit_key` varchar(10) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `clients`
--

LOCK TABLES `clients` WRITE;
/*!40000 ALTER TABLE `clients` DISABLE KEYS */;
INSERT INTO `clients` VALUES
(1,'IMSS','ABCD001231XXX','imss@correo.com',NULL,NULL,NULL,NULL,'2026-03-18 02:53:30');
/*!40000 ALTER TABLE `clients` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `concepts`
--

DROP TABLE IF EXISTS `concepts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `concepts` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `quote_id` bigint(20) unsigned NOT NULL,
  `concept` varchar(255) NOT NULL,
  `quantity` decimal(12,2) NOT NULL DEFAULT 0.00,
  `unit_price` decimal(12,2) NOT NULL DEFAULT 0.00,
  `tax_rate` decimal(5,4) NOT NULL DEFAULT 0.1600,
  `subtotal` decimal(14,2) GENERATED ALWAYS AS (`quantity` * `unit_price`) STORED,
  `iva` decimal(14,2) GENERATED ALWAYS AS (round(`quantity` * `unit_price` * `tax_rate`,2)) STORED,
  `total` decimal(14,2) GENERATED ALWAYS AS (round(`quantity` * `unit_price` + `quantity` * `unit_price` * `tax_rate`,2)) STORED,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_concepts_quote_id` (`quote_id`),
  CONSTRAINT `fk_concepts_quote` FOREIGN KEY (`quote_id`) REFERENCES `quote` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `CONSTRAINT_1` CHECK (`quantity` >= 0),
  CONSTRAINT `CONSTRAINT_2` CHECK (`unit_price` >= 0),
  CONSTRAINT `CONSTRAINT_3` CHECK (`tax_rate` >= 0 and `tax_rate` <= 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `concepts`
--

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

--
-- Table structure for table `contract_assignees`
--

DROP TABLE IF EXISTS `contract_assignees`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_assignees` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `role` varchar(50) DEFAULT NULL,
  `is_primary` tinyint(1) NOT NULL DEFAULT 0,
  `assigned_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_contract_user` (`contract_id`,`user_id`),
  KEY `idx_contract` (`contract_id`),
  KEY `idx_user` (`user_id`),
  KEY `idx_ca_user_contract` (`user_id`,`contract_id`),
  KEY `idx_ca_contract_user` (`contract_id`,`user_id`),
  CONSTRAINT `fk_ca_contract` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_ca_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_assignees`
--

LOCK TABLES `contract_assignees` WRITE;
/*!40000 ALTER TABLE `contract_assignees` DISABLE KEYS */;
INSERT INTO `contract_assignees` VALUES
(1,1,26,'engineer',1,'2026-03-17 20:54:11');
/*!40000 ALTER TABLE `contract_assignees` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contract_document_types`
--

DROP TABLE IF EXISTS `contract_document_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_document_types` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(50) NOT NULL,
  `name` varchar(150) NOT NULL,
  `allows_multiple` tinyint(1) NOT NULL DEFAULT 0,
  `is_system` tinyint(1) NOT NULL DEFAULT 0,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_cdt_code` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_document_types`
--

LOCK TABLES `contract_document_types` WRITE;
/*!40000 ALTER TABLE `contract_document_types` DISABLE KEYS */;
INSERT INTO `contract_document_types` VALUES
(2,'xml_factura','xml_factura',0,0,1,'2026-03-18 23:14:55');
/*!40000 ALTER TABLE `contract_document_types` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contract_documents`
--

DROP TABLE IF EXISTS `contract_documents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_documents` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `contract_round_id` int(10) unsigned DEFAULT NULL,
  `document_type_id` int(10) unsigned DEFAULT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `uploaded_by` int(11) NOT NULL,
  `uploaded_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_contract` (`contract_id`),
  KEY `fk_cdocs_user` (`uploaded_by`),
  KEY `fk_cdocs_type` (`document_type_id`),
  KEY `idx_cdocs_round` (`contract_round_id`),
  CONSTRAINT `fk_cdocs_contract` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_cdocs_round` FOREIGN KEY (`contract_round_id`) REFERENCES `contract_rounds` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_cdocs_type` FOREIGN KEY (`document_type_id`) REFERENCES `contract_document_types` (`id`),
  CONSTRAINT `fk_cdocs_user` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_documents`
--

LOCK TABLES `contract_documents` WRITE;
/*!40000 ALTER TABLE `contract_documents` DISABLE KEYS */;
INSERT INTO `contract_documents` VALUES
(2,1,1,2,'SOLICITUD 236103 DTDI XALAPA DACIA.xml','/uploads/contracts/1/doc-1773875714167-22745289.xml',1,'2026-03-18 17:15:14');
/*!40000 ALTER TABLE `contract_documents` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contract_required_documents`
--

DROP TABLE IF EXISTS `contract_required_documents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_required_documents` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `contract_round_id` int(10) unsigned DEFAULT NULL,
  `document_type_id` int(10) unsigned NOT NULL,
  `is_required` tinyint(1) NOT NULL DEFAULT 0,
  `sort_order` int(11) DEFAULT 1,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_crd_type` (`document_type_id`) USING BTREE,
  KEY `idx_crd_round` (`contract_round_id`) USING BTREE,
  CONSTRAINT `fk_crd_round` FOREIGN KEY (`contract_round_id`) REFERENCES `contract_rounds` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_crd_type` FOREIGN KEY (`document_type_id`) REFERENCES `contract_document_types` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_required_documents`
--

LOCK TABLES `contract_required_documents` WRITE;
/*!40000 ALTER TABLE `contract_required_documents` DISABLE KEYS */;
INSERT INTO `contract_required_documents` VALUES
(5,1,2,0,9999,1,'2026-03-18 23:16:48'),
(6,2,2,1,9999,1,'2026-03-18 23:16:48');
/*!40000 ALTER TABLE `contract_required_documents` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contract_rounds`
--

DROP TABLE IF EXISTS `contract_rounds`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_rounds` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `sort_order` int(11) NOT NULL DEFAULT 1,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_cr_contract` (`contract_id`),
  CONSTRAINT `fk_cr_contract` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_rounds`
--

LOCK TABLES `contract_rounds` WRITE;
/*!40000 ALTER TABLE `contract_rounds` DISABLE KEYS */;
INSERT INTO `contract_rounds` VALUES
(1,1,'PARTIDA 1',1,1,'2026-03-18 23:13:47'),
(2,1,'PARTIDA 2',2,1,'2026-03-18 23:16:40');
/*!40000 ALTER TABLE `contract_rounds` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contract_transfers`
--

DROP TABLE IF EXISTS `contract_transfers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_transfers` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `from_user_id` int(11) DEFAULT NULL,
  `to_user_id` int(11) NOT NULL,
  `reason` varchar(300) DEFAULT NULL,
  `transferred_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_ct_contract` (`contract_id`),
  KEY `idx_ct_from` (`from_user_id`),
  KEY `idx_ct_to` (`to_user_id`),
  CONSTRAINT `fk_ct_contract` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_ct_from_user_nullable_20251012` FOREIGN KEY (`from_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_ct_to_user` FOREIGN KEY (`to_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_transfers`
--

LOCK TABLES `contract_transfers` WRITE;
/*!40000 ALTER TABLE `contract_transfers` DISABLE KEYS */;
INSERT INTO `contract_transfers` VALUES
(1,1,NULL,26,'Asignación múltiple','2026-03-17 20:54:11');
/*!40000 ALTER TABLE `contract_transfers` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contract_xml_invoices`
--

DROP TABLE IF EXISTS `contract_xml_invoices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_xml_invoices` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `contract_round_id` int(10) unsigned DEFAULT NULL,
  `contract_document_id` bigint(20) unsigned DEFAULT NULL,
  `invoice_ref` varchar(100) DEFAULT NULL,
  `uuid` char(36) DEFAULT NULL,
  `amount` decimal(14,2) NOT NULL,
  `amount_source` enum('xml','manual') NOT NULL DEFAULT 'xml',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_cxi_uuid` (`uuid`),
  KEY `idx_cxi_contract` (`contract_id`),
  KEY `idx_cxi_round` (`contract_round_id`),
  KEY `idx_cxi_doc` (`contract_document_id`),
  CONSTRAINT `fk_cxi_contract` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_cxi_document` FOREIGN KEY (`contract_document_id`) REFERENCES `contract_documents` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_cxi_round` FOREIGN KEY (`contract_round_id`) REFERENCES `contract_rounds` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contract_xml_invoices`
--

LOCK TABLES `contract_xml_invoices` WRITE;
/*!40000 ALTER TABLE `contract_xml_invoices` DISABLE KEYS */;
INSERT INTO `contract_xml_invoices` VALUES
(1,1,1,2,NULL,'5ED770E1-8AD2-4F75-97D7-8E3C953C7D26',1380.40,'xml','2026-03-18 23:15:14');
/*!40000 ALTER TABLE `contract_xml_invoices` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `contracts`
--

DROP TABLE IF EXISTS `contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `contracts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_id` int(11) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `owner_user_id` int(11) DEFAULT NULL,
  `folio` varchar(50) NOT NULL,
  `dependency_contract_number` varchar(100) DEFAULT NULL,
  `place` varchar(150) DEFAULT NULL,
  `delegation` varchar(120) DEFAULT NULL,
  `municipality` varchar(120) DEFAULT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `total_amount` decimal(14,2) NOT NULL DEFAULT 0.00,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `status` enum('Borrador','Firmado','Activo','Finalizado','Cancelado') DEFAULT 'Borrador',
  `finalized_at` datetime DEFAULT NULL,
  `document_path` varchar(255) DEFAULT NULL,
  `signature_path` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `folio` (`folio`),
  UNIQUE KEY `folio_2` (`folio`),
  KEY `fk_contracts_client` (`client_id`),
  KEY `fk_contracts_user` (`created_by`),
  KEY `idx_contracts_owner` (`owner_user_id`),
  KEY `idx_contracts_created_at` (`created_at`),
  CONSTRAINT `fk_contracts_client` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_contracts_owner` FOREIGN KEY (`owner_user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `fk_contracts_user` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `contracts`
--

LOCK TABLES `contracts` WRITE;
/*!40000 ALTER TABLE `contracts` DISABLE KEYS */;
INSERT INTO `contracts` VALUES
(1,1,1,26,'CONT-260317-001','1','PENDIENTE','PENDIENTE','PENDIENTE','CONTRATO-1','CONTRATO DE PRUEBA',15000.00,'2026-03-17','2026-12-31','Borrador',NULL,NULL,NULL,'2026-03-18 02:53:58'),
(2,1,1,1,'CONT-260317-002','2','PENDIENTE','PENDIENTE','PENDIENTE','CONTRATO-2','PRUEBA',20000.00,'2026-03-17','2026-03-31','Borrador',NULL,NULL,NULL,'2026-03-18 02:55:04');
/*!40000 ALTER TABLE `contracts` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `daily_report_photos`
--

DROP TABLE IF EXISTS `daily_report_photos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `daily_report_photos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `report_id` int(11) NOT NULL,
  `photo_url` varchar(512) NOT NULL,
  `sort_order` int(11) NOT NULL DEFAULT 1,
  `caption` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_drp_report_order` (`report_id`,`sort_order`),
  KEY `idx_drp_report` (`report_id`),
  CONSTRAINT `fk_drp_report` FOREIGN KEY (`report_id`) REFERENCES `daily_reports` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `daily_report_photos`
--

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

--
-- Table structure for table `daily_reports`
--

DROP TABLE IF EXISTS `daily_reports`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `daily_reports` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `engineer_id` int(11) NOT NULL,
  `service_order_id` int(11) DEFAULT NULL,
  `report_date` date NOT NULL DEFAULT curdate(),
  `unidad_aplicativa` varchar(100) DEFAULT NULL,
  `direccion` varchar(255) DEFAULT NULL,
  `equipo` varchar(100) DEFAULT NULL,
  `inventario` varchar(50) DEFAULT NULL,
  `marca` varchar(50) DEFAULT NULL,
  `serie` varchar(50) DEFAULT NULL,
  `modelo` varchar(50) DEFAULT NULL,
  `ubicacion` varchar(100) DEFAULT NULL,
  `activities` text DEFAULT NULL,
  `observations` text DEFAULT NULL,
  `codigo` varchar(50) DEFAULT NULL,
  `descripcion` varchar(255) DEFAULT NULL,
  `cantidad` int(11) DEFAULT 0,
  `refacciones` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`refacciones`)),
  `signature_url` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `hr_person_id` int(11) DEFAULT NULL,
  `printed_person_name` varchar(205) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `service_order_id` (`service_order_id`),
  KEY `idx_contract_id` (`contract_id`),
  KEY `idx_engineer_id` (`engineer_id`),
  KEY `idx_report_date` (`report_date`),
  KEY `fk_dr_hr_person` (`hr_person_id`),
  FULLTEXT KEY `idx_text_fields` (`activities`,`observations`,`equipo`,`descripcion`),
  CONSTRAINT `daily_reports_ibfk_1` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `daily_reports_ibfk_2` FOREIGN KEY (`engineer_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `daily_reports_ibfk_3` FOREIGN KEY (`service_order_id`) REFERENCES `service_orders` (`id_service_order`) ON DELETE SET NULL,
  CONSTRAINT `fk_dr_hr_person` FOREIGN KEY (`hr_person_id`) REFERENCES `hr_person` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `daily_reports`
--

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

--
-- Table structure for table `diagnostic_photos`
--

DROP TABLE IF EXISTS `diagnostic_photos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `diagnostic_photos` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `diagnostic_sheet_id` bigint(20) unsigned NOT NULL,
  `photo_path` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_sheet` (`diagnostic_sheet_id`),
  CONSTRAINT `fk_photo_sheet` FOREIGN KEY (`diagnostic_sheet_id`) REFERENCES `diagnostic_sheets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `diagnostic_photos`
--

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

--
-- Table structure for table `diagnostic_sheets`
--

DROP TABLE IF EXISTS `diagnostic_sheets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `diagnostic_sheets` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `folio` varchar(30) NOT NULL,
  `fecha` date NOT NULL,
  `unidad_aplicativa` varchar(255) NOT NULL,
  `direccion` varchar(255) NOT NULL,
  `equipo` varchar(255) NOT NULL,
  `inventario` varchar(100) NOT NULL,
  `marca` varchar(100) NOT NULL,
  `serie` varchar(100) NOT NULL,
  `modelo` varchar(100) NOT NULL,
  `ubicacion` varchar(255) NOT NULL,
  `diagnostico` text NOT NULL,
  `id_user` int(10) unsigned NOT NULL,
  `contract_id` int(10) unsigned DEFAULT NULL,
  `state` varchar(50) NOT NULL DEFAULT 'BORRADOR',
  `firma_ing` varchar(255) DEFAULT NULL,
  `firma_responsable` varchar(255) 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 `folio` (`folio`),
  KEY `idx_folio` (`folio`),
  KEY `idx_fecha` (`fecha`),
  KEY `idx_user` (`id_user`),
  KEY `idx_contract` (`contract_id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `diagnostic_sheets`
--

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

--
-- Table structure for table `engineer_inventory`
--

DROP TABLE IF EXISTS `engineer_inventory`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `engineer_inventory` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) NOT NULL,
  `engineer_id` int(11) NOT NULL,
  `contract_ref` varchar(100) DEFAULT NULL,
  `quantity` int(11) NOT NULL DEFAULT 1,
  `date_assigned` timestamp NULL DEFAULT current_timestamp(),
  `expected_return` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_engineer_item_contract` (`engineer_id`,`item_id`,`contract_ref`),
  KEY `item_id` (`item_id`),
  CONSTRAINT `engineer_inventory_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `inventory_items` (`id`),
  CONSTRAINT `engineer_inventory_ibfk_2` FOREIGN KEY (`engineer_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `engineer_inventory`
--

LOCK TABLES `engineer_inventory` WRITE;
/*!40000 ALTER TABLE `engineer_inventory` DISABLE KEYS */;
INSERT INTO `engineer_inventory` VALUES
(1,1,26,'CONT-260317-001',1,'2026-03-20 16:10:34','2026-03-28'),
(2,2,26,'CONT-260317-001',1,'2026-03-20 16:19:41','2026-03-20');
/*!40000 ALTER TABLE `engineer_inventory` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `expenses`
--

DROP TABLE IF EXISTS `expenses`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `expenses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) NOT NULL,
  `concept` varchar(255) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `date` date NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `contract_id` (`contract_id`),
  CONSTRAINT `expenses_ibfk_1` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `expenses`
--

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

--
-- Table structure for table `finances`
--

DROP TABLE IF EXISTS `finances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `finances` (
  `finance_id` int(11) NOT NULL AUTO_INCREMENT,
  `admin_expense_id` int(11) NOT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `date_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`finance_id`),
  KEY `fund_transaction_id` (`admin_expense_id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `finances`
--

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

--
-- Table structure for table `fund_transactions`
--

DROP TABLE IF EXISTS `fund_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `fund_transactions` (
  `transaction_id` int(11) NOT NULL AUTO_INCREMENT,
  `fund_id` int(11) NOT NULL,
  `type_` enum('ABONO','GASTO') NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `crt_time` datetime DEFAULT current_timestamp(),
  `description` text DEFAULT NULL,
  `concept` text DEFAULT NULL,
  `admin_user_id` int(11) DEFAULT NULL,
  `tipo_pago` varchar(255) DEFAULT NULL,
  `nombre_rh` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`transaction_id`),
  KEY `fund_id` (`fund_id`),
  KEY `admin_user_id` (`admin_user_id`),
  CONSTRAINT `fund_transactions_ibfk_1` FOREIGN KEY (`fund_id`) REFERENCES `funds` (`fund_id`),
  CONSTRAINT `fund_transactions_ibfk_2` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `fund_transactions`
--

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

--
-- Table structure for table `funds`
--

DROP TABLE IF EXISTS `funds`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `funds` (
  `fund_id` int(11) NOT NULL AUTO_INCREMENT,
  `technician_user_id` int(11) NOT NULL,
  `contract_id` int(11) NOT NULL,
  `initial_amount` decimal(12,2) NOT NULL,
  `current_amount` decimal(12,2) NOT NULL,
  `crt_date` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`fund_id`),
  KEY `idx_funds_tech_contract` (`technician_user_id`,`contract_id`),
  KEY `idx_funds_contract_tech` (`contract_id`,`technician_user_id`),
  CONSTRAINT `funds_ibfk_1` FOREIGN KEY (`technician_user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `funds_ibfk_2` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `funds`
--

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

--
-- Table structure for table `history_service_orders`
--

DROP TABLE IF EXISTS `history_service_orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `history_service_orders` (
  `id_h_so` int(11) NOT NULL AUTO_INCREMENT,
  `id_ing` int(11) DEFAULT NULL,
  `sealed_service_order` varchar(50) DEFAULT NULL,
  `create_at` date DEFAULT curdate(),
  PRIMARY KEY (`id_h_so`),
  UNIQUE KEY `id_h_so` (`id_h_so`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `history_service_orders`
--

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

--
-- Table structure for table `hr_document`
--

DROP TABLE IF EXISTS `hr_document`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hr_document` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `person_id` int(11) NOT NULL,
  `document_type_id` int(11) NOT NULL,
  `status` enum('PENDING','RECEIVED','REJECTED','EXPIRED') NOT NULL DEFAULT 'PENDING',
  `issue_date` date DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `is_current` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `fk_hr_document_type` (`document_type_id`),
  KEY `idx_hr_doc_person_type` (`person_id`,`document_type_id`,`is_current`),
  KEY `idx_hr_doc_expiry` (`expiry_date`),
  KEY `idx_hr_doc_person_type_iscurrent` (`person_id`,`document_type_id`,`is_current`),
  KEY `idx_hr_doc_expiry_date` (`expiry_date`),
  CONSTRAINT `fk_hr_document_person` FOREIGN KEY (`person_id`) REFERENCES `hr_person` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_hr_document_type` FOREIGN KEY (`document_type_id`) REFERENCES `hr_document_type` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `hr_document`
--

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

--
-- Table structure for table `hr_document_file`
--

DROP TABLE IF EXISTS `hr_document_file`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hr_document_file` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `document_id` int(11) NOT NULL,
  `side` enum('FRONT','BACK','SINGLE','OTHER') NOT NULL DEFAULT 'SINGLE',
  `file_url` varchar(255) NOT NULL,
  `checksum_md5` char(32) DEFAULT NULL,
  `uploaded_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_hr_document_file_doc` (`document_id`),
  KEY `idx_hr_doc_file_doc` (`document_id`),
  CONSTRAINT `fk_hr_document_file_doc` FOREIGN KEY (`document_id`) REFERENCES `hr_document` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `hr_document_file`
--

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

--
-- Table structure for table `hr_document_type`
--

DROP TABLE IF EXISTS `hr_document_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hr_document_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(40) NOT NULL,
  `name` varchar(120) NOT NULL,
  `requires_both_sides` tinyint(1) NOT NULL DEFAULT 0,
  `allows_multiple` tinyint(1) NOT NULL DEFAULT 0,
  `requires_expiry` tinyint(1) NOT NULL DEFAULT 0,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `sort_order` int(11) DEFAULT 9999,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_hr_document_type_code` (`code`),
  KEY `idx_hr_document_type_active` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `hr_document_type`
--

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

--
-- Table structure for table `hr_person`
--

DROP TABLE IF EXISTS `hr_person`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hr_person` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `employee_code` varchar(30) NOT NULL,
  `first_name` varchar(100) NOT NULL,
  `last_name` varchar(100) NOT NULL,
  `phone` varchar(30) DEFAULT NULL,
  `email` varchar(150) DEFAULT NULL,
  `position` varchar(150) DEFAULT NULL,
  `signature_data` mediumtext DEFAULT NULL,
  `photo_url` varchar(255) DEFAULT NULL,
  `status` enum('ACTIVE','INACTIVE') NOT NULL DEFAULT 'ACTIVE',
  `user_id` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uq_hr_person_employee_code` (`employee_code`),
  UNIQUE KEY `uq_hr_person_user_id` (`user_id`),
  CONSTRAINT `fk_hr_person_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `hr_person`
--

LOCK TABLES `hr_person` WRITE;
/*!40000 ALTER TABLE `hr_person` DISABLE KEYS */;
INSERT INTO `hr_person` VALUES
(1,'001','DOMINIC JOSAFAT','VALDES GASCA','2294797622','dom@gmail.com',NULL,NULL,NULL,'ACTIVE',NULL,'2026-03-17 05:48:27','2026-03-23 01:33:53'),
(2,'003','Gabriel ','Diaz Rosales','','gabriel@correo.com','INGENIEROS DE SERVICIOS','',NULL,'ACTIVE',26,'2026-03-23 01:02:57','2026-03-23 02:10:53'),
(9,'222','Alberto','Sánchez','','alsanchezbeltran@gmail.com','CORDINACION DE PROYECTOS','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiYAAACWCAYAAADqm0MaAAAflUlEQVR4Xu2dCbi1U9nHbx9FyBwqigqRNEcRknkqQ4pQiddQpiQyj72mkCmFpIwJZQqRhFDSgCaUimgwNQv1fb/Wtb797Ofsc/Y+e5/jXfs8v/u6zvW+Z+/nWc9av7Wva//Pve5hpv/8n4UmAQlIQAISkIAECiAwk8KkgF1wChKQgAQkIAEJ/JeAwsQPggQkIAEJSEACxRBQmBSzFU5EAhKQgAQkIAGFiZ8BCUhAAhKQgASKIaAwKWYrnIgEJCABCUhAAgoTPwMSkIAEJCABCRRDQGFSzFY4EQlIQAISkIAEFCZ+BiQgAQlIQAISKIaAwqSYrXAiEpCABCQgAQkoTPwMSEACEpCABCRQDAGFSTFb4UQkIAEJSEACElCY+BmQgAQkIAEJSKAYAgqTYrbCiUhAAhKQgAQkoDDxMyABCUhAAhKQQDEEFCbFbIUTkYAEJCABCUhAYeJnQAISkIAEJCCBYggoTIrZCiciAQlIQAISkIDCxM+ABCQgAQlIQALFEFCYFLMVTkQCEpCABCQgAYWJnwEJSEACEpCABIohoDApZiuciAQkIAEJSEACChM/Ax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ZCQgAQlIQALNJqAwafb+u3oJSEACEpBAUQQUJkVth5ORgAQkIAEJNJuAwqTZ++/qJSABCUhAAkURUJgUtR1ORgISkIAEJNBsAgqTZu+/q5eABCQgAQkURUBhUtR2OBkJSEACEpBAswkoTJq9/65eAhKQgAQkUBQBhUlR2+FkJCABCUhAAs0moDBp9v67eglIQAISkEBRBBQmRW2Hk5GABCQgAQk0m4DCpNn77+olIAEJSEACRRFQmBS1HU5GAhKQgAQk0GwCCpNm77+rl4AEJCABCRRFQGFS1HY4GQlIQAISkECzCShMmr3/rl4CEpCABCRQFAGFSVHb4WQkIAEJSEACzSbwv8VG6MZvHMR0AAAAAElFTkSuQmCC',NULL,'ACTIVE',1,'2026-03-23 01:33:47','2026-03-23 01:55:14');
/*!40000 ALTER TABLE `hr_person` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `hr_user_assignment_history`
--

DROP TABLE IF EXISTS `hr_user_assignment_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hr_user_assignment_history` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `person_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `action` enum('ASSIGN','UNASSIGN') NOT NULL,
  `happened_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `actor_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_uah_person` (`person_id`,`happened_at`),
  KEY `idx_uah_user` (`user_id`,`happened_at`),
  KEY `fk_uah_actor` (`actor_id`),
  CONSTRAINT `fk_uah_actor` FOREIGN KEY (`actor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_uah_person` FOREIGN KEY (`person_id`) REFERENCES `hr_person` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_uah_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `hr_user_assignment_history`
--

LOCK TABLES `hr_user_assignment_history` WRITE;
/*!40000 ALTER TABLE `hr_user_assignment_history` DISABLE KEYS */;
INSERT INTO `hr_user_assignment_history` VALUES
(1,1,1,'ASSIGN','2026-03-17 05:48:46',NULL),
(2,2,26,'ASSIGN','2026-03-23 01:03:08',NULL),
(3,1,1,'UNASSIGN','2026-03-23 01:33:53',NULL),
(4,9,1,'ASSIGN','2026-03-23 01:34:00',NULL);
/*!40000 ALTER TABLE `hr_user_assignment_history` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inventory_items`
--

DROP TABLE IF EXISTS `inventory_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inventory_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `type` enum('vehículo','herramienta','consumible') NOT NULL,
  `description` text DEFAULT NULL,
  `serial_number` varchar(50) DEFAULT NULL,
  `stock` int(11) NOT NULL DEFAULT 0,
  `storage_location` varchar(120) DEFAULT NULL,
  `image_url` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_inventory_items_storage_location` (`storage_location`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inventory_items`
--

LOCK TABLES `inventory_items` WRITE;
/*!40000 ALTER TABLE `inventory_items` DISABLE KEYS */;
INSERT INTO `inventory_items` VALUES
(1,'TALADRO','herramienta','TALADRO TRUPER SEMINUEVO','21412421',1,'GABETA 1','/uploads/Inventory/image-1774023018294-575233736.jpg','2026-03-20 16:10:18','2026-03-20 10:10:34'),
(2,'TOYOTA COROLLA','vehículo','CARRO SEMINUEVO','43248',0,'LOTE 4','/uploads/Inventory/image-1774023393903-870974513.jpeg','2026-03-20 16:16:33','2026-03-20 10:19:41');
/*!40000 ALTER TABLE `inventory_items` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inventory_movement_signatures`
--

DROP TABLE IF EXISTS `inventory_movement_signatures`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inventory_movement_signatures` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `movement_id` int(11) NOT NULL,
  `signed_by` int(11) DEFAULT NULL,
  `signature_url` text NOT NULL,
  `signed_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_movement_signature` (`movement_id`),
  CONSTRAINT `inventory_movement_signatures_ibfk_1` FOREIGN KEY (`movement_id`) REFERENCES `inventory_movements` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inventory_movement_signatures`
--

LOCK TABLES `inventory_movement_signatures` WRITE;
/*!40000 ALTER TABLE `inventory_movement_signatures` DISABLE KEYS */;
INSERT INTO `inventory_movement_signatures` VALUES
(1,1,1,'/uploads/signatures/f8f6247e-c6b6-4f67-b80d-bc80acec51fd.png','2026-03-20 10:10:37'),
(2,2,1,'/uploads/signatures/5df5ff45-daaa-4e85-9445-8ce6c8920413.png','2026-03-20 10:21:56');
/*!40000 ALTER TABLE `inventory_movement_signatures` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inventory_movements`
--

DROP TABLE IF EXISTS `inventory_movements`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inventory_movements` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) NOT NULL,
  `type` enum('entrada','salida','devolución') NOT NULL,
  `quantity` int(11) NOT NULL,
  `engineer_id` int(11) DEFAULT NULL,
  `reason` text DEFAULT NULL,
  `contract_ref` varchar(100) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `status` enum('activo','cancelado') NOT NULL DEFAULT 'activo',
  `canceled_at` datetime DEFAULT NULL,
  `canceled_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `item_id` (`item_id`),
  KEY `engineer_id` (`engineer_id`),
  KEY `fk_inventory_movements_canceled_by` (`canceled_by`),
  KEY `idx_inventory_movements_contract_ref` (`contract_ref`),
  CONSTRAINT `fk_inventory_movements_canceled_by` FOREIGN KEY (`canceled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `inventory_movements_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `inventory_items` (`id`),
  CONSTRAINT `inventory_movements_ibfk_2` FOREIGN KEY (`engineer_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inventory_movements`
--

LOCK TABLES `inventory_movements` WRITE;
/*!40000 ALTER TABLE `inventory_movements` DISABLE KEYS */;
INSERT INTO `inventory_movements` VALUES
(1,1,'salida',1,26,'Asignación de herramienta','CONT-260317-001','2026-03-20 16:10:34','activo',NULL,NULL),
(2,2,'salida',1,26,'Asignación de vehículo','CONT-260317-001','2026-03-20 16:19:41','activo',NULL,NULL);
/*!40000 ALTER TABLE `inventory_movements` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `little_box`
--

DROP TABLE IF EXISTS `little_box`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `little_box` (
  `petty_cash_id` int(11) NOT NULL AUTO_INCREMENT,
  `admin_user_id` int(11) NOT NULL,
  `initial_amount` decimal(12,2) NOT NULL,
  `current_amount` decimal(12,2) NOT NULL,
  `create_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`petty_cash_id`),
  KEY `admin_user_id` (`admin_user_id`),
  CONSTRAINT `little_box_ibfk_1` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `little_box`
--

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

--
-- Table structure for table `quote`
--

DROP TABLE IF EXISTS `quote`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `quote` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `quote_date` date NOT NULL,
  `location` varchar(100) DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `entity` varchar(200) DEFAULT NULL,
  `sender` varchar(150) DEFAULT NULL,
  `department` varchar(200) DEFAULT NULL,
  `equipment` text DEFAULT NULL,
  `terms_and_conditions` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_quote_date` (`quote_date`),
  KEY `idx_location` (`location`),
  KEY `idx_entity` (`entity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `quote`
--

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

--
-- Table structure for table `roles_permissions`
--

DROP TABLE IF EXISTS `roles_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `roles_permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role` enum('admin','engineer','technician') NOT NULL,
  `permission` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `roles_permissions`
--

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

--
-- Table structure for table `service_orders`
--

DROP TABLE IF EXISTS `service_orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `service_orders` (
  `id_service_order` int(11) NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) DEFAULT NULL,
  `folio` varchar(50) DEFAULT NULL,
  `fecha` date DEFAULT NULL,
  `unidad_aplicativa` varchar(50) DEFAULT NULL,
  `direccion` varchar(100) DEFAULT NULL,
  `equipo` varchar(50) DEFAULT NULL,
  `inventario` varchar(45) DEFAULT NULL,
  `marca` varchar(50) DEFAULT NULL,
  `serie` varchar(35) DEFAULT NULL,
  `modelo` varchar(45) DEFAULT NULL,
  `ubicacion` varchar(60) DEFAULT NULL,
  `tipo_de_servicio` varchar(60) DEFAULT NULL,
  `procedimiento` varchar(1000) DEFAULT NULL,
  `foto_antes1` varchar(200) DEFAULT NULL,
  `foto_antes2` varchar(200) DEFAULT NULL,
  `foto_antes3` varchar(200) DEFAULT NULL,
  `foto_durante1` varchar(200) DEFAULT NULL,
  `foto_durante2` varchar(200) DEFAULT NULL,
  `foto_durante3` varchar(200) DEFAULT NULL,
  `foto_despues1` varchar(200) DEFAULT NULL,
  `foto_despues2` varchar(200) DEFAULT NULL,
  `foto_despues3` varchar(200) DEFAULT NULL,
  `creado` date DEFAULT NULL,
  `hora` varchar(15) DEFAULT NULL,
  `id_ing` int(11) DEFAULT NULL,
  `form_parameters` longtext DEFAULT NULL CHECK (json_valid(`form_parameters`)),
  `service_order_sheet_route` text DEFAULT NULL,
  `state` varchar(255) DEFAULT NULL,
  `type_` varchar(255) DEFAULT NULL,
  `so_param_type` varchar(255) DEFAULT NULL,
  `folio_base` varchar(50) DEFAULT NULL,
  `observaciones` varchar(1000) DEFAULT NULL,
  PRIMARY KEY (`id_service_order`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `service_orders`
--

LOCK TABLES `service_orders` WRITE;
/*!40000 ALTER TABLE `service_orders` DISABLE KEYS */;
INSERT INTO `service_orders` VALUES
(1,0,'TRI-001-2026','2026-03-17','6','876','7576','56','567','5','75','765','PREVENTIVO','65',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-12','10:15:23',1,NULL,NULL,'FINALIZADO','WARRANTY_SHEET',NULL,'001-2026',NULL),
(2,0,'TRI-002-2026','2026-03-12','UNIDAD 23','AV LEONA VICARIO','CHILLER','12323','LG','456334','PLUS','PISO 2',NULL,'EL EQUIPO ESTA FALLANDO',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-12','11:25:37',1,NULL,NULL,'FINALIZADO','DIAGNOSTIC_SHEET',NULL,'002-2026','TODO BIEN'),
(3,0,'TRI-003-2026','2026-03-16','456','5','45','465','45','4','654','654',NULL,'5',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-16','23:31:30',1,NULL,NULL,'FINALIZADO','DIAGNOSTIC_SHEET',NULL,'003-2026','323'),
(4,0,'TRI-004-2026','2026-03-01','5765','765','867','7','5','6','8765','65',NULL,'76576',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-16','23:59:10',1,NULL,NULL,'FINALIZADO','DIAGNOSTIC_SHEET',NULL,'004-2026','576'),
(5,0,'TRI-005-2026','2026-03-17','768','678','678','678','678','67','86','768',NULL,'7',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-17','00:33:12',1,NULL,NULL,'FINALIZADO','DIAGNOSTIC_SHEET',NULL,'005-2026','6876'),
(6,0,'TRI-006-2026','2026-03-17','576','576','5','46','57','857','67','7',NULL,'786',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-17','00:39:51',1,NULL,NULL,'FINALIZADO','DIAGNOSTIC_SHEET',NULL,'006-2026','86'),
(7,0,'TRI-007-2026','2026-03-17','456','54','6547','656','46','7','7','456467',NULL,'768',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-17','00:49:06',1,NULL,NULL,'FINALIZADO','DIAGNOSTIC_SHEET',NULL,'007-2026','67'),
(8,1,'TRI-008-2026','2026-03-18','1981','PENDIENTE','PENDIENTE','PENDIENTE','PENDIENTE','5555555','2322223','PENDIENTE','[\"INSTALACION\"]','SE REALIZO UN PROCEDIMIENTO',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-17','22:07:11',26,'[]',NULL,'BORRADOR','SERVICE_ORDER',NULL,'008-2026','OBSERVACION 1'),
(9,0,'TRI-009-2026','2026-03-19','577','6565','4654','67','5464','646','6','46',NULL,'756',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-03-19','18:18:00',1,NULL,NULL,'BORRADOR','DIAGNOSTIC_SHEET',NULL,'009-2026','456');
/*!40000 ALTER TABLE `service_orders` 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` text NOT NULL,
  `expiration` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `sessions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

--
-- Table structure for table `sp_debug_log`
--

DROP TABLE IF EXISTS `sp_debug_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `sp_debug_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `invoked_at` datetime DEFAULT NULL,
  `action` varchar(50) DEFAULT NULL,
  `p_id` int(11) DEFAULT NULL,
  `p_name` varchar(100) DEFAULT NULL,
  `p_stock` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `sp_debug_log`
--

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

--
-- Table structure for table `surveys_answers`
--

DROP TABLE IF EXISTS `surveys_answers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `surveys_answers` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `context_id` varchar(50) DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `engineer_name` varchar(255) DEFAULT NULL,
  `rh_name` varchar(255) DEFAULT NULL,
  `snapshot_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`snapshot_json`)),
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `surveys_answers`
--

LOCK TABLES `surveys_answers` WRITE;
/*!40000 ALTER TABLE `surveys_answers` DISABLE KEYS */;
INSERT INTO `surveys_answers` VALUES
(1,'0',NULL,NULL,'MARIO BONOLA','[{\"question\":\"DESEMPEÑO INGENIERO\",\"levels\":5,\"answer\":5},{\"question\":\"LIMPIEZA DEL AREA\",\"levels\":5,\"answer\":5},{\"question\":\"tiempo de ejecucion\",\"levels\":3,\"answer\":3}]','2026-03-17 05:32:10'),
(2,'0',1,'DOMINIC JOSAFAT VALDES GASCA','ROBERTO VASQUEZ','[{\"question\":\"DESEMPEÑO INGENIERO\",\"levels\":5,\"answer\":5},{\"question\":\"LIMPIEZA DEL AREA\",\"levels\":5,\"answer\":4},{\"question\":\"tiempo de ejecucion\",\"levels\":3,\"answer\":3}]','2026-03-17 06:33:12'),
(3,'TRI-006-2026',1,'DOMINIC JOSAFAT VALDES GASCA','PEDRO VELEZ','[{\"question\":\"DESEMPEÑO INGENIERO\",\"levels\":5,\"answer\":2},{\"question\":\"LIMPIEZA DEL AREA\",\"levels\":5,\"answer\":5},{\"question\":\"tiempo de ejecucion\",\"levels\":3,\"answer\":3}]','2026-03-17 06:39:52'),
(4,'TRI-007-2026',1,'DOMINIC JOSAFAT VALDES GASCA','PABLO PEREZ','[{\"question\":\"DESEMPEÑO INGENIERO\",\"levels\":5,\"answer\":5},{\"question\":\"LIMPIEZA DEL AREA\",\"levels\":5,\"answer\":4},{\"question\":\"tiempo de ejecucion\",\"levels\":3,\"answer\":2}]','2026-03-17 06:49:06'),
(5,'1',1,'DOMINIC JOSAFAT VALDES GASCA','Cliente','[{\"question\":\"DESEMPEÑO INGENIERO\",\"levels\":5,\"answer\":5},{\"question\":\"LIMPIEZA DEL AREA\",\"levels\":5,\"answer\":2},{\"question\":\"tiempo de ejecucion\",\"levels\":3,\"answer\":2}]','2026-03-17 07:05:35');
/*!40000 ALTER TABLE `surveys_answers` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `surveys_questions`
--

DROP TABLE IF EXISTS `surveys_questions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `surveys_questions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `question` varchar(255) DEFAULT NULL,
  `levels` int(11) DEFAULT 5,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `surveys_questions`
--

LOCK TABLES `surveys_questions` WRITE;
/*!40000 ALTER TABLE `surveys_questions` DISABLE KEYS */;
INSERT INTO `surveys_questions` VALUES
(1,'PUNTUALIDAD DEL TECNICO',5,'2026-03-24 18:40:31'),
(2,'PRESENTACION E IDENTIFICACION',5,'2026-03-24 18:40:31'),
(3,'TRATO Y ACTITUD',3,'2026-03-24 18:40:31'),
(4,'CONOCIMIENTO TECNICO',5,'2026-03-24 18:40:31'),
(5,'CLARIDAD AL EXPLICAR EL TRABAJO',5,'2026-03-24 18:40:31'),
(6,'ORDEN Y LIMPIEZA',5,'2026-03-24 18:40:31'),
(7,'TIEMPO DE EJECUCION',5,'2026-03-24 18:40:31'),
(8,'FUNCIONAMIENTO POSTERIOR DEL EQUIPO',5,'2026-03-24 18:40:31'),
(9,'TIEMPO DE RESPUESTA',5,'2026-03-24 18:40:31'),
(10,'¿EL TECNICO RESOLVIO COMPLETAMENTE LA SITUACION REPORTADA?',3,'2026-03-24 18:40:31'),
(11,'EN GENERAL, NIVEL DE SATISFACCION',5,'2026-03-24 18:40:31');
/*!40000 ALTER TABLE `surveys_questions` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `termsFinance`
--

DROP TABLE IF EXISTS `termsFinance`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `termsFinance` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `term` text NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `termsFinance`
--

LOCK TABLES `termsFinance` WRITE;
/*!40000 ALTER TABLE `termsFinance` DISABLE KEYS */;
/*!40000 ALTER TABLE `termsFinance` 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(100) NOT NULL,
  `email` varchar(100) NOT NULL,
  `profile_picture` varchar(255) DEFAULT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('admin','engineer','technician') NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `updated_by` int(11) DEFAULT NULL,
  `last_login` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`),
  UNIQUE KEY `unique_email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_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,'Admin','alsanchezbeltran@gmail.com','/uploads/profilePicture-1772602718872-500676084.png','$2b$10$uXLDSJ3UwZKEjZc93w0tCeDKUo834aZ03mARR.IrSGqQLaOHI0KoG','admin','2025-07-30 04:05:21','active',NULL,'2026-03-24 18:35:48',1,'2026-03-24 12:35:48'),
(26,'INGENIERO1','ingeniero1@trimape.com',NULL,'$2b$10$WHEn0eQsBTpxWWAMBHeH1OSEKHPwx78R6c/wZ0PmDSA7sHae2kFAC','engineer','2026-01-08 10:57:58','active',1,'2026-03-20 00:07:08',1,'2026-03-19 18:07:08'),
(27,'ADMIN2','admin2@trimape.com',NULL,'$2b$10$yn3fcLmvdCvRdvNZNfcop.PsC22ev/sUp0naNL3lhNHcNHnXM3MHW','admin','2026-02-04 22:40:24','active',1,'2026-02-17 00:28:51',NULL,'2026-02-16 18:28:51'),
(28,'ADMIN3','admin3@trimape.com',NULL,'$2b$10$2/.4gSrvmlKq1Vg/9541u.qOw1KtWaOi/ZhIDhgqDXqebUY8CwAbm','admin','2026-02-16 23:03:44','active',1,'2026-02-16 23:03:44',NULL,NULL);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Temporary table structure for view `v_user_person`
--

DROP TABLE IF EXISTS `v_user_person`;
/*!50001 DROP VIEW IF EXISTS `v_user_person`*/;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8mb4;
/*!50001 CREATE VIEW `v_user_person` AS SELECT
 1 AS `user_id`,
  1 AS `hr_person_id`,
  1 AS `person_full_name`,
  1 AS `person_status`,
  1 AS `user_name_fallback` */;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `vehicle_movement_data`
--

DROP TABLE IF EXISTS `vehicle_movement_data`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_movement_data` (
  `movement_id` int(11) NOT NULL,
  `inventory_item_id` int(11) NOT NULL,
  `engineer_id` int(11) DEFAULT NULL,
  `event_type` enum('SALIDA','DEVOLUCION') NOT NULL,
  `checks_snapshot_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`checks_snapshot_json`)),
  `contract_ref` varchar(100) DEFAULT NULL,
  `time_out` time DEFAULT NULL,
  `time_in` time DEFAULT NULL,
  `observations` text DEFAULT NULL,
  `route_summary` text DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `authorized_drivers_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  PRIMARY KEY (`movement_id`),
  KEY `idx_vmd_item` (`inventory_item_id`),
  KEY `idx_vmd_engineer` (`engineer_id`),
  KEY `idx_vmd_event` (`event_type`,`created_at`),
  KEY `fk_vmd_created_by` (`created_by`),
  CONSTRAINT `fk_vmd_created_by` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_vmd_engineer` FOREIGN KEY (`engineer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_vmd_item` FOREIGN KEY (`inventory_item_id`) REFERENCES `inventory_items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_vmd_movement` FOREIGN KEY (`movement_id`) REFERENCES `inventory_movements` (`id`) ON DELETE CASCADE,
  CONSTRAINT `authorized_drivers_json_chk` CHECK (`authorized_drivers_json` is null or json_valid(`authorized_drivers_json`))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vehicle_movement_data`
--

LOCK TABLES `vehicle_movement_data` WRITE;
/*!40000 ALTER TABLE `vehicle_movement_data` DISABLE KEYS */;
INSERT INTO `vehicle_movement_data` VALUES
(2,2,26,'SALIDA','{\"P01_UNIDAD_LUCES\":true,\"P02_4_LUCES\":false,\"P03_ANTENA\":false,\"P04_ESPEJO_LATERAL_DERECHO\":false,\"P05_ESPEJO_LATERAL_IZQUIERDO\":false,\"P06_TAPONES_LLANTAS\":false,\"P07_DEFENSA_TRASERA\":false,\"P08_DEFENSA_DELANTERA\":true,\"P09_4_LLANTAS\":false,\"P10_MOLDURAS_COMPLETAS\":false,\"P11_TAPON_GASOLINA\":false,\"P12_GOLPES\":false,\"P13_BOCINAS_CLAXON\":false,\"P14_LODERAS\":false,\"P15_VINILES_ROTULACION\":false,\"P16_LLANTA_REFACCION\":false,\"P17_ESCAPE\":true,\"P18_PUERTA_BATEA\":false,\"P19_BOLA_REMOLQUE\":false,\"P20_GOLPES_CARROCERIA\":false,\"P21_RAYONES_CARROCERIA\":false,\"P22_BOLAS_EN_LLANTAS\":false,\"P23_SEGURO_COFRE\":true,\"P24_PLACA_TRASERA\":false,\"P25_PLACA_DELANTERA\":false,\"P26_NO_APLICA\":false,\"P27_GATO\":false,\"P28_MANERAL_GATO\":false,\"P29_LLAVE_RUEDAS\":true,\"P30_ESTUCHE_HERRAMIENTA\":false,\"P31_TRIANGULO\":false,\"P32_EXTINGUIDOR\":false,\"P33_VESTIDURAS\":false,\"P34_ESPEJO_RETROVISOR\":false,\"P35_CINTURONES\":false,\"P36_PALANCA\":false,\"P37_ESTEREO\":false,\"P38_CONSOLA_AC\":false,\"P39_LLANTA_REFACCION\":false,\"DOC_CIRCULACION\":true,\"DOC_SEGURO\":true,\"DOC_VERIFICACION\":true}','CONT-260317-001','10:19:00',NULL,'SE ENCUENTRA EN BUEN ESTADO',NULL,1,'2026-03-20 16:21:51','2026-03-20 16:21:51','[{\"name\":\"DOMINIC VALDES\",\"license\":\"324734798\"}]');
/*!40000 ALTER TABLE `vehicle_movement_data` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `vehicle_movement_photos`
--

DROP TABLE IF EXISTS `vehicle_movement_photos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_movement_photos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `movement_id` int(11) NOT NULL,
  `slot` enum('TABLERO_SALIDA','TABLERO_REGRESO','LADO_PASAJERO','LADO_CONDUCTOR','EXTRA_1','EXTRA_2','EXTRA_3','EXTRA_4') NOT NULL,
  `url` varchar(255) NOT NULL,
  `uploaded_by` int(11) DEFAULT NULL,
  `uploaded_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_vehicle_photo_slot` (`movement_id`,`slot`),
  KEY `idx_vehicle_photo_movement` (`movement_id`),
  KEY `fk_vmp_uploaded_by` (`uploaded_by`),
  CONSTRAINT `fk_vmp_movement` FOREIGN KEY (`movement_id`) REFERENCES `inventory_movements` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_vmp_uploaded_by` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vehicle_movement_photos`
--

LOCK TABLES `vehicle_movement_photos` WRITE;
/*!40000 ALTER TABLE `vehicle_movement_photos` DISABLE KEYS */;
INSERT INTO `vehicle_movement_photos` VALUES
(1,2,'TABLERO_SALIDA','/uploads/VehicleLogs/2/TABLERO_SALIDA-1774023712578-0n13x6.jpg',1,'2026-03-20 16:21:52'),
(2,2,'LADO_PASAJERO','/uploads/VehicleLogs/2/LADO_PASAJERO-1774023712590-3ckx7u.png',1,'2026-03-20 16:21:52'),
(3,2,'LADO_CONDUCTOR','/uploads/VehicleLogs/2/LADO_CONDUCTOR-1774023712593-wj7akj.jpeg',1,'2026-03-20 16:21:52'),
(4,2,'EXTRA_1','/uploads/VehicleLogs/2/EXTRA_1-1774023712596-adhm31.jpg',1,'2026-03-20 16:21:52'),
(5,2,'EXTRA_2','/uploads/VehicleLogs/2/EXTRA_2-1774023712597-nc2prr.jpg',1,'2026-03-20 16:21:52');
/*!40000 ALTER TABLE `vehicle_movement_photos` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `vehicle_state`
--

DROP TABLE IF EXISTS `vehicle_state`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_state` (
  `inventory_item_id` int(11) NOT NULL,
  `unit_number` varchar(50) DEFAULT NULL,
  `plates` varchar(20) DEFAULT NULL,
  `checks_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`checks_json`)),
  `notes` text DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`inventory_item_id`),
  KEY `fk_vehicle_state_updated_by` (`updated_by`),
  CONSTRAINT `fk_vehicle_state_item` FOREIGN KEY (`inventory_item_id`) REFERENCES `inventory_items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_vehicle_state_updated_by` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vehicle_state`
--

LOCK TABLES `vehicle_state` WRITE;
/*!40000 ALTER TABLE `vehicle_state` DISABLE KEYS */;
INSERT INTO `vehicle_state` VALUES
(2,'V-0002','VB23023','{\"P01_UNIDAD_LUCES\":true,\"P02_4_LUCES\":false,\"P03_ANTENA\":false,\"P04_ESPEJO_LATERAL_DERECHO\":false,\"P05_ESPEJO_LATERAL_IZQUIERDO\":false,\"P06_TAPONES_LLANTAS\":false,\"P07_DEFENSA_TRASERA\":false,\"P08_DEFENSA_DELANTERA\":true,\"P09_4_LLANTAS\":false,\"P10_MOLDURAS_COMPLETAS\":false,\"P11_TAPON_GASOLINA\":false,\"P12_GOLPES\":false,\"P13_BOCINAS_CLAXON\":false,\"P14_LODERAS\":false,\"P15_VINILES_ROTULACION\":false,\"P16_LLANTA_REFACCION\":false,\"P17_ESCAPE\":true,\"P18_PUERTA_BATEA\":false,\"P19_BOLA_REMOLQUE\":false,\"P20_GOLPES_CARROCERIA\":false,\"P21_RAYONES_CARROCERIA\":false,\"P22_BOLAS_EN_LLANTAS\":false,\"P23_SEGURO_COFRE\":true,\"P24_PLACA_TRASERA\":false,\"P25_PLACA_DELANTERA\":false,\"P26_NO_APLICA\":false,\"P27_GATO\":false,\"P28_MANERAL_GATO\":false,\"P29_LLAVE_RUEDAS\":true,\"P30_ESTUCHE_HERRAMIENTA\":false,\"P31_TRIANGULO\":false,\"P32_EXTINGUIDOR\":false,\"P33_VESTIDURAS\":false,\"P34_ESPEJO_RETROVISOR\":false,\"P35_CINTURONES\":false,\"P36_PALANCA\":false,\"P37_ESTEREO\":false,\"P38_CONSOLA_AC\":false,\"P39_LLANTA_REFACCION\":false,\"DOC_CIRCULACION\":true,\"DOC_SEGURO\":true,\"DOC_VERIFICACION\":true}','SE ENCUENTRA EN BUEN ESTADO',1,'2026-03-20 16:21:51');
/*!40000 ALTER TABLE `vehicle_state` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `vehicles`
--

DROP TABLE IF EXISTS `vehicles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(50) NOT NULL,
  `license_plate` varchar(20) NOT NULL,
  `status` enum('available','assigned','maintenance') DEFAULT 'available',
  `current_mileage` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vehicles`
--

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

--
-- Table structure for table `vouchers`
--

DROP TABLE IF EXISTS `vouchers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vouchers` (
  `voucher_id` int(11) NOT NULL AUTO_INCREMENT,
  `fund_transaction_id` int(11) NOT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `date_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`voucher_id`),
  KEY `fund_transaction_id` (`fund_transaction_id`),
  CONSTRAINT `vouchers_ibfk_1` FOREIGN KEY (`fund_transaction_id`) REFERENCES `fund_transactions` (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vouchers`
--

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

--
-- Final view structure for view `v_user_person`
--

/*!50001 DROP VIEW IF EXISTS `v_user_person`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8mb4 */;
/*!50001 SET character_set_results     = utf8mb4 */;
/*!50001 SET collation_connection      = utf8mb4_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`trimape_admin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `v_user_person` AS with last_action as (select `h`.`user_id` AS `user_id`,`h`.`person_id` AS `person_id`,`h`.`action` AS `action`,`h`.`happened_at` AS `happened_at` from (`hr_user_assignment_history` `h` join (select `hr_user_assignment_history`.`user_id` AS `user_id`,max(`hr_user_assignment_history`.`happened_at`) AS `max_ts` from `hr_user_assignment_history` group by `hr_user_assignment_history`.`user_id`) `m` on(`m`.`user_id` = `h`.`user_id` and `m`.`max_ts` = `h`.`happened_at`)))select `u`.`id` AS `user_id`,coalesce(`hp_direct`.`id`,case when `la`.`action` = 'ASSIGN' then `hp_hist`.`id` end) AS `hr_person_id`,coalesce(`format_person_name`(`hp_direct`.`first_name`,`hp_direct`.`last_name`),case when `la`.`action` = 'ASSIGN' then `format_person_name`(`hp_hist`.`first_name`,`hp_hist`.`last_name`) end) AS `person_full_name`,coalesce(`hp_direct`.`status`,`hp_hist`.`status`) AS `person_status`,`u`.`name` AS `user_name_fallback` from (((`users` `u` left join `hr_person` `hp_direct` on(`hp_direct`.`user_id` = `u`.`id`)) left join `last_action` `la` on(`la`.`user_id` = `u`.`id`)) left join `hr_person` `hp_hist` on(`hp_hist`.`id` = `la`.`person_id`)) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;
/*!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-03-24 12:58:31
