134 lines
5.6 KiB
PHP
134 lines
5.6 KiB
PHP
<?php
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
require_once 'includes/auth.php';
|
|
require_login();
|
|
require_once 'includes/helpers.php';
|
|
|
|
$page_title = 'Profil użytkownika';
|
|
$user_role = get_user_role();
|
|
$user_id = $_SESSION['user_id'];
|
|
$client_id = $_SESSION['client_id'] ?? null;
|
|
$user_email = '';
|
|
$client_name = '';
|
|
$error_message = '';
|
|
|
|
try {
|
|
$pdo = db();
|
|
|
|
// Fetch user email
|
|
$stmt = $pdo->prepare("SELECT email FROM users WHERE id = ?");
|
|
$stmt->execute([$user_id]);
|
|
$user_email = $stmt->fetchColumn();
|
|
|
|
// Fetch client name if client_id exists
|
|
if ($client_id) {
|
|
$stmt = $pdo->prepare("SELECT name FROM clients WHERE id = ?");
|
|
$stmt->execute([$client_id]);
|
|
$client_name = $stmt->fetchColumn();
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
error_log("Profile page error: " . $e->getMessage());
|
|
$error_message = 'Wystąpił błąd podczas ładowania danych profilu. Prosimy spróbować ponownie później.';
|
|
}
|
|
|
|
$lang = 'pl';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($page_title); ?> - B2B Commerce</title>
|
|
|
|
<meta name="description" content="Zarządzaj swoim profilem w platformie B2B Commerce.">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php">
|
|
<img src="assets/pasted-20251209-065617-6bf1b4e6.png" alt="Logo" style="height: 40px;">
|
|
</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 align-items-center">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="index.php">Katalog</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="cart.php">
|
|
<i class="bi bi-cart"></i> Koszyk
|
|
<span class="badge bg-primary rounded-pill"><?= count($_SESSION['cart'] ?? []) ?></span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="orders.php">Zamówienia</a>
|
|
</li>
|
|
<?php if ($user_role === 'admin'): ?>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/admin/products.php">Admin</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="bi bi-person-circle"></i> Witaj, <?= isset($_SESSION['username']) ? htmlspecialchars($_SESSION['username']) : '' ?>
|
|
</a>
|
|
<ul class="dropdown-menu dropdown-menu-end">
|
|
<li><a class="dropdown-item p-2" href="profile.php">Profil</a></li>
|
|
<li><hr class="dropdown-divider"></li>
|
|
<li><a class="dropdown-item p-2" href="logout.php">Wyloguj</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container my-5">
|
|
<h1 class="mb-4"><?php echo htmlspecialchars($page_title); ?></h1>
|
|
|
|
<?php if ($error_message): ?>
|
|
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></div>
|
|
<?php else: ?>
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Witaj, <?php echo htmlspecialchars($_SESSION['username']); ?></h5>
|
|
<ul class="list-group list-group-flush">
|
|
<li class="list-group-item">
|
|
<strong>Adres e-mail:</strong> <?php echo htmlspecialchars($user_email); ?>
|
|
</li>
|
|
<?php if ($client_name): ?>
|
|
<li class="list-group-item">
|
|
<strong>Klient:</strong> <?php echo htmlspecialchars($client_name); ?>
|
|
</li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mt-4">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Zarządzanie hasłem</h5>
|
|
<p class="card-text">Funkcja w przygotowaniu.</p>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<footer class="text-center py-4 mt-auto text-muted bg-light">
|
|
<div class="container">
|
|
<p class="mb-0">© <?php echo date("Y"); ?> powered by LEA24. All Rights Reserved.</p>
|
|
</div>
|
|
</footer>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|