<?php
// cek_kapal.php - Cek daftar kapal & rute

require_once 'config/database.php';

$db = Database::getInstance();
$pdo = $db->getConnection();

echo "\n========================================\n";
echo "   ⛵ DAFTAR KAPAL & RUTE\n";
echo "========================================\n\n";

// Ambil kapal yang sudah diverifikasi
$stmt = $pdo->query("
    SELECT k.id, k.nama_kapal, k.kapasitas 
    FROM kapal k 
    WHERE k.status_verifikasi = 'verified' AND k.status_aktif = 1 
    ORDER BY k.nama_kapal
");
$kapal = $stmt->fetchAll(PDO::FETCH_ASSOC);

foreach($kapal as $k) {
    echo "Kapal: " . $k['nama_kapal'] . " (ID: {$k['id']}, Kapasitas: {$k['kapasitas']} org)\n";
    
    // Ambil rute kapal
    $stmt2 = $pdo->prepare("SELECT id, asal, tujuan, harga_jual FROM kapal_rute WHERE kapal_id = ? AND is_active = 1");
    $stmt2->execute([$k['id']]);
    $rute = $stmt2->fetchAll(PDO::FETCH_ASSOC);
    
    foreach($rute as $r) {
        echo "   Rute ID: {$r['id']} - {$r['asal']} -> {$r['tujuan']} (Rp " . number_format($r['harga_jual'], 0, ',', '.') . ")\n";
    }
    echo "\n";
}

echo "========================================\n";