92 lines
3.9 KiB
PHP
92 lines
3.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/app.php';
|
|
app_bootstrap();
|
|
$orderId = (int) ($_GET['id'] ?? 0);
|
|
$detail = fetch_order_detail($orderId);
|
|
if (!$detail) {
|
|
http_response_code(404);
|
|
render_header('الطلب غير موجود', 'sales');
|
|
?>
|
|
<div class="card panel-card">
|
|
<div class="empty-state">
|
|
<div class="empty-title">الطلب غير موجود</div>
|
|
<div class="empty-copy">تحقق من الرابط أو ارجع إلى قائمة أوامر البيع.</div>
|
|
<a class="btn btn-dark mt-3" href="sales.php">العودة إلى أوامر البيع</a>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
render_footer();
|
|
exit;
|
|
}
|
|
$order = $detail['order'];
|
|
$items = $detail['items'];
|
|
render_header('تفاصيل أمر البيع', 'sales');
|
|
?>
|
|
<section class="mb-4">
|
|
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap mb-4">
|
|
<div>
|
|
<span class="section-kicker">Order detail</span>
|
|
<h1 class="page-title mb-2"><?= h($order['order_number']) ?></h1>
|
|
<p class="page-lead mb-0">تم إنشاء الطلب لهذا العميل مع خصم المخزون فوراً. يمكنك استخدام هذه الصفحة كنقطة انطلاق للطباعة وPDF في الخطوة التالية.</p>
|
|
</div>
|
|
<div class="d-flex gap-2 flex-wrap">
|
|
<button type="button" class="btn btn-outline-secondary" onclick="window.print()">طباعة</button>
|
|
<a class="btn btn-dark" href="sales.php">أمر جديد</a>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<div class="row g-4">
|
|
<div class="col-lg-8">
|
|
<div class="card panel-card h-100">
|
|
<div class="table-responsive">
|
|
<table class="table align-middle app-table mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th>الصنف</th>
|
|
<th>SKU</th>
|
|
<th>الكمية</th>
|
|
<th>سعر الوحدة</th>
|
|
<th>الإجمالي</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($items as $item): ?>
|
|
<tr>
|
|
<td><?= h($item['product_name']) ?></td>
|
|
<td><?= h($item['sku']) ?></td>
|
|
<td><?= h(format_qty((float) $item['qty'])) ?> <?= h($item['unit']) ?></td>
|
|
<td><?= h(format_money((float) $item['unit_price'])) ?></td>
|
|
<td class="fw-semibold"><?= h(format_money((float) $item['line_total'])) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-4">
|
|
<div class="card panel-card h-100">
|
|
<div class="summary-grid">
|
|
<div class="summary-row"><span>العميل</span><strong><?= h($order['customer_name']) ?></strong></div>
|
|
<div class="summary-row"><span>الفرع</span><strong><?= h($order['branch_name']) ?></strong></div>
|
|
<div class="summary-row"><span>الهاتف</span><strong dir="ltr"><?= h($order['phone'] ?: '—') ?></strong></div>
|
|
<div class="summary-row"><span>تاريخ الإنشاء</span><strong><?= h(date('Y-m-d H:i', strtotime($order['created_at']))) ?></strong></div>
|
|
<div class="summary-row"><span>الحالة</span><strong>مؤكد</strong></div>
|
|
<div class="summary-row total"><span>إجمالي البيع</span><strong><?= h(format_money((float) $order['subtotal'])) ?></strong></div>
|
|
<div class="summary-row"><span>الربح المتوقع</span><strong><?= h(format_money((float) $order['expected_profit'])) ?></strong></div>
|
|
</div>
|
|
<?php if (!empty($order['notes'])): ?>
|
|
<div class="alert alert-light border mt-4 mb-0">
|
|
<strong class="d-block mb-1">ملاحظات</strong>
|
|
<?= nl2br(h($order['notes'])) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<?php render_footer(); ?>
|