Files
bildirchin/views/admin/order_detail.php
T

97 lines
6.4 KiB
PHP

<?php
$pageTitle = 'جزییات سفارش ' . $order['order_code'];
require __DIR__ . '/layout_header.php';
?>
<div class="max-w-5xl mx-auto space-y-6">
<div class="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 bg-white p-6 rounded-2xl border border-stone-200 shadow-sm">
<div>
<span class="text-xs text-stone-400">کد رهگیری سفارش:</span>
<h2 class="text-xl font-black text-stone-900 font-mono"><?= htmlspecialchars($order['order_code']) ?></h2>
<span class="text-xs text-stone-500">ثبت در تاریخ: <?= \Bildirchin\Helpers::getJalaliDate($order['created_at']) ?></span>
</div>
<div class="flex items-center gap-3">
<a href="/admin/invoice/<?= $order['id'] ?>" target="_blank" class="px-4 py-2 rounded-xl bg-stone-800 text-white text-xs font-bold hover:bg-stone-700 transition flex items-center gap-1.5">
<i class="fas fa-print"></i> نسخه چاپی فاکتور
</a>
<!-- Status Changer -->
<form action="/admin/order/update-status" method="POST" class="flex items-center gap-2">
<input type="hidden" name="order_id" value="<?= $order['id'] ?>">
<select name="status" class="bg-stone-50 border border-stone-300 rounded-xl p-2 text-xs font-bold focus:outline-none">
<option value="pending" <?= $order['status'] === 'pending' ? 'selected' : '' ?>>در انتظار تایید</option>
<option value="confirmed" <?= $order['status'] === 'confirmed' ? 'selected' : '' ?>>تایید شده</option>
<option value="packing" <?= $order['status'] === 'packing' ? 'selected' : '' ?>>در حال بسته‌بندی</option>
<option value="shipped" <?= $order['status'] === 'shipped' ? 'selected' : '' ?>>تحویل باربری / ارسال شده</option>
<option value="delivered" <?= $order['status'] === 'delivered' ? 'selected' : '' ?>>تحویل داده شده</option>
<option value="cancelled" <?= $order['status'] === 'cancelled' ? 'selected' : '' ?>>لغو شده</option>
</select>
<button type="submit" class="px-3 py-2 rounded-xl bg-amber-500 hover:bg-amber-600 text-stone-950 font-bold text-xs">
ثبت وضعیت
</button>
</form>
</div>
</div>
<!-- Customer & Destination Card -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-white p-6 rounded-2xl border border-stone-200 shadow-sm text-xs space-y-3">
<h4 class="font-bold text-stone-900 border-b pb-2 text-sm">مشخصات خریدار</h4>
<div class="flex justify-between"><span>نام و نام خانوادگی:</span><span class="font-bold text-stone-900"><?= htmlspecialchars($order['customer_name']) ?></span></div>
<div class="flex justify-between"><span>شماره تماس:</span><span class="font-bold text-stone-900 font-mono"><?= htmlspecialchars($order['customer_phone']) ?></span></div>
<div class="flex justify-between"><span>شیوه پرداخت:</span><span class="font-bold text-stone-900"><?= htmlspecialchars($order['payment_method']) ?></span></div>
<div class="flex justify-between"><span>روش ارسال:</span><span class="font-bold text-stone-900"><?= htmlspecialchars($order['shipping_method']) ?></span></div>
</div>
<div class="bg-white p-6 rounded-2xl border border-stone-200 shadow-sm text-xs space-y-3">
<h4 class="font-bold text-stone-900 border-b pb-2 text-sm">آدرس و مقصد تحویل</h4>
<div class="flex justify-between"><span>استان و شهر:</span><span class="font-bold text-stone-900"><?= htmlspecialchars($order['province']) ?> - <?= htmlspecialchars($order['city']) ?></span></div>
<div class="flex justify-between"><span>کد پستی:</span><span class="font-bold text-stone-900 font-mono"><?= htmlspecialchars($order['postal_code'] ?: '-') ?></span></div>
<div><span>آدرس کامل:</span><p class="font-bold text-stone-900 mt-1"><?= htmlspecialchars($order['address']) ?></p></div>
<?php if ($order['notes']): ?>
<div><span>یادداشت:</span><p class="text-amber-800 font-bold mt-1"><?= htmlspecialchars($order['notes']) ?></p></div>
<?php endif; ?>
</div>
</div>
<!-- Items List -->
<div class="bg-white rounded-2xl border border-stone-200 shadow-sm overflow-hidden">
<div class="p-4 border-b font-bold text-sm text-stone-900">اقلام فاکتور</div>
<table class="w-full text-right text-xs">
<thead class="bg-stone-50 border-b">
<tr>
<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-left">مجموع</th>
</tr>
</thead>
<tbody class="divide-y divide-stone-100">
<?php foreach ($order['items'] as $it): ?>
<tr>
<td class="p-3 font-bold text-stone-900"><?= htmlspecialchars($it['product_name']) ?></td>
<td class="p-3 font-bold"><?= \Bildirchin\Helpers::toPersianDigits($it['quantity']) ?></td>
<td class="p-3"><?= \Bildirchin\Helpers::formatPrice($it['unit_price']) ?></td>
<td class="p-3">
<?= $it['is_wholesale'] ? '<span class="text-emerald-600 font-bold">نرخ عمده</span>' : 'عادی' ?>
</td>
<td class="p-3 text-left font-black text-stone-900"><?= \Bildirchin\Helpers::formatPrice($it['total_price']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot class="bg-stone-50 font-bold">
<tr>
<td colspan="4" class="p-3 text-left">مجموع کل:</td>
<td class="p-3 text-left font-black text-amber-900 text-sm"><?= \Bildirchin\Helpers::formatPrice($order['final_amount']) ?></td>
</tr>
</tfoot>
</table>
</div>
</div>
<?php
require __DIR__ . '/layout_footer.php';
?>