<?php
require_once __DIR__ . '/../../app/core/bootstrap.php';
$pdo = crm_pdo();
try {
    $stmt = $pdo->query("
        SELECT p.id, p.title, p.code, c.name as customer_name, p.status 
        FROM projects p
        LEFT JOIN customers c ON p.customer_id = c.id
        WHERE p.status NOT IN ('completed', 'cancelled') 
        AND (p.start_date IS NULL OR p.start_date = '0000-00-00' OR p.start_date = '' OR p.start_date LIKE '0000%')
        ORDER BY p.created_at DESC
    ");
    $unscheduledProjects = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo "Count: " . count($unscheduledProjects) . "\n";
    print_r($unscheduledProjects);
} catch (Throwable $e) {
    echo "Error: " . $e->getMessage();
}
