diff --git a/assets/css/custom.css b/assets/css/custom.css
index 66c6d7bf..3b6ebd20 100644
--- a/assets/css/custom.css
+++ b/assets/css/custom.css
@@ -1,4 +1,11 @@
-/* Resetting styles for the new theme. */
+:root {
+ --status-default: #444;
+ --status-default-dark: #6c757d;
+ --status-processing: #ffc107;
+ --status-shipped: #0d6efd;
+ --status-completed: #198754;
+ --status-cancelled: #dc3545;
+}
.about-us-list {
width: 80vw;
@@ -57,8 +64,6 @@
}
}
-/* --- Order Tracking Modal Styles --- */
-
.tracking-modal-container {
position: fixed;
top: 0;
@@ -181,7 +186,6 @@
margin-left: 8px;
}
-/* --- Status Tracker --- */
.status-tracker {
position: relative;
display: flex;
@@ -199,7 +203,7 @@
width: calc(100% - 40px);
margin: 0 20px;
height: 4px;
- background-color: #444;
+ background-color: var(--status-default);
z-index: 1;
}
@@ -209,9 +213,8 @@
transform: translateY(-50%);
right: 20px;
height: 4px;
- background-color: var(--bs-primary);
z-index: 2;
- transition: width 0.5s ease;
+ transition: width 0.5s ease, background-color 0.5s ease;
}
.status-step {
@@ -225,11 +228,11 @@
width: 20px;
height: 20px;
border-radius: 50%;
- background-color: #444;
+ background-color: var(--status-default);
border: 3px solid #2c2c2c;
margin: 0 auto;
transform: translateY(-8px);
- transition: background-color 0.5s ease;
+ transition: background-color 0.5s ease, box-shadow 0.3s ease;
}
.status-step .label {
@@ -240,34 +243,24 @@
transition: color 0.5s ease;
}
-/* State Styling */
-.status-step.completed .dot {
- background-color: var(--bs-primary);
-}
-
-.status-step.active .dot {
- background-color: #fff;
- box-shadow: 0 0 10px var(--bs-primary);
-}
-
-.status-step.completed .label {
+.status-step.completed .label,
+.status-step.active .label {
color: #f0f0f0;
font-weight: 500;
}
-.status-tracker.is-cancelled ~ .status-step:not([data-status="cancelled"]) {
- opacity: 0.3;
-}
-.status-tracker.is-cancelled .status-step[data-status="cancelled"] .dot {
- background-color: var(--bs-danger);
-}
-.status-tracker.is-cancelled .status-step[data-status="cancelled"] .label {
- color: var(--bs-danger);
- font-weight: bold;
+.status-step.active .dot {
+ box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}
+.status-tracker.is-cancelled .status-step {
+ opacity: 0.5;
+}
+
+.status-tracker.is-cancelled .label {
+ color: var(--status-cancelled);
+}
-/* --- Products List --- */
#modal-products-list {
display: flex;
flex-direction: column;
@@ -308,7 +301,6 @@
font-weight: bold;
}
-/* --- Product Color Dot --- */
.product-meta {
display: flex;
align-items: center;
@@ -330,4 +322,24 @@
border-radius: 50%;
border: 1px solid rgba(255, 255, 255, 0.2);
display: inline-block;
+}
+
+@media (max-width: 768px) {
+ footer {
+ text-align: center;
+ }
+
+ footer .row > * {
+ margin-bottom: 1.5rem;
+ }
+
+ footer .row {
+ justify-content: center;
+ }
+
+ /* Center social icons and contact list items on mobile */
+ footer .social-icons,
+ footer .list-unstyled .d-flex {
+ justify-content: center;
+ }
}
\ No newline at end of file
diff --git a/includes/header.php b/includes/header.php
index 7c484e07..7417c42b 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -108,20 +108,18 @@ $page_title = $page_title ?? 'فروشگاه آتیمه'; // Default title
-
+
+
+
+
ورود / ثبتنام
diff --git a/profile.php b/profile.php
index 22fb5332..9281d353 100644
--- a/profile.php
+++ b/profile.php
@@ -1,10 +1,8 @@
prepare("UPDATE users SET first_name = ?, last_name = ?, email = ? WHERE id = ?");
- $stmt->execute([$first_name, $last_name, $email, $user_id]);
- $_SESSION['profile_message'] = 'اطلاعات شما با موفقیت بهروزرسانی شد.';
- $_SESSION['profile_message_type'] = 'success';
- } catch (PDOException $e) {
- // Check for duplicate email error
- if ($e->errorInfo[1] == 1062) {
- $_SESSION['profile_message'] = 'این ایمیل قبلاً ثبت شده است. لطفاً ایمیل دیگری را امتحان کنید.';
- } else {
- $_SESSION['profile_message'] = 'خطا در بهروزرسانی اطلاعات.';
- }
- $_SESSION['profile_message_type'] = 'danger';
+ try {
+ if ($action === 'update_details') {
+ $first_name = trim($_POST['first_name'] ?? '');
+ $last_name = trim($_POST['last_name'] ?? '');
+ $email = trim($_POST['email'] ?? '');
+
+ if (empty($first_name) || empty($last_name) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ throw new Exception('لطفاً تمام فیلدها را به درستی پر کنید.');
}
- }
- header('Location: profile.php?page=account');
- exit;
- } elseif ($_POST['action'] === 'update_password') {
- $new_password = $_POST['new_password'] ?? '';
- $confirm_password = $_POST['confirm_password'] ?? '';
+ $stmt = $pdo->prepare("UPDATE users SET first_name = ?, last_name = ?, email = ? WHERE id = ?");
+ $stmt->execute([$first_name, $last_name, $email, $user_id]);
+ $_SESSION['profile_message'] = 'اطلاعات شما با موفقیت بهروزرسانی شد.';
+ $_SESSION['profile_message_type'] = 'success';
+ $redirect_page = 'account';
+ } elseif ($action === 'update_password') {
+ $new_password = $_POST['new_password'] ?? '';
+ $confirm_password = $_POST['confirm_password'] ?? '';
- if (strlen($new_password) < 8) {
- $_SESSION['profile_message'] = 'رمز عبور جدید باید حداقل ۸ کاراکتر باشد.';
- $_SESSION['profile_message_type'] = 'danger';
- } elseif ($new_password !== $confirm_password) {
- $_SESSION['profile_message'] = 'رمزهای عبور جدید با هم مطابقت ندارند.';
- $_SESSION['profile_message_type'] = 'danger';
- } elseif (!empty($new_password)) {
+ if (strlen($new_password) < 8) {
+ throw new Exception('رمز عبور جدید باید حداقل ۸ کاراکتر باشد.');
+ } elseif ($new_password !== $confirm_password) {
+ throw new Exception('رمزهای عبور جدید با هم مطابقت ندارند.');
+ }
+
$hashed_password = password_hash($new_password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("UPDATE users SET password = ? WHERE id = ?");
- if ($stmt->execute([$hashed_password, $user_id])) {
- $_SESSION['profile_message'] = 'رمز عبور شما با موفقیت تغییر کرد.';
- $_SESSION['profile_message_type'] = 'success';
- } else {
- $_SESSION['profile_message'] = 'خطا در تغییر رمز عبور.';
- $_SESSION['profile_message_type'] = 'danger';
- }
- }
- header('Location: profile.php?page=account');
- exit;
- } elseif ($_POST['action'] === 'add_address') {
- $province = trim($_POST['province'] ?? '');
- $city = trim($_POST['city'] ?? '');
- $address_line = trim($_POST['address_line'] ?? '');
- $postal_code = trim($_POST['postal_code'] ?? '');
- $is_default = isset($_POST['is_default']);
+ $stmt->execute([$hashed_password, $user_id]);
+ $_SESSION['profile_message'] = 'رمز عبور شما با موفقیت تغییر کرد.';
+ $_SESSION['profile_message_type'] = 'success';
+ $redirect_page = 'account';
- if (empty($province) || empty($city) || empty($address_line) || empty($postal_code)) {
- $_SESSION['profile_message'] = 'لطفاً تمام فیلدهای آدرس را پر کنید.';
- $_SESSION['profile_message_type'] = 'danger';
- } else {
- $pdo->beginTransaction();
- try {
- if ($is_default) {
- $stmt = $pdo->prepare("UPDATE user_addresses SET is_default = 0 WHERE user_id = ?");
- $stmt->execute([$user_id]);
- }
- $stmt = $pdo->prepare("INSERT INTO user_addresses (user_id, province, city, address_line, postal_code, is_default) VALUES (?, ?, ?, ?, ?, ?)");
- $stmt->execute([$user_id, $province, $city, $address_line, $postal_code, $is_default ? 1 : 0]);
- $pdo->commit();
- $_SESSION['profile_message'] = 'آدرس جدید با موفقیت اضافه شد.';
- $_SESSION['profile_message_type'] = 'success';
- } catch (PDOException $e) {
- $pdo->rollBack();
- $_SESSION['profile_message'] = 'خطا در افزودن آدرس.';
- $_SESSION['profile_message_type'] = 'danger';
+ } elseif ($action === 'add_address') {
+ $province = trim($_POST['province'] ?? '');
+ $city = trim($_POST['city'] ?? '');
+ $address_line = trim($_POST['address_line'] ?? '');
+ $postal_code = trim($_POST['postal_code'] ?? '');
+ $is_default = isset($_POST['is_default']);
+ if (empty($province) || empty($city) || empty($address_line) || empty($postal_code)) {
+ throw new Exception('لطفاً تمام فیلدهای آدرس را پر کنید.');
}
- }
- header('Location: profile.php?page=addresses');
- exit;
- } elseif ($_POST['action'] === 'delete_address') {
- $address_id = $_POST['address_id'] ?? 0;
- $stmt = $pdo->prepare("DELETE FROM user_addresses WHERE id = ? AND user_id = ?");
- if ($stmt->execute([$address_id, $user_id])) {
+
+ $pdo->beginTransaction();
+ if ($is_default) {
+ $stmt = $pdo->prepare("UPDATE user_addresses SET is_default = 0 WHERE user_id = ?");
+ $stmt->execute([$user_id]);
+ }
+ $stmt = $pdo->prepare("INSERT INTO user_addresses (user_id, province, city, address_line, postal_code, is_default) VALUES (?, ?, ?, ?, ?, ?)");
+ $stmt->execute([$user_id, $province, $city, $address_line, $postal_code, $is_default ? 1 : 0]);
+ $pdo->commit();
+
+ $_SESSION['profile_message'] = 'آدرس جدید با موفقیت اضافه شد.';
+ $_SESSION['profile_message_type'] = 'success';
+ $redirect_page = 'addresses';
+ } elseif ($action === 'delete_address') {
+ $address_id = $_POST['address_id'] ?? 0;
+ $stmt = $pdo->prepare("DELETE FROM user_addresses WHERE id = ? AND user_id = ?");
+ if (!$stmt->execute([$address_id, $user_id])) throw new Exception('خطا در حذف آدرس.');
+
$_SESSION['profile_message'] = 'آدرس با موفقیت حذف شد.';
$_SESSION['profile_message_type'] = 'success';
- } else {
- $_SESSION['profile_message'] = 'خطا در حذف آدرس.';
- $_SESSION['profile_message_type'] = 'danger';
- }
- header('Location: profile.php?page=addresses');
- exit;
- } elseif ($_POST['action'] === 'set_default_address') {
- $address_id = $_POST['address_id'] ?? 0;
- $pdo->beginTransaction();
- try {
+ $redirect_page = 'addresses';
+ } elseif ($action === 'set_default_address') {
+ $address_id = $_POST['address_id'] ?? 0;
+ $pdo->beginTransaction();
$stmt1 = $pdo->prepare("UPDATE user_addresses SET is_default = 0 WHERE user_id = ?");
$stmt1->execute([$user_id]);
$stmt2 = $pdo->prepare("UPDATE user_addresses SET is_default = 1 WHERE id = ? AND user_id = ?");
@@ -117,16 +87,37 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
$pdo->commit();
$_SESSION['profile_message'] = 'آدرس پیشفرض با موفقیت تغییر کرد.';
$_SESSION['profile_message_type'] = 'success';
- } catch (PDOException $e) {
- $pdo->rollBack();
- $_SESSION['profile_message'] = 'خطا در تغییر آدرس پیشفرض.';
- $_SESSION['profile_message_type'] = 'danger';
+ $redirect_page = 'addresses';
}
- header('Location: profile.php?page=addresses');
- exit;
+ } catch (PDOException $e) {
+ if (isset($pdo) && $pdo->inTransaction()) {
+ $pdo->rollBack();
+ }
+ if ($e->errorInfo[1] == 1062) { // Duplicate entry
+ $_SESSION['profile_message'] = 'این ایمیل قبلاً ثبت شده است.';
+ } else {
+ $_SESSION['profile_message'] = 'یک خطای پایگاه داده رخ داد: ' . $e->getMessage();
+ }
+ $_SESSION['profile_message_type'] = 'danger';
+ } catch (Exception $e) {
+ $_SESSION['profile_message'] = $e->getMessage();
+ $_SESSION['profile_message_type'] = 'danger';
}
+
+ header('Location: profile.php?page=' . $redirect_page);
+ exit;
}
+// Determine current page
+$page = $_GET['page'] ?? 'dashboard';
+$page_map = [
+ 'dashboard' => 'داشبورد',
+ 'orders' => 'سفارشات من',
+ 'addresses' => 'آدرسهای من',
+ 'account' => 'جزئیات حساب',
+];
+$page_title = $page_map[$page] ?? 'حساب کاربری';
+
// Retrieve flash message
if (isset($_SESSION['profile_message'])) {
$flash_message = $_SESSION['profile_message'];
@@ -135,444 +126,303 @@ if (isset($_SESSION['profile_message'])) {
unset($_SESSION['profile_message_type']);
}
-// Fetch user data
-$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
-$stmt->execute([$user_id]);
-$user = $stmt->fetch(PDO::FETCH_ASSOC);
+// Fetch all necessary data
+$stmt_user = $pdo->prepare("SELECT * FROM users WHERE id = ?");
+$stmt_user->execute([$user_id]);
+$user = $stmt_user->fetch(PDO::FETCH_ASSOC);
-// Fetch user addresses
-$stmt_addresses = $pdo->prepare("SELECT * FROM user_addresses WHERE user_id = ? ORDER BY is_default DESC, id DESC");
-$stmt_addresses->execute([$user_id]);
-$addresses = $stmt_addresses->fetchAll(PDO::FETCH_ASSOC);
-
-// Fetch user orders with items
$stmt_orders = $pdo->prepare("SELECT * FROM orders WHERE user_id = ? ORDER BY created_at DESC");
$stmt_orders->execute([$user_id]);
$orders = $stmt_orders->fetchAll(PDO::FETCH_ASSOC);
-// Calculate total purchase amount from COMPLETED orders
-$total_purchase_amount = 0;
-foreach ($orders as $order) {
- if (strtolower($order['status']) === 'completed') {
- $total_purchase_amount += $order['total_amount'];
- }
-}
+$stmt_addresses = $pdo->prepare("SELECT * FROM user_addresses WHERE user_id = ? ORDER BY is_default DESC, id DESC");
+$stmt_addresses->execute([$user_id]);
+$addresses = $stmt_addresses->fetchAll(PDO::FETCH_ASSOC);
+$total_purchase_amount = array_reduce($orders, function ($sum, $order) {
+ return strtolower($order['status']) === 'completed' ? $sum + $order['total_amount'] : $sum;
+}, 0);
-$page_title = 'حساب کاربری';
-require_once 'includes/header.php';
?>
+
+
+
+
+
+ = htmlspecialchars($page_title) ?> - پنل کاربری
+
+
+
+
+
+
+
+
+
-
-