qqqqqqqqqqqqqqqqqqqqqq

This commit is contained in:
Flatlogic Bot 2025-12-07 20:08:31 +00:00
parent 6c608b6ba5
commit 7da45b4e24
31 changed files with 2359 additions and 3702 deletions

View File

@ -30,29 +30,29 @@ require_once 'includes/header.php';
<div class="text-center mb-5" data-aos="fade-down"> <div class="text-center mb-5" data-aos="fade-down">
<h2 class="fw-bold">ارزش‌های ما</h2> <h2 class="fw-bold">ارزش‌های ما</h2>
</div> </div>
<div class="row text-center g-4 justify-content-center"> <ul class="about-us-list">
<div class="col-md-4" data-aos="fade-up" data-aos-delay="100"> <li class="about-us-item" data-aos="fade-up" data-aos-delay="100">
<div class="values-card h-100"> <div class="inner">
<i class="ri-gem-line mb-3"></i> <i class="ri-award-line ri-2x mb-3"></i>
<h4 class="fw-bold">تعهد به کیفیت</h4> <h4 class="fw-bold">تعهد به کیفیت</h4>
<p class="text-muted px-3">استفاده از بهترین مواد اولیه و کنترل کیفی دقیق در تمام مراحل تولید.</p> <p class="text-muted px-3">استفاده از بهترین مواد اولیه و کنترل کیفی دقیق در تمام مراحل تولید.</p>
</div> </div>
</div> </li>
<div class="col-md-4" data-aos="fade-up" data-aos-delay="200"> <li class="about-us-item" data-aos="fade-up" data-aos-delay="200">
<div class="values-card h-100"> <div class="inner">
<i class="ri-hand-heart-line mb-3"></i> <i class="ri-hand-heart-line ri-2x mb-3"></i>
<h4 class="fw-bold">هنر دست</h4> <h4 class="fw-bold">هنر دست</h4>
<p class="text-muted px-3">تمام محصولات ما با عشق و دقت توسط هنرمندان ماهر ساخته می‌شوند.</p> <p class="text-muted px-3">تمام محصولات ما با عشق و دقت توسط هنرمندان ماهر ساخته می‌شوند.</p>
</div> </div>
</div> </li>
<div class="col-md-4" data-aos="fade-up" data-aos-delay="300"> <li class="about-us-item" data-aos="fade-up" data-aos-delay="300">
<div class="values-card h-100"> <div class="inner">
<i class="ri-leaf-line mb-3"></i> <i class="ri-leaf-line ri-2x mb-3"></i>
<h4 class="fw-bold">طراحی ماندگار</h4> <h4 class="fw-bold">طراحی ماندگار</h4>
<p class="text-muted px-3">خلق آثاری مدرن و در عین حال کلاسیک که هیچ‌گاه از مد نمی‌افتند.</p> <p class="text-muted px-3">خلق آثاری مدرن و در عین حال کلاسیک که هیچ‌گاه از مد نمی‌افتند.</p>
</div> </div>
</div> </li>
</div> </ul>
</section> </section>
</div> </div>

View File

