<?php
require_once 'includes/config.php';
$db = getDB();
header('Content-Type: application/json');
$result = [];

// Check tables exist
try {
    $db->query("SELECT 1 FROM drive_packages LIMIT 1");
    $result['drive_packages'] = 'exists';
} catch(Exception $e) { $result['drive_packages'] = 'MISSING: '.$e->getMessage(); }

try {
    $db->query("SELECT 1 FROM drive_requests LIMIT 1");
    $result['drive_requests'] = 'exists';
} catch(Exception $e) { $result['drive_requests'] = 'MISSING'; }

// Check commission.php
$result['commission_file'] = file_exists('includes/commission.php') ? 'exists' : 'MISSING';

// Check drive_requests columns
try {
    $cols = $db->query("SHOW COLUMNS FROM drive_requests")->fetchAll(PDO::FETCH_COLUMN);
    $result['drive_requests_cols'] = $cols;
} catch(Exception $e) { $result['drive_requests_cols'] = 'error'; }

echo json_encode($result, JSON_PRETTY_PRINT);
