format(new DateTime($date)); return $formattedDate; } // Get the first name of the user $stmt = $db->prepare("SELECT username, firstname FROM user WHERE id = :userId"); $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER); $result = $stmt->execute(); $user = $result->fetchArray(SQLITE3_ASSOC); $first_name = $user['firstname'] ?? $user['username'] ?? ''; // Fetch the next 3 enabled subscriptions up for payment $stmt = $db->prepare("SELECT id, logo, name, price, currency_id, next_payment, inactive FROM subscriptions WHERE user_id = :userId AND next_payment >= date('now') AND inactive = 0 ORDER BY next_payment ASC LIMIT 3"); $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER); $result = $stmt->execute(); $upcomingSubscriptions = []; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $upcomingSubscriptions[] = $row; } // Fetch enabled subscriptions with manual renewal that are overdue $stmt = $db->prepare("SELECT id, logo, name, price, currency_id, next_payment, inactive, auto_renew FROM subscriptions WHERE user_id = :userId AND next_payment < date('now') AND auto_renew = 0 AND inactive = 0 ORDER BY next_payment ASC"); $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER); $result = $stmt->execute(); $overdueSubscriptions = []; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $overdueSubscriptions[] = $row; } $hasOverdueSubscriptions = !empty($overdueSubscriptions); require_once 'includes/stats_calculations.php'; // Get AI Recommendations for user $stmt = $db->prepare("SELECT * FROM ai_recommendations WHERE user_id = :userId"); $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER); $result = $stmt->execute(); $aiRecommendations = []; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $aiRecommendations[] = $row; } ?>

    $recommendation) { ?>

0) { ?>

%

0) { ?>

0) { ?>

0) { ?>

0) { ?>