@ -132,5 +132,120 @@ if ($action === 'get_stats') {
exit; exit;
} }
if ($action === 'get_reports_data') {
try {
// 1. General Stats
$stats_query = "
SELECT
(SELECT SUM(total_amount) FROM orders WHERE status = 'Delivered') as total_revenue,
(SELECT COUNT(*) FROM orders) as total_orders,
(SELECT COUNT(*) FROM users WHERE is_admin = 0) as total_users,
(SELECT COUNT(*) FROM products) as total_products
";
$stats_stmt = $pdo->query($stats_query);
$stats = $stats_stmt->fetch(PDO::FETCH_ASSOC);
// 2. Recent Orders
$recent_orders_query = "
SELECT o.id, o.total_amount, o.status, COALESCE(CONCAT(u.first_name, ' ', u.last_name), o.billing_name) AS customer_display_name
FROM orders o
LEFT JOIN users u ON o.user_id = u.id
ORDER BY o.created_at DESC
LIMIT 5
";
$recent_orders_stmt = $pdo->query($recent_orders_query);
$recent_orders = $recent_orders_stmt->fetchAll(PDO::FETCH_ASSOC);
// 3. Top Selling Products (Calculated in PHP)
$orders_for_products_query = "SELECT items_json FROM orders WHERE status = 'Delivered'";
$orders_for_products_stmt = $pdo->query($orders_for_products_query);
$all_orders_items = $orders_for_products_stmt->fetchAll(PDO::FETCH_ASSOC);
$product_sales = [];
foreach ($all_orders_items as $order_items) {
$items = json_decode($order_items['items_json'], true);
if (is_array($items)) {
foreach ($items as $item) {
if (isset($item['name']) && isset($item['quantity'])) {
$product_name = $item['name'];
$quantity = (int)$item['quantity'];
if (!isset($product_sales[$product_name])) {
$product_sales[$product_name] = 0;
}
$product_sales[$product_name] += $quantity;
}
}
}
}
arsort($product_sales);
$top_products = [];
$count = 0;
foreach ($product_sales as $name => $total_sold) {
$top_products[] = ['name' => $name, 'total_sold' => $total_sold];
$count++;
if ($count >= 5) break;
}
echo json_encode([
'stats' => [
'total_revenue' => (float)($stats['total_revenue'] ?? 0),
'total_orders' => (int)($stats['total_orders'] ?? 0),
'total_users' => (int)($stats['total_users'] ?? 0),
'total_products' => (int)($stats['total_products'] ?? 0),
],
'recent_orders' => $recent_orders,
'top_products' => $top_products
]);
} catch (PDOException $e) {
http_response_code(500);
error_log("API Error (get_reports_data): " . $e->getMessage());
echo json_encode(['error' => 'Database error while fetching report data.']);
}
exit;
}
if ($action === 'get_monthly_sales') {
require_once __DIR__ . '/../includes/jdf.php';
try {
$stmt = $pdo->prepare("
SELECT
YEAR(created_at) as year,
MONTH(created_at) as month,
SUM(total_amount) as total_sales
FROM orders
WHERE status = 'Delivered'
GROUP BY year, month
ORDER BY year ASC, month ASC
");
$stmt->execute();
$sales_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$labels = [];
$values = [];
$jalali_months = [
1 => 'فروردین', 2 => 'اردیبهشت', 3 => 'خرداد',
4 => 'تیر', 5 => 'مرداد', 6 => 'شهریور',
7 => 'مهر', 8 => 'آبان', 9 => 'آذر',
10 => 'دی', 11 => 'بهمن', 12 => 'اسفند'
];
foreach ($sales_data as $row) {
$jalali_date = gregorian_to_jalali($row['year'], $row['month'], 1);
$labels[] = $jalali_months[(int)$jalali_date[1]] . ' ' . $jalali_date[0];
$values[] = (float)$row['total_sales'];
}
echo json_encode(['labels' => $labels, 'values' => $values]);
} catch (PDOException $e) {
http_response_code(500);
error_log("API Error (get_monthly_sales): " . $e->getMessage());
echo json_encode(['error' => 'Database error while fetching monthly sales.']);
}
exit;
}
http_response_code(400); http_response_code(400);
echo json_encode(['error' => 'Invalid action']); echo json_encode(['error' => 'Invalid action']);

View File

@ -1,347 +0,0 @@
/*
* Admin Panel Main Stylesheet
* A clean, modern, and professional light theme.
*/
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');
@import url('https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css');
:root {
--admin-bg-light: #f4f7f9; /* Light gray background */
--admin-surface-light: #ffffff; /* White surface for cards, sidebar */
--admin-border-light: #e0e5ec; /* Soft border color */
--admin-text-primary: #2d3748; /* Dark text for high contrast */
--admin-text-secondary: #718096; /* Lighter text for muted info */
--admin-primary: #4a5568; /* A neutral, professional primary color */
--admin-primary-active: #2d3748;
--admin-success: #38a169;
--admin-danger: #e53e3e;
--admin-warning: #dd6b20;
--admin-info: #3182ce;
}
body.admin-theme {
background-color: var(--admin-bg-light);
color: var(--admin-text-primary);
font-family: 'Vazirmatn', sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
display: flex;
min-height: 100vh;
}
.admin-wrapper {
display: flex;
width: 100%;
}
/* --- Sidebar / Navigation --- */
.admin-sidebar {
width: 250px;
background-color: var(--admin-surface-light);
border-right: 1px solid var(--admin-border-light);
padding: 1.5rem 0;
display: flex;
flex-direction: column;
transition: width 0.3s ease;
box-shadow: 0 0 20px rgba(0,0,0,0.03);
}
.sidebar-header {
padding: 0 1.5rem 1.5rem 1.5rem;
text-align: center;
border-bottom: 1px solid var(--admin-border-light);
}
.sidebar-header h2 a {
color: var(--admin-text-primary);
text-decoration: none;
font-size: 1.5rem;
font-weight: 700;
}
.sidebar-header h2 a span {
color: var(--admin-primary-active);
}
.admin-nav {
flex-grow: 1;
list-style: none;
padding: 1.5rem 0 0 0;
margin: 0;
}
.admin-nav-item {
margin: 0 1rem;
}
.admin-nav-link {
display: flex;
align-items: center;
gap: 0.9rem;
padding: 0.8rem 1rem;
color: var(--admin-text-secondary);
text-decoration: none;
font-weight: 600;
font-size: 0.9rem;
border-radius: 8px;
transition: all 0.3s ease;
}
.admin-nav-link i {
font-size: 1.2rem;
width: 20px;
text-align: center;
}
.admin-nav-link:hover {
background-color: var(--admin-bg-light);
color: var(--admin-primary-active);
}
.admin-nav-link.active {
background-color: var(--admin-primary);
color: #ffffff;
font-weight: 700;
}
.admin-nav-link.active:hover {
color: #ffffff;
background-color: var(--admin-primary-active);
}
.admin-nav-link.active i {
color: #ffffff;
}
.sidebar-footer {
padding: 1.5rem;
text-align: center;
border-top: 1px solid var(--admin-border-light);
}
.sidebar-footer a {
color: var(--admin-text-secondary);
text-decoration: none;
font-size: 0.9rem;
}
.sidebar-footer a:hover {
color: var(--admin-primary-active);
}
/* --- Main Content --- */
.admin-main-content {
flex-grow: 1;
padding: 2rem;
overflow-y: auto;
}
.admin-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
}
.admin-header h1 {
margin: 0;
font-size: 1.8rem;
font-weight: 700;
}
/* --- General Components --- */
.card {
background-color: var(--admin-surface-light);
border: 1px solid var(--admin-border-light);
border-radius: 12px;
margin-bottom: 2rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}
.card-header {
padding: 1rem 1.5rem;
border-bottom: 1px solid var(--admin-border-light);
font-size: 1.1rem;
font-weight: 600;
}
.card-body {
padding: 1.5rem;
}
.table {
width: 100%;
border-collapse: collapse;
}
.table th, .table td {
padding: 1rem 1.2rem;
text-align: right;
border-bottom: 1px solid var(--admin-border-light);
}
.table th {
font-weight: 700;
color: var(--admin-text-secondary);
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.table tbody tr:last-child td {
border-bottom: none;
}
.table tbody tr:hover {
background-color: var(--admin-bg-light);
}
.btn {
padding: 0.6rem 1.2rem;
border-radius: 8px;
text-decoration: none;
font-weight: 600;
transition: all 0.3s ease;
border: 1px solid transparent;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background-color: var(--admin-primary-active);
border-color: var(--admin-primary-active);
color: #fff;
}
.btn-primary:hover {
background-color: #2c3e50; /* Slightly darker */
}
.btn-danger {
background-color: var(--admin-danger);
color: #fff;
}
/* --- Stat Cards --- */
.stat-card {
background-color: var(--admin-surface-light);
border-radius: 12px;
padding: 1.5rem;
display: flex;
align-items: center;
gap: 1.5rem;
border: 1px solid var(--admin-border-light);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}
.stat-card .icon {
font-size: 1.8rem;
padding: 1rem;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
}
.stat-card .stat-info p {
margin: 0;
font-size: 0.9rem;
color: var(--admin-text-secondary);
}
.stat-card .stat-info h3 {
margin: 0;
font-size: 2rem;
font-weight: 700;
}
.icon.bg-success { background-color: var(--admin-success); }
.icon.bg-danger { background-color: var(--admin-danger); }
.icon.bg-warning { background-color: var(--admin-warning); }
.icon.bg-info { background-color: var(--admin-info); }
/* --- Chart Container --- */
.chart-container {
background-color: var(--admin-surface-light);
padding: 2rem;
border-radius: 12px;
border: 1px solid var(--admin-border-light);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}
.chart-container h5 {
font-weight: 700;
margin-bottom: 1.5rem;
font-size: 1.2rem;
}
/* --- Form styles --- */
.form-group {
margin-bottom: 1.5rem;
}
.form-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
color: var(--admin-text-primary);
}
.form-control {
width: 100%;
padding: 0.8rem 1rem;
background-color: var(--admin-surface-light);
border: 1px solid var(--admin-border-light);
color: var(--admin-text-primary);
border-radius: 8px;
box-sizing: border-box;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.form-control:focus {
outline: none;
border-color: var(--admin-primary);
box-shadow: 0 0 0 3px rgba(74, 85, 104, 0.1);
}
textarea.form-control {
min-height: 120px;
resize: vertical;
}
/* Admin Login Page */
.admin-login-wrapper {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 100vh;
background-color: var(--admin-bg-light);
}
.admin-login-box {
width: 100%;
max-width: 400px;
padding: 3rem;
background: var(--admin-surface-light);
border-radius: 12px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}
.admin-login-box h2 {
font-weight: 700;
text-align: center;
margin-bottom: 0.5rem;
}
.admin-login-box p {
text-align: center;
color: var(--admin-text-secondary);
margin-bottom: 2rem;
}
/* Responsive adjustments will be added later if needed */

View File

@ -1,348 +1,331 @@
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;600;700&display=swap'); /*
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css'); * Admin Panel Luxury Redesign
* This file centralizes all styles for the admin panel.
*/
/* --- Variable Imports & Overrides ---
We can re-use variables from the main theme.css. Let's define some admin-specific ones.
*/
:root { :root {
--admin-bg: #111214; --admin-bg: #111111; /* Deep Dark */
--admin-surface: #1a1b1e; --admin-surface: #1a1a1a; /* Slightly lighter surface */
--admin-text: #eceff1; --admin-card-bg: #242424; /* Card background */
--admin-text-muted: #90a4ae; --admin-border: #333333;
--admin-primary: #c09f80; /* Soft gold from luxury theme */ --admin-text: #E0E0E0;
--admin-border: #37474f; --admin-text-muted: #888;
--admin-success: #4caf50; --admin-gold: #e5b56e;
--admin-danger: #f44336; --admin-blue: #4a90e2;
--admin-warning: #ff9800; --admin-success: #50e3c2;
--admin-info: #2196f3; --admin-danger: #e35050;
--admin-warning: #f5a623;
--admin-info: #4a90e2;
--sidebar-width: 260px;
--sidebar-width-collapsed: 80px;
} }
body.admin-dark-theme { body.admin-body {
background-color: var(--admin-bg); background-color: var(--admin-bg);
color: var(--admin-text); color: var(--admin-text);
font-family: 'Vazirmatn', sans-serif; font-family: 'Vazirmatn', sans-serif;
line-height: 1.6; -webkit-font-smoothing: antialiased;
margin: 0; -moz-osx-font-smoothing: grayscale;
padding: 0; }
/* --- Main Layout --- */
.admin-wrapper {
display: flex; display: flex;
min-height: 100vh; min-height: 100vh;
} }
.admin-wrapper {
display: flex;
width: 100%;
}
/* --- Sidebar / Navigation --- */
.admin-sidebar { .admin-sidebar {
width: 260px; width: var(--sidebar-width);
background-color: var(--admin-surface); background-color: var(--admin-surface);
border-right: 1px solid var(--admin-border); border-left: 1px solid var(--admin-border);
padding: 1.5rem 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
transition: width 0.3s ease; transition: width 0.3s ease;
position: fixed;
top: 0;
right: 0;
bottom: 0;
z-index: 1000;
} }
.admin-main-content {
flex-grow: 1;
padding: 2rem;
margin-right: var(--sidebar-width);
transition: margin-right 0.3s ease;
background-color: var(--admin-bg);
}
/* Sidebar Header */
.sidebar-header { .sidebar-header {
padding: 0 1.5rem 1.5rem 1.5rem; padding: 1.5rem;
text-align: center; text-align: center;
border-bottom: 1px solid var(--admin-border); border-bottom: 1px solid var(--admin-border);
} }
.sidebar-header h2 a { .sidebar-header h2 a {
color: var(--admin-text); color: var(--admin-gold);
text-decoration: none;
font-size: 1.5rem;
font-weight: 700; font-weight: 700;
text-decoration: none;
font-size: 1.8rem;
}
.sidebar-header h2 span {
color: var(--admin-text);
} }
.sidebar-header h2 a span { /* Sidebar Navigation */
color: var(--admin-primary);
}
.admin-nav { .admin-nav {
flex-grow: 1; padding: 1rem 0;
list-style: none; list-style: none;
padding: 1.5rem 0 0 0; flex-grow: 1;
margin: 0;
}
.admin-nav-item {
margin: 0;
} }
.admin-nav-link { .admin-nav-link {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.8rem; padding: 1rem 1.5rem;
padding: 0.9rem 1.5rem;
color: var(--admin-text-muted); color: var(--admin-text-muted);
text-decoration: none; text-decoration: none;
font-weight: 600;
font-size: 0.95rem;
border-left: 4px solid transparent;
transition: all 0.3s ease; transition: all 0.3s ease;
font-weight: 500;
border-right: 4px solid transparent;
} }
.admin-nav-link i { .admin-nav-link i {
font-size: 1.1rem; font-size: 1.2rem;
width: 20px; width: 30px;
text-align: center; text-align: center;
margin-left: 0.8rem;
} }
.admin-nav-link:hover { .admin-nav-link:hover {
background-color: var(--admin-bg); background-color: var(--admin-bg);
color: var(--admin-primary); color: var(--admin-gold);
border-left-color: var(--admin-primary);
} }
.admin-nav-link.active { .admin-nav-link.active {
background-color: var(--admin-bg); color: var(--admin-gold);
color: var(--admin-text);
border-left-color: var(--admin-primary);
font-weight: 700; font-weight: 700;
background-color: var(--admin-bg);
border-right-color: var(--admin-gold);
} }
/* Sidebar Footer */
.sidebar-footer { .sidebar-footer {
padding: 1.5rem; padding: 1.5rem;
text-align: center;
border-top: 1px solid var(--admin-border); border-top: 1px solid var(--admin-border);
} }
.sidebar-footer a { .sidebar-footer a {
display: block;
color: var(--admin-text-muted); color: var(--admin-text-muted);
text-decoration: none; text-decoration: none;
font-size: 0.9rem; margin-bottom: 0.5rem;
transition: color 0.3s ease;
} }
.sidebar-footer a:hover { .sidebar-footer a:hover {
color: var(--admin-primary); color: var(--admin-gold);
} }
/* --- Main Content --- */ /* --- Header Bar --- */
.admin-main-content { .admin-header-bar {
flex-grow: 1;
padding: 2rem;
overflow-y: auto;
}
.admin-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 2rem; padding: 1rem 2rem;
}
.admin-header h1 {
margin: 0;
font-size: 2rem;
font-weight: 700;
}
/* --- General Components --- */
.card {
background-color: var(--admin-surface); background-color: var(--admin-surface);
border: 1px solid var(--admin-border); border-bottom: 1px solid var(--admin-border);
border-radius: 12px; position: sticky;
top: 0;
z-index: 999;
margin-bottom: 2rem; margin-bottom: 2rem;
} }
.card-header { #sidebar-toggle {
padding: 1rem 1.5rem; background: none;
border-bottom: 1px solid var(--admin-border);
font-size: 1.1rem;
font-weight: 600;
}
.card-body {
padding: 1.5rem;
}
.table {
width: 100%;
border-collapse: collapse;
}
.table th, .table td {
padding: 1rem;
text-align: right;
border-bottom: 1px solid var(--admin-border);
}
.table th {
font-weight: 700;
color: var(--admin-text-muted);
font-size: 0.9rem;
text-transform: uppercase;
}
.table tbody tr:last-child td {
border-bottom: none;
}
.table tbody tr:hover {
background-color: var(--admin-bg);
}
.btn {
padding: 0.6rem 1.2rem;
border-radius: 8px;
text-decoration: none;
font-weight: 600;
transition: all 0.3s ease;
border: none; border: none;
color: var(--admin-text);
font-size: 1.5rem;
cursor: pointer; cursor: pointer;
} }
.btn-primary { .admin-header-title h1 {
background-color: var(--admin-primary); font-size: 1.5rem;
color: var(--admin-bg); margin: 0;
}
.btn-primary:hover {
opacity: 0.9;
}
.btn-danger {
background-color: var(--admin-danger);
color: var(--admin-text); color: var(--admin-text);
} }
/* --- Stat Cards (from dashboard) --- */
.stat-card { /* --- Main Content Styling --- */
background-color: var(--admin-surface);
border-radius: 12px; /* Cards */
padding: 1.5rem; .card {
display: flex; background-color: var(--admin-card-bg);
align-items: center;
gap: 1.5rem;
border: 1px solid var(--admin-border); border: 1px solid var(--admin-border);
transition: transform 0.3s ease, box-shadow 0.3s ease; border-radius: 12px;
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.card-header {
background-color: rgba(0,0,0,0.2);
border-bottom: 1px solid var(--admin-border);
font-weight: 600;
color: var(--admin-text);
} }
/* Stat Cards on Dashboard */
.stat-cards-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.stat-card {
display: flex;
align-items: center;
padding: 1.5rem;
background-color: var(--admin-card-bg);
border-radius: 12px;
border: 1px solid var(--admin-border);
transition: transform 0.3s, box-shadow 0.3s;
}
.stat-card:hover { .stat-card:hover {
transform: translateY(-5px); transform: translateY(-5px);
box-shadow: 0 5px 15px rgba(0,0,0,0.2); box-shadow: 0 8px 30px rgba(0,0,0,0.3);
} }
.stat-card .icon { .stat-card .icon {
font-size: 2rem; font-size: 2rem;
padding: 1rem; padding: 1rem;
border-radius: 50%; border-radius: 50%;
display: flex; margin-left: 1rem;
align-items: center; color: #fff;
justify-content: center;
color: var(--admin-text);
} }
.stat-card .icon.bg-primary { background-color: var(--admin-blue); }
.stat-card .icon.bg-warning { background-color: var(--admin-warning); }
.stat-card .icon.bg-success { background-color: var(--admin-success); }
.stat-card .icon.bg-danger { background-color: var(--admin-danger); }
.stat-card .stat-info p { .stat-card .stat-info p {
margin: 0; margin: 0;
font-size: 0.9rem;
color: var(--admin-text-muted); color: var(--admin-text-muted);
} }
.stat-card .stat-info h3 { .stat-card .stat-info h3 {
margin: 0; margin: 0;
font-size: 2rem; font-size: 2rem;
font-weight: 700; font-weight: 700;
color: var(--admin-text);
} }
.icon.bg-success { background-color: var(--admin-success); } /* Tables */
.icon.bg-danger { background-color: var(--admin-danger); } .table {
.icon.bg-warning { background-color: var(--admin-warning); } border-color: var(--admin-border);
.icon.bg-info { background-color: var(--admin-info); }
.icon.bg-primary { background-color: var(--admin-primary); }
/* --- Chart Container --- */
.chart-container {
background-color: var(--admin-surface);
padding: 2rem;
border-radius: 12px;
border: 1px solid var(--admin-border);
} }
.table th {
.chart-container h5 { color: var(--admin-gold);
font-weight: 700;
margin-bottom: 1.5rem;
font-size: 1.2rem;
}
/* --- Form styles --- */
.form-group {
margin-bottom: 1.5rem;
}
.form-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600; font-weight: 600;
color: var(--admin-text-muted); border-bottom-width: 2px;
border-color: var(--admin-border) !important;
}
.table td {
color: var(--admin-text);
vertical-align: middle;
}
.table-hover tbody tr:hover {
background-color: var(--admin-surface);
color: var(--admin-text);
} }
.form-control { /* Status Badges */
width: 100%; .status-badge {
padding: 0.8rem 1rem; padding: 0.4em 0.8em;
background-color: var(--admin-bg); border-radius: 8px;
border: 1px solid var(--admin-border); font-size: 0.85rem;
font-weight: 600;
color: #111;
}
.status-processing, .status-badge.bg-info { background-color: var(--admin-info); }
.status-shipped, .status-badge.bg-warning { background-color: var(--admin-warning); }
.status-completed, .status-badge.bg-success { background-color: var(--admin-success); }
.status-cancelled, .status-badge.bg-danger { background-color: var(--admin-danger); }
.status-pending, .status-badge.bg-secondary { background-color: var(--admin-text-muted); color: #fff; }
/* Forms */
.form-control, .form-select {
background-color: var(--admin-surface);
border-color: var(--admin-border);
color: var(--admin-text); color: var(--admin-text);
border-radius: 8px; border-radius: 8px;
box-sizing: border-box; }
.form-control:focus, .form-select:focus {
background-color: var(--admin-surface);
border-color: var(--admin-gold);
color: var(--admin-text);
box-shadow: 0 0 0 0.2rem rgba(229, 181, 110, 0.2);
} }
.form-control:focus { .btn-primary {
outline: none; background-color: var(--admin-gold);
border-color: var(--admin-primary); border-color: var(--admin-gold);
box-shadow: 0 0 0 2px rgba(192, 159, 128, 0.2); color: #111;
font-weight: 600;
}
.btn-primary:hover {
background-color: #d4a55a;
border-color: #d4a55a;
} }
textarea.form-control { /* --- Responsive & Collapsed State --- */
min-height: 120px;
resize: vertical;
}
/* Responsive */
@media (max-width: 992px) { @media (max-width: 992px) {
.admin-sidebar { .admin-sidebar {
width: 70px; position: fixed;
top: 0;
right: -100%;
height: 100vh;
z-index: 1050; /* Above bootstrap backdrop */
transition: right 0.4s ease;
} }
.sidebar-header h2 { .admin-sidebar.open {
right: 0;
}
.admin-main-content {
margin-right: 0;
}
.sidebar-backdrop {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
z-index: 1040;
display: none; display: none;
} }
.admin-nav-link { .sidebar-backdrop.show {
justify-content: center; display: block;
}
.admin-nav-link span {
display: none;
} }
} }
@media (max-width: 768px) {
.admin-wrapper { @media (min-width: 993px) {
flex-direction: column; .admin-wrapper.sidebar-collapsed .admin-sidebar {
width: var(--sidebar-width-collapsed);
} }
.admin-sidebar { .admin-wrapper.sidebar-collapsed .admin-main-content {
width: 100%; margin-right: var(--sidebar-width-collapsed);
height: auto;
border-right: none;
border-bottom: 1px solid var(--admin-border);
flex-direction: row;
align-items: center;
padding: 0;
} }
.sidebar-header { .admin-wrapper.sidebar-collapsed .admin-sidebar .sidebar-header h2 a {
font-size: 1.5rem;
}
.admin-wrapper.sidebar-collapsed .admin-sidebar .sidebar-header h2 span,
.admin-wrapper.sidebar-collapsed .admin-sidebar .admin-nav-link span,
.admin-wrapper.sidebar-collapsed .admin-sidebar .sidebar-footer {
display: none; display: none;
} }
.admin-nav { .admin-wrapper.sidebar-collapsed .admin-sidebar .admin-nav-link {
display: flex; justify-content: center;
justify-content: space-around;
flex-grow: 1;
padding: 0;
} }
.admin-nav-link { }
border-left: none;
border-bottom: 4px solid transparent;
}
.admin-nav-link:hover, .admin-nav-link.active {
border-left-color: transparent;
border-bottom-color: var(--admin-primary);
}
.sidebar-footer {
display: none;
}
}

View File

@ -3,111 +3,88 @@ $page_title = 'داشبورد';
require_once __DIR__ . '/header.php'; require_once __DIR__ . '/header.php';
?> ?>
<div class="admin-header"> <div class="admin-header">
<h1><?php echo $page_title; ?></h1> <h1><?php echo $page_title; ?></h1>
</div> </div>
<div id="dashboard-error" class="card d-none" style="color: var(--admin-danger);"><div class="card-body"></div></div> <div class="tabs">
<div class="tab-links">
<a href="#reports" class="tab-link active">گزارشات</a>
<a href="#settings" class="tab-link">تنظیمات</a>
</div>
<div class="tab-content">
<div id="reports" class="tab-pane active">
<h3>گزارشات فروش</h3>
<div class="stat-cards-grid-reports">
<div class="stat-card-report">
<p>مجموع فروش (تکمیل شده)</p>
<h3 id="total-sales">...</h3>
</div>
<div class="stat-card-report">
<p>مجموع کاربران</p>
<h3 id="total-users">...</h3>
</div>
<div class="stat-card-report">
<p>سفارشات در حال پردازش</p>
<h3 id="processing-orders">...</h3>
</div>
</div>
<div class="dashboard-container"> <div class="card" style="margin-top: 2rem;">
<div class="stat-cards-grid-reports"> <h5>نمودار فروش ماهانه (سفارشات تحویل شده)</h5>
<div class="stat-card"> <div style="height: 350px;">
<div class="icon-container" style="background-color: #28a74555;"><i class="fas fa-dollar-sign" style="color: #28a745;"></i></div> <canvas id="salesChart"></canvas>
<div class="stat-info"> </div>
<p>مجموع فروش (تحویل شده)</p>
<h3 id="total-sales">...</h3>
</div> </div>
</div> </div>
<div class="stat-card"> <div id="settings" class="tab-pane">
<div class="icon-container" style="background-color: #17a2b855;"><i class="fas fa-users" style="color: #17a2b8;"></i></div> <h3>تنظیمات</h3>
<div class="stat-info"> <p>این بخش برای تنظیمات آینده در نظر گرفته شده است.</p>
<p>مجموع کاربران</p>
<h3 id="total-users">...</h3>
</div>
</div>
<div class="stat-card">
<div class="icon-container" style="background-color: #007bff55;"><i class="fas fa-truck" style="color: #007bff;"></i></div>
<div class="stat-info">
<p>سفارشات در حال ارسال</p>
<h3 id="shipped-orders">...</h3>
</div>
</div>
<div class="stat-card">
<div class="icon-container" style="background-color: #dc354555;"><i class="fas fa-times-circle" style="color: #dc3545;"></i></div>
<div class="stat-info">
<p>سفارشات لغو شده</p>
<h3 id="cancelled-orders">...</h3>
</div>
</div>
<div class="stat-card">
<div class="icon-container" style="background-color: #ffc10755;"><i class="fas fa-spinner" style="color: #ffc107;"></i></div>
<div class="stat-info">
<p>سفارشات در حال پردازش</p>
<h3 id="processing-orders">...</h3>
</div>
</div>
<div class="stat-card">
<div class="icon-container" style="background-color: #6f42c155;"><i class="fas fa-eye" style="color: #6f42c1;"></i></div>
<div class="stat-info">
<p>کل بازدید صفحات</p>
<h3 id="total-page-views">...</h3>
</div>
</div> </div>
</div> </div>
<div class="chart-container" style="position: relative; height:40vh; max-height: 450px;">
<h5>نمودار فروش ماهانه (سفارشات تحویل شده)</h5>
<canvas id="salesChart"></canvas>
</div> </div>
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
const errorDiv = document.getElementById('dashboard-error'); // Tab functionality
const errorBody = errorDiv.querySelector('.card-body'); const tabLinks = document.querySelectorAll('.tab-link');
const tabPanes = document.querySelectorAll('.tab-pane');
function showError(message) { tabLinks.forEach(link => {
errorBody.textContent = message; link.addEventListener('click', function(e) {
errorDiv.classList.remove('d-none'); e.preventDefault();
} const targetId = this.getAttribute('href');
// Fetch all data in parallel for faster loading tabLinks.forEach(l => l.classList.remove('active'));
tabPanes.forEach(p => p.classList.remove('active'));
this.classList.add('active');
document.querySelector(targetId).classList.add('active');
});
});
// Fetch data for stats and chart
Promise.all([ Promise.all([
fetch('api.php?action=get_stats').then(res => res.json()), fetch('api.php?action=get_stats').then(res => res.ok ? res.json() : Promise.reject('Failed to load stats')),
fetch('api.php?action=get_sales_data').then(res => res.json()) fetch('api.php?action=get_sales_data').then(res => res.ok ? res.json() : Promise.reject('Failed to load sales data'))
]).then(([statsData, salesData]) => { ]).then(([statsData, salesData]) => {
if (statsData.error) throw new Error(statsData.error);
// Handle stats data
if (statsData.error) throw new Error(`آمار: ${statsData.error}`);
document.getElementById('total-sales').textContent = new Intl.NumberFormat('fa-IR').format(statsData.total_sales) + ' تومان'; document.getElementById('total-sales').textContent = new Intl.NumberFormat('fa-IR').format(statsData.total_sales) + ' تومان';
document.getElementById('total-users').textContent = statsData.total_users; document.getElementById('total-users').textContent = statsData.total_users;
document.getElementById('shipped-orders').textContent = statsData.shipped_orders;
document.getElementById('cancelled-orders').textContent = statsData.cancelled_orders;
document.getElementById('processing-orders').textContent = statsData.processing_orders; document.getElementById('processing-orders').textContent = statsData.processing_orders;
document.getElementById('total-page-views').textContent = statsData.total_page_views.count;
// Handle sales chart data if (salesData.error) throw new Error(salesData.error);
if (salesData.error) throw new Error(`نمودار فروش: ${salesData.error}`);
renderSalesChart(salesData.labels, salesData.data); renderSalesChart(salesData.labels, salesData.data);
}).catch(error => { }).catch(error => {
console.error(`خطا:`, error); console.error('Dashboard Error:', error);
showError(`خطا در بارگذاری گزارشات: ${error.message}`); const reportsTab = document.getElementById('reports');
reportsTab.innerHTML = `<div style="color: #F44336; padding: 2rem; text-align: center;">خطا در بارگذاری داده‌های داشبورد. لطفاً بعداً تلاش کنید.</div>`;
}); });
function renderSalesChart(labels, data) { function renderSalesChart(labels, data) {
const ctx = document.getElementById('salesChart').getContext('2d'); const ctx = document.getElementById('salesChart').getContext('2d');
const style = getComputedStyle(document.body); const primaryColor = getComputedStyle(document.body).getPropertyValue('--admin-primary').trim();
// Use a more vibrant and visible color for the chart
const chartColor = '#FFD700'; // A nice gold color
const gradient = ctx.createLinearGradient(0, 0, 0, 400);
gradient.addColorStop(0, `${chartColor}60`); // 40% opacity
gradient.addColorStop(1, `${chartColor}00`); // 0% opacity
new Chart(ctx, { new Chart(ctx, {
type: 'line', type: 'line',
@ -116,60 +93,18 @@ document.addEventListener('DOMContentLoaded', function() {
datasets: [{ datasets: [{
label: 'میزان فروش', label: 'میزان فروش',
data: data, data: data,
backgroundColor: gradient, backgroundColor: `${primaryColor}33`, // 20% opacity
borderColor: chartColor, borderColor: primaryColor,
borderWidth: 3, borderWidth: 2,
fill: 'start', fill: true,
tension: 0.4, // Makes the line curvy tension: 0.4
pointBackgroundColor: chartColor,
pointRadius: 4,
pointHoverRadius: 6,
pointBorderColor: style.getPropertyValue('--admin-bg').trim(),
pointBorderWidth: 2,
}] }]
}, },
options: { options: {
responsive: true, responsive: true,
maintainAspectRatio: false, maintainAspectRatio: false,
plugins: { scales: {
legend: {
display: false
},
tooltip: {
backgroundColor: style.getPropertyValue('--admin-surface').trim(),
titleColor: style.getPropertyValue('--admin-text').trim(),
bodyColor: style.getPropertyValue('--admin-text-muted').trim(),
titleFont: { family: 'Vazirmatn', size: 14, weight: 'bold' },
bodyFont: { family: 'Vazirmatn', size: 12 },
padding: 12,
cornerRadius: 8,
displayColors: false,
callbacks: {
label: (context) => `مجموع فروش: ${new Intl.NumberFormat('fa-IR').format(context.parsed.y)} تومان`
}
}
},
scales: {
x: {
grid: {
display: false
},
ticks: {
color: style.getPropertyValue('--admin-text-muted').trim(),
font: { family: 'Vazirmatn', size: 12 }
}
},
y: { y: {
grid: {
color: style.getPropertyValue('--admin-border').trim(),
drawBorder: false,
},
ticks: {
color: style.getPropertyValue('--admin-text-muted').trim(),
font: { family: 'Vazirmatn', size: 12 },
padding: 10,
callback: (value) => new Intl.NumberFormat('fa-IR', { notation: 'compact' }).format(value)
},
beginAtZero: true beginAtZero: true
} }
} }

View File

@ -1,5 +1,35 @@
</div><!-- /.admin-main-content --> </main> <!-- .admin-main-content's inner main -->
</div><!-- /.admin-wrapper --> </div> <!-- .admin-main-content -->
</div> <!-- .admin-wrapper -->
<div class="sidebar-backdrop" id="sidebar-backdrop"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const sidebar = document.querySelector('.admin-sidebar');
const sidebarToggle = document.getElementById('sidebar-toggle');
const adminWrapper = document.querySelector('.admin-wrapper');
const backdrop = document.getElementById('sidebar-backdrop');
if (sidebarToggle) {
sidebarToggle.addEventListener('click', function() {
if (window.innerWidth <= 992) {
sidebar.classList.toggle('open');
backdrop.classList.toggle('show');
} else {
adminWrapper.classList.toggle('sidebar-collapsed');
}
});
}
if (backdrop) {
backdrop.addEventListener('click', function() {
sidebar.classList.remove('open');
this.classList.remove('show');
});
}
});
</script>
</body> </body>
</html> </html>

View File

@ -32,6 +32,46 @@ if ($action === 'update_order_status') {
} }
} }
if ($action === 'add_user') {
$first_name = filter_input(INPUT_POST, 'first_name', FILTER_SANITIZE_STRING);
$last_name = filter_input(INPUT_POST, 'last_name', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING);
$password = $_POST['password'] ?? '';
$is_admin = filter_input(INPUT_POST, 'is_admin', FILTER_VALIDATE_INT) ? 1 : 0;
if ($first_name && $last_name && $email && !empty($password)) {
try {
$pdo = db();
// Check if user already exists
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$_SESSION['error_message'] = "کاربری با این ایمیل از قبل وجود دارد.";
header('Location: users.php');
exit;
}
// Hash password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Insert user
$stmt = $pdo->prepare("INSERT INTO users (first_name, last_name, email, phone, password, is_admin, created_at) VALUES (?, ?, ?, ?, ?, ?, NOW())");
$stmt->execute([$first_name, $last_name, $email, $phone, $hashed_password, $is_admin]);
$_SESSION['success_message'] = "کاربر جدید با موفقیت اضافه شد.";
} catch (PDOException $e) {
error_log("Add user failed: " . $e->getMessage());
$_SESSION['error_message'] = "خطایی در افزودن کاربر جدید رخ داد.";
}
} else {
$_SESSION['error_message'] = "اطلاعات وارد شده نامعتبر است. لطفاً تمام فیلدهای ستاره‌دار را پر کنید.";
}
header('Location: users.php');
exit;
}
header('Location: orders.php'); header('Location: orders.php');
exit; exit;
?> ?>

View File

@ -5,8 +5,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo isset($page_title) ? $page_title . ' - ' : ''; ?>پنل مدیریت آتیمه</title> <title><?php echo isset($page_title) ? $page_title . ' - ' : ''; ?>پنل مدیریت آتیمه</title>
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
<!-- IRANSans Font -->
<link rel="stylesheet" href="https://font-ir.s3.ir-thr-at1.arvanstorage.com/IRANSans/css/IRANSans.css">
<!-- Main Theme CSS -->
<link rel="stylesheet" href="../assets/css/theme.css?v=<?php echo time(); ?>">
<!-- Font Awesome for admin icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- Main Admin Stylesheet -->
<link rel="stylesheet" href="assets/css/admin_style.css?v=<?php echo time(); ?>"> <link rel="stylesheet" href="assets/css/admin_style.css?v=<?php echo time(); ?>">
<!-- SweetAlert2 --> <!-- SweetAlert2 -->
@ -15,8 +22,17 @@
<!-- Chart.js --> <!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head> </head>
<body class="admin-dark-theme"> <body class="admin-body">
<div class="admin-wrapper"> <div class="admin-wrapper">
<?php require_once 'nav.php'; // The sidebar is included here ?> <?php require_once 'nav.php'; ?>
<main class="admin-main-content"> <div class="admin-main-content">
<header class="admin-header-bar">
<button id="sidebar-toggle" class="btn">
<i class="fas fa-bars"></i>
</button>
<div class="admin-header-title">
<h1><?php echo isset($page_title) ? $page_title : 'داشبورد'; ?></h1>
</div>
</header>
<main>

View File

@ -2,6 +2,8 @@
session_start(); session_start();
require_once __DIR__ . '/auth_check.php'; require_once __DIR__ . '/auth_check.php';
require_once __DIR__ . '/../db/config.php'; require_once __DIR__ . '/../db/config.php';
$page_title = 'داشبورد';
require_once __DIR__ . '/header.php'; require_once __DIR__ . '/header.php';
$dashboard_error = null; $dashboard_error = null;
@ -48,30 +50,7 @@ function get_status_badge_class($status) {
} }
?> ?>
<style>
.status-badge {
padding: 0.3em 0.6em;
border-radius: 6px;
font-size: 0.8rem;
font-weight: 600;
color: #fff;
}
.status-processing { background-color: var(--admin-info); }
.status-shipped { background-color: var(--admin-warning); }
.status-delivered { background-color: var(--admin-success); }
.status-cancelled { background-color: var(--admin-danger); }
.status-pending { background-color: var(--admin-text-muted); }
.stat-cards-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
</style>
<div class="admin-header">
<h1>داشبورد اصلی</h1>
</div>
<?php if ($flash_message): ?> <?php if ($flash_message): ?>
<script> <script>

View File

@ -7,27 +7,39 @@
<ul class="admin-nav"> <ul class="admin-nav">
<li class="admin-nav-item"> <li class="admin-nav-item">
<a class="admin-nav-link <?php echo ($current_page == 'index.php' || $current_page == 'dashboard.php') ? 'active' : ''; ?>" href="index.php"> <a class="admin-nav-link <?php echo ($current_page == 'index.php' || $current_page == 'dashboard.php') ? 'active' : ''; ?>" href="index.php">
<i class="ri-dashboard-line"></i> <i class="fas fa-tachometer-alt"></i>
<span>داشبورد</span> <span>داشبورد</span>
</a> </a>
</li> </li>
<li class="admin-nav-item"> <li class="admin-nav-item">
<a class="admin-nav-link <?php echo in_array($current_page, ['products.php', 'add_product.php', 'edit_product.php']) ? 'active' : ''; ?>" href="products.php"> <a class="admin-nav-link <?php echo in_array($current_page, ['products.php', 'add_product.php', 'edit_product.php']) ? 'active' : ''; ?>" href="products.php">
<i class="ri-shopping-cart-2-line"></i> <i class="fas fa-box"></i>
<span>محصولات</span> <span>محصولات</span>
</a> </a>
</li> </li>
<li class="admin-nav-item"> <li class="admin-nav-item">
<a class="admin-nav-link <?php echo ($current_page == 'orders.php') ? 'active' : ''; ?>" href="orders.php"> <a class="admin-nav-link <?php echo ($current_page == 'orders.php') ? 'active' : ''; ?>" href="orders.php">
<i class="ri-file-list-3-line"></i> <i class="fas fa-clipboard-list"></i>
<span>سفارشات</span> <span>سفارشات</span>
</a> </a>
</li> </li>
<li class="admin-nav-item">
<a class="admin-nav-link <?php echo ($current_page == 'reports.php') ? 'active' : ''; ?>" href="reports.php">
<i class="fas fa-chart-bar"></i>
<span>گزارشات</span>
</a>
</li>
<li class="admin-nav-item">
<a class="admin-nav-link <?php echo ($current_page == 'users.php') ? 'active' : ''; ?>" href="users.php">
<i class="fas fa-users"></i>
<span>کاربران</span>
</a>
</li>
</ul> </ul>
</nav> </nav>
<div class="sidebar-footer"> <div class="sidebar-footer">
<a href="../index.php" target="_blank"><i class="ri-external-link-line"></i> مشاهده سایت</a> <a href="../index.php" target="_blank"><i class="fas fa-external-link-alt"></i> مشاهده سایت</a>
<hr style="border-color: var(--admin-border-light); margin: 1rem 0;"> <hr style="border-color: var(--admin-border-light); margin: 1rem 0;">
<a href="logout.php"><i class="ri-logout-box-line"></i> خروج</a> <a href="logout.php"><i class="fas fa-sign-out-alt"></i> خروج</a>
</div> </div>
</aside> </aside>

View File

@ -68,7 +68,8 @@ document.addEventListener('DOMContentLoaded', () => {
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<table class="table"> <div class="table-responsive">
<table class="table">
<thead> <thead>
<tr><th>شماره</th><th>نام مشتری</th><th>مبلغ کل</th><th>وضعیت</th><th>تاریخ</th><th style="text-align: left;">عملیات</th></tr> <tr><th>شماره</th><th>نام مشتری</th><th>مبلغ کل</th><th>وضعیت</th><th>تاریخ</th><th style="text-align: left;">عملیات</th></tr>
</thead> </thead>
@ -91,6 +92,7 @@ document.addEventListener('DOMContentLoaded', () => {
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div> </div>
@ -111,6 +113,7 @@ document.addEventListener('DOMContentLoaded', () => {
<strong>تلفن:</strong> <?php echo htmlspecialchars($order['billing_phone']); ?></p> <strong>تلفن:</strong> <?php echo htmlspecialchars($order['billing_phone']); ?></p>
<hr style="border-color: var(--admin-border);"> <hr style="border-color: var(--admin-border);">
<h6>محصولات</h6> <h6>محصولات</h6>
<div class="table-responsive">
<table class="table items-list"> <table class="table items-list">
<thead> <thead>
<tr> <tr>
@ -137,6 +140,7 @@ document.addEventListener('DOMContentLoaded', () => {
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div>
<hr style="border-color: var(--admin-border);"> <hr style="border-color: var(--admin-border);">
<h5 style="text-align: left;">مبلغ نهایی: <?php echo number_format($order['total_amount']); ?> تومان</h5> <h5 style="text-align: left;">مبلغ نهایی: <?php echo number_format($order['total_amount']); ?> تومان</h5>
</div> </div>

View File

@ -25,7 +25,8 @@ if ($flash_message) {
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<table class="table"> <div class="table-responsive">
<table class="table">
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
@ -52,6 +53,7 @@ if ($flash_message) {
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div> </div>

175
admin/reports.php Normal file
View File

@ -0,0 +1,175 @@
<?php
$page_title = 'گزارشات';
require_once __DIR__ . '/header.php';
?>
<div class="admin-header">
<h1><?php echo $page_title; ?></h1>
</div>
<!-- Stat Cards -->
<div class="stat-cards-grid-reports" style="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));">
<div class="stat-card-report">
<p>مجموع درآمد</p>
<h3 id="total-revenue">...</h3>
</div>
<div class="stat-card-report">
<p>تعداد سفارشات</p>
<h3 id="total-orders">...</h3>
</div>
<div class="stat-card-report">
<p>تعداد کاربران</p>
<h3 id="total-users">...</h3>
</div>
<div class="stat-card-report">
<p>تعداد محصولات</p>
<h3 id="total-products">...</h3>
</div>
</div>
<!-- Sales Chart -->
<div class="card">
<div class="card-header">نمودار فروش ماهانه</div>
<div class="card-body">
<canvas id="salesChart"></canvas>
</div>
</div>
<div class="row" style="display: flex; gap: 2rem; margin-top: 2rem;">
<!-- Recent Orders -->
<div class="card" style="flex: 1;">
<div class="card-header">آخرین سفارشات</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>شماره سفارش</th>
<th>مشتری</th>
<th>مبلغ</th>
<th>وضعیت</th>
</tr>
</thead>
<tbody id="recent-orders-body">
<!-- Data will be loaded via JS -->
</tbody>
</table>
</div>
</div>
</div>
<!-- Top Selling Products -->
<div class="card" style="flex: 1;">
<div class="card-header">محصولات پرفروش</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>محصول</th>
<th>تعداد فروش</th>
</tr>
</thead>
<tbody id="top-products-body">
<!-- Data will be loaded via JS -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Fetch general reports data
fetch('api.php?action=get_reports_data')
.then(response => response.json())
.then(data => {
if (data.error) {
console.error(data.error);
return;
}
document.getElementById('total-revenue').textContent = new Intl.NumberFormat('fa-IR').format(data.stats.total_revenue) + ' تومان';
document.getElementById('total-orders').textContent = data.stats.total_orders;
document.getElementById('total-users').textContent = data.stats.total_users;
document.getElementById('total-products').textContent = data.stats.total_products;
const recentOrdersBody = document.getElementById('recent-orders-body');
if(data.recent_orders.length > 0) {
data.recent_orders.forEach(order => {
let row = `<tr>
<td>#${order.id}</td>
<td>${order.customer_display_name}</td>
<td>${new Intl.NumberFormat('fa-IR').format(order.total_amount)} تومان</td>
<td><span class="status-badge status-${order.status.toLowerCase()}">${order.status}</span></td>
</tr>`;
recentOrdersBody.innerHTML += row;
});
} else {
recentOrdersBody.innerHTML = '<tr><td colspan="4" class="text-center">سفارشی یافت نشد.</td></tr>';
}
const topProductsBody = document.getElementById('top-products-body');
if(data.top_products.length > 0) {
data.top_products.forEach(product => {
let row = `<tr>
<td>${product.name}</td>
<td>${product.total_sold} عدد</td>
</tr>`;
topProductsBody.innerHTML += row;
});
} else {
topProductsBody.innerHTML = '<tr><td colspan="2" class="text-center">محصولی یافت نشد.</td></tr>';
}
})
.catch(error => console.error('Error fetching reports:', error));
// Fetch monthly sales data for the chart
fetch('api.php?action=get_monthly_sales')
.then(response => response.json())
.then(data => {
if (data.error) {
console.error('Error fetching chart data:', data.error);
return;
}
const ctx = document.getElementById('salesChart').getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: data.labels,
datasets: [{
label: 'فروش ماهانه',
data: data.values,
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value, index, values) {
return new Intl.NumberFormat('fa-IR').format(value) + ' تومان';
}
}
}
}
}
});
})
.catch(error => console.error('Error fetching chart data:', error));
});
</script>
<?php
require_once __DIR__ . '/footer.php';
?>

136
admin/users.php Normal file
View File

@ -0,0 +1,136 @@
<?php
$page_title = 'مدیریت کاربران';
require_once __DIR__ . '/header.php';
require_once __DIR__ . '/../db/config.php';
try {
$pdo = db();
$stmt = $pdo->query("SELECT id, first_name, last_name, email, phone, created_at FROM users WHERE is_admin = 0 ORDER BY created_at DESC");
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
$user_count = count($users);
} catch (PDOException $e) {
die("Error fetching users: " . $e->getMessage());
}
?>
<div class="admin-header">
<h1><?php echo $page_title; ?></h1>
<div style="display: flex; align-items: center; gap: 1rem;">
<button id="add-user-btn" class="btn btn-primary">افزودن کاربر جدید</button>
<span>تعداد کل کاربران:</span>
<span class="badge bg-primary" style="font-size: 1rem; background-color: var(--admin-primary) !important; color: #000 !important; padding: 0.5rem 1rem; border-radius: 8px;"><?php echo $user_count; ?></span>
</div>
</div>
<?php if (isset($_SESSION['success_message'])): ?>
<div class="alert alert-success" style="background-color: var(--admin-success); color: #fff; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;"><?php echo $_SESSION['success_message']; unset($_SESSION['success_message']); ?></div>
<?php endif; ?>
<?php if (isset($_SESSION['error_message'])): ?>
<div class="alert alert-danger" style="background-color: var(--admin-danger); color: #fff; padding: 1rem; border-radius: 8px; margin-bottom: 1rem;"><?php echo $_SESSION['error_message']; unset($_SESSION['error_message']); ?></div>
<?php endif; ?>
<div id="add-user-form-container" class="card" style="display: none; margin-bottom: 2rem;">
<div class="card-header">فرم افزودن کاربر جدید</div>
<div class="card-body">
<form action="handler.php" method="POST">
<input type="hidden" name="action" value="add_user">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem;">
<div class="form-group">
<label for="first_name" class="form-label">نام</label>
<input type="text" id="first_name" name="first_name" class="form-control" required>
</div>
<div class="form-group">
<label for="last_name" class="form-label">نام خانوادگی</label>
<input type="text" id="last_name" name="last_name" class="form-control" required>
</div>
<div class="form-group">
<label for="email" class="form-label">ایمیل</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="phone" class="form-label">شماره تلفن</label>
<input type="text" id="phone" name="phone" class="form-control">
</div>
<div class="form-group">
<label for="password" class="form-label">رمز عبور</label>
<input type="password" id="password" name="password" class="form-control" required>
</div>
<div class="form-group" style="align-self: center;">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="is_admin" id="is_admin" value="1">
<label class="form-check-label" for="is_admin">
ادمین باشد؟
</label>
</div>
</div>
</div>
<div style="text-align: left;">
<button type="submit" class="btn btn-primary">ذخیره کاربر</button>
<button type="button" id="cancel-add-user" class="btn btn-secondary">انصراف</button>
</div>
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const addUserBtn = document.getElementById('add-user-btn');
const addUserForm = document.getElementById('add-user-form-container');
const cancelBtn = document.getElementById('cancel-add-user');
if(addUserBtn) {
addUserBtn.addEventListener('click', () => {
addUserForm.style.display = 'block';
addUserBtn.style.display = 'none';
});
}
if(cancelBtn) {
cancelBtn.addEventListener('click', () => {
addUserForm.style.display = 'none';
addUserBtn.style.display = 'block';
});
}
});
</script>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>نام</th>
<th>ایمیل</th>
<th>شماره تلفن</th>
<th>تاریخ عضویت</th>
</tr>
</thead>
<tbody>
<?php if (empty($users)):
?>
<tr><td colspan="5" style="text-align: center; padding: 2rem;">هیچ کاربری یافت نشد.</td></tr>
<?php else: ?>
<?php foreach ($users as $user):
?>
<tr>
<td><?php echo htmlspecialchars($user['id']); ?></td>
<td><?php echo htmlspecialchars(trim($user['first_name'] . ' ' . $user['last_name'])); ?></td>
<td><?php echo htmlspecialchars($user['email']); ?></td>
<td><?php echo htmlspecialchars($user['phone'] ?? 'ثبت نشده'); ?></td>
<td><?php echo date("Y-m-d", strtotime($user['created_at'])); ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<?php
require_once __DIR__ . '/footer.php';
?>

View File

@ -1,89 +1,143 @@
<?php <?php
session_start();
header('Content-Type: application/json'); header('Content-Type: application/json');
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', '/var/log/apache2/flatlogic_error.log');
require_once '../db/config.php'; require_once '../db/config.php';
require_once '../includes/jdf.php'; require_once '../includes/jdf.php';
// Function to translate order status // Function to send JSON error response
function get_persian_status($status) { function send_error($message) {
switch ($status) { echo json_encode(['error' => $message]);
case 'pending': return 'در انتظار پرداخت'; exit();
case 'processing': return 'در حال پردازش';
case 'shipped': return 'ارسال شده';
case 'completed': return 'تکمیل شده';
case 'cancelled': return 'لغو شده';
case 'refunded': return 'مسترد شده';
default: return 'نامشخص';
}
} }
$response = ['success' => false, 'message' => 'Invalid request']; if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
send_error('Invalid request method.');
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_data = json_decode(file_get_contents('php://input'), true);
try {
// Read JSON from the request body
$json_data = file_get_contents('php://input');
$data = json_decode($json_data, true);
$tracking_id = $data['tracking_id'] ?? '';
if (empty($tracking_id)) { if (!isset($input_data['tracking_id']) || empty($input_data['tracking_id'])) {
throw new Exception('کد رهگیری سفارش الزامی است.'); send_error('شناسه رهگیری مشخص نشده است.');
} }
$db = db(); $tracking_id = $input_data['tracking_id'];
$stmt = $db->prepare(
"SELECT
o.*,
o.billing_name AS full_name
FROM orders o
WHERE o.tracking_id = :tracking_id"
);
$stmt->execute([':tracking_id' => $tracking_id]);
$order = $stmt->fetch(PDO::FETCH_ASSOC);
if ($order) { try {
$items_json = $order['items_json']; $db = db();
$items = json_decode($items_json, true);
$products = [];
if (is_array($items)) {
$product_stmt = $db->prepare("SELECT name, price, image_url FROM products WHERE id = :product_id");
foreach ($items as $item) {
$product_stmt->execute([':product_id' => $item['id']]);
$product_details = $product_stmt->fetch(PDO::FETCH_ASSOC);
if ($product_details) {
$products[] = [
'name' => $product_details['name'],
'price' => $product_details['price'],
'image_url' => $product_details['image_url'],
'quantity' => $item['quantity'],
'color' => $item['color'] ?? null,
];
}
}
}
// Format data for response
$order['created_at_jalali'] = jdate('Y/m/d H:i', strtotime($order['created_at']));
$order['status_jalali'] = get_persian_status($order['status']);
$response['success'] = true;
$response['message'] = 'سفارش یافت شد.';
$response['order'] = $order;
$response['products'] = $products;
} else {
$response['message'] = 'سفارشی با این مشخصات یافت نشد.';
}
} catch (PDOException $e) {
error_log("Order tracking PDO error: " . $e->getMessage());
$response['message'] = 'خطا در پایگاه داده رخ داد: ' . $e->getMessage();
} catch (Exception $e) {
error_log("Order tracking general error: " . $e->getMessage());
$response['message'] = $e->getMessage(); // Show the specific error message for now
}
echo json_encode($response);
// 1. Fetch the order by tracking_id
$stmt = $db->prepare(
"SELECT id, billing_name, billing_email, billing_address, billing_city, billing_province, billing_postal_code, total_amount, items_json, created_at, status
FROM orders
WHERE tracking_id = :tracking_id"
);
$stmt->bindParam(':tracking_id', $tracking_id, PDO::PARAM_STR);
$stmt->execute();
$order = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$order) {
send_error('سفارشی با این کد رهگیری یافت نشد.');
}
// 2. Decode items JSON and fetch product details
$items_from_db = json_decode($order['items_json'], true);
$products_response = [];
$product_ids = [];
if (is_array($items_from_db)) {
foreach ($items_from_db as $item) {
if (isset($item['product_id'])) {
$product_ids[] = $item['product_id'];
}
}
}
if (!empty($product_ids)) {
$placeholders = implode(',', array_fill(0, count($product_ids), '?'));
// Price is taken from items_json, not the products table, which is correct.
// The selected color is also in items_json.
$stmt_products = $db->prepare("SELECT id, name, image_url FROM products WHERE id IN ($placeholders)");
$stmt_products->execute($product_ids);
$products_data = $stmt_products->fetchAll(PDO::FETCH_ASSOC);
$products_by_id = [];
foreach ($products_data as $product) {
$products_by_id[$product['id']] = $product;
}
foreach ($items_from_db as $item) {
$product_id = $item['product_id'];
if (isset($products_by_id[$product_id])) {
$product = $products_by_id[$product_id];
$products_response[] = [
'id' => $product['id'],
'name' => $product['name'],
'price' => number_format($item['price']) . ' تومان',
'image_url' => $product['image_url'],
'quantity' => $item['quantity'],
'color' => $item['color'] ?? null // Add the selected color from the order
];
}
}
}
// 3. Format the response
$status_map = [
'pending' => 'در انتظار پرداخت',
'processing' => 'در حال پردازش',
'shipped' => 'ارسال شده',
'completed' => 'تکمیل شده',
'delivered' => 'تحویل شده', // Add mapping for Delivered
'cancelled' => 'لغو شده',
'refunded' => 'مسترد شده'
];
$status_persian = $status_map[strtolower($order['status'])] ?? $order['status'];
// Robust date formatting to prevent errors
try {
// Create DateTime object to reliably parse the date from DB
$date = new DateTime($order['created_at']);
$timestamp = $date->getTimestamp();
// Format the timestamp into Jalali date
$order_date_jalali = jdate('Y/m/d ساعت H:i', $timestamp);
} catch (Exception $e) {
// If parsing fails, log the error and return a safe value
error_log("Jalali date conversion failed for order ID {$order['id']}: " . $e->getMessage());
$order_date_jalali = 'تاریخ نامعتبر';
}
$order_response = [
'id' => $order['id'],
'order_date' => $order_date_jalali,
'total_amount' => number_format($order['total_amount']) . ' تومان',
'discount_amount' => '0 تومان',
'status' => $order['status'], // Pass original status to JS for logic
'status_persian' => $status_persian, // Pass Persian status for display
'shipping_name' => $order['billing_name'],
'shipping_address' => trim(implode(', ', array_filter([$order['billing_province'], $order['billing_city'], $order['billing_address']]))),
'shipping_postal_code' => $order['billing_postal_code']
];
// Final JSON structure
$response = [
'success' => true,
'order' => $order_response,
'products' => $products_response
];
echo json_encode($response, JSON_UNESCAPED_UNICODE);
} catch (PDOException $e) {
error_log("API Error in get_order_details.php: " . $e->getMessage());
send_error('خطای سرور: مشکل در ارتباط با پایگاه داده.');
} catch (Exception $e) {
error_log("API Error in get_order_details.php: " . $e->getMessage());
send_error('خطای سرور: یک مشکل پیش بینی نشده رخ داد.');
} }
?> ?>

View File

@ -1,3 +1,333 @@
.empty-cart-container .btn-checkout i { /* Resetting styles for the new theme. */
color: inherit !important;
.about-us-list {
width: 80vw;
display: grid;
list-style: none;
padding: 0;
grid-template-columns: repeat(3, 1fr);
justify-items: center;
margin: 0 auto;
gap: 20px;
}
.about-us-item {
width: 20vw;
min-width: 200px;
border-radius: 20px;
text-align: center;
border: 1px solid #ebebeb;
}
.inner {
position: relative;
inset: 0px;
overflow: hidden;
transition: inherit;
}
.inner::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(-65deg, #0000 40%, #fff7 50%, #0000 70%);
background-size: 200% 100%;
background-repeat: no-repeat;
animation: thing 1.5s ease infinite;
border-radius: 20px;
}
@keyframes thing {
0% {
background-position: 130%;
opacity: 1;
}
to {
background-position: -166%;
opacity: 0;
}
}
@media (max-width: 768px) {
.about-us-list {
grid-template-columns: 1fr;
}
.about-us-item {
width: 80%;
}
}
/* --- Order Tracking Modal Styles --- */
.tracking-modal-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1050;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.tracking-modal-container.visible {
opacity: 1;
visibility: visible;
}
.modal-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
}
.modal-content {
position: relative;
background-color: #2c2c2c;
color: #f0f0f0;
border-radius: 15px;
width: 90%;
max-width: 800px;
max-height: 90vh;
overflow-y: auto;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.1);
transform: scale(0.95);
transition: transform 0.3s ease;
}
.tracking-modal-container.visible .modal-content {
transform: scale(1);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1.5rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.modal-header h3 {
margin: 0;
font-size: 1.5rem;
font-weight: 500;
}
#modal-order-id {
font-weight: bold;
color: var(--bs-primary);
}
.modal-close-btn {
background: none;
border: none;
color: #f0f0f0;
font-size: 2rem;
line-height: 1;
cursor: pointer;
opacity: 0.7;
transition: opacity 0.2s;
}
.modal-close-btn:hover {
opacity: 1;
}
.modal-body {
padding: 1.5rem;
display: grid;
gap: 2rem;
}
.order-summary,
.shipping-details,
.products-list,
.status-details {
background-color: rgba(255, 255, 255, 0.05);
padding: 1.5rem;
border-radius: 10px;
}
.order-summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
}
.modal-body h4 {
margin-top: 0;
margin-bottom: 1rem;
font-weight: 500;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
padding-bottom: 0.5rem;
}
.detail-item {
font-size: 0.95rem;
}
.detail-item strong {
color: #a0a0a0;
margin-left: 8px;
}
/* --- Status Tracker --- */
.status-tracker {
position: relative;
display: flex;
justify-content: space-between;
padding: 20px 0;
margin-top: 20px;
}
.status-tracker::before {
content: '';
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
width: calc(100% - 40px);
margin: 0 20px;
height: 4px;
background-color: #444;
z-index: 1;
}
.status-progress {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 20px;
height: 4px;
background-color: var(--bs-primary);
z-index: 2;
transition: width 0.5s ease;
}
.status-step {
position: relative;
z-index: 3;
text-align: center;
width: 100px;
}
.status-step .dot {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #444;
border: 3px solid #2c2c2c;
margin: 0 auto;
transform: translateY(-8px);
transition: background-color 0.5s ease;
}
.status-step .label {
display: block;
margin-top: 10px;
font-size: 0.8rem;
color: #a0a0a0;
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 {
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;
}
/* --- Products List --- */
#modal-products-list {
display: flex;
flex-direction: column;
gap: 1rem;
}
.product-item {
display: flex;
align-items: center;
gap: 1rem;
background: rgba(255, 255, 255, 0.05);
padding: 10px;
border-radius: 8px;
}
.product-item img {
width: 60px;
height: 60px;
object-fit: cover;
border-radius: 6px;
}
.product-info {
flex-grow: 1;
}
.product-name {
display: block;
font-weight: 500;
}
.product-quantity {
font-size: 0.9rem;
color: #a0a0a0;
}
.product-price {
font-weight: bold;
}
/* --- Product Color Dot --- */
.product-meta {
display: flex;
align-items: center;
gap: 1rem;
font-size: 0.9rem;
color: #a0a0a0;
margin-top: 4px;
}
.product-color-wrapper {
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.product-color-dot {
width: 16px;
height: 16px;
border-radius: 50%;
border: 1px solid rgba(255, 255, 255, 0.2);
display: inline-block;
} }

