-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
661 lines (593 loc) · 37.7 KB
/
admin.php
File metadata and controls
661 lines (593 loc) · 37.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
<?php
include 'activity/config.php';
if (!isset($_COOKIE['login'])) {
header(header: 'Location: https://sohanvijeamin.com/');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<script src="tailwind.js"></script>
<link href="tailwind.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body class="bg-gray-50" dir="rtl">
<div id="admin-panel" class="admin-panel ">
<div class="admin-content">
<!-- Sidebar -->
<div class="admin-sidebar ">
<div class="flex justify-between items-center px-5 pb-5 border-b border-gray-600">
<h2 class="text-lg">پنل مدیریت</h2>
<button id="close-admin" class="text-red-400 hover:text-red-300 text-2xl">×</button>
</div>
<div class="mt-5">
<div class="admin-menu-item active" data-section="dashboard">
<div class="flex items-center">
<i class="fas fa-tachometer-alt ml-3"></i>
<span class="text-[14px]">داشبورد</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
<div class="admin-menu-item" data-section="content">
<div class="flex items-center">
<i class="fas fa-edit ml-3"></i>
<span class="text-[14px]">مدیریت محتوا</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
<div class="admin-menu-item" data-section="images">
<div class="flex items-center">
<i class="fas fa-images ml-3"></i>
<span class="text-[14px]">مدیریت تصاویر</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
<div class="admin-menu-item" data-section="slider">
<div class="flex items-center">
<i class="fas fa-sliders-h ml-3"></i>
<span class="text-[14px]">مدیریت اسلایدر</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
<div class="admin-menu-item" data-section="products">
<div class="flex items-center">
<i class="fas fa-box ml-3"></i>
<span class="text-[14px]">مدیریت محصولات</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
<div class="admin-menu-item" data-section="contact">
<div class="flex items-center">
<i class="fas fa-address-book ml-3"></i>
<span class="text-[14px]">اطلاعات تماس</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
<div class="admin-menu-item" data-section="orders">
<div class="flex items-center">
<i class="fas fa-shopping-cart ml-3"></i>
<span class="text-[14px]">مدیریت سفارشات</span>
</div>
<i class="fas fa-chevron-left text-[10px]"></i>
</div>
</div>
</div>
<!-- Main Content -->
<div class="admin-main border border-gray-700 bg-gray-900 ">
<!-- Dashboard Section -->
<div id="dashboard-section" class="admin-section active">
<h3 class="text-lg mb-6 text-[#ecf0f1]">داشبورد</h3>
<div class="grid md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div class="border border-gray-700 bg-gray-900 p-6 rounded-lg shadow">
<div class="flex items-center">
<div class="p-3 bg-blue-100 rounded-full">
<i class="fas fa-box text-blue-600 text-xl"></i>
</div>
<div class="mr-4">
<h4 class="text-[#ecf0f1] text-[14px]">تعداد محصولات</h4>
<p class="text-lg font-bold text-[#ecf0f1]" id="dashboard-products-count">
<?php
$products_count = select("SELECT COUNT(*) FROM `product`");
echo $products_count[0]["COUNT(*)"];
?>
</p>
</div>
</div>
</div>
<div class="border border-gray-700 bg-gray-900 p-6 rounded-lg shadow">
<div class="flex items-center">
<div class="p-3 bg-green-100 rounded-full">
<i class="fas fa-shopping-cart text-green-600 text-xl"></i>
</div>
<div class="mr-4">
<h4 class="text-[#ecf0f1] text-[14px]">تعداد سفارشات</h4>
<p class="text-lg font-bold text-[#ecf0f1]" id="dashboard-orders-count">
<?php
$orders_count = select("SELECT COUNT(*) FROM `order_pay`");
echo $orders_count[0]["COUNT(*)"];
?>
</p>
</div>
</div>
</div>
<div class="border border-gray-700 bg-gray-900 p-6 rounded-lg shadow">
<div class="flex items-center">
<div class="p-3 bg-yellow-100 rounded-full">
<i class="fas fa-images text-yellow-600 text-xl"></i>
</div>
<div class="mr-4">
<h4 class="text-[#ecf0f1] text-[14px]">تعداد تصاویر</h4>
<p class="text-lg font-bold text-[#ecf0f1]" id="dashboard-images-count">
<?php
$images_count = select("SELECT COUNT(*) FROM `images`");
echo $images_count[0]["COUNT(*)"];
?>
</p>
</div>
</div>
</div>
<div class="border border-gray-700 bg-gray-900 p-6 rounded-lg shadow">
<div class="flex items-center">
<div class="p-3 bg-purple-100 rounded-full">
<i class="fas fa-sliders-h text-purple-600 text-xl"></i>
</div>
<div class="mr-4">
<h4 class="text-[#ecf0f1] text-[14px]">تعداد اسلایدها</h4>
<p class="text-lg font-bold text-[#ecf0f1]" id="dashboard-slides-count">
<?php
$slides_count = select("SELECT COUNT(*) FROM `slider`");
echo $slides_count[0]["COUNT(*)"];
?>
</p>
</div>
</div>
</div>
</div>
<div class="border border-gray-700 bg-gray-900 p-6 rounded-lg shadow">
<h4 class="text-lg text-[#ecf0f1] mb-4">خلاصه فعالیتها</h4>
<p class="text-gray-600">به پنل مدیریت خوش آمدید. از منوی سمت راست میتوانید بخشهای مختلف را
مدیریت کنید.</p>
</div>
</div>
<!-- Content Management Section -->
<div id="content-section" class="admin-section ">
<h3 class="text-lg mb-6 text-[#ecf0f1]">مدیریت محتوا</h3>
<div class="bg-white p-6 rounded-lg shadow ">
<div class="space-y-4">
<div>
<label class="block font-semibold mb-2">عنوان سایت:</label>
<input type="text" id="admin-site-title" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">متن درباره ما:</label>
<textarea id="admin-about-text" class="w-full p-3 border rounded-lg"
rows="6"></textarea>
</div>
<button id="update-content"
class="bg-blue-500 text-white px-6 py-3 rounded-lg hover:bg-blue-600 transition">
<i class="fas fa-save ml-2"></i>
بروزرسانی محتوا
</button>
</div>
</div>
</div>
<!-- Image Management Section -->
<div id="images-section" class="admin-section ">
<h3 class="text-lg mb-6 text-[#ecf0f1]">مدیریت تصاویر</h3>
<div class="grid md:grid-cols-2 gap-6 ">
<div class="border bg-white p-6 rounded-[16px] shadow">
<h4 class="text-lg font-bold mb-4">آپلود تصاویر</h4>
<div class="space-y-4">
<div>
<label class="block font-semibold mb-2">لوگو:</label>
<input type="file" id="admin-logo-file" accept="image/*"
class="w-full p-2 bg-white border border-[#bdc3c7] rounded-[9px]">
<button onclick="uploadLogo()"
class="mt-2 bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
آپلود لوگو
</button>
</div>
<div>
<label class="block font-semibold mb-2 ">تصویر اسلاید:</label>
<input type="file" id="slide-image-file" accept="image/*"
class="w-full p-2 bg-white border border-[#bdc3c7] rounded-[9px]">
<button onclick="uploadSlideImage()"
class="mt-2 bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">
آپلود تصویر اسلاید
</button>
</div>
<div>
<label class="block font-semibold mb-2 ">تصویر محصول:</label>
<input type="file" id="product-image-file" accept="image/*"
class="w-full p-2 bg-white border border-[#bdc3c7] border rounded-[9px]">
<button onclick="uploadProductImage()"
class="mt-2 bg-purple-500 text-white px-4 py-2 rounded hover:bg-purple-600">
آپلود تصویر محصول
</button>
</div>
</div>
</div>
<div class="border border-gray-700 bg-gray-900 p-6 rounded-[16px] shadow">
<h4 class="text-lg text-[#ecf0f1] mb-4">تصاویر آپلود شده</h4>
<div id="uploaded-images" class="grid grid-cols-2 gap-3 max-h-96 overflow-y-auto">
<?php
$image_lists = select('SELECT * FROM `images`');
foreach ($image_lists as $image_list) {
?>
<div id="a<?php echo $image_list['id']; ?>" class="relative">
<img src="<?php echo $image_list['link']; ?>" alt=""
class="w-full h-20 object-cover rounded">
<div
class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-70 text-white text-xs p-1 rounded-b">
<?php echo $image_list["name"]; ?>
</div>
<button onclick="removeUploadedImage(<?php echo $image_list['id']; ?>)"
class="absolute top-1 right-1 bg-red-500 text-white rounded-full w-5 h-5 text-xs">×</button>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
<!-- Slider Management Section -->
<div id="slider-section" class="admin-section">
<h3 class="text-lg mb-6 text-[#ecf0f1]">مدیریت اسلایدر</h3>
<div class="grid md:grid-cols-2 gap-6">
<div class="bg-white p-6 rounded-lg shadow">
<h4 class="text-lg font-bold mb-4">افزودن اسلاید جدید</h4>
<div class="space-y-4">
<!--<div>-->
<!-- <label class="block font-semibold mb-2">عنوان اسلاید:</label>-->
<!-- <input type="text" id="slide-title" class="w-full p-3 border rounded-lg">-->
<!--</div>-->
<!--<div>-->
<!-- <label class="block font-semibold mb-2">توضیحات:</label>-->
<!-- <input type="text" id="slide-description" class="w-full p-3 border rounded-lg">-->
<!--</div>-->
<div>
<label class="block font-semibold mb-2">تصویر اسلاید:</label>
<select id="slide-image-select" class="w-full p-3 border rounded-lg">
<option value="">انتخاب تصویر آپلود شده</option>
<?php
$image_lists = select("SELECT * FROM `images` WHERE `type` = 'slide'; ");
foreach ($image_lists as $image_list) {
?>
<option value="<?php echo $image_list["link"]; ?>">
<?php echo $image_list["name"]; ?>
</option>
<?php
} ?>
</select>
</div>
<button id="add-slide"
class="bg-green-500 text-white px-6 py-3 rounded-lg hover:bg-green-600 transition">
<i class="fas fa-plus ml-2"></i>
افزودن اسلاید
</button>
</div>
</div>
<div class="bg-white p-6 rounded-lg shadow">
<h4 class="text-lg font-bold mb-4">لیست اسلایدها</h4>
<div id="slides-list" class="max-h-96 overflow-y-auto">
<?php
$slide_lists = select("SELECT * FROM `slider` ");
foreach ($slide_lists as $slide_list) {
?>
<div class="flex justify-between items-center p-2 bg-white rounded mb-2">
<img style="width:100px" src="<?php echo $slide_list["link"]; ?>">
<button onclick="removeSlide(<?php echo $slide_list['id']; ?>)"
class="text-red-500">حذف</button>
</div>
<?php
}
?>
<!-- Slides list will be shown here -->
</div>
</div>
</div>
</div>
<!-- Product Management Section -->
<div id="products-section" class="admin-section">
<h3 class="text-lg mb-6 text-[#ecf0f1]">مدیریت محصولات</h3>
<div class="grid md:grid-cols-2 gap-6">
<div class="bg-white p-6 rounded-lg shadow">
<h4 class="text-lg font-bold mb-4">افزودن/ویرایش محصول</h4>
<div class="space-y-4">
<div>
<label class="block font-semibold mb-2">نام محصول:</label>
<input type="text" id="product-name" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">قیمت (تومان):</label>
<input type="number" id="product-price" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">دستهبندی:</label>
<input type="text" id="product-category" class="w-full p-3 border rounded-lg"
placeholder="نام دستهبندی را وارد کنید">
<div class="mt-2">
<small class="text-gray-600">دستهبندیهای موجود:</small>
<div id="existing-categories" class="flex flex-wrap gap-1 mt-1">
<span
class="bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm cursor-pointer hover:bg-blue-200"
onclick="selectCategory('sohan')">sohan</span>
<span
class="bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm cursor-pointer hover:bg-blue-200"
onclick="selectCategory('gaz')">gaz</span>
</div>
</div>
</div>
<div>
<label class="block font-semibold mb-2">تصویر محصول:</label>
<select id="product-image-select" class="w-full p-3 border rounded-lg">
<option value="">انتخاب تصویر آپلود شده</option>
</select>
</div>
<div class="flex space-x-2 space-x-reverse">
<button id="add-product"
class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">
<i class="fas fa-plus ml-1"></i>
افزودن محصول
</button>
<button style="display:none" id="update-product"
class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600 ">
<i class="fas fa-edit ml-1"></i>
بروزرسانی محصول
</button>
<button style="display:none" id="cancel-edit"
class="bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600 ">
لغو ویرایش
</button>
</div>
</div>
</div>
<div class="border border-gray-700 bg-gray-900 p-6 rounded-lg shadow">
<h4 class="text-lg text-[#ecf0f1] mb-4">لیست محصولات</h4>
<div id="products-list" class="max-h-96 overflow-y-auto">
<?php
$list_products = select('SELECT * FROM `product` ');
foreach ($list_products as $list_product) {
?>
<div class="flex justify-between items-center rounded mb-2">
<div class="flex items-center space-x-3 space-x-reverse">
<div class="w-12 h-12 rounded overflow-hidden">
<?php if ($list_product["image"] != null) {
echo "<img src='/upload/" . $list_product["image"] . "''>";
} else {
echo '<div class="w-full h-full bg-gradient-to-br from-yellow-400 to-orange-500 flex items-center justify-center">
<i class="fas fa-cookie-bite text-white"></i>
</div>';
} ?>
</div>
<div>
<div class="font-semibold text-[11px] text-[#ecf0f1]">
<?php echo $list_product["name"]; ?>
</div>
<div class="text-[10px] text-[#bdc3c7]">
<?php echo $list_product["price"]; ?>
تومان - <?php echo $list_product["category"]; ?>
</div>
</div>
</div>
<div class="flex space-x-2 space-x-reverse">
<button onclick="editProduct(<?php echo $list_product['id']; ?>)"
class="bg-blue-500 text-white px-3 py-1 rounded text-sm hover:bg-blue-600">
ویرایش
</button>
<button onclick="deleteProduct(<?php echo $list_product['id']; ?>)"
class="bg-red-500 text-white px-3 py-1 rounded text-sm hover:bg-red-600">
حذف
</button>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
<!-- Contact Management Section -->
<div id="contact-section" class="admin-section">
<h3 class="text-lg mb-6 text-[#ecf0f1]">مدیریت اطلاعات تماس</h3>
<div class="bg-white p-6 rounded-lg shadow">
<div class="space-y-4">
<div>
<label class="block font-semibold mb-2">آدرس کارخانه:</label>
<input type="text" id="admin-address" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">شماره تلفن:</label>
<input type="text" id="admin-phone" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">واتساپ:</label>
<input type="text" id="admin-whatsapp" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">اینستاگرام:</label>
<input type="text" id="admin-instagram" class="w-full p-3 border rounded-lg">
</div>
<div>
<label class="block font-semibold mb-2">ایمیل:</label>
<input type="email" id="admin-email" class="w-full p-3 border rounded-lg">
</div>
<button id="update-contact"
class="bg-orange-500 text-white px-6 py-3 rounded-lg hover:bg-orange-600 transition">
<i class="fas fa-save ml-2"></i>
بروزرسانی اطلاعات تماس
</button>
</div>
</div>
</div>
<!-- Orders Management Section -->
<div id="orders-section" class="admin-section">
<h3 class="text-lg mb-6 text-[#ecf0f1]">مدیریت سفارشات</h3>
<div class="bg-white p-6 rounded-lg shadow">
<div id="orders-list">
<?php
$orders_list = select("SELECT * FROM `order_pay` ORDER BY `id` DESC");
if (!$orders_list) {
echo '<p class="text-gray-500 text-center">هنوز سفارشی ثبت نشده است.</p>';
} else {
$status_labels = [
-1 => 'لغو شده',
1 => 'تکمیل شده',
0 => 'ارسال شده',
];
?>
<div class="overflow-x-auto">
<div class="min-w-full">
<div
class="grid grid-cols-7 text-[12px] font-semibold text-gray-500 uppercase tracking-wide border-b border-gray-200 pb-3">
<span class="text-center">ردیف</span>
<span>مشتری</span>
<span>تلفن</span>
<span>آدرس</span>
<span>محصولات</span>
<span class="text-center">وضعیت</span>
<span class="text-center">جزئیات</span>
</div>
<?php
$rowNumber = 1;
foreach ($orders_list as $order_list) {
$products = json_decode($order_list["product"], true) ?: [];
$products_preview = array_slice($products, 0, 2);
$products_text = [];
foreach ($products_preview as $p) {
$qty = isset($p["count"]) ? $p["count"] : (isset($p["quantity"]) ? $p["quantity"] : 1);
$products_text[] = ($p["name"] ?? "محصول ناشناس") . " × " . $qty;
}
$preview_label = implode('، ', $products_text);
if (count($products) > 2) {
$preview_label .= " و " . (count($products) - 2) . " مورد دیگر";
}
$status_value = isset($order_list["status"]) ? (int) $order_list["status"] : 0;
$popup_id = 'order-popup-' . $order_list['id'];
$total_amount = 0;
?>
<div
class="grid grid-cols-7 items-center text-sm border-b border-gray-100 py-3 last:border-b-0">
<span
class="text-center font-semibold text-gray-700"><?php echo $rowNumber++; ?></span>
<span
class="font-medium text-gray-900"><?php echo htmlspecialchars($order_list["name"]); ?></span>
<span
class="text-gray-600"><?php echo htmlspecialchars($order_list["phone"]); ?></span>
<span class="text-gray-600 truncate"
title="<?php echo htmlspecialchars($order_list["address"]); ?>"><?php echo htmlspecialchars($order_list["address"]); ?></span>
<span
class="text-gray-600"><?php echo $preview_label ?: '—'; ?></span>
<span class="text-center">
<select
class="order-status-select text-xs border border-gray-300 rounded-lg px-3 py-1 bg-white focus:outline-none focus:ring-2 focus:ring-gray-900"
data-order-id="<?php echo $order_list["id"]; ?>"
data-status="<?php echo $status_value; ?>"
onchange="handleOrderStatusChange(this)">
<?php foreach ($status_labels as $value => $label) { ?>
<option value="<?php echo $value; ?>" <?php echo $status_value === $value ? 'selected' : ''; ?>>
<?php echo $label; ?>
</option>
<?php } ?>
</select>
</span>
<span class="text-center">
<div class="relative inline-block order-popup-wrapper">
<button type="button"
onclick="toggleOrderPopup('<?php echo $popup_id; ?>', event)"
class="order-items-btn bg-gray-900 text-white text-xs px-4 py-2 rounded-lg hover:bg-gray-800 transition">
مشاهده اقلام
</button>
</div>
<div id="<?php echo $popup_id; ?>" style="transform: translate(-50% , -50%); background: gray;"
class="order-popup hidden absolute top-1/2 left-1/2 mr-4 w-80 bg-white border border-gray-200 rounded-2xl shadow-2xl p-4 text-right z-40">
<div class="text-sm text-gray-700 space-y-1">
<p style="color:#fff"><span class="font-semibold">نام مشتری:</span>
<?php echo htmlspecialchars($order_list["name"]); ?></p>
<p style="color:#fff"><span class="font-semibold">شماره تماس:</span>
<?php echo htmlspecialchars($order_list["phone"]); ?></p>
<p style="color:#fff"><span class="font-semibold">آدرس:</span>
<?php echo htmlspecialchars($order_list["address"]); ?></p>
<p style="color:#fff"><span class="font-semibold">کد پستی:</span>
<?php echo htmlspecialchars($order_list["postcode"]); ?></p>
</div>
<div class="mt-3 border border-gray-200 rounded-xl overflow-hidden">
<table class="w-full text-xs text-gray-600">
<thead class="bg-gray-100 text-gray-700">
<tr>
<th class="py-2 px-2 text-right">محصول</th>
<th class="py-2 px-2 text-center">تعداد</th>
<th class="py-2 px-2 text-left">قیمت</th>
</tr>
</thead>
<tbody style="color:#fff">
<?php
if ($products) {
foreach ($products as $product_item) {
$qty = isset($product_item["count"]) ? (int) $product_item["count"] : (isset($product_item["quantity"]) ? (int) $product_item["quantity"] : 1);
$price = isset($product_item["amount"]) ? (int) $product_item["amount"] : (isset($product_item["price"]) ? (int) $product_item["price"] : 0);
$line_total = $qty * $price;
$total_amount += $line_total;
?>
<tr class="border-t border-gray-100">
<td class="py-2 px-2">
<?php echo $product_item["name"] ?? 'محصول ناشناس'; ?>
</td>
<td class="py-2 px-2 text-center">
<?php echo $qty; ?></td>
<td class="py-2 px-2 text-left">
<?php echo $price ? number_format($price) . ' تومان' : '—'; ?>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="3"
class="py-3 text-center text-gray-500">هیچ
محصولی ثبت نشده است</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
if ($total_amount === 0 && isset($order_list["price"])) {
$total_amount = (int) $order_list["price"];
}
?>
<div
class="flex justify-between items-center mt-3 text-sm font-bold" style="color:#fff">
<span>جمع کل</span>
<span><?php echo number_format($total_amount) . ' تومان'; ?></span>
</div>
</div>
</span>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="order-popup-overlay" class="fixed inset-0 bg-black bg-opacity-50 hidden z-30"></div>
<script src="https://netstreet.ir/sohan/main.js"></script>
</body>
</html>