diff --git a/admin/index.php b/admin/index.php index 8ebf26a..38c716d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,25 +1,44 @@ 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']; +} ?>
-انبارداری، استعلامها و کاتالوگ محصولات
+جهت دسترسی به انبار، قیمتها و استعلامها رمز عبور را وارد کنید.