File diff suppressed because it is too large Load Diff

325
assets/css/theme.css Normal file
View File

@ -0,0 +1,325 @@
/*
* Dark & Luxury Theme
* Palette: Black, Gray, Custom Blue
* Font: Vazirmatn
*/
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');
:root {
/* Color Palette */
--color-dark-bg: #111111; /* پس‌زمینه اصلی (مشکی) */
--color-surface: #1f2326; /* پس‌زمینه بخش‌ها (خاکستری تیره‌تر) */
--color-card-bg: #2a2f34; /* پس‌زمینه کارت‌ها */
--color-border: #333333; /* رنگ جداکننده‌ها و حاشیه‌ها */
--color-gold: #e5b56e; /* رنگ شاخص (طلایی سفارشی) */
--color-gold-hover: #e9bc7e; /* رنگ هاور طلایی سفارشی */
/* Text Colors */
--color-text-primary: #F5F5F5; /* متن اصلی (سفید دودی) */
--color-text-secondary: #E0E0E0; /* متن ثانویه (خاکستری روشن) */
/* Bootstrap Overrides */
--bs-body-bg: var(--color-dark-bg);
--bs-body-color: var(--color-text-primary);
--bs-border-color: var(--color-border);
--bs-primary: var(--color-gold);
--bs-primary-rgb: 229, 181, 110;
/* Spacing */
--section-padding-lg: 6rem;
--section-padding-md: 4rem;
}
/* --- Base & Typography --- */
body {
font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
direction: rtl;
text-align: right;
line-height: 1.8;
font-weight: 400;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html {
scroll-behavior: smooth;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 700; /* فونت ضخیم‌تر برای عناوین */
color: var(--color-text-primary);
}
a {
color: var(--color-gold);
text-decoration: none;
transition: color 0.3s ease;
}
a:hover {
color: var(--color-gold-hover);
}
/* --- Layout & Spacing --- */
.section-padding {
padding-top: var(--section-padding-md);
padding-bottom: var(--section-padding-md);
}
@media (min-width: 992px) {
.section-padding {
padding-top: var(--section-padding-lg);
padding-bottom: var(--section-padding-lg);
}
}
.section-title {
position: relative;
padding-bottom: 15px;
}
.section-title::after {
content: '';
position: absolute;
display: block;
width: 60px;
height: 3px;
background: var(--color-gold);
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
/* For right-aligned titles */
.text-md-end .section-title::after,
.text-end .section-title::after {
left: auto;
right: 0;
transform: none;
}
/* --- Page Specific --- */
/* Hero Section */
.hero-section .hero-title {
font-weight: 800;
text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}
.hero-section .hero-subtitle {
text-shadow: 0 2px 15px rgba(0,0,0,0.5);
font-weight: 300;
letter-spacing: 0.5px;
}
/* About Us Section */
.about-us-image {
border-radius: 12px;
box-shadow: 0 15px 40px rgba(0,0,0,0.4);
transition: transform 0.4s ease;
}
.about-us-image:hover {
transform: scale(1.03);
}
/* --- General Components --- */
.card {
background-color: var(--color-card-bg);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 15px; /* کمی گردتر */
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
transition: all 0.4s ease;
overflow: hidden;
}
.card:hover {
transform: translateY(-8px);
box-shadow: 0 12px 45px rgba(0, 0, 0, 0.5);
border-color: rgba(var(--bs-primary-rgb), 0.5);
}
.card.card-static:hover {
transform: none;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); /* Keep original shadow */
border-color: rgba(255, 255, 255, 0.05); /* Keep original border */
}
.card-header, .card-footer {
background-color: rgba(0,0,0,0.1);
border-bottom: 1px solid var(--color-border);
}
.btn-primary {
background-color: var(--color-gold);
border-color: var(--color-gold);
color: #111; /* رنگ متن تیره برای کنتراست روی دکمه طلایی */
font-weight: 600;
padding: 10px 25px;
border-radius: 8px;
transition: all 0.3s ease;
}
.btn-primary:hover, .btn-primary:focus {
background-color: var(--color-gold-hover);
border-color: var(--color-gold-hover);
color: #000;
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(218, 165, 32, 0.2);
}
.form-control {
background-color: var(--color-surface);
border-color: var(--color-border);
color: var(--color-text-primary);
border-radius: 8px;
}
.form-control:focus {
background-color: var(--color-surface);
border-color: var(--color-gold);
color: var(--color-text-primary);
box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}
.form-control::placeholder {
color: var(--color-text-secondary);
opacity: 0.7;
}
/* --- Utilities --- */
.text-gold {
color: var(--color-gold) !important;
}
.text-muted {
color: #bbbbbb !important;
}
.bg-surface {
background-color: var(--color-surface) !important;
}
/* --- Header --- */
.site-header {
background-color: rgba(17, 17, 17, 0.85);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-bottom: 1px solid transparent;
transition: border-color 0.3s ease;
}
.site-header.header-scrolled {
border-color: var(--color-border);
}
.site-header .navbar-brand {
color: var(--color-gold);
}
.site-header .nav-link {
color: var(--color-text-secondary);
transition: color 0.3s ease;
}
.site-header .nav-link:hover, .site-header .nav-link.active {
color: var(--color-gold);
}
.navbar-toggler {
border-color: rgba(var(--bs-primary-rgb), 0.5) !important;
}
.navbar-toggler-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(229, 181, 110, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}
/* --- Product Card --- */
.product-card {
/* This class is a specific implementation of the .card component. */
/* It inherits border, background, shadow, etc. from .card */
padding: 0; /* Remove card-body padding if any is added globally */
}
/* The hover effect for product-card is slightly different, so we override the transform */
.product-card:hover {
transform: translateY(-8px); /* Keep the slightly larger lift */
}
.product-card .product-image {
aspect-ratio: 3 / 4;
overflow: hidden;
}
.product-card .product-image img {
width: 100%;
height: 100%;
object-fit: cover; /* پوشش کامل کادر بدون تغییر نسبت */
transition: transform 0.5s ease;
}
.product-card:hover .product-image img {
transform: scale(1.08); /* افکت زوم روی هاور */
}
.product-card .product-info {
padding: 1.5rem 0.5rem;
}
.product-card .product-title a {
font-size: 1.1rem;
font-weight: 600;
color: var(--color-text-primary);
text-decoration: none;
}
.product-card .product-price {
color: var(--color-gold);
font-size: 1.2rem;
font-weight: 700;
margin-top: 0.5rem;
}
/* --- Footer --- */
.site-footer {
background-color: var(--color-surface);
border-top: 1px solid var(--color-border);
}
.site-footer h5 {
color: var(--color-gold);
}
.site-footer p,
.site-footer .text-white-50 {
color: var(--color-text-secondary) !important;
}
.site-footer a,
.site-footer a.text-white-50 {
color: var(--color-text-secondary) !important;
transition: color 0.3s ease;
}
.site-footer a:hover {
color: var(--color-gold) !important;
}
.site-footer .social-icon {
font-size: 1.5rem;
color: var(--color-text-secondary);
transition: color 0.3s ease;
}
.site-footer .social-icon:hover {
color: var(--color-gold);
}

View File

@ -1,11 +1,30 @@
// Custom JavaScript will go here
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// --- AOS Initialization --- // Initialize AOS (Animate on Scroll)
AOS.init({ AOS.init({
duration: 800, duration: 800, // Animation duration in ms
once: true, offset: 100, // Offset (in px) from the original trigger point
once: true, // Whether animation should happen only once - while scrolling down
}); });
}); // Add a class to the header when the page is scrolled
const header = document.querySelector('.site-header');
if (header) {
const scrollThreshold = 50; // Pixels to scroll before adding the class
const handleScroll = () => {
if (window.scrollY > scrollThreshold) {
header.classList.add('header-scrolled');
} else {
header.classList.remove('header-scrolled');
}
};
// Listen for the scroll event
window.addEventListener('scroll', handleScroll);
// Initial check in case the page is already scrolled on load
handleScroll();
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

167
cart.php
View File

@ -7,98 +7,105 @@ $cart_items = $_SESSION['cart'] ?? [];
$total_price = 0; $total_price = 0;
?> ?>
<div class="cart-page-wrapper"> <main>
<div class="container"> <section class="section-padding">
<div class="container">
<?php if (empty($cart_items)): ?> <?php if (empty($cart_items)): ?>
<div class="empty-cart-container"> <div class="card card-body text-center p-4 p-md-5" data-aos="fade-up">
<i class="ri-shopping-cart-line"></i> <div class="d-inline-block mx-auto mb-4">
<h2>سبد خرید شما خالی است</h2> <i class="ri-shopping-cart-2-line display-1 text-gold"></i>
<p>به نظر می‌رسد هنوز محصولی به سبد خرید خود اضافه نکرده‌اید. همین حالا گشتی در فروشگاه بزنید.</p> </div>
<a href="shop.php" class="btn btn-primary btn-lg btn-checkout"> <h2 class="mb-3">سبد خرید شما خالی است</h2>
<i class="ri-store-2-line me-2"></i> <p class="text-muted fs-5 mb-4">به نظر می‌رسد هنوز محصولی به سبد خرید خود اضافه نکرده‌اید. همین حالا گشتی در فروشگاه بزنید.</p>
رفتن به فروشگاه <div class="d-inline-block">
</a> <a href="shop.php" class="btn btn-primary btn-lg">
</div> <i class="ri-store-2-line me-2"></i>
<?php else: ?> رفتن به فروشگاه
<div class="text-center mb-5"> </a>
<h1 class="fw-bold display-5">سبد خرید شما</h1> </div>
<p class="text-muted fs-5">جزئیات سفارش خود را بررسی و نهایی کنید.</p> </div>
</div> <?php else: ?>
<div class="row g-5"> <div class="text-center" data-aos="fade-down">
<div class="col-lg-8"> <h1 class="section-title">سبد خرید شما</h1>
<?php foreach ($cart_items as $item_id => $item): <p class="text-muted fs-5">جزئیات سفارش خود را بررسی و نهایی کنید.</p>
$item_total = $item['price'] * $item['quantity']; </div>
$total_price += $item_total;
?> <div class="row g-5 mt-5">
<div class="cart-item-card"> <div class="col-lg-8">
<div class="remove-item-btn"> <?php foreach ($cart_items as $item_id => $item):
<form action="cart_handler.php" method="POST" class="d-inline"> $item_total = $item['price'] * $item['quantity'];
<input type="hidden" name="product_id" value="<?php echo $item['product_id']; ?>"> $total_price += $item_total;
<input type="hidden" name="product_color" value="<?php echo htmlspecialchars($item['color'] ?? ''); ?>"> ?>
<input type="hidden" name="action" value="remove"> <div class="card card-body mb-4" data-aos="fade-up">
<button type="submit" class="btn btn-link text-decoration-none p-0"><i class="ri-close-circle-line"></i></button> <div class="remove-item-btn">
</form> <form action="cart_handler.php" method="POST" class="d-inline">
</div>
<div class="row align-items-center g-3">
<div class="col-md-2 col-3 cart-item-image">
<a href="product.php?id=<?php echo $item['product_id']; ?>">
<img src="<?php echo htmlspecialchars($item['image_url']); ?>" class="img-fluid" alt="<?php echo htmlspecialchars($item['name']); ?>">
</a>
</div>
<div class="col-md-4 col-9 cart-item-details">
<h5><a href="product.php?id=<?php echo $item['product_id']; ?>"><?php echo htmlspecialchars($item['name']); ?></a></h5>
<?php if (!empty($item['color'])) : ?>
<div class="d-flex align-items-center">
<small class="text-muted me-2">رنگ:</small>
<span class="cart-item-color-swatch" style="background-color: <?php echo htmlspecialchars($item['color']); ?>;"></span>
</div>
<?php endif; ?>
</div>
<div class="col-md-3 col-7">
<form action="cart_handler.php" method="POST" class="quantity-selector">
<input type="hidden" name="product_id" value="<?php echo $item['product_id']; ?>"> <input type="hidden" name="product_id" value="<?php echo $item['product_id']; ?>">
<input type="hidden" name="product_color" value="<?php echo htmlspecialchars($item['color'] ?? ''); ?>"> <input type="hidden" name="product_color" value="<?php echo htmlspecialchars($item['color'] ?? ''); ?>">
<input type="hidden" name="action" value="update"> <input type="hidden" name="action" value="remove">
<button type="submit" class="btn btn-link text-decoration-none p-0"><i class="ri-close-circle-line"></i></button>
<button type="submit" name="quantity" value="<?php echo $item['quantity'] + 1; ?>" class="btn">+</button>
<input type="text" value="<?php echo $item['quantity']; ?>" class="quantity-input" readonly>
<button type="submit" name="quantity" value="<?php echo $item['quantity'] - 1; ?>" class="btn" <?php echo $item['quantity'] <= 1 ? 'disabled' : ''; ?>>-</button>
</form> </form>
</div> </div>
<div class="col-md-3 col-5 text-end"> <div class="row align-items-center g-3">
<span class="item-price"><?php echo number_format($item_total); ?> <small>تومان</small></span> <div class="col-md-2 col-3 cart-item-image">
<a href="product.php?id=<?php echo $item['product_id']; ?>">
<img src="<?php echo htmlspecialchars($item['image_url']); ?>" class="img-fluid rounded" alt="<?php echo htmlspecialchars($item['name']); ?>">
</a>
</div>
<div class="col-md-4 col-9 cart-item-details">
<h5><a href="product.php?id=<?php echo $item['product_id']; ?>"><?php echo htmlspecialchars($item['name']); ?></a></h5>
<?php if (!empty($item['color'])) : ?>
<div class="d-flex align-items-center">
<small class="text-muted me-2">رنگ:</small>
<span class="cart-item-color-swatch" style="background-color: <?php echo htmlspecialchars($item['color']); ?>;"></span>
</div>
<?php endif; ?>
</div>
<div class="col-md-3 col-7">
<form action="cart_handler.php" method="POST" class="quantity-selector">
<input type="hidden" name="product_id" value="<?php echo $item['product_id']; ?>">
<input type="hidden" name="product_color" value="<?php echo htmlspecialchars($item['color'] ?? ''); ?>">
<input type="hidden" name="action" value="update">
<button type="submit" name="quantity" value="<?php echo $item['quantity'] + 1; ?>" class="btn">+</button>
<input type="text" value="<?php echo $item['quantity']; ?>" class="quantity-input" readonly>
<button type="submit" name="quantity" value="<?php echo $item['quantity'] - 1; ?>" class="btn" <?php echo $item['quantity'] <= 1 ? 'disabled' : ''; ?>>-</button>
</form>
</div>
<div class="col-md-3 col-5 text-end">
<span class="item-price"><?php echo number_format($item_total); ?> <small>تومان</small></span>
</div>
</div> </div>
</div> </div>
</div> <?php endforeach; ?>
<?php endforeach; ?> </div>
</div>
<div class="col-lg-4"> <div class="col-lg-4">
<div class="order-summary-card"> <div class="card card-body position-sticky" style="top: 2rem;" data-aos="fade-left">
<h4 class="card-title">خلاصه سفارش</h4> <h4 class="card-title">خلاصه سفارش</h4>
<div class="summary-item"> <div class="summary-item">
<span class="label">جمع کل</span> <span class="label">جمع کل</span>
<span class="value"><?php echo number_format($total_price); ?> تومان</span>
</div>
<div class="summary-item">
<span class="label">هزینه ارسال</span>
<span class="value text-success">رایگان</span>
</div>
<div class="summary-total">
<div class="summary-item">
<span class="label">مبلغ نهایی</span>
<span class="value"><?php echo number_format($total_price); ?> تومان</span> <span class="value"><?php echo number_format($total_price); ?> تومان</span>
</div> </div>
</div> <div class="summary-item">
<div class="d-grid mt-4"> <span class="label">هزینه ارسال</span>
<a href="checkout.php" class="btn btn-primary btn-lg btn-checkout"><i class="ri-secure-payment-line me-2"></i>ادامه و پرداخت</a> <span class="value text-success">رایگان</span>
</div>
<div class="summary-total">
<div class="summary-item">
<span class="label">مبلغ نهایی</span>
<span class="value"><?php echo number_format($total_price); ?> تومان</span>
</div>
</div>
<div class="d-grid mt-4">
<a href="checkout.php" class="btn btn-primary btn-lg btn-checkout"><i class="ri-secure-payment-line me-2"></i>ادامه و پرداخت</a>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <?php endif; ?>
<?php endif; ?> </div>
</div> </section>
</div> </main>
<?php require_once 'includes/footer.php'; ?> <?php require_once 'includes/footer.php'; ?>

View File

@ -72,114 +72,123 @@ $grand_total = $total_price + $shipping_cost;
?> ?>
<main class="container my-5 checkout-page-wrapper"> <main class="checkout-page-wrapper">
<div class="row"> <section class="section-padding">
<!-- Billing Details Column --> <div class="container">
<div class="col-lg-8"> <div class="text-center" data-aos="fade-down">
<h2 class="mb-4">جزئیات صورتحساب</h2> <h1 class="section-title">تکمیل سفارش و پرداخت</h1>
<p class="text-muted fs-5">اطلاعات خود را برای ارسال سفارش وارد کنید.</p>
</div>
<?php <div class="row g-5 mt-5">
if (!empty($_SESSION['checkout_errors'])) { <!-- Billing Details Column -->
echo '<div class="alert alert-danger"><ul>'; <div class="col-lg-8" data-aos="fade-right">
foreach ($_SESSION['checkout_errors'] as $error) { <h3 class="mb-4">جزئیات صورتحساب</h3>
echo '<li>' . htmlspecialchars($error) . '</li>';
}
echo '</ul></div>';
// Unset the session variable so it doesn't show again on refresh
unset($_SESSION['checkout_errors']);
}
?>
<form id="checkout-form" action="checkout_handler.php" method="POST">
<div class="checkout-card"> <?php
<div class="card-header">اطلاعات تماس</div> if (!empty($_SESSION['checkout_errors'])) {
<div class="card-body"> echo '<div class="alert alert-danger"><ul>';
<div class="row"> foreach ($_SESSION['checkout_errors'] as $error) {
<div class="col-md-6 mb-3"> echo '<li>' . htmlspecialchars($error) . '</li>';
<label for="firstName" class="form-label">نام</label> }
<input type="text" class="form-control" id="firstName" name="first_name" value="<?= htmlspecialchars($user['first_name'] ?? '') ?>" required> echo '</ul></div>';
</div> // Unset the session variable so it doesn't show again on refresh
<div class="col-md-6 mb-3"> unset($_SESSION['checkout_errors']);
<label for="lastName" class="form-label">نام خانوادگی</label> }
<input type="text" class="form-control" id="lastName" name="last_name" value="<?= htmlspecialchars($user['last_name'] ?? '') ?>" required> ?>
</div>
<div class="col-md-6 mb-3"> <form id="checkout-form" action="checkout_handler.php" method="POST">
<label for="email" class="form-label">ایمیل (اختیاری)</label>
<input type="email" class="form-control" id="email" name="email" value="<?= htmlspecialchars($user['email'] ?? '') ?>"> <div class="card mb-4">
</div> <div class="card-header">اطلاعات تماس</div>
<div class="col-md-6 mb-3"> <div class="card-body">
<label for="phone" class="form-label">تلفن همراه</label> <div class="row">
<input type="tel" class="form-control" id="phone" name="phone_number" value="<?= htmlspecialchars($address['phone_number'] ?? $user['phone_number'] ?? '') ?>" required> <div class="col-md-6 mb-3">
<label for="firstName" class="form-label">نام</label>
<input type="text" class="form-control" id="firstName" name="first_name" value="<?= htmlspecialchars($user['first_name'] ?? '') ?>" required>
</div>
<div class="col-md-6 mb-3">
<label for="lastName" class="form-label">نام خانوادگی</label>
<input type="text" class="form-control" id="lastName" name="last_name" value="<?= htmlspecialchars($user['last_name'] ?? '') ?>" required>
</div>
<div class="col-md-6 mb-3">
<label for="email" class="form-label">ایمیل (اختیاری)</label>
<input type="email" class="form-control" id="email" name="email" value="<?= htmlspecialchars($user['email'] ?? '') ?>">
</div>
<div class="col-md-6 mb-3">
<label for="phone" class="form-label">تلفن همراه</label>
<input type="tel" class="form-control" id="phone" name="phone_number" value="<?= htmlspecialchars($address['phone_number'] ?? $user['phone_number'] ?? '') ?>" required>
</div>
</div>
</div> </div>
</div> </div>
</div>
</div>
<div class="checkout-card"> <div class="card mb-4">
<div class="card-header">آدرس جهت ارسال</div> <div class="card-header">آدرس جهت ارسال</div>
<div class="card-body"> <div class="card-body">
<div class="mb-3"> <div class="mb-3">
<label for="address" class="form-label">آدرس</label> <label for="address" class="form-label">آدرس</label>
<input type="text" class="form-control" id="address" name="address_line" placeholder="خیابان اصلی، کوچه فرعی، پلاک ۱۲۳" value="<?= htmlspecialchars($address['address_line'] ?? '') ?>" required> <input type="text" class="form-control" id="address" name="address_line" placeholder="خیابان اصلی، کوچه فرعی، پلاک ۱۲۳" value="<?= htmlspecialchars($address['address_line'] ?? '') ?>" required>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
<label for="city" class="form-label">شهر</label> <label for="city" class="form-label">شهر</label>
<input type="text" class="form-control" id="city" name="city" value="<?= htmlspecialchars($address['city'] ?? '') ?>" required> <input type="text" class="form-control" id="city" name="city" value="<?= htmlspecialchars($address['city'] ?? '') ?>" required>
</div> </div>
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
<label for="state" class="form-label">استان</label> <label for="state" class="form-label">استان</label>
<input type="text" class="form-control" id="state" name="province" value="<?= htmlspecialchars($address['province'] ?? '') ?>" required> <input type="text" class="form-control" id="state" name="province" value="<?= htmlspecialchars($address['province'] ?? '') ?>" required>
</div> </div>
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
<label for="zip" class="form-label">کد پستی</label> <label for="zip" class="form-label">کد پستی</label>
<input type="text" class="form-control" id="zip" name="postal_code" value="<?= htmlspecialchars($address['postal_code'] ?? '') ?>" required> <input type="text" class="form-control" id="zip" name="postal_code" value="<?= htmlspecialchars($address['postal_code'] ?? '') ?>" required>
</div>
</div>
</div> </div>
</div> </div>
</div>
</form>
</div> </div>
</form> <!-- Order Summary Column -->
</div> <div class="col-lg-4" data-aos="fade-left">
<div class="card card-body position-sticky" style="top: 2rem;">
<h3 class="card-title">خلاصه سفارش شما</h3>
<ul class="summary-item-list">
<?php foreach ($product_details as $item) : ?>
<li>
<span class="product-name"><?= htmlspecialchars($item['name']) ?> <span class="text-muted">(x<?= $item['quantity'] ?>)</span></span>
<span class="product-total">T <?= number_format($item['total']) ?></span>
</li>
<?php endforeach; ?>
</ul>
<!-- Order Summary Column --> <div class="summary-totals">
<div class="col-lg-4"> <div class="total-row">
<div class="order-summary-card checkout-order-summary"> <span class="label">جمع کل</span>
<h3 class="card-title">خلاصه سفارش شما</h3> <span class="value">T <?= number_format($total_price) ?></span>
<ul class="summary-item-list"> </div>
<?php foreach ($product_details as $item) : ?> <div class="total-row">
<li> <span class="label">هزینه ارسال</span>
<span class="product-name"><?= htmlspecialchars($item['name']) ?> <span class="text-muted">(x<?= $item['quantity'] ?>)</span></span> <span class="value">T <?= number_format($shipping_cost) ?></span>
<span class="product-total">T <?= number_format($item['total']) ?></span> </div>
</li> <div class="total-row grand-total mt-3">
<?php endforeach; ?> <span class="label">مبلغ قابل پرداخت</span>
</ul> <span class="value">T <?= number_format($grand_total) ?></span>
</div>
</div>
<div class="summary-totals"> <div class="d-grid mt-4">
<div class="total-row"> <button type="submit" form="checkout-form" class="btn btn-primary btn-lg">
<span class="label">جمع کل</span> <i class="ri-secure-payment-line me-2"></i>
<span class="value">T <?= number_format($total_price) ?></span> پرداخت و ثبت نهایی سفارش
</button>
</div>
</div> </div>
<div class="total-row">
<span class="label">هزینه ارسال</span>
<span class="value">T <?= number_format($shipping_cost) ?></span>
</div>
<div class="total-row grand-total mt-3">
<span class="label">مبلغ قابل پرداخت</span>
<span class="value">T <?= number_format($grand_total) ?></span>
</div>
</div>
<div class="d-grid mt-4">
<button type="submit" form="checkout-form" class="btn btn-primary btn-lg">
<i class="ri-secure-payment-line me-2"></i>
پرداخت و ثبت نهایی سفارش
</button>
</div> </div>
</div> </div>
</div> </div>
</div> </section>
</main> </main>
<?php require_once 'includes/footer.php'; ?> <?php require_once 'includes/footer.php'; ?>

View File

@ -0,0 +1 @@
ALTER TABLE `users` ADD COLUMN `phone` VARCHAR(255) NULL AFTER `email`;

View File

@ -34,32 +34,8 @@ $page_title = $page_title ?? 'فروشگاه آتیمه'; // Default title
<title><?php echo htmlspecialchars($page_title); ?></title> <title><?php echo htmlspecialchars($page_title); ?></title>
<meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'خرید محصولات چرمی لوکس و با کیفیت.'); ?>"> <meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'خرید محصولات چرمی لوکس و با کیفیت.'); ?>">
<!-- Google Fonts --> <!-- IRANSans Font -->
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="stylesheet" href="https://font-ir.s3.ir-thr-at1.arvanstorage.com/IRANSans/css/IRANSans.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&display=swap" rel="stylesheet">
<!-- Bootstrap Variable Overrides for Dark Luxury Theme -->
<style>
:root {
--luxury-bg: #111214;
--luxury-surface: #1a1b1e;
--luxury-text: #eceff1;
--luxury-text-muted: #90a4ae;
--luxury-primary: #c09f80;
--luxury-border: #37474f;
/* Override Bootstrap's root variables */
--bs-body-bg: var(--luxury-bg);
--bs-body-color: var(--luxury-text);
--bs-primary: var(--luxury-primary);
--bs-primary-rgb: 192, 159, 128;
--bs-link-color: var(--luxury-primary);
--bs-link-hover-color: #d4b090; /* A lighter gold for hover */
--bs-border-color: var(--luxury-border);
--bs-tertiary-bg: var(--luxury-surface);
}
</style>
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
@ -70,10 +46,11 @@ $page_title = $page_title ?? 'فروشگاه آتیمه'; // Default title
<!-- AOS CSS --> <!-- AOS CSS -->
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet"> <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<!-- Main Theme CSS -->
<link rel="stylesheet" href="/assets/css/theme.css?v=<?php echo time(); ?>">
<!-- Custom CSS --> <!-- Custom CSS -->
<link rel="stylesheet" href="/assets/css/custom.css?v=<?php echo time(); ?>"> <link rel="stylesheet" href="/assets/css/custom.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="/assets/css/dark_luxury.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script> <script>
// Apply theme from local storage before page load to prevent flashing // Apply theme from local storage before page load to prevent flashing

