<?php
require_once __DIR__ . '/../../app/core/bootstrap.php';
$pdo = crm_pdo();

$stmt = $pdo->query("SELECT id, title, start_date, end_date_planned, status FROM projects WHERE status NOT IN ('completed', 'cancelled')");
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo "Total active projects: " . count($rows) . "\n\n";

foreach ($rows as $r) {
    if (empty($r['start_date']) || $r['start_date'] === '0000-00-00' || strpos($r['start_date'], '0000-00-00') !== false) {
        echo "ID: {$r['id']} | Title: {$r['title']} | Start: '{$r['start_date']}' | End: '{$r['end_date_planned']}'\n";
    }
}
