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

header('Content-Type: application/json; charset=utf-8');

try {
    $cities = $pdo->query("
        SELECT DISTINCT city 
        FROM projects 
        WHERE city IS NOT NULL AND city != '' 
        ORDER BY city ASC
    ")->fetchAll(PDO::FETCH_COLUMN);
    
    echo json_encode(['ok' => true, 'cities' => $cities], JSON_UNESCAPED_UNICODE);
} catch (Exception $e) {
    http_response_code(500);
    echo json_encode(['ok' => false, 'error' => $e->getMessage()]);
}