View File

@ -35,7 +35,7 @@ require_once 'db/config.php';
<!-- Featured Products Section --> <!-- Featured Products Section -->
<section id="featured-products" class="py-5"> <section id="featured-products" class="section-padding">
<div class="container"> <div class="container">
<?php <?php
if (isset($_SESSION['success_message'])) { if (isset($_SESSION['success_message'])) {
@ -47,7 +47,7 @@ require_once 'db/config.php';
unset($_SESSION['error_message']); unset($_SESSION['error_message']);
} }
?> ?>
<div class="section-title text-center mb-5" data-aos="fade-up"> <div class="section-title text-center" data-aos="fade-up">
<h1>مجموعه برگزیده ما</h1> <h1>مجموعه برگزیده ما</h1>
<p class="fs-5 text-muted">دست‌چین شده برای سلیقه‌های خاص.</p> <p class="fs-5 text-muted">دست‌چین شده برای سلیقه‌های خاص.</p>
</div> </div>
@ -96,18 +96,18 @@ require_once 'db/config.php';
</section> </section>
<!-- About Us Section --> <!-- About Us Section -->
<section id="about-us" class="py-5"> <section id="about-us" class="section-padding bg-surface">
<div class="container"> <div class="container">
<div class="row align-items-center g-5"> <div class="row align-items-center g-5">
<div class="col-md-6" data-aos="fade-right"> <div class="col-md-6" data-aos="fade-right">
<img src="<?= htmlspecialchars($about_us_image_url) ?>" alt="درباره ما" class="about-us-image img-fluid"> <img src="<?= htmlspecialchars($about_us_image_url) ?>" alt="درباره ما" class="about-us-image img-fluid">
</div> </div>
<div class="col-md-6" data-aos="fade-left"> <div class="col-md-6" data-aos="fade-left">
<div class="section-title text-md-end text-center"> <div class="section-title text-md-end text-start">
<h1>داستان آتیمه</h1> <h1>داستان آتیمه</h1>
</div> </div>
<p class="text-muted fs-5 mt-3 text-md-end text-center">ما در آتیمه، به تلفیق هنر سنتی و طراحی مدرن باور داریم. هر محصول، حاصل ساعت‌ها کار دست هنرمندان ماهر و استفاده از بهترین چرم‌های طبیعی است. هدف ما خلق آثاری است که نه تنها یک وسیله، بلکه بخشی از داستان و استایل شما باشند.</p> <p class="text-muted fs-5 mt-3 text-md-end text-start">ما در آتیمه، به تلفیق هنر سنتی و طراحی مدرن باور داریم. هر محصول، حاصل ساعت‌ها کار دست هنرمندان ماهر و استفاده از بهترین چرم‌های طبیعی است. هدف ما خلق آثاری است که نه تنها یک وسیله، بلکه بخشی از داستان و استایل شما باشند.</p>
<div class="text-md-end text-center"> <div class="text-md-end text-start">
<a href="about.php" class="btn btn-primary mt-3" data-aos="fade-up" data-aos-delay="200">بیشتر بدانید</a> <a href="about.php" class="btn btn-primary mt-3" data-aos="fade-up" data-aos-delay="200">بیشتر بدانید</a>
</div> </div>
</div> </div>

