feat: enhance admin control panel with KPI charts, inline inventory editing, lead CRM and settings
This commit is contained in:
+624
-218
@@ -1,25 +1,44 @@
|
||||
<?php
|
||||
// admin/index.php
|
||||
session_start();
|
||||
require_once __DIR__ . '/../includes/db.php';
|
||||
|
||||
$message = '';
|
||||
$error = '';
|
||||
|
||||
// Handle add / update tire
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Simple authentication
|
||||
$adminPass = 'admin123';
|
||||
if (isset($_POST['login_pass'])) {
|
||||
if ($_POST['login_pass'] === $adminPass) {
|
||||
$_SESSION['gasemi_admin'] = true;
|
||||
} else {
|
||||
$error = 'رمز عبور مدیریت اشتباه است.';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['logout'])) {
|
||||
unset($_SESSION['gasemi_admin']);
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$isLoggedIn = !empty($_SESSION['gasemi_admin']);
|
||||
|
||||
// Handle Actions if logged in
|
||||
if ($isLoggedIn && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['admin_action'] ?? '';
|
||||
|
||||
if ($action === 'add_tire') {
|
||||
$id = 'TR-' . (count(TireStore::getTires()) + 101);
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$brand = trim($_POST['brand'] ?? '');
|
||||
$country = trim($_POST['country'] ?? '');
|
||||
$country = trim($_POST['country'] ?? 'ایران');
|
||||
$category = trim($_POST['category'] ?? 'سواری');
|
||||
$width = intval($_POST['width'] ?? 185);
|
||||
$aspect = intval($_POST['aspect_ratio'] ?? 65);
|
||||
$rim = intval($_POST['rim'] ?? 14);
|
||||
$speed = trim($_POST['speed_index'] ?? 'H');
|
||||
$load = trim($_POST['load_index'] ?? '86');
|
||||
$speed = trim($_POST['speed_index'] ?? 'H (210 km/h)');
|
||||
$load = trim($_POST['load_index'] ?? '86 (530 kg)');
|
||||
$price = intval($_POST['price'] ?? 0);
|
||||
$stock = intval($_POST['stock'] ?? 10);
|
||||
$warranty = intval($_POST['warranty_months'] ?? 36);
|
||||
@@ -65,6 +84,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'quick_update_tire') {
|
||||
$id = $_POST['tire_id'] ?? '';
|
||||
$price = intval($_POST['price'] ?? 0);
|
||||
$stock = intval($_POST['stock'] ?? 0);
|
||||
$discount = intval($_POST['discount_percent'] ?? 0);
|
||||
|
||||
if ($id && $price > 0) {
|
||||
TireStore::updateTire($id, [
|
||||
"price" => $price,
|
||||
"stock" => $stock,
|
||||
"discount_percent" => $discount
|
||||
]);
|
||||
$message = "مشخصات تایر {$id} با موفقیت بهروزرسانی شد.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'delete_tire') {
|
||||
$delId = $_POST['tire_id'] ?? '';
|
||||
if ($delId) {
|
||||
@@ -72,257 +107,628 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$message = "تایر با شناسه {$delId} حذف گردید.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'update_consultation') {
|
||||
$cId = $_POST['consultation_id'] ?? '';
|
||||
$cStatus = $_POST['status'] ?? 'جدید';
|
||||
$cNote = trim($_POST['admin_note'] ?? '');
|
||||
if ($cId) {
|
||||
TireStore::updateConsultationStatus($cId, $cStatus, $cNote);
|
||||
$message = "وضعیت استعلام {$cId} بهروز شد.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'delete_consultation') {
|
||||
$cId = $_POST['consultation_id'] ?? '';
|
||||
if ($cId) {
|
||||
TireStore::deleteConsultation($cId);
|
||||
$message = "درخواست مشاوره حذف گردید.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action === 'update_settings') {
|
||||
$sitePhone = trim($_POST['site_phone'] ?? '');
|
||||
$emergencyPhone = trim($_POST['emergency_phone'] ?? '');
|
||||
$announcement = trim($_POST['announcement'] ?? '');
|
||||
$centralAddress = trim($_POST['central_address'] ?? '');
|
||||
|
||||
TireStore::updateSettings([
|
||||
"site_phone" => $sitePhone,
|
||||
"emergency_phone" => $emergencyPhone,
|
||||
"announcement" => $announcement,
|
||||
"central_address" => $centralAddress
|
||||
]);
|
||||
$message = "تنظیمات و اطلاعات تماس فروشگاه ذخیره گردید.";
|
||||
}
|
||||
}
|
||||
|
||||
$tires = TireStore::getTires();
|
||||
$consultations = TireStore::getConsultations();
|
||||
$settings = TireStore::getSettings();
|
||||
|
||||
// Inventory calculations
|
||||
$totalStockCount = array_sum(array_column($tires, 'stock'));
|
||||
$totalInventoryValue = 0;
|
||||
foreach ($tires as $t) {
|
||||
$totalInventoryValue += ($t['price'] * $t['stock']);
|
||||
}
|
||||
|
||||
// Brand distribution
|
||||
$brandCounts = [];
|
||||
foreach ($tires as $t) {
|
||||
$b = $t['brand'];
|
||||
$brandCounts[$b] = ($brandCounts[$b] ?? 0) + $t['stock'];
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fa" dir="rtl" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>پنل مدیریت و انبارداری | تایر قاسمی</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;600;700;900&display=swap" rel="stylesheet">
|
||||
<title>پنل مدیریت هوشمند و انبارداری | تایر قاسمی</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
<style>
|
||||
* { font-family: 'Vazirmatn', sans-serif; }
|
||||
* { font-family: 'Vazirmatn', sans-serif; scroll-behavior: smooth; }
|
||||
.glass-card {
|
||||
background: rgba(17, 24, 39, 0.9);
|
||||
backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-[#0b0f17] text-slate-100 min-h-screen">
|
||||
<body class="bg-[#090d16] text-slate-100 min-h-screen">
|
||||
|
||||
<!-- Top Admin Bar -->
|
||||
<header class="border-b border-slate-800 bg-slate-900/80 sticky top-0 z-40 backdrop-blur">
|
||||
<div class="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-9 h-9 rounded-xl bg-brand-600 flex items-center justify-center text-white">
|
||||
<i data-lucide="shield" class="w-5 h-5"></i>
|
||||
<?php if (!$isLoggedIn): ?>
|
||||
<!-- Login Modal / Card -->
|
||||
<div class="min-h-screen flex items-center justify-center p-4">
|
||||
<div class="glass-card rounded-3xl p-8 max-w-md w-full border border-slate-800 shadow-2xl space-y-6 text-center">
|
||||
<div class="w-14 h-14 rounded-2xl bg-gradient-to-br from-rose-600 to-amber-600 mx-auto flex items-center justify-center text-white shadow-xl shadow-rose-900/40">
|
||||
<i data-lucide="lock" class="w-7 h-7"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="text-base font-black text-white">داشبورد مدیریت تایر قاسمی</h1>
|
||||
<p class="text-[10px] text-slate-400">انبارداری، استعلامها و کاتالوگ محصولات</p>
|
||||
<h2 class="text-xl font-black text-white">ورود به پنل مدیریت تایر قاسمی</h2>
|
||||
<p class="text-xs text-slate-400 mt-1">جهت دسترسی به انبار، قیمتها و استعلامها رمز عبور را وارد کنید.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="../index.php" class="px-3.5 py-1.5 rounded-xl bg-slate-800 hover:bg-slate-700 text-xs font-bold text-slate-300 flex items-center gap-1.5">
|
||||
<i data-lucide="external-link" class="w-3.5 h-3.5"></i>
|
||||
مشاهده سایت
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="max-w-7xl mx-auto px-4 py-8 space-y-8">
|
||||
|
||||
<?php if ($message): ?>
|
||||
<div class="p-4 rounded-2xl bg-emerald-500/20 border border-emerald-500/30 text-emerald-300 text-xs font-bold flex items-center gap-2">
|
||||
<i data-lucide="check-circle" class="w-4 h-4"></i> <?= htmlspecialchars($message) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?>
|
||||
<div class="p-3 rounded-xl bg-rose-500/20 border border-rose-500/30 text-rose-300 text-xs font-bold">
|
||||
<?= htmlspecialchars($error) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="p-4 rounded-2xl bg-rose-500/20 border border-rose-500/30 text-rose-300 text-xs font-bold flex items-center gap-2">
|
||||
<i data-lucide="alert-circle" class="w-4 h-4"></i> <?= htmlspecialchars($error) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form method="POST" class="space-y-4">
|
||||
<div class="text-right">
|
||||
<label class="block text-xs font-bold text-slate-300 mb-1.5">رمز عبور ادمین:</label>
|
||||
<input type="password" name="login_pass" value="admin123" required class="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-rose-500 text-center font-mono">
|
||||
<span class="text-[10px] text-slate-500 mt-1 block text-center">رمز پیشفرض سیستم: <code class="text-amber-400 font-mono">admin123</code></span>
|
||||
</div>
|
||||
|
||||
<!-- Stats Overview Cards -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div class="p-5 rounded-2xl bg-slate-900 border border-slate-800">
|
||||
<span class="text-xs text-slate-400">تنوع کل تایرها در انبار</span>
|
||||
<div class="text-2xl font-black text-white mt-1"><?= count($tires) ?> <span class="text-xs text-slate-500 font-normal">مدل</span></div>
|
||||
</div>
|
||||
<button type="submit" class="w-full py-3 rounded-xl bg-gradient-to-r from-rose-600 to-amber-600 hover:from-rose-500 hover:to-amber-500 text-white font-bold text-sm shadow-lg shadow-rose-600/30 transition-all">
|
||||
ورود به داشبورد
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="p-5 rounded-2xl bg-slate-900 border border-slate-800">
|
||||
<span class="text-xs text-slate-400">مجموع موجودی حلقهها</span>
|
||||
<div class="text-2xl font-black text-amber-400 mt-1"><?= array_sum(array_column($tires, 'stock')) ?> <span class="text-xs text-slate-500 font-normal">حلقه</span></div>
|
||||
</div>
|
||||
|
||||
<div class="p-5 rounded-2xl bg-slate-900 border border-slate-800">
|
||||
<span class="text-xs text-slate-400">درخواستهای مشاوره و استعلام</span>
|
||||
<div class="text-2xl font-black text-emerald-400 mt-1"><?= count($consultations) ?> <span class="text-xs text-slate-500 font-normal">مورد</span></div>
|
||||
</div>
|
||||
|
||||
<div class="p-5 rounded-2xl bg-slate-900 border border-slate-800">
|
||||
<span class="text-xs text-slate-400">وضعیت سرور و اتصال گیت</span>
|
||||
<div class="text-sm font-bold text-cyan-400 mt-2 flex items-center gap-1.5">
|
||||
<span class="w-2 h-2 rounded-full bg-emerald-400 animate-pulse"></span> آنلاین و فعال
|
||||
<div class="pt-4 border-t border-slate-800">
|
||||
<a href="../index.php" class="text-xs text-slate-400 hover:text-white flex items-center justify-center gap-1.5">
|
||||
<i data-lucide="arrow-right" class="w-3.5 h-3.5"></i> بازگشت به وبسایت اصلی
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<!-- Add New Tire Form Accordion -->
|
||||
<div class="p-6 rounded-3xl bg-slate-900 border border-slate-800 space-y-4">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="plus-circle" class="w-5 h-5 text-brand-400"></i>
|
||||
افزودن تایر جدید به انبار و کاتالوگ
|
||||
</h2>
|
||||
<!-- Logged In Admin Layout -->
|
||||
<div class="min-h-screen flex flex-col">
|
||||
|
||||
<!-- Top Navbar -->
|
||||
<header class="border-b border-slate-800 bg-slate-900/90 sticky top-0 z-40 backdrop-blur">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3.5 flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 rounded-xl bg-rose-600 flex items-center justify-center text-white shadow-lg shadow-rose-900/40">
|
||||
<i data-lucide="shield-check" class="w-6 h-6"></i>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center gap-2">
|
||||
<h1 class="text-base font-black text-white">سامانه مدیریت تایر قاسمی</h1>
|
||||
<span class="px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400 text-[10px] font-bold">ادمین فعال</span>
|
||||
</div>
|
||||
<p class="text-[11px] text-slate-400">انبارداری، استعلامها، قیمتگذاری و تنظیمات</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 text-xs">
|
||||
<input type="hidden" name="admin_action" value="add_tire">
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="../api.php?action=export_backup" class="hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-300 text-xs font-bold border border-slate-700 transition-colors" title="دانلود نسخه پشتیبان">
|
||||
<i data-lucide="download" class="w-3.5 h-3.5 text-cyan-400"></i>
|
||||
پشتیبانگیری JSON
|
||||
</a>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">نام و مدل تایر *</label>
|
||||
<input type="text" name="name" required placeholder="مثلاً: بارز پریمیوم P660" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
<a href="../index.php" target="_blank" class="px-3.5 py-1.5 rounded-xl bg-slate-800 hover:bg-slate-700 text-xs font-bold text-slate-200 flex items-center gap-1.5 border border-slate-700">
|
||||
<i data-lucide="external-link" class="w-3.5 h-3.5"></i>
|
||||
نمایش سایت
|
||||
</a>
|
||||
|
||||
<a href="?logout=1" class="px-3 py-1.5 rounded-xl bg-rose-600/20 hover:bg-rose-600 text-rose-300 hover:text-white text-xs font-bold transition-colors flex items-center gap-1">
|
||||
<i data-lucide="log-out" class="w-3.5 h-3.5"></i>
|
||||
خروج
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">برند سازنده *</label>
|
||||
<input type="text" name="brand" required placeholder="بارز، کویر، هانکوک..." class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">کشور سازنده</label>
|
||||
<input type="text" name="country" placeholder="ایران، کره جنوبی، فرانسه..." class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">دستهبندی</label>
|
||||
<select name="category" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
<option value="سواری">سواری شهری</option>
|
||||
<option value="اسپرت">اسپرت و ریسینگ</option>
|
||||
<option value="شاسی بلند و آفرود (SUV/4x4)">شاسی بلند و آفرود (SUV/4x4)</option>
|
||||
<option value="لوکس و پرمیوم">لوکس و پرمیوم</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">پهنا (Width - mm)</label>
|
||||
<input type="number" name="width" value="205" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">نسبت فاق (Aspect - %)</label>
|
||||
<input type="number" name="aspect_ratio" value="55" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">قطر رینگ (Rim - اینچ)</label>
|
||||
<input type="number" name="rim" value="16" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">قیمت هر حلقه (تومان) *</label>
|
||||
<input type="number" name="price" required placeholder="5500000" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">موجودی انبار (حلقه)</label>
|
||||
<input type="number" name="stock" value="20" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">گارانتی (ماه)</label>
|
||||
<input type="number" name="warranty_months" value="36" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block font-bold text-slate-300 mb-1">خودروهای سازگار (با کاما جدا کنید)</label>
|
||||
<input type="text" name="vehicles" placeholder="دنا پلاس, تارا, شاهین, مگان" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4">
|
||||
<label class="block font-bold text-slate-300 mb-1">توضیحات فنی و کاربرد</label>
|
||||
<input type="text" name="description" placeholder="توضیح کوتاه درباره کارایی و چسبندگی تایر..." class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4 pt-2">
|
||||
<button type="submit" class="px-6 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white font-bold transition-all shadow">
|
||||
افزودن و انتشار در کاتالوگ
|
||||
<!-- Navigation Tabs Bar -->
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex items-center gap-2 overflow-x-auto text-xs font-bold py-2 border-t border-slate-800/80">
|
||||
<button onclick="switchAdminTab('dashboard')" id="btn-tab-dashboard" class="tab-btn px-4 py-2 rounded-xl bg-rose-600 text-white flex items-center gap-2 transition-all">
|
||||
<i data-lucide="layout-dashboard" class="w-4 h-4"></i> داشبورد و آمار
|
||||
</button>
|
||||
<button onclick="switchAdminTab('tires')" id="btn-tab-tires" class="tab-btn px-4 py-2 rounded-xl text-slate-400 hover:text-white flex items-center gap-2 transition-all">
|
||||
<i data-lucide="disc-3" class="w-4 h-4"></i> مدیریت انبار تایرها (<?= count($tires) ?>)
|
||||
</button>
|
||||
<button onclick="switchAdminTab('leads')" id="btn-tab-leads" class="tab-btn px-4 py-2 rounded-xl text-slate-400 hover:text-white flex items-center gap-2 transition-all">
|
||||
<i data-lucide="headset" class="w-4 h-4"></i> استعلامها و لیدها (<?= count($consultations) ?>)
|
||||
</button>
|
||||
<button onclick="switchAdminTab('settings')" id="btn-tab-settings" class="tab-btn px-4 py-2 rounded-xl text-slate-400 hover:text-white flex items-center gap-2 transition-all">
|
||||
<i data-lucide="sliders" class="w-4 h-4"></i> تنظیمات سایت و شعب
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</header>
|
||||
|
||||
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8 flex-1 w-full">
|
||||
|
||||
<?php if ($message): ?>
|
||||
<div class="p-4 rounded-2xl bg-emerald-500/20 border border-emerald-500/30 text-emerald-300 text-xs font-bold flex items-center gap-2">
|
||||
<i data-lucide="check-circle" class="w-4 h-4"></i> <?= htmlspecialchars($message) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="p-4 rounded-2xl bg-rose-500/20 border border-rose-500/30 text-rose-300 text-xs font-bold flex items-center gap-2">
|
||||
<i data-lucide="alert-circle" class="w-4 h-4"></i> <?= htmlspecialchars($error) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- TAB 1: DASHBOARD & OVERVIEW -->
|
||||
<div id="tab-dashboard" class="space-y-8">
|
||||
|
||||
<!-- KPI Cards -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5">
|
||||
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 relative overflow-hidden">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs font-bold text-slate-400">تنوع مدلهای تایر</span>
|
||||
<div class="w-10 h-10 rounded-xl bg-blue-500/20 text-blue-400 flex items-center justify-center">
|
||||
<i data-lucide="layers" class="w-5 h-5"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-black text-white mt-3"><?= count($tires) ?> <span class="text-xs text-slate-400 font-normal">مدل فعال</span></div>
|
||||
<div class="text-[11px] text-emerald-400 mt-2 flex items-center gap-1">
|
||||
<i data-lucide="check" class="w-3.5 h-3.5"></i> ۱۰۰٪ کاتالوگ آنلاین
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 relative overflow-hidden">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs font-bold text-slate-400">کل موجودی انبار</span>
|
||||
<div class="w-10 h-10 rounded-xl bg-amber-500/20 text-amber-400 flex items-center justify-center">
|
||||
<i data-lucide="package" class="w-5 h-5"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-black text-amber-400 mt-3"><?= number_format($totalStockCount) ?> <span class="text-xs text-slate-400 font-normal">حلقه</span></div>
|
||||
<div class="text-[11px] text-slate-400 mt-2">میانگین <?= round($totalStockCount / max(count($tires), 1)) ?> حلقه به ازای هر مدل</div>
|
||||
</div>
|
||||
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 relative overflow-hidden">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs font-bold text-slate-400">ارزش کل موجودی انبار</span>
|
||||
<div class="w-10 h-10 rounded-xl bg-emerald-500/20 text-emerald-400 flex items-center justify-center">
|
||||
<i data-lucide="banknote" class="w-5 h-5"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-2xl font-black text-emerald-400 mt-3"><?= number_format($totalInventoryValue / 10000000) ?> <span class="text-xs text-slate-400 font-normal">میلیون تومان</span></div>
|
||||
<div class="text-[11px] text-slate-400 mt-2"><?= number_format($totalInventoryValue) ?> تومان</div>
|
||||
</div>
|
||||
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 relative overflow-hidden">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs font-bold text-slate-400">درخواستهای مشاوره</span>
|
||||
<div class="w-10 h-10 rounded-xl bg-rose-500/20 text-rose-400 flex items-center justify-center">
|
||||
<i data-lucide="phone-call" class="w-5 h-5"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-black text-rose-400 mt-3"><?= count($consultations) ?> <span class="text-xs text-slate-400 font-normal">لید دریافتی</span></div>
|
||||
<div class="text-[11px] text-slate-400 mt-2">نیازمند پیگیری تلفنی</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Distribution Charts & Quick Leads Grid -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-12 gap-8">
|
||||
|
||||
<!-- Left: Brand Inventory Share -->
|
||||
<div class="lg:col-span-6 glass-card p-6 rounded-3xl border border-slate-800 space-y-4">
|
||||
<h3 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="pie-chart" class="w-5 h-5 text-amber-400"></i>
|
||||
سهم موجودی انبار بر اساس برند
|
||||
</h3>
|
||||
|
||||
<div class="space-y-3 pt-2">
|
||||
<?php foreach ($brandCounts as $bName => $bCount):
|
||||
$pct = $totalStockCount > 0 ? round(($bCount / $totalStockCount) * 100) : 0;
|
||||
?>
|
||||
<div>
|
||||
<div class="flex justify-between text-xs mb-1">
|
||||
<span class="font-bold text-white"><?= htmlspecialchars($bName) ?></span>
|
||||
<span class="text-slate-400 font-mono"><?= $bCount ?> حلقه (<?= $pct ?>%)</span>
|
||||
</div>
|
||||
<div class="w-full bg-slate-950 h-2 rounded-full overflow-hidden">
|
||||
<div class="bg-gradient-to-r from-rose-600 to-amber-500 h-full rounded-full" style="width: <?= $pct ?>%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right: Urgent Inquiries -->
|
||||
<div class="lg:col-span-6 glass-card p-6 rounded-3xl border border-slate-800 space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="bell" class="w-5 h-5 text-rose-400"></i>
|
||||
آخرین استعلامها جهت پیگیری
|
||||
</h3>
|
||||
<button onclick="switchAdminTab('leads')" class="text-xs text-rose-400 font-bold hover:underline">مشاهده همه</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3">
|
||||
<?php foreach (array_slice(array_reverse($consultations), 0, 4) as $c): ?>
|
||||
<div class="p-3.5 rounded-2xl bg-slate-950 border border-slate-800 flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-xs font-bold text-white"><?= htmlspecialchars($c['name']) ?> <span class="text-slate-400 font-normal">(<?= htmlspecialchars($c['car'] ?: 'نامشخص') ?>)</span></div>
|
||||
<div class="text-[11px] text-slate-400 font-mono mt-0.5"><?= htmlspecialchars($c['phone']) ?> • <?= $c['created_at'] ?></div>
|
||||
</div>
|
||||
<a href="tel:<?= htmlspecialchars($c['phone']) ?>" class="px-3 py-1.5 rounded-xl bg-rose-600 hover:bg-rose-500 text-white text-xs font-bold flex items-center gap-1">
|
||||
<i data-lucide="phone" class="w-3.5 h-3.5"></i> تماس
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- TAB 2: TIRES & INVENTORY MANAGEMENT -->
|
||||
<div id="tab-tires" class="hidden space-y-8">
|
||||
|
||||
<!-- Add Tire Form -->
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 space-y-4">
|
||||
<div class="flex items-center justify-between pb-3 border-b border-slate-800">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="plus-circle" class="w-5 h-5 text-emerald-400"></i>
|
||||
ثبت تایر جدید در کاتالوگ و انبار
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 text-xs">
|
||||
<input type="hidden" name="admin_action" value="add_tire">
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">نام کامل مدل تایر *</label>
|
||||
<input type="text" name="name" required placeholder="مثلاً: هانکوک K127 اسپرت" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white focus:outline-none focus:border-rose-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">برند سازنده *</label>
|
||||
<input type="text" name="brand" required placeholder="بارز، کویر، میشلن..." class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white focus:outline-none focus:border-rose-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">کشور سازنده</label>
|
||||
<input type="text" name="country" placeholder="ایران، کره جنوبی، آلمان..." class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white focus:outline-none focus:border-rose-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">دستهبندی</label>
|
||||
<select name="category" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white focus:outline-none focus:border-rose-500">
|
||||
<option value="سواری">سواری شهری</option>
|
||||
<option value="اسپرت">اسپرت و ریسینگ</option>
|
||||
<option value="شاسی بلند و آفرود (SUV/4x4)">شاسی بلند و آفرود (SUV/4x4)</option>
|
||||
<option value="لوکس و پرمیوم">لوکس و پرمیوم</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">پهنا (mm)</label>
|
||||
<input type="number" name="width" value="205" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">نسبت فاق (%)</label>
|
||||
<input type="number" name="aspect_ratio" value="55" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">قطر رینگ (اینچ)</label>
|
||||
<input type="number" name="rim" value="16" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">قیمت هر حلقه (تومان) *</label>
|
||||
<input type="number" name="price" required placeholder="6800000" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">موجودی انبار (حلقه)</label>
|
||||
<input type="number" name="stock" value="16" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">مدت گارانتی (ماه)</label>
|
||||
<input type="number" name="warranty_months" value="36" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block font-bold text-slate-300 mb-1">خودروهای سازگار (با کاما جدا کنید)</label>
|
||||
<input type="text" name="vehicles" placeholder="دنا پلاس, تارا, شاهین, سراتو" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4">
|
||||
<label class="block font-bold text-slate-300 mb-1">توضیحات و مشخصات کاربردی</label>
|
||||
<input type="text" name="description" placeholder="تایر نرم، چسبندگی فوقالعاده در بارندگی با طول عمر بالا..." class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2 text-white">
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-4 pt-2">
|
||||
<button type="submit" class="px-6 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white font-bold transition-all shadow">
|
||||
افزودن تایر به انبار
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Inventory Table -->
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 space-y-4">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="database" class="w-5 h-5 text-amber-400"></i>
|
||||
لیست و ویرایش سریع موجودی و قیمت تایرها
|
||||
</h2>
|
||||
|
||||
<div class="relative max-w-xs w-full">
|
||||
<i data-lucide="search" class="w-4 h-4 text-slate-400 absolute right-3 top-3"></i>
|
||||
<input type="text" id="admin-tire-search" oninput="filterAdminTires()" placeholder="جستجوی مدل یا برند..." class="w-full bg-slate-950 border border-slate-800 rounded-xl pr-9 pl-3 py-2 text-xs text-white focus:outline-none focus:border-rose-500">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-right text-xs" id="admin-tires-table">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-800 text-slate-400">
|
||||
<th class="p-3">کد تایر</th>
|
||||
<th class="p-3">تصویر</th>
|
||||
<th class="p-3">نام و مدل تایر</th>
|
||||
<th class="p-3">سایز</th>
|
||||
<th class="p-3">قیمت مصوب (تومان)</th>
|
||||
<th class="p-3">موجودی</th>
|
||||
<th class="p-3">تخفیف %</th>
|
||||
<th class="p-3 text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-800/60 text-slate-200">
|
||||
<?php foreach ($tires as $t): ?>
|
||||
<tr class="admin-tire-row hover:bg-slate-800/30">
|
||||
<td class="p-3 font-mono text-slate-400"><?= $t['id'] ?></td>
|
||||
<td class="p-3">
|
||||
<img src="../<?= htmlspecialchars($t['image']) ?>" alt="<?= htmlspecialchars($t['name']) ?>" class="w-10 h-10 object-contain">
|
||||
</td>
|
||||
<td class="p-3 font-bold text-white">
|
||||
<div><?= htmlspecialchars($t['name']) ?></div>
|
||||
<span class="text-[10px] text-rose-400 font-normal"><?= htmlspecialchars($t['brand']) ?> (<?= $t['country'] ?>)</span>
|
||||
</td>
|
||||
<td class="p-3"><span class="px-2 py-0.5 rounded bg-slate-950 font-bold"><?= $t['size_str'] ?></span></td>
|
||||
|
||||
<!-- Inline Quick Update Form -->
|
||||
<form method="POST">
|
||||
<input type="hidden" name="admin_action" value="quick_update_tire">
|
||||
<input type="hidden" name="tire_id" value="<?= $t['id'] ?>">
|
||||
|
||||
<td class="p-3">
|
||||
<input type="number" name="price" value="<?= $t['price'] ?>" class="w-28 bg-slate-950 border border-slate-800 rounded-lg px-2 py-1 text-white font-mono text-xs">
|
||||
</td>
|
||||
<td class="p-3">
|
||||
<input type="number" name="stock" value="<?= $t['stock'] ?>" class="w-16 bg-slate-950 border border-slate-800 rounded-lg px-2 py-1 text-white font-mono text-xs">
|
||||
</td>
|
||||
<td class="p-3">
|
||||
<input type="number" name="discount_percent" value="<?= $t['discount_percent'] ?? 0 ?>" class="w-14 bg-slate-950 border border-slate-800 rounded-lg px-2 py-1 text-white font-mono text-xs">
|
||||
</td>
|
||||
<td class="p-3 text-center flex items-center justify-center gap-1.5">
|
||||
<button type="submit" class="p-1.5 rounded-lg bg-emerald-600/20 hover:bg-emerald-600 text-emerald-300 hover:text-white transition-colors" title="ذخیره تغییرات">
|
||||
<i data-lucide="check" class="w-4 h-4"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" onsubmit="return confirm('آیا از حذف این تایر مطمئن هستید؟');" class="inline">
|
||||
<input type="hidden" name="admin_action" value="delete_tire">
|
||||
<input type="hidden" name="tire_id" value="<?= $t['id'] ?>">
|
||||
<button type="submit" class="p-1.5 rounded-lg bg-rose-500/10 hover:bg-rose-500/30 text-rose-400 transition-colors" title="حذف تایر">
|
||||
<i data-lucide="trash-2" class="w-4 h-4"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- TAB 3: LEADS & INQUIRIES -->
|
||||
<div id="tab-leads" class="hidden space-y-8">
|
||||
|
||||
<div class="glass-card p-6 rounded-3xl border border-slate-800 space-y-4">
|
||||
<div class="flex items-center justify-between pb-3 border-b border-slate-800">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="headset" class="w-5 h-5 text-rose-400"></i>
|
||||
مدیریت و پیگیری درخواستهای مشاوره و خرید مشتریان
|
||||
</h2>
|
||||
<span class="text-xs text-slate-400 font-bold"><?= count($consultations) ?> استعلام ثبتشده</span>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-800 text-slate-400">
|
||||
<th class="p-3">کد</th>
|
||||
<th class="p-3">نام متقاضی</th>
|
||||
<th class="p-3">شماره تماس</th>
|
||||
<th class="p-3">خودرو</th>
|
||||
<th class="p-3">پیام مشتری</th>
|
||||
<th class="p-3">تاریخ ثبت</th>
|
||||
<th class="p-3">وضعیت پیگیری</th>
|
||||
<th class="p-3">یادداشت مدیر</th>
|
||||
<th class="p-3 text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-800/60 text-slate-200">
|
||||
<?php foreach (array_reverse($consultations) as $c): ?>
|
||||
<tr class="hover:bg-slate-800/30">
|
||||
<td class="p-3 font-mono text-slate-400"><?= $c['id'] ?></td>
|
||||
<td class="p-3 font-bold text-white"><?= htmlspecialchars($c['name']) ?></td>
|
||||
<td class="p-3">
|
||||
<a href="tel:<?= htmlspecialchars($c['phone']) ?>" class="font-mono text-rose-400 font-bold hover:underline flex items-center gap-1">
|
||||
<i data-lucide="phone" class="w-3.5 h-3.5"></i> <?= htmlspecialchars($c['phone']) ?>
|
||||
</a>
|
||||
</td>
|
||||
<td class="p-3 text-slate-300"><?= htmlspecialchars($c['car'] ?: '-') ?></td>
|
||||
<td class="p-3 text-slate-400 max-w-xs"><?= htmlspecialchars($c['message'] ?: '-') ?></td>
|
||||
<td class="p-3 text-slate-500 font-mono"><?= htmlspecialchars($c['created_at']) ?></td>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="admin_action" value="update_consultation">
|
||||
<input type="hidden" name="consultation_id" value="<?= $c['id'] ?>">
|
||||
|
||||
<td class="p-3">
|
||||
<select name="status" class="bg-slate-950 border border-slate-800 rounded-lg px-2 py-1 text-xs text-white">
|
||||
<option value="جدید" <?= ($c['status'] ?? '') === 'جدید' ? 'selected' : '' ?>>جدید</option>
|
||||
<option value="در حال پیگیری" <?= ($c['status'] ?? '') === 'در حال پیگیری' ? 'selected' : '' ?>>در حال پیگیری</option>
|
||||
<option value="تماس گرفته شد" <?= ($c['status'] ?? '') === 'تماس گرفته شد' ? 'selected' : '' ?>>تماس گرفته شد</option>
|
||||
<option value="سفارش نهایی شد" <?= ($c['status'] ?? '') === 'سفارش نهایی شد' ? 'selected' : '' ?>>سفارش نهایی شد</option>
|
||||
<option value="لغو شده" <?= ($c['status'] ?? '') === 'لغو شده' ? 'selected' : '' ?>>لغو شده</option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<td class="p-3">
|
||||
<input type="text" name="admin_note" value="<?= htmlspecialchars($c['admin_note'] ?? '') ?>" placeholder="یادداشت کارشناس..." class="bg-slate-950 border border-slate-800 rounded-lg px-2 py-1 text-xs text-slate-300 w-36">
|
||||
</td>
|
||||
|
||||
<td class="p-3 text-center flex items-center justify-center gap-1.5">
|
||||
<button type="submit" class="p-1.5 rounded-lg bg-emerald-600/20 hover:bg-emerald-600 text-emerald-300 hover:text-white transition-colors" title="ذخیره وضعیت">
|
||||
<i data-lucide="save" class="w-4 h-4"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" onsubmit="return confirm('آیا از حذف این درخواست مطمئن هستید؟');" class="inline">
|
||||
<input type="hidden" name="admin_action" value="delete_consultation">
|
||||
<input type="hidden" name="consultation_id" value="<?= $c['id'] ?>">
|
||||
<button type="submit" class="p-1.5 rounded-lg bg-rose-500/10 hover:bg-rose-500/30 text-rose-400 transition-colors" title="حذف">
|
||||
<i data-lucide="trash-2" class="w-4 h-4"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- TAB 4: SETTINGS -->
|
||||
<div id="tab-settings" class="hidden space-y-8">
|
||||
|
||||
<div class="glass-card p-6 sm:p-8 rounded-3xl border border-slate-800 space-y-6">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="settings" class="w-5 h-5 text-amber-400"></i>
|
||||
تنظیمات عمومی، تلفنها و شعب فروشگاه تایر قاسمی
|
||||
</h2>
|
||||
|
||||
<form method="POST" class="space-y-4 text-xs">
|
||||
<input type="hidden" name="admin_action" value="update_settings">
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">شماره تلفن ثابت فروشگاه</label>
|
||||
<input type="text" name="site_phone" value="<?= htmlspecialchars($settings['site_phone'] ?? '021-88889900') ?>" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white font-mono text-left">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">شماره تماس اضطراری و امداد سیار</label>
|
||||
<input type="text" name="emergency_phone" value="<?= htmlspecialchars($settings['emergency_phone'] ?? '09123456789') ?>" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white font-mono text-left">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">متن بنر اعلان بالای صفحه (Top Banner)</label>
|
||||
<input type="text" name="announcement" value="<?= htmlspecialchars($settings['announcement'] ?? 'تضمین اصالت کالا و گارانتی معتبر شرکتی تا ۶۰ ماه') ?>" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-bold text-slate-300 mb-1">آدرس شعبه مرکزی</label>
|
||||
<input type="text" name="central_address" value="<?= htmlspecialchars($settings['central_address'] ?? 'تهران، خیابان آزادی، تقاطع یادگار امام، مجتمع خدمات خودرویی تایر قاسمی') ?>" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-3 py-2.5 text-white">
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<button type="submit" class="px-6 py-2.5 rounded-xl bg-rose-600 hover:bg-rose-500 text-white font-bold transition-all shadow">
|
||||
ذخیره تنظیمات
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- Admin Footer -->
|
||||
<footer class="border-t border-slate-800/80 bg-slate-950 py-4 px-4 text-center text-xs text-slate-500">
|
||||
سامانه مدیریت یکپارچه تایر قاسمی • نسخه ۲.۰ • سرور پایدار PHP 8
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Tire Inventory Table -->
|
||||
<div class="p-6 rounded-3xl bg-slate-900 border border-slate-800 space-y-4">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="database" class="w-5 h-5 text-amber-400"></i>
|
||||
مدیریت موجودی و قیمت تایرها
|
||||
</h2>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-800 text-slate-400">
|
||||
<th class="p-3">کد</th>
|
||||
<th class="p-3">نام و مدل تایر</th>
|
||||
<th class="p-3">برند</th>
|
||||
<th class="p-3">سایز</th>
|
||||
<th class="p-3">قیمت مصوب</th>
|
||||
<th class="p-3">موجودی</th>
|
||||
<th class="p-3">گارانتی</th>
|
||||
<th class="p-3 text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-800/60 text-slate-200">
|
||||
<?php foreach ($tires as $t): ?>
|
||||
<tr class="hover:bg-slate-800/30">
|
||||
<td class="p-3 font-mono text-slate-400"><?= $t['id'] ?></td>
|
||||
<td class="p-3 font-bold text-white"><?= htmlspecialchars($t['name']) ?></td>
|
||||
<td class="p-3 text-brand-400 font-medium"><?= htmlspecialchars($t['brand']) ?></td>
|
||||
<td class="p-3"><span class="px-2 py-0.5 rounded bg-slate-800"><?= $t['size_str'] ?></span></td>
|
||||
<td class="p-3 font-bold"><?= number_format($t['price']) ?> تومان</td>
|
||||
<td class="p-3"><span class="px-2 py-0.5 rounded <?= $t['stock'] > 10 ? 'bg-emerald-500/20 text-emerald-400' : 'bg-rose-500/20 text-rose-400' ?>"><?= $t['stock'] ?> حلقه</span></td>
|
||||
<td class="p-3"><?= $t['warranty_months'] ?> ماه</td>
|
||||
<td class="p-3 text-center">
|
||||
<form method="POST" onsubmit="return confirm('آیا از حذف این تایر مطمئن هستید؟');" class="inline">
|
||||
<input type="hidden" name="admin_action" value="delete_tire">
|
||||
<input type="hidden" name="tire_id" value="<?= $t['id'] ?>">
|
||||
<button type="submit" class="p-1.5 rounded-lg bg-rose-500/10 hover:bg-rose-500/30 text-rose-400 transition-colors" title="حذف تایر">
|
||||
<i data-lucide="trash-2" class="w-4 h-4"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Inquiries / Consultations Table -->
|
||||
<div class="p-6 rounded-3xl bg-slate-900 border border-slate-800 space-y-4">
|
||||
<h2 class="text-base font-black text-white flex items-center gap-2">
|
||||
<i data-lucide="headset" class="w-5 h-5 text-emerald-400"></i>
|
||||
درخواستهای استعلام قیمت و مشاوره کاربران
|
||||
</h2>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-800 text-slate-400">
|
||||
<th class="p-3">کد</th>
|
||||
<th class="p-3">نام مشتری</th>
|
||||
<th class="p-3">شماره تماس</th>
|
||||
<th class="p-3">خودرو</th>
|
||||
<th class="p-3">متن پیام</th>
|
||||
<th class="p-3">تاریخ ثبت</th>
|
||||
<th class="p-3">وضعیت</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-800/60 text-slate-200">
|
||||
<?php foreach ($consultations as $c): ?>
|
||||
<tr class="hover:bg-slate-800/30">
|
||||
<td class="p-3 font-mono text-slate-400"><?= $c['id'] ?></td>
|
||||
<td class="p-3 font-bold text-white"><?= htmlspecialchars($c['name']) ?></td>
|
||||
<td class="p-3 font-mono text-brand-400"><?= htmlspecialchars($c['phone']) ?></td>
|
||||
<td class="p-3 text-slate-300"><?= htmlspecialchars($c['car'] ?: '-') ?></td>
|
||||
<td class="p-3 text-slate-400 max-w-xs truncate"><?= htmlspecialchars($c['message'] ?: '-') ?></td>
|
||||
<td class="p-3 text-slate-500"><?= htmlspecialchars($c['created_at']) ?></td>
|
||||
<td class="p-3"><span class="px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-400 font-bold"><?= htmlspecialchars($c['status']) ?></span></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
<?php endif; ?>
|
||||
|
||||
<script>
|
||||
lucide.createIcons();
|
||||
|
||||
function switchAdminTab(tab) {
|
||||
['dashboard', 'tires', 'leads', 'settings'].forEach(t => {
|
||||
const el = document.getElementById('tab-' + t);
|
||||
const btn = document.getElementById('btn-tab-' + t);
|
||||
if (el) el.classList.add('hidden');
|
||||
if (btn) {
|
||||
btn.className = 'tab-btn px-4 py-2 rounded-xl text-slate-400 hover:text-white flex items-center gap-2 transition-all';
|
||||
}
|
||||
});
|
||||
|
||||
const activeEl = document.getElementById('tab-' + tab);
|
||||
const activeBtn = document.getElementById('btn-tab-' + tab);
|
||||
if (activeEl) activeEl.classList.remove('hidden');
|
||||
if (activeBtn) {
|
||||
activeBtn.className = 'tab-btn px-4 py-2 rounded-xl bg-rose-600 text-white flex items-center gap-2 transition-all';
|
||||
}
|
||||
}
|
||||
|
||||
function filterAdminTires() {
|
||||
const q = document.getElementById('admin-tire-search').value.toLowerCase().trim();
|
||||
const rows = document.querySelectorAll('.admin-tire-row');
|
||||
rows.forEach(r => {
|
||||
if (r.innerText.toLowerCase().includes(q)) {
|
||||
r.classList.remove('hidden');
|
||||
} else {
|
||||
r.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -60,6 +60,12 @@ switch ($action) {
|
||||
echo json_encode(["status" => "success", "message" => "درخواست مشاوره شما با موفقیت ثبت شد. کارشناسان ما به زودی با شما تماس خواهند گرفت.", "data" => $res], JSON_UNESCAPED_UNICODE);
|
||||
break;
|
||||
|
||||
case 'export_backup':
|
||||
$data = TireStore::getData();
|
||||
header('Content-Disposition: attachment; filename="gasemi_tier_backup_' . date('Y-m-d_H-i') . '.json"');
|
||||
echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
|
||||
default:
|
||||
echo json_encode(["status" => "error", "message" => "Invalid action"], JSON_UNESCAPED_UNICODE);
|
||||
break;
|
||||
|
||||
@@ -55,11 +55,35 @@ class TireStore {
|
||||
$entry['id'] = 'CNS-' . (count($data['consultations'] ?? []) + 101);
|
||||
$entry['created_at'] = date('Y-m-d H:i');
|
||||
$entry['status'] = 'جدید';
|
||||
$entry['admin_note'] = '';
|
||||
$data['consultations'][] = $entry;
|
||||
self::saveData($data);
|
||||
return $entry;
|
||||
}
|
||||
|
||||
public static function updateConsultationStatus($id, $status, $note = '') {
|
||||
$data = self::getData();
|
||||
foreach ($data['consultations'] as &$c) {
|
||||
if ($c['id'] === $id) {
|
||||
$c['status'] = $status;
|
||||
if ($note !== '') {
|
||||
$c['admin_note'] = $note;
|
||||
}
|
||||
self::saveData($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteConsultation($id) {
|
||||
$data = self::getData();
|
||||
$data['consultations'] = array_values(array_filter($data['consultations'], function($c) use ($id) {
|
||||
return $c['id'] !== $id;
|
||||
}));
|
||||
return self::saveData($data);
|
||||
}
|
||||
|
||||
public static function addTire($tire) {
|
||||
$data = self::getData();
|
||||
$data['tires'][] = $tire;
|
||||
@@ -86,4 +110,20 @@ class TireStore {
|
||||
}));
|
||||
return self::saveData($data);
|
||||
}
|
||||
|
||||
public static function getSettings() {
|
||||
$data = self::getData();
|
||||
return $data['settings'] ?? [
|
||||
"site_phone" => "021-88889900",
|
||||
"emergency_phone" => "09123456789",
|
||||
"announcement" => "تضمین اصالت کالا و گارانتی معتبر شرکتی تا ۶۰ ماه | تاریخ تولید روز (2026)",
|
||||
"central_address" => "تهران، خیابان آزادی، تقاطع یادگار امام، مجتمع تایر قاسمی"
|
||||
];
|
||||
}
|
||||
|
||||
public static function updateSettings($settings) {
|
||||
$data = self::getData();
|
||||
$data['settings'] = array_merge($data['settings'] ?? [], $settings);
|
||||
return self::saveData($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user