diff --git a/citas.php b/citas.php
new file mode 100644
index 0000000..6653581
--- /dev/null
+++ b/citas.php
@@ -0,0 +1,168 @@
+exec("CREATE TABLE IF NOT EXISTS citas (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ fecha DATE NOT NULL,
+ hora TIME NOT NULL,
+ id_departamento INT NOT NULL,
+ lugar VARCHAR(255),
+ usuarios TEXT,
+ estado VARCHAR(50) DEFAULT 'Pendiente',
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (id_departamento) REFERENCES departamentos(id)
+ )");
+
+ // Handle form submission
+ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_cita'])) {
+ $fecha = $_POST['fecha'];
+ $hora = $_POST['hora'];
+ $id_departamento = $_POST['id_departamento'];
+ $lugar = trim($_POST['lugar']);
+ $usuarios = trim($_POST['usuarios']);
+ $estado = $_POST['estado'];
+
+ if (!empty($fecha) && !empty($hora) && !empty($id_departamento)) {
+ $stmt = $pdo->prepare("INSERT INTO citas (fecha, hora, id_departamento, lugar, usuarios, estado) VALUES (?, ?, ?, ?, ?, ?)");
+ $stmt->execute([$fecha, $hora, $id_departamento, $lugar, $usuarios, $estado]);
+ echo '
Cita añadida con éxito.
';
+ } else {
+ echo '
Fecha, hora y departamento son obligatorios.
';
+ }
+ }
+
+ // Fetch all departments for dropdown
+ $departamentos_stmt = $pdo->query("SELECT id, nombre FROM departamentos ORDER BY nombre");
+ $departamentos = $departamentos_stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ // Fetch all citas
+ $stmt = $pdo->query("SELECT c.id, c.fecha, c.hora, dep.nombre as departamento_nombre, c.lugar, c.usuarios, c.estado, c.created_at
+ FROM citas c
+ JOIN departamentos dep ON c.id_departamento = dep.id
+ ORDER BY c.fecha DESC, c.hora DESC");
+ $citas = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+} catch (PDOException $e) {
+ die("Error de base de datos: " . $e->getMessage());
+}
+?>
+
+
+
+
diff --git a/consultas.php b/consultas.php
new file mode 100644
index 0000000..6a12016
--- /dev/null
+++ b/consultas.php
@@ -0,0 +1,149 @@
+exec("CREATE TABLE IF NOT EXISTS consultas (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ id_taxista INT NOT NULL,
+ id_departamento INT NOT NULL,
+ resultado TEXT,
+ fecha_consulta TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (id_taxista) REFERENCES drivers(id),
+ FOREIGN KEY (id_departamento) REFERENCES departamentos(id)
+ )");
+
+ // Handle form submission
+ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_consulta'])) {
+ $id_taxista = $_POST['id_taxista'];
+ $id_departamento = $_POST['id_departamento'];
+ $resultado = trim($_POST['resultado']);
+
+ if (!empty($id_taxista) && !empty($id_departamento)) {
+ $stmt = $pdo->prepare("INSERT INTO consultas (id_taxista, id_departamento, resultado) VALUES (?, ?, ?)");
+ $stmt->execute([$id_taxista, $id_departamento, $resultado]);
+ echo '
Consulta añadida con éxito.
';
+ } else {
+ echo '
Taxista y departamento son obligatorios.
';
+ }
+ }
+
+ // Fetch all drivers for dropdown
+ $drivers_stmt = $pdo->query("SELECT id, name FROM drivers ORDER BY name");
+ $drivers = $drivers_stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ // Fetch all departments for dropdown
+ $departamentos_stmt = $pdo->query("SELECT id, nombre FROM departamentos ORDER BY nombre");
+ $departamentos = $departamentos_stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ // Fetch all consultas
+ $stmt = $pdo->query("SELECT c.id, d.name as taxista_nombre, dep.nombre as departamento_nombre, c.resultado, c.fecha_consulta
+ FROM consultas c
+ JOIN drivers d ON c.id_taxista = d.id
+ JOIN departamentos dep ON c.id_departamento = dep.id
+ ORDER BY c.fecha_consulta DESC");
+ $consultas = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+} catch (PDOException $e) {
+ die("Error de base de datos: " . $e->getMessage());
+}
+?>
+
+