View File

@ -20,7 +20,7 @@ $page_title = "ورود یا ثبت‌نام";
<!-- Remixicon --> <!-- Remixicon -->
<link href="https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css" rel="stylesheet" /> <link href="https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css" rel="stylesheet" />
<!-- Main Custom CSS (for variables) --> <!-- Main Custom CSS (for variables) -->
<link rel="stylesheet" href="assets/css/dark_luxury.css?v=<?= time(); ?>"> <link rel="stylesheet" href="assets/css/theme.css?v=<?= time(); ?>">
</head> </head>
<body class="dark-luxury"> <body class="dark-luxury">

View File

@ -46,51 +46,54 @@ if (!empty($product['colors'])) {
?> ?>
<main class="container py-5"> <main class="container section-padding">
<div class="row g-5"> <div class="row g-5">
<div class="col-lg-6" data-aos="fade-right"> <div class="col-lg-6" data-aos="fade-right">
<div class="product-image-gallery"> <div class="card card-static p-3">
<img src="<?php echo htmlspecialchars($product['image_url']); ?>" class="img-fluid" alt="<?php echo htmlspecialchars($product['name']); ?>"> <img src="<?php echo htmlspecialchars($product['image_url']); ?>" class="img-fluid rounded" alt="<?php echo htmlspecialchars($product['name']); ?>">
</div> </div>
</div> </div>
<div class="col-lg-6 product-details" data-aos="fade-left"> <div class="col-lg-6" data-aos="fade-left">
<h1 class="display-5 fw-bold mb-3"><?php echo htmlspecialchars($product['name']); ?></h1> <div class="card h-100">
<div class="card-body p-4 p-lg-5">
<h1 class="display-5 fw-bold mb-3"><?php echo htmlspecialchars($product['name']); ?></h1>
<div class="d-flex align-items-center mb-4"> <div class="d-flex align-items-center mb-4">
<p class="display-6 fw-bold m-0"><?php echo number_format($product['price']); ?> تومان</p> <p class="display-6 fw-bold m-0"><?php echo number_format($product['price']); ?> تومان</p>
</div> </div>
<p class="fs-5 mb-4 text-muted"><?php echo nl2br(htmlspecialchars($product['description'])); ?></p> <p class="fs-5 mb-4 text-muted"><?php echo nl2br(htmlspecialchars($product['description'])); ?></p>
<form action="cart_handler.php" method="POST"> <form action="cart_handler.php" method="POST" class="mt-auto">
<input type="hidden" name="product_id" value="<?php echo $product['id']; ?>"> <input type="hidden" name="product_id" value="<?php echo $product['id']; ?>">
<input type="hidden" name="action" value="add"> <input type="hidden" name="action" value="add">
<?php if (!empty($available_colors)): ?> <?php if (!empty($available_colors)): ?>
<div class="mb-4"> <div class="mb-4">
<h5 class="mb-3">انتخاب رنگ:</h5> <h5 class="mb-3">انتخاب رنگ:</h5>
<div class="color-swatches"> <div class="color-swatches">
<?php foreach ($available_colors as $index => $color_hex): ?> <?php foreach ($available_colors as $index => $color_hex): ?>
<input type="radio" class="btn-check" name="product_color" id="color_<?php echo $index; ?>" value="<?php echo htmlspecialchars($color_hex); ?>" autocomplete="off" <?php echo (count($available_colors) === 1) ? 'checked' : ''; ?>/> <input type="radio" class="btn-check" name="product_color" id="color_<?php echo $index; ?>" value="<?php echo htmlspecialchars($color_hex); ?>" autocomplete="off" <?php echo (count($available_colors) === 1) ? 'checked' : ''; ?>/>
<label class="btn" for="color_<?php echo $index; ?>" style="background-color: <?php echo htmlspecialchars($color_hex); ?>;"></label> <label class="btn" for="color_<?php echo $index; ?>" style="background-color: <?php echo htmlspecialchars($color_hex); ?>;"></label>
<?php endforeach; ?> <?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<div class="row align-items-center mb-4">
<div class="col-md-5 col-lg-4 quantity-input-wrapper">
<label for="quantity" class="form-label fw-bold">تعداد:</label>
<input type="number" name="quantity" id="quantity" class="form-control quantity-input text-center" value="1" min="1" max="10">
</div>
</div> </div>
</div>
<?php endif; ?>
<div class="row align-items-center mb-4"> <div class="d-grid gap-2 add-to-cart-btn">
<div class="col-md-5 col-lg-4 quantity-input-wrapper"> <button type="submit" class="btn btn-primary"><i class="ri-shopping-bag-add-line"></i> افزودن به سبد خرید</button>
<label for="quantity" class="form-label fw-bold">تعداد:</label> </div>
<input type="number" name="quantity" id="quantity" class="form-control quantity-input text-center" value="1" min="1" max="10"> </form>
</div>
</div> </div>
</div>
<div class="d-grid gap-2 add-to-cart-btn">
<button type="submit" class="btn btn-primary"><i class="ri-shopping-bag-add-line"></i> افزودن به سبد خرید</button>
</div>
</form>
</div> </div>
</div> </div>
</main> </main>

View File

@ -168,240 +168,286 @@ require_once 'includes/header.php';
$page = $_GET['page'] ?? 'dashboard'; $page = $_GET['page'] ?? 'dashboard';
?> ?>
<div class="container my-5"> <main>
<div class="profile-container"> <section class="section-padding">
<!-- Profile Sidebar --> <div class="container">
<aside class="profile-sidebar"> <div class="text-center mb-5" data-aos="fade-down">
<div class="user-card"> <h1 class="section-title">حساب کاربری من</h1>
<div class="user-avatar">
<i class="ri-user-fill"></i>
</div>
<h5><?= htmlspecialchars(($user['first_name'] ?? '') . ' ' . ($user['last_name'] ?? '')); ?></h5>
<p><?= htmlspecialchars($user['email'] ?? ''); ?></p>
</div> </div>
<ul class="nav flex-column profile-nav"> <div class="row g-4">
<li class="nav-item">
<a class="nav-link <?= ($page === 'dashboard') ? 'active' : '' ?>" href="profile.php?page=dashboard">
<i class="ri-dashboard-line"></i>
داشبورد
</a>
</li>
<li class="nav-item">
<a class="nav-link <?= ($page === 'orders') ? 'active' : '' ?>" href="profile.php?page=orders">
<i class="ri-shopping-bag-3-line"></i>
سفارشات من
</a>
</li>
<li class="nav-item">
<a class="nav-link <?= ($page === 'addresses') ? 'active' : '' ?>" href="profile.php?page=addresses">
<i class="ri-map-pin-line"></i>
آدرس‌های من
</a>
</li>
<li class="nav-item">
<a class="nav-link <?= ($page === 'account') ? 'active' : '' ?>" href="profile.php?page=account">
<i class="ri-user-line"></i>
جزئیات حساب
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="logout.php">
<i class="ri-logout-box-r-line"></i>
خروج از حساب
</a>
</li>
</ul>
</aside>
<!-- Profile Content --> <!-- Off-canvas Toggle Button (Visible on Mobile) -->
<main class="profile-content"> <div class="d-lg-none col-12">
<?php if (isset($flash_message)): ?> <button class="btn btn-primary w-100" type="button" data-bs-toggle="offcanvas" data-bs-target="#profileOffcanvas" aria-controls="profileOffcanvas">
<div class="alert alert-<?= $flash_message_type; ?> alert-dismissible fade show" role="alert"> <i class="ri-menu-line me-2"></i>
<?= htmlspecialchars($flash_message); ?> منوی حساب کاربری
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </button>
</div> </div>
<?php endif; ?>
<?php if ($page === 'dashboard'): ?> <!-- Profile Sidebar -->
<div class="dashboard-welcome"> <div class="col-lg-3">
<h3 class="dashboard-title">سلام، <?= htmlspecialchars($user['first_name'] ?? 'کاربر'); ?> عزیز!</h3> <div class="offcanvas-lg offcanvas-end bg-dark" tabindex="-1" id="profileOffcanvas" aria-labelledby="profileOffcanvasLabel">
<p>به پنل کاربری خود در [نام فروشگاه] خوش آمدید. از اینجا می‌توانید آخرین سفارشات خود را مشاهده کرده، اطلاعات حساب خود را مدیریت کنید و آدرس‌های خود را به‌روزرسانی نمایید.</p> <div class="offcanvas-header border-bottom">
</div> <h5 class="offcanvas-title" id="profileOffcanvasLabel">منوی کاربری</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close" data-bs-target="#profileOffcanvas"></button>
<!-- Placeholder for summary cards -->
<div class="row g-4">
<div class="col-md-6">
<div class="summary-card">
<i class="ri-shopping-cart-2-line"></i>
<div class="summary-card-info">
<span>تعداد کل سفارشات</span>
<strong><?= count($orders); ?></strong>
</div>
</div> </div>
</div> <div class="offcanvas-body">
<div class="col-md-6"> <div class="card card-body text-center mb-4" data-aos="fade-up">
<div class="summary-card"> <div class="user-avatar mb-3">
<i class="ri-wallet-3-line"></i> <i class="ri-user-fill display-4"></i>
<div class="summary-card-info"> </div>
<span>مجموع خرید شما</span> <h5><?= htmlspecialchars(($user['first_name'] ?? '') . ' ' . ($user['last_name'] ?? '')); ?></h5>
<strong><?= number_format($total_purchase_amount); ?> تومان</strong> <p class="text-muted mb-0"><?= htmlspecialchars($user['email'] ?? ''); ?></p>
</div>
<div class="card card-body p-2" data-aos="fade-up" data-aos-delay="100">
<ul class="nav flex-column profile-nav">
<li class="nav-item">
<a class="nav-link <?= ($page === 'dashboard') ? 'active' : '' ?>" href="profile.php?page=dashboard">
<i class="ri-dashboard-line me-2"></i>
داشبورد
</a>
</li>
<li class="nav-item">
<a class="nav-link <?= ($page === 'orders') ? 'active' : '' ?>" href="profile.php?page=orders">
<i class="ri-shopping-bag-3-line me-2"></i>
سفارشات من
</a>
</li>
<li class="nav-item">
<a class="nav-link <?= ($page === 'addresses') ? 'active' : '' ?>" href="profile.php?page=addresses">
<i class="ri-map-pin-line me-2"></i>
آدرس‌های من
</a>
</li>
<li class="nav-item">
<a class="nav-link <?= ($page === 'account') ? 'active' : '' ?>" href="profile.php?page=account">
<i class="ri-user-settings-line me-2"></i>
جزئیات حساب
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="logout.php">
<i class="ri-logout-box-r-line me-2"></i>
خروج از حساب
</a>
</li>
</ul>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php elseif ($page === 'orders'): ?> <!-- Profile Content -->
<div class="dashboard-card"> <div class="col-lg-9" data-aos="fade-left">
<h3 class="dashboard-card-header">تاریخچه سفارشات</h3> <?php if (isset($flash_message)): ?>
<div class="dashboard-card-body"> <div class="alert alert-<?= $flash_message_type; ?> alert-dismissible fade show" role="alert">
<?php if (empty($orders)): ?> <?= htmlspecialchars($flash_message); ?>
<div class="alert alert-secondary text-center">شما هنوز هیچ سفارشی ثبت نکرده‌اید.</div> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<?php else: ?> </div>
<div class="table-responsive"> <?php endif; ?>
<table class="table table-dark table-hover align-middle">
<thead> <?php if ($page === 'dashboard'): ?>
<tr> <div class="card card-body p-4 p-md-5 text-center text-md-start">
<th>شماره سفارش</th> <h3 class="dashboard-title">سلام، <?= htmlspecialchars($user['first_name'] ?? 'کاربر'); ?> عزیز!</h3>
<th>تاریخ</th> <p>به پنل کاربری خود خوش آمدید. از اینجا می‌توانید آخرین سفارشات خود را مشاهده کرده، اطلاعات حساب خود را مدیریت کنید و آدرس‌های خود را به‌روزرسانی نمایید.</p>
<th>وضعیت</th> </div>
<th>مبلغ کل</th>
<th class="text-end">عملیات</th> <div class="row g-4 mt-4">
</tr> <div class="col-md-6">
</thead> <div class="card card-body summary-card">
<tbody> <i class="ri-shopping-cart-2-line"></i>
<?php foreach ($orders as $order): ?> <div class="summary-card-info">
<?php <span>تعداد کل سفارشات</span>
$status_map = [ <strong><?= count($orders); ?></strong>
'pending' => 'در انتظار پرداخت', </div>
'processing' => 'در حال پردازش', </div>
'shipped' => 'ارسال شده', </div>
'completed' => 'تکمیل شده', <div class="col-md-6">
'cancelled' => 'لغو شده', <div class="card card-body summary-card">
]; <i class="ri-wallet-3-line"></i>
$order_status_lower = strtolower($order['status']); <div class="summary-card-info">
$status_label = $status_map[$order_status_lower] ?? htmlspecialchars($order['status']); <span>مجموع خرید شما</span>
$status_class = 'status-' . htmlspecialchars($order_status_lower); <strong><?= number_format($total_purchase_amount); ?> تومان</strong>
?> </div>
<tr> </div>
<td><strong>#<?= $order['id']; ?></strong></td> </div>
<td><?= jdate('d F Y', strtotime($order['created_at'])); ?></td> </div>
<td><span class="order-status <?= $status_class; ?>"><?= $status_label; ?></span></td>
<td><?= number_format($order['total_amount']); ?> تومان</td> <?php elseif ($page === 'orders'): ?>
<td class="text-end"> <div class="card">
<button type="button" class="btn btn-sm btn-outline-primary view-order-btn" data-tracking-id="<?= htmlspecialchars($order['tracking_id']); ?>">نمایش جزئیات</button> <div class="card-header">
</td> <h4 class="m-0">تاریخچه سفارشات</h4>
</tr> </div>
<div class="card-body">
<?php if (empty($orders)): ?>
<div class="alert alert-secondary text-center">شما هنوز هیچ سفارشی ثبت نکرده‌اید.</div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-dark table-hover align-middle">
<thead>
<tr>
<th>شماره سفارش</th>
<th>تاریخ</th>
<th>وضعیت</th>
<th>مبلغ کل</th>
<th class="text-end">عملیات</th>
</tr>
</thead>
<tbody>
<?php foreach ($orders as $order): ?>
<?php
$status_map = [
'pending' => 'در انتظار پرداخت',
'processing' => 'در حال پردازش',
'shipped' => 'ارسال شده',
'completed' => 'تکمیل شده',
'cancelled' => 'لغو شده',
];
$order_status_lower = strtolower($order['status']);
$status_label = $status_map[$order_status_lower] ?? htmlspecialchars($order['status']);
$status_class = 'status-' . htmlspecialchars($order_status_lower);
?>
<tr>
<td><strong>#<?= $order['id']; ?></strong></td>
<td><?= jdate('d F Y', strtotime($order['created_at'])); ?></td>
<td><span class="order-status <?= $status_class; ?>"><?= $status_label; ?></span></td>
<td><?= number_format($order['total_amount']); ?> تومان</td>
<td class="text-end">
<button type="button" class="btn btn-sm btn-outline-primary view-order-btn" data-tracking-id="<?= htmlspecialchars($order['tracking_id']); ?>">نمایش جزئیات</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<?php elseif ($page === 'addresses'): ?>
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h4 class="m-0">آدرس‌های من</h4>
<button class="btn btn-primary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#add-address-form" aria-expanded="false" aria-controls="add-address-form">
<i class="ri-add-line me-1"></i> افزودن آدرس جدید
</button>
</div>
<div class="card-body">
<div class="collapse p-3 border rounded bg-dark mb-4" id="add-address-form">
<form method="POST">
<input type="hidden" name="action" value="add_address">
<div class="row">
<div class="col-md-4 mb-3">
<label for="add_province" class="form-label">استان</label>
<input type="text" class="form-control" id="add_province" name="province" required>
</div>
<div class="col-md-4 mb-3">
<label for="add_city" class="form-label">شهر</label>
<input type="text" class="form-control" id="add_city" name="city" required>
</div>
<div class="col-md-4 mb-3">
<label for="add_postal_code" class="form-label">کد پستی</label>
<input type="text" class="form-control" id="add_postal_code" name="postal_code" required>
</div>
</div>
<div class="mb-3">
<label for="new_address" class="form-label">آدرس کامل</label>
<textarea class="form-control" id="new_address" name="address_line" rows="2" required placeholder="خیابان، کوچه، پلاک، واحد"></textarea>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" name="is_default" id="is_default">
<label class="form-check-label" for="is_default">
انتخاب به عنوان آدرس پیش‌فرض
</label>
</div>
<button type="submit" class="btn btn-success">ذخیره آدرس</button>
</form>
</div>
<?php if (empty($addresses)): ?>
<div class="alert alert-secondary text-center">شما هنوز هیچ آدرسی ثبت نکرده‌اید.</div>
<?php else: ?>
<div class="address-list">
<?php foreach ($addresses as $address): ?>
<div class="card card-body mb-3 address-item">
<div class="address-content">
<p><?= htmlspecialchars(implode(', ', array_filter([$address['province'], $address['city'], $address['address_line'], $address['postal_code']]))) ?></p>
<?php if ($address['is_default']): ?>
<span class="badge bg-primary">پیش‌فرض</span>
<?php endif; ?>
</div>
<div class="address-actions">
<form method="POST" class="d-inline">
<input type="hidden" name="action" value="delete_address">
<input type="hidden" name="address_id" value="<?= $address['id']; ?>">
<button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('آیا از حذف این آدرس مطمئن هستید؟');">حذف</button>
</form>
<?php if (!$address['is_default']): ?>
<form method="POST" class="d-inline">
<input type="hidden" name="action" value="set_default_address">
<input type="hidden" name="address_id" value="<?= $address['id']; ?>">
<button type="submit" class="btn btn-sm btn-outline-secondary">انتخاب به عنوان پیش‌فرض</button>
</form>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </div>
</table> <?php endif; ?>
</div> </div>
<?php endif; ?>
</div>
</div>
<?php elseif ($page === 'addresses'): ?>
<div class="dashboard-card">
<div class="dashboard-card-header d-flex justify-content-between align-items-center">
<h3 class="m-0">آدرس‌های من</h3>
<button class="btn btn-primary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#add-address-form" aria-expanded="false" aria-controls="add-address-form">
<i class="ri-add-line me-1"></i> افزودن آدرس جدید
</button>
</div>
<div class="dashboard-card-body">
<div class="collapse" id="add-address-form">
<form method="POST" class="mb-4 p-3 border rounded">
<input type="hidden" name="action" value="add_address">
<div class="row">
<div class="col-md-4 mb-3">
<label for="add_province" class="form-label">استان</label>
<input type="text" class="form-control" id="add_province" name="province" required>
</div>
<div class="col-md-4 mb-3">
<label for="add_city" class="form-label">شهر</label>
<input type="text" class="form-control" id="add_city" name="city" required>
</div>
<div class="col-md-4 mb-3">
<label for="add_postal_code" class="form-label">کد پستی</label>
<input type="text" class="form-control" id="add_postal_code" name="postal_code" required>
</div>
</div>
<div class="mb-3">
<label for="new_address" class="form-label">آدرس کامل</label>
<textarea class="form-control" id="new_address" name="address_line" rows="2" required placeholder="خیابان، کوچه، پلاک، واحد"></textarea>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" name="is_default" id="is_default">
<label class="form-check-label" for="is_default">
انتخاب به عنوان آدرس پیش‌فرض
</label>
</div>
<button type="submit" class="btn btn-success">ذخیره آدرس</button>
</form>
</div> </div>
<?php if (empty($addresses)): ?> <?php elseif ($page === 'account'): ?>
<div class="alert alert-secondary text-center">شما هنوز هیچ آدرسی ثبت نکرده‌اید.</div> <div class="card">
<?php else: ?> <div class="card-header"><h4 class="m-0">جزئیات حساب</h4></div>
<div class="address-list"> <div class="card-body">
<?php foreach ($addresses as $address): ?> <form id="account-details-form" method="POST">
<div class="address-item"> <input type="hidden" name="action" value="update_details">
<div class="address-content"> <p class="fs-6 text-muted">اطلاعات شخصی خود را اینجا ویرایش کنید.</p>
<p><?= htmlspecialchars(implode(', ', array_filter([$address['province'], $address['city'], $address['address_line'], $address['postal_code']]))) ?></p> <div class="row">
<?php if ($address['is_default']): ?> <div class="col-md-6 mb-3">
<span class="badge bg-primary">پیش‌فرض</span> <label for="first_name" class="form-label">نام</label>
<?php endif; ?> <input type="text" class="form-control" id="first_name" name="first_name" value="<?= htmlspecialchars($user['first_name'] ?? ''); ?>" required>
</div> </div>
<div class="address-actions"> <div class="col-md-6 mb-3">
<form method="POST" class="d-inline"> <label for="last_name" class="form-label">نام خانوادگی</label>
<input type="hidden" name="action" value="delete_address"> <input type="text" class="form-control" id="last_name" name="last_name" value="<?= htmlspecialchars($user['last_name'] ?? ''); ?>" required>
<input type="hidden" name="address_id" value="<?= $address['id']; ?>">
<button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('آیا از حذف این آدرس مطمئن هستید؟');">حذف</button>
</form>
<?php if (!$address['is_default']): ?>
<form method="POST" class="d-inline">
<input type="hidden" name="action" value="set_default_address">
<input type="hidden" name="address_id" value="<?= $address['id']; ?>">
<button type="submit" class="btn btn-sm btn-outline-secondary">انتخاب به عنوان پیش‌فرض</button>
</form>
<?php endif; ?>
</div> </div>
</div> </div>
<?php endforeach; ?> <div class="mb-3">
<label for="email" class="form-label">آدرس ایمیل</label>
<input type="email" class="form-control" id="email" name="email" value="<?= htmlspecialchars($user['email'] ?? ''); ?>" required>
</div>
<button type="submit" class="btn btn-primary">ذخیره تغییرات</button>
</form>
</div> </div>
<?php endif; ?> </div>
</div> <div class="card mt-4">
</div> <div class="card-header"><h4 class="m-0">تغییر رمز عبور</h4></div>
<div class="card-body">
<form id="password-form" method="POST">
<input type="hidden" name="action" value="update_password">
<div class="mb-3">
<label for="new_password" class="form-label">رمز عبور جدید</label>
<input type="password" class="form-control" id="new_password" name="new_password" required>
</div>
<div class="mb-3">
<label for="confirm_password" class="form-label">تکرار رمز عبور جدید</label>
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
</div>
<button type="submit" class="btn btn-primary">تغییر رمز عبور</button>
</form>
</div>
</div>
<?php elseif ($page === 'account'): ?> <?php else: ?>
<div class="dashboard-card"> <div class="alert alert-danger">صفحه مورد نظر یافت نشد.</div>
<h3 class="dashboard-card-header">جزئیات حساب</h3> <?php endif; ?>
<div class="dashboard-card-body">
<form id="account-details-form" method="POST">
<input type="hidden" name="action" value="update_details">
<div class="row">
<div class="col-md-6 mb-3">
<label for="first_name" class="form-label">نام</label>
<input type="text" class="form-control" id="first_name" name="first_name" value="<?= htmlspecialchars($user['first_name'] ?? ''); ?>" required>
</div>
<div class="col-md-6 mb-3">
<label for="last_name" class="form-label">نام خانوادگی</label>
<input type="text" class="form-control" id="last_name" name="last_name" value="<?= htmlspecialchars($user['last_name'] ?? ''); ?>" required>
</div>
</div>
<div class="mb-3">
<label for="email" class="form-label">آدرس ایمیل</label>
<input type="email" class="form-control" id="email" name="email" value="<?= htmlspecialchars($user['email'] ?? ''); ?>" required>
</div>
<button type="submit" class="btn btn-primary">ذخیره تغییرات</button>
</form>
</div>
</div> </div>
</div>
<?php else: ?> </div>
<div class="alert alert-danger">صفحه مورد نظر یافت نشد.</div> </section>
<?php endif; ?> </main>
</main>
</div>
</div>
<!-- The Modal for Order Details --> <!-- The Modal for Order Details -->

View File

@ -15,9 +15,9 @@ try {
} }
?> ?>
<main class="container py-5"> <main class="container section-padding">
<div class="section-title text-center mb-5" data-aos="fade-down"> <div class="text-center" data-aos="fade-down">
<h1>مجموعه کامل محصولات</h1> <h1 class="section-title">مجموعه کامل محصولات</h1>
<p class="fs-5 text-muted">دست‌سازه‌هایی از چرم طبیعی، با عشق و دقت.</p> <p class="fs-5 text-muted">دست‌سازه‌هایی از چرم طبیعی، با عشق و دقت.</p>
</div> </div>
@ -32,13 +32,13 @@ try {
<p class="text-center text-muted fs-4">در حال حاضر محصولی برای نمایش وجود ندارد.</p> <p class="text-center text-muted fs-4">در حال حاضر محصولی برای نمایش وجود ندارد.</p>
</div> </div>
<?php else: ?> <?php else: ?>
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 g-lg-5"> <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 g-lg-5 mt-5">
<?php <?php
$delay = 0; $delay = 0;
foreach ($products as $product): foreach ($products as $product):
?> ?>
<div class="col" data-aos="fade-up" data-aos-delay="<?= $delay ?>"> <div class="col" data-aos="fade-up" data-aos-delay="<?= $delay ?>">
<div class="product-card h-100"> <div class="card product-card h-100">
<div class="product-image"> <div class="product-image">
<a href="product.php?id=<?= htmlspecialchars($product['id']) ?>"> <a href="product.php?id=<?= htmlspecialchars($product['id']) ?>">
<img src="<?= htmlspecialchars($product['image_url']) ?>" alt="<?= htmlspecialchars($product['name']) ?>"> <img src="<?= htmlspecialchars($product['image_url']) ?>" alt="<?= htmlspecialchars($product['name']) ?>">

View File

@ -3,144 +3,226 @@ $page_title = "پیگیری سفارش";
include 'includes/header.php'; include 'includes/header.php';
?> ?>
<div class="container my-5"> <div class="container section-padding">
<div class="track-container"> <div class="row justify-content-center">
<h1><i class="ri-search-eye-line me-2"></i>پیگیری سفارش</h1> <div class="col-md-8 col-lg-6">
<p>کد رهگیری سفارش خود را برای مشاهده جزئیات وارد کنید.</p> <div class="card">
<div class="card-body p-5">
<form id="track-order-form" class="mt-4"> <h1 class="text-center"><i class="ri-search-eye-line me-2"></i>پیگیری سفارش</h1>
<div class="mb-3"> <p class="text-center text-muted">کد رهگیری سفارش خود را برای مشاهده جزئیات وارد کنید.</p>
<input type="text" id="tracking_id" name="tracking_id" class="form-control" placeholder="کد رهگیری سفارش" required>
</div> <form id="track-order-form" class="mt-4">
<div class="d-grid"> <div class="mb-3">
<button type="submit" class="btn btn-primary"><i class="ri-search-line me-2"></i>جستجو</button> <input type="text" id="tracking_id" name="tracking_id" class="form-control form-control-lg" placeholder="کد رهگیری سفارش" required>
</div> </div>
</form> <div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg"><i class="ri-search-line me-2"></i>جستجو</button>
</div>
</form>
<div id="result-message" class="mt-3"></div> <div id="result-message" class="mt-4 text-center"></div>
</div> </div>
</div> </div>
<!-- The Modal -->
<div id="order-modal" class="order-modal">
<div class="order-modal-content">
<span class="order-modal-close-btn">&times;</span>
<div id="modal-body">
<!-- Order details will be injected here by JavaScript -->
</div> </div>
</div> </div>
</div> </div>
<script> <!-- New Tracking Modal -->
document.addEventListener('DOMContentLoaded', function () { <div class="tracking-modal-container" id="tracking-modal">
const form = document.getElementById('track-order-form'); <div class="modal-overlay"></div>
const modal = document.getElementById('order-modal'); <div class="modal-content">
const modalBody = document.getElementById('modal-body'); <div class="modal-header">
const closeBtn = document.querySelector('.order-modal-close-btn'); <h3>جزئیات سفارش <span id="modal-order-id"></span></h3>
const resultMessage = document.getElementById('result-message'); <button class="modal-close-btn">&times;</button>
</div>
form.addEventListener('submit', async function (e) { <div class="modal-body">
e.preventDefault(); <div class="order-summary">
const trackingId = document.getElementById('tracking_id').value; <div class="detail-item"><strong>تاریخ ثبت:</strong> <span id="modal-order-date"></span></div>
<div class="detail-item"><strong>مبلغ کل:</strong> <span id="modal-order-amount"></span></div>
resultMessage.innerHTML = `<div class="spinner-border spinner-border-sm" role="status"><span class="visually-hidden">Loading...</span></div> در حال جستجو...`; <div class="detail-item"><strong>تخفیف:</strong> <span id="modal-order-discount"></span></div>
resultMessage.className = 'text-muted';
try {
const response = await fetch('api/get_order_details.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ tracking_id: trackingId }),
});
if (!response.ok) {
throw new Error(`خطای سرور: ${response.status}`);
}
const data = await response.json();
if (data.success) {
resultMessage.textContent = '';
displayOrderDetails(data.order, data.products);
modal.style.display = 'block';
} else {
resultMessage.textContent = data.message;
resultMessage.className = 'text-danger fw-bold';
}
} catch (error) {
console.error('Fetch Error:', error);
resultMessage.textContent = 'خطا در برقراری ارتباط با سرور.';
resultMessage.className = 'text-danger fw-bold';
}
});
function displayOrderDetails(order, products) {
let productsHtml = `
<div class="detail-box" style="grid-column: 1 / -1;">
<h3>محصولات سفارش</h3>
<table class="products-table">
<thead>
<tr>
<th>محصول</th>
<th>تعداد</th>
<th>رنگ</th>
<th>قیمت واحد</th>
<th>قیمت کل</th>
</tr>
</thead>
<tbody>
`;
products.forEach(p => {
productsHtml += `
<tr>
<td data-label="محصول"><img src="${p.image_url}" alt="${p.name}" class="me-2">${p.name}</td>
<td data-label="تعداد">${p.quantity}</td>
<td data-label="رنگ"><span class="cart-item-color-swatch" style="background-color: ${p.color || 'transparent'}"></span></td>
<td data-label="قیمت واحد">${parseInt(p.price).toLocaleString()} تومان</td>
<td data-label="قیمت کل">${(p.quantity * p.price).toLocaleString()} تومان</td>
</tr>
`;
});
productsHtml += `</tbody></table></div>`;
modalBody.innerHTML = `
<div class="order-modal-header">
<h2>جزئیات سفارش</h2>
<p class="text-muted">کد رهگیری: ${order.tracking_id}</p>
</div> </div>
<div class="order-details-grid"> <div class="status-details">
<div class="detail-box"> <h4>وضعیت سفارش: <span id="modal-order-status-text" style="font-weight: bold;"></span></h4>
<h3>اطلاعات خریدار</h3> <div class="status-tracker" id="modal-status-tracker">
<p><strong>نام:</strong> ${order.full_name}</p> <div class="status-progress"></div>
<p><strong>ایمیل:</strong> ${order.email}</p> <div class="status-step" data-status="processing">
<p><strong>تلفن:</strong> ${order.billing_phone}</p> <div class="dot"></div><span class="label">در حال پردازش</span>
</div>
<div class="status-step" data-status="shipped">
<div class="dot"></div><span class="label">ارسال شده</span>
</div>
<div class="status-step" data-status="completed">
<div class="dot"></div><span class="label">تکمیل شده</span>
</div>
<div class="status-step" data-status="cancelled">
<div class="dot"></div><span class="label">لغو شده</span>
</div>
</div>
</div>
<div class="shipping-details">
<h4>اطلاعات ارسال</h4>
<div class="detail-item"><strong>تحویل گیرنده:</strong> <span id="modal-shipping-name"></span></div>
<div class="detail-item"><strong>آدرس:</strong> <span id="modal-shipping-address"></span></div>
<div class="detail-item"><strong>کدپستی:</strong> <span id="modal-shipping-postal-code"></span></div>
</div>
<div class="products-list">
<h4>محصولات سفارش</h4>
<div id="modal-products-list"></div>
</div>
</div>
</div> </div>
<div class="detail-box">
<h3>اطلاعات سفارش</h3>
<p><strong>وضعیت:</strong> <span class="order-status status-${order.status}">${order.status_jalali}</span></p>
<p><strong>تاریخ ثبت:</strong> ${order.created_at_jalali}</p>
<p><strong>آدرس:</strong> ${order.address}</p>
</div> </div>
${productsHtml}
</div> <script>
<div class="summary-totals mt-4 text-center"> document.addEventListener('DOMContentLoaded', function () {
<div class="grand-total"> const form = document.getElementById('track-order-form');
<span class="label">جمع کل: </span> const modal = document.getElementById('tracking-modal');
<span class="value">${parseInt(order.total_amount).toLocaleString()} تومان</span> const overlay = document.querySelector('.modal-overlay');
</div> const closeBtn = document.querySelector('.modal-close-btn');
</div> const resultMessage = document.getElementById('result-message');
`;
} form.addEventListener('submit', async function (e) {
e.preventDefault();
closeBtn.onclick = () => modal.style.display = 'none'; const trackingId = document.getElementById('tracking_id').value;
window.onclick = (event) => {
if (event.target == modal) { resultMessage.innerHTML = `<div class="spinner-border spinner-border-sm" role="status"><span class="visually-hidden">Loading...</span></div> در حال جستجو...`;
modal.style.display = 'none'; resultMessage.className = 'text-center text-muted';
}
} try {
}); const response = await fetch('api/get_order_details.php', {
</script> method: 'POST',
headers: { 'Content-Type': 'application/json' },
<?php include 'includes/footer.php'; ?> body: JSON.stringify({ tracking_id: trackingId }),
});
const data = await response.json();
if (data.success) {
resultMessage.innerHTML = '';
displayOrderDetails(data.order, data.products);
modal.classList.add('visible');
} else {
resultMessage.innerHTML = data.message;
resultMessage.className = 'text-center text-danger fw-bold';
}
} catch (error) {
console.error('Fetch Error:', error);
resultMessage.innerHTML = 'خطا در برقراری ارتباط با سرور. لطفاً اتصال اینترنت خود را بررسی کنید.';
resultMessage.className = 'text-center text-danger fw-bold';
}
});
function displayOrderDetails(order, products) {
document.getElementById('modal-order-id').textContent = '#' + order.id;
document.getElementById('modal-order-date').textContent = order.order_date;
document.getElementById('modal-order-amount').textContent = order.total_amount;
document.getElementById('modal-order-discount').textContent = order.discount_amount;
document.getElementById('modal-shipping-name').textContent = order.shipping_name;
document.getElementById('modal-shipping-address').textContent = order.shipping_address;
document.getElementById('modal-shipping-postal-code').textContent = order.shipping_postal_code;
const productsContainer = document.getElementById('modal-products-list');
productsContainer.innerHTML = '';
if (products && products.length > 0) {
products.forEach(p => {
const imageUrl = p.image_url ? p.image_url : 'assets/images/placeholder.png';
productsContainer.innerHTML += `
<div class="product-item">
<img src="${imageUrl}" alt="${p.name}" onerror="this.onerror=null;this.src='assets/images/placeholder.png';">
<div class="product-info">
<span class="product-name">${p.name}</span>
<div class="product-meta">
<span class="product-quantity">تعداد: ${p.quantity}</span>
${p.color ? `
<span class="product-color-wrapper">
رنگ: <span class="product-color-dot" style="background-color: ${p.color};"></span>
</span>` : ''}
</div>
</div>
<div class="product-price">${p.price}</div>
</div>
`;
});
} else {
productsContainer.innerHTML = '<p class="text-center text-muted">محصولی برای این سفارش یافت نشد.</p>';
}
updateStatusTracker(order.status, order.status_persian);
}
function updateStatusTracker(status, statusPersian) {
console.log('--- Debugging Status Animation ---');
console.log('Received status:', status);
const statusTextEl = document.getElementById('modal-order-status-text');
const statusMap = {
'pending': 'processing',
'processing': 'processing',
'shipped': 'shipped',
'delivered': 'completed',
'completed': 'completed',
'cancelled': 'cancelled'
};
const mappedStatus = status ? statusMap[status.toLowerCase()] : 'processing';
const statusDisplayMap = {
'processing': { color: '#ffc107', text: 'در حال پردازش' },
'shipped': { color: '#0d6efd', text: 'ارسال شده' },
'completed': { color: '#198754', text: 'تکمیل شده' },
'cancelled': { color: '#dc3545', text: 'لغو شده' }
};
const displayInfo = statusDisplayMap[mappedStatus] || statusDisplayMap['processing'];
statusTextEl.textContent = statusPersian || displayInfo.text;
statusTextEl.style.color = displayInfo.color;
const tracker = document.getElementById('modal-status-tracker');
tracker.className = 'status-tracker';
const progress = tracker.querySelector('.status-progress');
const steps = Array.from(tracker.querySelectorAll('.status-step'));
steps.forEach(step => step.classList.remove('active', 'completed'));
const statusOrder = ['processing', 'shipped', 'completed'];
let statusIndex = statusOrder.indexOf(mappedStatus);
console.log('Mapped status:', mappedStatus, '| Calculated status index:', statusIndex);
if (mappedStatus === 'cancelled') {
tracker.classList.add('is-cancelled');
const cancelledStep = tracker.querySelector('[data-status="cancelled"]');
if(cancelledStep) cancelledStep.classList.add('active');
progress.style.width = '0%';
} else {
tracker.classList.remove('is-cancelled');
if (statusIndex !== -1) {
for (let i = 0; i <= statusIndex; i++) {
const step = tracker.querySelector(`[data-status="${statusOrder[i]}"]`);
if(step) step.classList.add('completed');
}
const activeStep = tracker.querySelector(`[data-status="${mappedStatus}"]`);
if(activeStep) {
activeStep.classList.remove('completed');
activeStep.classList.add('active');
}
const progressPercentage = statusIndex >= 0 ? (statusIndex / (statusOrder.length - 1)) * 100 : 0;
console.log('Progress percentage:', progressPercentage);
progress.style.width = `${progressPercentage}%`;
} else {
progress.style.width = '0%';
console.log('Unknown status. Resetting progress bar.');
}
}
}
function closeModal() {
modal.classList.remove('visible');
}
closeBtn.addEventListener('click', closeModal);
overlay.addEventListener('click', closeModal);
});
</script>
<?php include 'includes/footer.php'; ?>