-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Servidor: localhost:3306
-- Tiempo de generación: 30-05-2026 a las 00:06:20
-- Versión del servidor: 10.11.16-MariaDB-cll-lve
-- Versión de PHP: 8.4.21

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


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

--
-- Base de datos: `spum1935_gocar24`
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_abonos`
--

CREATE TABLE `transfer_abonos` (
  `id` int(11) NOT NULL,
  `conductor_id` int(11) NOT NULL,
  `importe` decimal(8,2) DEFAULT 50.00,
  `stripe_pi_id` varchar(64) DEFAULT NULL,
  `estado` enum('pendiente','pagado','fallido') DEFAULT 'pendiente',
  `periodo_desde` date DEFAULT NULL,
  `periodo_hasta` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_conductores`
--

CREATE TABLE `transfer_conductores` (
  `id` int(11) NOT NULL,
  `nombre` varchar(120) NOT NULL,
  `email` varchar(180) NOT NULL,
  `telefono` varchar(30) DEFAULT NULL,
  `direccion` varchar(255) DEFAULT NULL,
  `nif` varchar(20) DEFAULT NULL,
  `password_hash` varchar(255) NOT NULL,
  `foto` varchar(255) DEFAULT NULL,
  `descripcion` text DEFAULT NULL,
  `idiomas` varchar(255) DEFAULT NULL,
  `precio_km` decimal(6,4) DEFAULT 0.3000,
  `online` tinyint(1) DEFAULT 0,
  `verificado` tinyint(1) DEFAULT 0,
  `token` varchar(64) DEFAULT NULL,
  `modalidad_cobro` enum('auto','gestionado') DEFAULT 'gestionado',
  `stripe_account_id` varchar(64) DEFAULT NULL,
  `payout_frecuencia` enum('semanal','quincenal','mensual') DEFAULT 'mensual',
  `valoracion_media` decimal(3,2) DEFAULT 0.00,
  `num_valoraciones` int(11) DEFAULT 0,
  `abono_activo` tinyint(1) DEFAULT 0,
  `abono_expira` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `ubicacion_base_lat` decimal(10,7) DEFAULT NULL,
  `ubicacion_base_lng` decimal(10,7) DEFAULT NULL,
  `ubicacion_base_dir` varchar(255) DEFAULT NULL,
  `ubicacion_temp_lat` decimal(10,7) DEFAULT NULL,
  `ubicacion_temp_lng` decimal(10,7) DEFAULT NULL,
  `ubicacion_temp_dir` varchar(255) DEFAULT NULL,
  `ubicacion_temp_hasta` datetime DEFAULT NULL,
  `radio_operacion_km` int(11) DEFAULT 50,
  `tramo_vacio_politica` enum('gratis','combustible','completo') DEFAULT 'combustible',
  `tramo_vacio_pct` tinyint(4) DEFAULT 40
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_config`
--

CREATE TABLE `transfer_config` (
  `clave` varchar(64) NOT NULL,
  `valor` text NOT NULL,
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `transfer_config`
--

INSERT INTO `transfer_config` (`clave`, `valor`, `updated_at`) VALUES
('demanda_activa', '0', '2026-05-24 11:23:33'),
('demanda_auto', '0', '2026-05-24 11:23:33'),
('demanda_umbral', '10', '2026-05-24 11:23:33'),
('email_admin', '', '2026-05-24 11:23:33'),
('fechas_senaladas', '[]', '2026-05-24 11:23:33'),
('hora_nocturna_fin', '6', '2026-05-24 11:23:33'),
('hora_nocturna_inicio', '22', '2026-05-24 11:23:33'),
('min_horas_reserva', '6', '2026-05-24 11:23:33'),
('precio_demanda', '0.40', '2026-05-24 11:23:33'),
('precio_diurno', '0.19', '2026-05-24 11:23:33'),
('precio_festivo', '0.35', '2026-05-24 11:23:33'),
('precio_nocturno', '0.28', '2026-05-24 11:23:33'),
('stripe_public_key', '', '2026-05-24 11:23:33'),
('stripe_secret_key', '', '2026-05-24 11:23:33'),
('vuelta_porcentaje', '50', '2026-05-24 11:23:33');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_consultas`
--

CREATE TABLE `transfer_consultas` (
  `id` int(11) NOT NULL,
  `ip` varchar(45) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_disponibilidad`
--

CREATE TABLE `transfer_disponibilidad` (
  `id` int(11) NOT NULL,
  `conductor_id` int(11) NOT NULL,
  `fecha` date NOT NULL,
  `tipo` enum('bloqueado','disponible') DEFAULT 'bloqueado',
  `nota` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_horario`
--

CREATE TABLE `transfer_horario` (
  `id` int(11) NOT NULL,
  `conductor_id` int(11) NOT NULL,
  `dia_semana` tinyint(4) NOT NULL COMMENT '0=Lun,1=Mar,...,6=Dom',
  `hora_inicio` time NOT NULL,
  `hora_fin` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_pagos_pendientes`
--

CREATE TABLE `transfer_pagos_pendientes` (
  `id` int(11) NOT NULL,
  `conductor_id` int(11) NOT NULL,
  `reserva_id` int(11) NOT NULL,
  `importe` decimal(8,2) NOT NULL,
  `comision` decimal(8,2) DEFAULT 0.00,
  `importe_neto` decimal(8,2) NOT NULL,
  `estado` enum('pendiente','transferido') DEFAULT 'pendiente',
  `transferido_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_pasajeros`
--

CREATE TABLE `transfer_pasajeros` (
  `id` int(11) NOT NULL,
  `nombre` varchar(120) NOT NULL,
  `email` varchar(180) NOT NULL,
  `telefono` varchar(30) DEFAULT NULL,
  `direccion` varchar(255) DEFAULT NULL,
  `nif` varchar(20) DEFAULT NULL,
  `password_hash` varchar(255) NOT NULL,
  `verificado` tinyint(1) DEFAULT 0,
  `token` varchar(64) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_peajes`
--

CREATE TABLE `transfer_peajes` (
  `id` int(11) NOT NULL,
  `nombre` varchar(100) NOT NULL COMMENT 'Ej: A6 Villefranche',
  `autopista` varchar(20) DEFAULT NULL COMMENT 'Ej: A6, A7, AP7',
  `lat` decimal(10,7) NOT NULL,
  `lng` decimal(10,7) NOT NULL,
  `radio_m` int(11) DEFAULT 500 COMMENT 'Radio de detección en metros',
  `precio` decimal(6,2) NOT NULL COMMENT 'Precio en €',
  `direccion` enum('ambas','norte_sur','sur_norte','este_oeste','oeste_este') DEFAULT 'ambas',
  `pais` varchar(3) DEFAULT 'FR' COMMENT 'Código ISO país',
  `activo` tinyint(1) DEFAULT 1,
  `notas` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `transfer_peajes`
--

INSERT INTO `transfer_peajes` (`id`, `nombre`, `autopista`, `lat`, `lng`, `radio_m`, `precio`, `direccion`, `pais`, `activo`, `notas`, `created_at`, `updated_at`) VALUES
(1, 'Péage de Villefranche', 'A6', 45.9897000, 4.7231000, 500, 3.50, 'ambas', 'FR', 1, NULL, '2026-05-29 23:56:42', '2026-05-29 23:56:42'),
(2, 'Péage de Belleville', 'A6', 46.1089000, 4.7456000, 500, 2.80, 'ambas', 'FR', 1, NULL, '2026-05-29 23:56:42', '2026-05-29 23:56:42'),
(3, 'Péage de Mâcon Nord', 'A6', 46.3201000, 4.8234000, 500, 4.20, 'ambas', 'FR', 1, NULL, '2026-05-29 23:56:42', '2026-05-29 23:56:42'),
(4, 'Péage de Lyon Nord', 'A46', 45.8123000, 4.9876000, 500, 3.10, 'ambas', 'FR', 1, NULL, '2026-05-29 23:56:42', '2026-05-29 23:56:42'),
(5, 'Péage Tunnel de Fourvière', 'A6', 45.7534000, 4.8123000, 500, 3.00, 'ambas', 'FR', 1, NULL, '2026-05-29 23:56:42', '2026-05-29 23:56:42');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_reservas`
--

CREATE TABLE `transfer_reservas` (
  `id` int(11) NOT NULL,
  `conductor_id` int(11) DEFAULT NULL,
  `pasajero_id` int(11) DEFAULT NULL,
  `nombre` varchar(120) NOT NULL,
  `email` varchar(180) NOT NULL,
  `telefono` varchar(30) DEFAULT NULL,
  `origen` text NOT NULL,
  `destino` text NOT NULL,
  `fecha_viaje` datetime NOT NULL,
  `distancia_km` decimal(8,2) DEFAULT NULL,
  `tarifa_tipo` varchar(20) DEFAULT NULL,
  `precio_km` decimal(6,4) DEFAULT NULL,
  `importe` decimal(8,2) NOT NULL,
  `pasajeros` tinyint(4) DEFAULT 1,
  `maletas` tinyint(4) DEFAULT 0,
  `idioma_req` varchar(50) DEFAULT NULL,
  `con_vuelta` tinyint(1) DEFAULT 0,
  `stripe_pi_id` varchar(64) DEFAULT NULL,
  `estado` enum('pendiente','confirmada','cancelada') DEFAULT 'pendiente',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `conductor_lat` decimal(10,7) DEFAULT NULL,
  `conductor_lng` decimal(10,7) DEFAULT NULL,
  `tramo_vacio_km` decimal(8,2) DEFAULT 0.00,
  `tramo_vacio_coste` decimal(8,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_valoraciones`
--

CREATE TABLE `transfer_valoraciones` (
  `id` int(11) NOT NULL,
  `reserva_id` int(11) NOT NULL,
  `de` enum('pasajero','conductor') NOT NULL,
  `puntuacion` tinyint(4) NOT NULL,
  `comentario` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `transfer_vehiculos`
--

CREATE TABLE `transfer_vehiculos` (
  `id` int(11) NOT NULL,
  `conductor_id` int(11) NOT NULL,
  `marca` varchar(60) NOT NULL,
  `modelo` varchar(60) NOT NULL,
  `anio` year(4) DEFAULT NULL,
  `matricula` varchar(20) DEFAULT NULL,
  `color` varchar(30) DEFAULT NULL,
  `plazas` tinyint(4) DEFAULT 4,
  `maleteros` tinyint(4) DEFAULT 2,
  `foto` varchar(255) DEFAULT NULL,
  `activo` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Índices para tablas volcadas
--

--
-- Indices de la tabla `transfer_abonos`
--
ALTER TABLE `transfer_abonos`
  ADD PRIMARY KEY (`id`),
  ADD KEY `conductor_id` (`conductor_id`);

--
-- Indices de la tabla `transfer_conductores`
--
ALTER TABLE `transfer_conductores`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Indices de la tabla `transfer_config`
--
ALTER TABLE `transfer_config`
  ADD PRIMARY KEY (`clave`);

--
-- Indices de la tabla `transfer_consultas`
--
ALTER TABLE `transfer_consultas`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_created` (`created_at`);

--
-- Indices de la tabla `transfer_disponibilidad`
--
ALTER TABLE `transfer_disponibilidad`
  ADD PRIMARY KEY (`id`),
  ADD KEY `conductor_id` (`conductor_id`);

--
-- Indices de la tabla `transfer_horario`
--
ALTER TABLE `transfer_horario`
  ADD PRIMARY KEY (`id`),
  ADD KEY `conductor_id` (`conductor_id`);

--
-- Indices de la tabla `transfer_pagos_pendientes`
--
ALTER TABLE `transfer_pagos_pendientes`
  ADD PRIMARY KEY (`id`),
  ADD KEY `conductor_id` (`conductor_id`),
  ADD KEY `reserva_id` (`reserva_id`);

--
-- Indices de la tabla `transfer_pasajeros`
--
ALTER TABLE `transfer_pasajeros`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Indices de la tabla `transfer_peajes`
--
ALTER TABLE `transfer_peajes`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_activo` (`activo`),
  ADD KEY `idx_pais` (`pais`);

--
-- Indices de la tabla `transfer_reservas`
--
ALTER TABLE `transfer_reservas`
  ADD PRIMARY KEY (`id`),
  ADD KEY `conductor_id` (`conductor_id`),
  ADD KEY `pasajero_id` (`pasajero_id`);

--
-- Indices de la tabla `transfer_valoraciones`
--
ALTER TABLE `transfer_valoraciones`
  ADD PRIMARY KEY (`id`),
  ADD KEY `reserva_id` (`reserva_id`);

--
-- Indices de la tabla `transfer_vehiculos`
--
ALTER TABLE `transfer_vehiculos`
  ADD PRIMARY KEY (`id`),
  ADD KEY `conductor_id` (`conductor_id`);

--
-- AUTO_INCREMENT de las tablas volcadas
--

--
-- AUTO_INCREMENT de la tabla `transfer_abonos`
--
ALTER TABLE `transfer_abonos`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_conductores`
--
ALTER TABLE `transfer_conductores`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_consultas`
--
ALTER TABLE `transfer_consultas`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_disponibilidad`
--
ALTER TABLE `transfer_disponibilidad`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_horario`
--
ALTER TABLE `transfer_horario`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_pagos_pendientes`
--
ALTER TABLE `transfer_pagos_pendientes`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_pasajeros`
--
ALTER TABLE `transfer_pasajeros`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_peajes`
--
ALTER TABLE `transfer_peajes`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT de la tabla `transfer_reservas`
--
ALTER TABLE `transfer_reservas`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_valoraciones`
--
ALTER TABLE `transfer_valoraciones`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de la tabla `transfer_vehiculos`
--
ALTER TABLE `transfer_vehiculos`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `transfer_abonos`
--
ALTER TABLE `transfer_abonos`
  ADD CONSTRAINT `transfer_abonos_ibfk_1` FOREIGN KEY (`conductor_id`) REFERENCES `transfer_conductores` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `transfer_disponibilidad`
--
ALTER TABLE `transfer_disponibilidad`
  ADD CONSTRAINT `transfer_disponibilidad_ibfk_1` FOREIGN KEY (`conductor_id`) REFERENCES `transfer_conductores` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `transfer_horario`
--
ALTER TABLE `transfer_horario`
  ADD CONSTRAINT `transfer_horario_ibfk_1` FOREIGN KEY (`conductor_id`) REFERENCES `transfer_conductores` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `transfer_pagos_pendientes`
--
ALTER TABLE `transfer_pagos_pendientes`
  ADD CONSTRAINT `transfer_pagos_pendientes_ibfk_1` FOREIGN KEY (`conductor_id`) REFERENCES `transfer_conductores` (`id`),
  ADD CONSTRAINT `transfer_pagos_pendientes_ibfk_2` FOREIGN KEY (`reserva_id`) REFERENCES `transfer_reservas` (`id`);

--
-- Filtros para la tabla `transfer_reservas`
--
ALTER TABLE `transfer_reservas`
  ADD CONSTRAINT `transfer_reservas_ibfk_1` FOREIGN KEY (`conductor_id`) REFERENCES `transfer_conductores` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `transfer_reservas_ibfk_2` FOREIGN KEY (`pasajero_id`) REFERENCES `transfer_pasajeros` (`id`) ON DELETE SET NULL;

--
-- Filtros para la tabla `transfer_valoraciones`
--
ALTER TABLE `transfer_valoraciones`
  ADD CONSTRAINT `transfer_valoraciones_ibfk_1` FOREIGN KEY (`reserva_id`) REFERENCES `transfer_reservas` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `transfer_vehiculos`
--
ALTER TABLE `transfer_vehiculos`
  ADD CONSTRAINT `transfer_vehiculos_ibfk_1` FOREIGN KEY (`conductor_id`) REFERENCES `transfer_conductores` (`id`) ON DELETE CASCADE;
COMMIT;

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