refactor(ui): redesign order detail shortcode layout and styles
Refactor the `ifnex_order_detail_shortcode` function to improve code structure and visual presentation. - Implement a modern, grid-based layout for order details. - Replace inline HTML/CSS with a more structured approach using internal CSS. - Add a visual progress tracker (stages) based on the order status. - Clean up redundant comments and improve variable handling for AWB and download links. - Improve responsiveness and styling of action buttons and status badges.
This commit is contained in:
parent
537d3c70a9
commit
2c924e2749
@ -961,7 +961,6 @@ function ifnex_order_detail_shortcode($atts) {
|
||||
$atts = shortcode_atts(array('order_id' => ''), $atts);
|
||||
$order_id = $atts['order_id'] ?: ($_GET['order_id'] ?? 0);
|
||||
|
||||
// اگر از URL pretty استفاده شده (order-detail/14/)
|
||||
if (!$order_id && isset($_SERVER['REQUEST_URI'])) {
|
||||
if (preg_match('/order-detail\/(\d+)/', $_SERVER['REQUEST_URI'], $matches)) {
|
||||
$order_id = $matches[1];
|
||||
@ -972,7 +971,6 @@ function ifnex_order_detail_shortcode($atts) {
|
||||
return '<p class="ifnex-error">شناسه سفارش مشخص نشده است.</p>';
|
||||
}
|
||||
|
||||
// Handle PDF download
|
||||
$download_type = sanitize_text_field($_GET['download'] ?? '');
|
||||
if ($download_type && in_array($download_type, ['awb', 'invoice', 'label', 'import-invoice'])) {
|
||||
ifnex_handle_pdf_download($order_id, $download_type);
|
||||
@ -990,434 +988,274 @@ function ifnex_order_detail_shortcode($atts) {
|
||||
|
||||
$data = $order['data'];
|
||||
$status = $data['status'];
|
||||
$awb = $data['awb_no'];
|
||||
$oid = (int)$order_id;
|
||||
$dl_base = home_url('/order-detail/?order_id=' . $oid . '&download=');
|
||||
|
||||
// مراحل پیشرفت
|
||||
$status_val = $status['value'] ?? '';
|
||||
$stage_order = ['pending_approval'=>1,'approved'=>2,'processed'=>3,'picked_up'=>4,'in_transit'=>5,'out_for_delivery'=>6,'delivered'=>7];
|
||||
$current_stage = $stage_order[$status_val] ?? 0;
|
||||
$stages = [
|
||||
1 => 'ثبت', 2 => 'تأیید', 3 => 'پرداخت', 4 => 'جمعآوری',
|
||||
5 => 'ارسال', 6 => 'تحویل'
|
||||
];
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="ifnex-order-detail">
|
||||
<!-- هدر با وضعیت -->
|
||||
<div class="ifnex-detail-header">
|
||||
<div class="ifnex-detail-title">
|
||||
<h2>📦 جزئیات سفارش</h2>
|
||||
<code class="ifnex-awb-code"><?php echo esc_html($data['awb_no']); ?></code>
|
||||
</div>
|
||||
<span class="ifnex-badge ifnex-badge-<?php echo esc_attr($status['color']); ?> ifnex-badge-lg">
|
||||
<?php echo esc_html($status['label']); ?>
|
||||
</span>
|
||||
<style>
|
||||
.ifnex-od{font-family:inherit;color:#0f172a}
|
||||
.ifnex-od h3{font-size:15px;font-weight:700;margin:0 0 12px;display:flex;align-items:center;gap:6px}
|
||||
.ifnex-od-header{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:16px}
|
||||
.ifnex-od-header h2{font-size:20px;font-weight:800;margin:0}
|
||||
.ifnex-od-awb{background:#f1f5f9;padding:4px 10px;border-radius:6px;font-size:13px;color:#475569}
|
||||
.ifnex-od-actions{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}
|
||||
.ifnex-od-actions .ifnex-btn{font-size:13px;padding:8px 14px;border-radius:8px;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;gap:4px;border:none}
|
||||
.ifnex-od-actions .ifnex-btn-sm{font-size:13px}
|
||||
.ifnex-od-actions .ifnex-btn-success{background:#10b981;color:#fff}
|
||||
.ifnex-od-actions .ifnex-btn-danger{background:#ef4444;color:#fff}
|
||||
.ifnex-od-actions .ifnex-btn-info{background:#3b82f6;color:#fff}
|
||||
.ifnex-od-actions .ifnex-btn-default{background:#f1f5f9;color:#475569}
|
||||
.ifnex-od-actions .ifnex-btn-warning{background:#f59e0b;color:#fff}
|
||||
.ifnex-od-review{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:16px;margin-bottom:16px}
|
||||
.ifnex-od-review h4{margin:0 0 8px;color:#92400e;font-size:15px}
|
||||
.ifnex-od-review p{margin:4px 0;font-size:13px;color:#78350f}
|
||||
.ifnex-od-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
|
||||
.ifnex-od-left,.ifnex-od-right{display:flex;flex-direction:column;gap:16px}
|
||||
.ifnex-od-card{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:16px;box-shadow:0 1px 3px rgba(0,0,0,.04)}
|
||||
.ifnex-od-card.sticky{position:sticky;top:16px}
|
||||
.ifnex-od-route{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
|
||||
.ifnex-od-route-point{flex:1;min-width:120px}
|
||||
.ifnex-od-route-point strong{display:block;font-size:12px;color:#64748b;margin-bottom:2px}
|
||||
.ifnex-od-route-point span{font-size:14px;font-weight:600}
|
||||
.ifnex-od-plane{font-size:20px;color:#f59e0b}
|
||||
.ifnex-od-info{display:grid;grid-template-columns:1fr 1fr;gap:8px}
|
||||
.ifnex-od-info>div{font-size:13px}
|
||||
.ifnex-od-info>div span{color:#64748b;display:block;font-size:11px}
|
||||
.ifnex-od-table{width:100%;border-collapse:collapse;font-size:12px}
|
||||
.ifnex-od-table th{background:#f8fafc;padding:8px 10px;text-align:right;font-weight:600;color:#64748b;border-bottom:1px solid #e2e8f0}
|
||||
.ifnex-od-table td{padding:8px 10px;border-bottom:1px solid #f1f5f9}
|
||||
.ifnex-od-table tbody tr:last-child td{border-bottom:none}
|
||||
.ifnex-od-people{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
||||
.ifnex-od-person h4{margin:0 0 6px;font-size:13px;color:#64748b}
|
||||
.ifnex-od-person p{margin:3px 0;font-size:13px}
|
||||
.ifnex-od-progress{display:flex;justify-content:space-between;align-items:center;gap:4px;position:relative}
|
||||
.ifnex-od-progress::before{content:'';position:absolute;top:14px;right:5%;left:5%;height:2px;background:#e2e8f0;z-index:0}
|
||||
.ifnex-od-stage{display:flex;flex-direction:column;align-items:center;gap:4px;z-index:1;flex:1}
|
||||
.ifnex-od-stage-dot{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700}
|
||||
.ifnex-od-stage.done .ifnex-od-stage-dot{background:#10b981;color:#fff}
|
||||
.ifnex-od-stage.current .ifnex-od-stage-dot{background:#f59e0b;color:#fff;box-shadow:0 0 0 4px rgba(245,158,11,.15)}
|
||||
.ifnex-od-stage.pending .ifnex-od-stage-dot{background:#e2e8f0;color:#94a3b8}
|
||||
.ifnex-od-stage-label{font-size:10px;color:#64748b;text-align:center;white-space:nowrap}
|
||||
.ifnex-od-stage.done .ifnex-od-stage-label{color:#10b981;font-weight:600}
|
||||
.ifnex-od-stage.current .ifnex-od-stage-label{color:#f59e0b;font-weight:600}
|
||||
.ifnex-od-price{text-align:center}
|
||||
.ifnex-od-price-total{font-size:22px;font-weight:800;color:#0f172a;margin-bottom:4px}
|
||||
.ifnex-od-price-total small{font-size:12px;color:#64748b;font-weight:400}
|
||||
.ifnex-od-price-status{font-size:13px}
|
||||
.ifnex-od-price-status.paid{color:#10b981}
|
||||
.ifnex-od-price-status.unpaid{color:#f59e0b}
|
||||
.ifnex-od-dl{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.ifnex-od-dl-btn{flex:1;min-width:100px;text-align:center;padding:12px 8px;border-radius:10px;background:#f8fafc;border:1px solid #e2e8f0;text-decoration:none;color:#475569;font-size:13px;font-weight:600;transition:all .15s;display:flex;flex-direction:column;align-items:center;gap:4px}
|
||||
.ifnex-od-dl-btn:hover{background:#fffbeb;border-color:#fde68a;color:#d97706}
|
||||
.ifnex-od-dl-icon{font-size:20px}
|
||||
.ifnex-od-timeline{position:relative;padding-right:24px}
|
||||
.ifnex-od-timeline::before{content:'';position:absolute;top:0;bottom:0;right:11px;width:2px;background:#e2e8f0}
|
||||
.ifnex-od-tl-item{position:relative;padding-bottom:16px;padding-right:12px}
|
||||
.ifnex-od-tl-item:last-child{padding-bottom:0}
|
||||
.ifnex-od-tl-dot{position:absolute;right:0;top:4px;width:12px;height:12px;border-radius:50%;background:#f59e0b;border:2px solid #fff;box-shadow:0 0 0 2px #fde68a}
|
||||
.ifnex-od-tl-item:last-child .ifnex-od-tl-dot{background:#10b981;box-shadow:0 0 0 2px #d1fae5}
|
||||
.ifnex-od-tl-body strong{font-size:13px;display:block}
|
||||
.ifnex-od-tl-date{font-size:11px;color:#94a3b8}
|
||||
.ifnex-od-tl-loc{font-size:12px;color:#64748b;margin-top:2px}
|
||||
.ifnex-od-full{margin-top:16px}
|
||||
@media(max-width:768px){
|
||||
.ifnex-od-grid{grid-template-columns:1fr}
|
||||
.ifnex-od-card.sticky{position:static}
|
||||
.ifnex-od-people{grid-template-columns:1fr}
|
||||
.ifnex-od-progress::before{display:none}
|
||||
.ifnex-od-stage{gap:2px}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="ifnex-od">
|
||||
<div class="ifnex-od-header">
|
||||
<div>
|
||||
<h2>📦 جزئیات سفارش</h2>
|
||||
<code class="ifnex-od-awb"><?php echo esc_html($awb); ?></code>
|
||||
</div>
|
||||
|
||||
<!-- دکمههای عملیاتی -->
|
||||
<div class="ifnex-detail-actions">
|
||||
<a href="<?php echo esc_url(home_url('/my-orders/')); ?>" class="ifnex-btn ifnex-btn-sm">
|
||||
← بازگشت به سفارشات
|
||||
</a>
|
||||
|
||||
<?php if ($status['can_pay']): ?>
|
||||
<a href="<?php echo esc_url(home_url('/order-payment/?order_id=' . $order_id)); ?>"
|
||||
class="ifnex-btn ifnex-btn-sm ifnex-btn-success">
|
||||
💳 پرداخت
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($status['can_cancel']): ?>
|
||||
<button class="ifnex-btn ifnex-btn-sm ifnex-btn-danger ifnex-cancel-order-detail"
|
||||
data-order-id="<?php echo esc_attr($order_id); ?>">
|
||||
❌ لغو سفارش
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<button onclick="window.print()" class="ifnex-btn ifnex-btn-sm ifnex-btn-info">
|
||||
🖨️ چاپ
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($data['review'])): ?>
|
||||
<div class="ifnex-detail-section ifnex-review-section">
|
||||
<div class="ifnex-review-header">
|
||||
<h3>🔎 وضعیت بررسی سفارش</h3>
|
||||
|
||||
<span class="ifnex-badge ifnex-badge-<?php echo esc_attr($data['review']['color'] ?? ''); ?>">
|
||||
<?php echo esc_html($data['review']['label'] ?? 'نامشخص'); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php if (($data['review']['state'] ?? '') === 'changes_requested' && !empty($data['review']['latest'])): ?>
|
||||
<div class="ifnex-warning-box">
|
||||
<h4>⚠️ نیاز به اصلاح اطلاعات سفارش</h4>
|
||||
|
||||
<?php if (!empty($data['review']['latest']['reason'])): ?>
|
||||
<p>
|
||||
<strong>دلیل:</strong>
|
||||
<?php echo esc_html($data['review']['latest']['reason']); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($data['review']['latest']['notes'])): ?>
|
||||
<p>
|
||||
<strong>توضیحات:</strong>
|
||||
<?php echo nl2br(esc_html($data['review']['latest']['notes'])); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($data['review']['can_resubmit'])): ?>
|
||||
<a
|
||||
href="<?php echo esc_url(home_url('/new-order/?resubmit=' . $order_id)); ?>"
|
||||
class="ifnex-btn ifnex-btn-warning">
|
||||
✏️ اصلاح و ارسال مجدد سفارش
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($data['review']['history']) && is_array($data['review']['history'])): ?>
|
||||
<details class="ifnex-review-history">
|
||||
<summary>تاریخچه بررسی سفارش</summary>
|
||||
|
||||
<div class="ifnex-review-history-list">
|
||||
<?php foreach ($data['review']['history'] as $review): ?>
|
||||
<div class="ifnex-review-history-item">
|
||||
<div>
|
||||
<strong>
|
||||
Revision <?php echo esc_html($review['revision'] ?? '—'); ?>
|
||||
</strong>
|
||||
|
||||
<span class="ifnex-badge ifnex-badge-<?php echo esc_attr($review['color'] ?? ''); ?>">
|
||||
<?php echo esc_html($review['label'] ?? $review['decision'] ?? ''); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($review['reason'])): ?>
|
||||
<p><?php echo esc_html($review['reason']); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($review['notes'])): ?>
|
||||
<p><?php echo nl2br(esc_html($review['notes'])); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($review['reviewed_at'])): ?>
|
||||
<small><?php echo esc_html($review['reviewed_at']); ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- مسیر ارسال -->
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>🗺️ مسیر ارسال</h3>
|
||||
<div class="ifnex-route-detail">
|
||||
<div class="ifnex-route-point from">
|
||||
<div class="ifnex-point-label">از</div>
|
||||
<div class="ifnex-point-country">
|
||||
<?php echo esc_html($data['from_country']['name'] ?? '—'); ?>
|
||||
</div>
|
||||
<div class="ifnex-point-iso">
|
||||
<?php echo esc_html($data['from_country']['iso_code'] ?? ''); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ifnex-route-line">
|
||||
<div class="ifnex-plane-icon">✈️</div>
|
||||
</div>
|
||||
<div class="ifnex-route-point to">
|
||||
<div class="ifnex-point-label">به</div>
|
||||
<div class="ifnex-point-country">
|
||||
<?php echo esc_html($data['to_country']['name'] ?? '—'); ?>
|
||||
</div>
|
||||
<div class="ifnex-point-iso">
|
||||
<?php echo esc_html($data['to_country']['iso_code'] ?? ''); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- اطلاعات مرسوله -->
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📦 اطلاعات مرسوله</h3>
|
||||
<div class="ifnex-info-grid">
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">نوع سرویس</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['type'] ?? '—'); ?></span>
|
||||
</div>
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">جهت ارسال</span>
|
||||
<span class="ifnex-info-value">
|
||||
<?php echo ($data['direction'] ?? '') === 'export' ? 'صادرات' : 'واردات'; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">وزن واقعی</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['weight'] ?? '—'); ?> kg</span>
|
||||
</div>
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">وزن قابل محاسبه</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['chargeable_weight'] ?? '—'); ?> kg</span>
|
||||
</div>
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">تاریخ ثبت</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['created_at_jalali'] ?? '—'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($data['packages']) && is_array($data['packages'])): ?>
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📦 بستههای مرسوله</h3>
|
||||
|
||||
<div class="ifnex-packages-list">
|
||||
<?php foreach ($data['packages'] as $package): ?>
|
||||
<div class="ifnex-package-card">
|
||||
<div class="ifnex-package-header">
|
||||
<strong>بسته <?php echo esc_html($package['package_no'] ?? '—'); ?></strong>
|
||||
<?php if (!empty($package['description'])): ?>
|
||||
<span><?php echo esc_html($package['description']); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="ifnex-info-grid">
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">وزن</span>
|
||||
<span class="ifnex-info-value">
|
||||
<?php echo esc_html($package['weight'] ?? '—'); ?> kg
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">وزن حجمی</span>
|
||||
<span class="ifnex-info-value">
|
||||
<?php echo esc_html($package['volumetric_weight'] ?? '—'); ?> kg
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">وزن قابل محاسبه</span>
|
||||
<span class="ifnex-info-value">
|
||||
<?php echo esc_html($package['chargeable_weight'] ?? '—'); ?> kg
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">ابعاد</span>
|
||||
<span class="ifnex-info-value">
|
||||
<?php echo esc_html($package['dimensions'] ?? '—'); ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- اطلاعات مالی -->
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>💰 اطلاعات مالی</h3>
|
||||
<div class="ifnex-price-breakdown">
|
||||
<div class="ifnex-price-row">
|
||||
<span>مبلغ خالص (درهم):</span>
|
||||
<span><?php echo number_format($data['net_dirham'] ?? 0); ?> AED</span>
|
||||
</div>
|
||||
<div class="ifnex-price-row">
|
||||
<span>مبلغ خالص (ریال):</span>
|
||||
<span><?php echo number_format($data['net_rial'] ?? 0); ?> ریال</span>
|
||||
</div>
|
||||
<div class="ifnex-price-row total">
|
||||
<span>مبلغ کل:</span>
|
||||
<span><?php echo number_format($data['total_fee'] ?? 0); ?> ریال</span>
|
||||
</div>
|
||||
<div class="ifnex-price-row">
|
||||
<span>وضعیت پرداخت:</span>
|
||||
<span class="<?php echo $status['is_paid'] ? 'ifnex-text-success' : 'ifnex-text-warning'; ?>">
|
||||
<?php echo $status['is_paid'] ? '✅ پرداخت شده' : '⏳ در انتظار پرداخت'; ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- اطلاعات فرستنده -->
|
||||
<?php if (!empty($data['sender']['name']) || !empty($data['sender']['phone'])): ?>
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>👤 اطلاعات فرستنده</h3>
|
||||
<div class="ifnex-info-grid">
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">نام</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['sender']['name'] ?? '—'); ?></span>
|
||||
</div>
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">تلفن</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['sender']['phone'] ?? '—'); ?></span>
|
||||
</div>
|
||||
<div class="ifnex-info-item full">
|
||||
<span class="ifnex-info-label">آدرس</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['sender']['address'] ?? '—'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- اطلاعات گیرنده -->
|
||||
<?php if (!empty($data['receiver']['name']) || !empty($data['receiver']['phone'])): ?>
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📮 اطلاعات گیرنده</h3>
|
||||
<div class="ifnex-info-grid">
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">نام</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['receiver']['name'] ?? '—'); ?></span>
|
||||
</div>
|
||||
<div class="ifnex-info-item">
|
||||
<span class="ifnex-info-label">تلفن</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['receiver']['phone'] ?? '—'); ?></span>
|
||||
</div>
|
||||
<div class="ifnex-info-item full">
|
||||
<span class="ifnex-info-label">آدرس</span>
|
||||
<span class="ifnex-info-value"><?php echo esc_html($data['receiver']['address'] ?? '—'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- دانلود مدارک -->
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📄 دانلود مدارک</h3>
|
||||
<div class="ifnex-docs-grid">
|
||||
<a href="<?php echo esc_url(home_url('/my-account/?tab=order-detail&order_id=' . $order_id . '&download=awb')); ?>" class="ifnex-doc-btn" target="_blank">
|
||||
<span class="ifnex-doc-icon">📦</span>
|
||||
<span class="ifnex-doc-label">AWB</span>
|
||||
</a>
|
||||
<a href="<?php echo esc_url(home_url('/my-account/?tab=order-detail&order_id=' . $order_id . '&download=label')); ?>" class="ifnex-doc-btn" target="_blank">
|
||||
<span class="ifnex-doc-icon">🏷️</span>
|
||||
<span class="ifnex-doc-label">Label</span>
|
||||
</a>
|
||||
<?php if (!empty($data['items']) || ($data['type'] ?? '') === 'PARCEL'): ?>
|
||||
<a href="<?php echo esc_url(home_url('/my-account/?tab=order-detail&order_id=' . $order_id . '&download=invoice')); ?>" class="ifnex-doc-btn" target="_blank">
|
||||
<span class="ifnex-doc-icon">🧾</span>
|
||||
<span class="ifnex-doc-label">Invoice</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (($data['direction'] ?? '') === 'import'): ?>
|
||||
<a href="<?php echo esc_url(home_url('/my-account/?tab=order-detail&order_id=' . $order_id . '&download=import-invoice')); ?>" class="ifnex-doc-btn" target="_blank">
|
||||
<span class="ifnex-doc-icon">📋</span>
|
||||
<span class="ifnex-doc-label">Service Invoice</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- تعهدنامهها -->
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📝 تعهدنامهها</h3>
|
||||
<div id="ifnex-commitment-forms">
|
||||
<p>در حال بارگذاری...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Timeline رهگیری -->
|
||||
<?php if (!empty($data['tracking_events'])): ?>
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📍 تاریخچه رهگیری</h3>
|
||||
<div class="ifnex-timeline">
|
||||
<?php foreach ($data['tracking_events'] as $event): ?>
|
||||
<div class="ifnex-timeline-item">
|
||||
<div class="ifnex-timeline-dot"></div>
|
||||
<div class="ifnex-timeline-content">
|
||||
<div class="ifnex-timeline-header">
|
||||
<strong><?php echo esc_html($event['description'] ?? ''); ?></strong>
|
||||
<span class="ifnex-timeline-date">
|
||||
<?php echo esc_html($event['date'] ?? ''); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php if (!empty($event['location'])): ?>
|
||||
<div class="ifnex-timeline-location">
|
||||
📍 <?php echo esc_html($event['location']); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="ifnex-detail-section">
|
||||
<h3>📍 تاریخچه رهگیری</h3>
|
||||
<p class="ifnex-empty-timeline">هنوز رویدادی ثبت نشده است.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<span class="ifnex-badge ifnex-badge-<?php echo esc_attr($status['color']); ?> ifnex-badge-lg"><?php echo esc_html($status['label']); ?></span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('.ifnex-cancel-order-detail').on('click', function() {
|
||||
if (!confirm('آیا از لغو این سفارش اطمینان دارید؟')) return;
|
||||
|
||||
var btn = $(this);
|
||||
var orderId = btn.data('order-id');
|
||||
|
||||
btn.prop('disabled', true).text('در حال لغو...');
|
||||
|
||||
$.ajax({
|
||||
url: ifnex_ajax.ajax_url,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: 'ifnex_cancel_order',
|
||||
order_id: orderId,
|
||||
nonce: ifnex_ajax.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
alert('سفارش با موفقیت لغو شد.');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('خطا: ' + response.data);
|
||||
btn.prop('disabled', false).text('❌ لغو سفارش');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('خطا در ارتباط با سرور.');
|
||||
btn.prop('disabled', false).text('❌ لغو سفارش');
|
||||
}
|
||||
});
|
||||
<div class="ifnex-od-actions">
|
||||
<a href="<?php echo esc_url(home_url('/my-orders/')); ?>" class="ifnex-btn ifnex-btn-sm ifnex-btn-default">← بازگشت</a>
|
||||
<?php if ($status['can_pay']): ?>
|
||||
<a href="<?php echo esc_url(home_url('/order-payment/?order_id=' . $oid)); ?>" class="ifnex-btn ifnex-btn-sm ifnex-btn-success">💳 پرداخت</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($status['can_cancel']): ?>
|
||||
<button class="ifnex-btn ifnex-btn-sm ifnex-btn-danger ifnex-cancel-order-detail" data-order-id="<?php echo esc_attr($oid); ?>">❌ لغو</button>
|
||||
<?php endif; ?>
|
||||
<button onclick="window.print()" class="ifnex-btn ifnex-btn-sm ifnex-btn-info">🖨️ چاپ</button>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($data['review']) && ($data['review']['state'] ?? '') === 'changes_requested'): ?>
|
||||
<div class="ifnex-od-review">
|
||||
<h4>⚠️ نیاز به اصلاح اطلاعات سفارش</h4>
|
||||
<?php if (!empty($data['review']['latest']['reason'])): ?><p><strong>دلیل:</strong> <?php echo esc_html($data['review']['latest']['reason']); ?></p><?php endif; ?>
|
||||
<?php if (!empty($data['review']['latest']['notes'])): ?><p><strong>توضیحات:</strong> <?php echo nl2br(esc_html($data['review']['latest']['notes'])); ?></p><?php endif; ?>
|
||||
<?php if (!empty($data['review']['can_resubmit'])): ?>
|
||||
<a href="<?php echo esc_url(home_url('/new-order/?resubmit=' . $oid)); ?>" class="ifnex-btn ifnex-btn-sm ifnex-btn-warning">✏️ اصلاح و ارسال مجدد</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="ifnex-od-grid">
|
||||
<div class="ifnex-od-left">
|
||||
<div class="ifnex-od-card">
|
||||
<h3>🗺️ مسیر ارسال</h3>
|
||||
<div class="ifnex-od-route">
|
||||
<div class="ifnex-od-route-point"><strong>از</strong><span><?php echo esc_html($data['from_country']['name'] ?? '—'); ?></span></div>
|
||||
<div class="ifnex-od-plane">✈️</div>
|
||||
<div class="ifnex-od-route-point"><strong>به</strong><span><?php echo esc_html($data['to_country']['name'] ?? '—'); ?></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ifnex-od-card">
|
||||
<h3>📦 اطلاعات مرسوله</h3>
|
||||
<div class="ifnex-od-info">
|
||||
<div><span>نوع سرویس</span><?php echo esc_html($data['type'] ?? '—'); ?></div>
|
||||
<div><span>جهت</span><?php echo ($data['direction'] ?? '') === 'export' ? 'صادرات' : 'واردات'; ?></div>
|
||||
<div><span>وزن واقعی</span><?php echo esc_html($data['weight'] ?? '—'); ?> kg</div>
|
||||
<div><span>وزن محاسبهای</span><?php echo esc_html($data['chargeable_weight'] ?? '—'); ?> kg</div>
|
||||
<div><span>تاریخ ثبت</span><?php echo esc_html($data['created_at_jalali'] ?? '—'); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!empty($data['packages']) && is_array($data['packages'])): ?>
|
||||
<div class="ifnex-od-card">
|
||||
<h3>📦 بستهها</h3>
|
||||
<table class="ifnex-od-table">
|
||||
<thead><tr><th>#</th><th>وزن</th><th>وزن حجمی</th><th>ابعاد</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($data['packages'] as $pkg): ?>
|
||||
<tr><td><?php echo esc_html($pkg['package_no'] ?? '—'); ?></td><td><?php echo esc_html($pkg['weight'] ?? '—'); ?> kg</td><td><?php echo esc_html($pkg['volumetric_weight'] ?? '—'); ?> kg</td><td><?php echo esc_html($pkg['dimensions'] ?? '—'); ?></td></tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="ifnex-od-card">
|
||||
<h3>👤 فرستنده / 📮 گیرنده</h3>
|
||||
<div class="ifnex-od-people">
|
||||
<div class="ifnex-od-person">
|
||||
<h4>👤 فرستنده</h4>
|
||||
<p><?php echo esc_html($data['sender']['name'] ?? '—'); ?></p>
|
||||
<p>📞 <?php echo esc_html($data['sender']['phone'] ?? '—'); ?></p>
|
||||
<p>📍 <?php echo esc_html($data['sender']['address'] ?? '—'); ?></p>
|
||||
</div>
|
||||
<div class="ifnex-od-person">
|
||||
<h4>📮 گیرنده</h4>
|
||||
<p><?php echo esc_html($data['receiver']['name'] ?? '—'); ?></p>
|
||||
<p>📞 <?php echo esc_html($data['receiver']['phone'] ?? '—'); ?></p>
|
||||
<p>📍 <?php echo esc_html($data['receiver']['address'] ?? '—'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ifnex-od-right">
|
||||
<div class="ifnex-od-card">
|
||||
<h3>📊 مراحل سفارش</h3>
|
||||
<div class="ifnex-od-progress">
|
||||
<?php foreach ($stages as $num => $label):
|
||||
$cls = $num <= $current_stage ? 'done' : ($num === $current_stage + 1 ? 'current' : 'pending');
|
||||
$icon = $num <= $current_stage ? '✓' : $num;
|
||||
?>
|
||||
<div class="ifnex-od-stage <?php echo $cls; ?>">
|
||||
<div class="ifnex-od-stage-dot"><?php echo $icon; ?></div>
|
||||
<span class="ifnex-od-stage-label"><?php echo $label; ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ifnex-od-card sticky">
|
||||
<h3>💰 خلاصه مالی</h3>
|
||||
<div class="ifnex-od-price">
|
||||
<div class="ifnex-od-price-total"><?php echo number_format((float)($data['total_fee'] ?? 0)); ?><br><small>ریال</small></div>
|
||||
<div class="ifnex-od-price-status <?php echo $status['is_paid'] ? 'paid' : 'unpaid'; ?>"><?php echo $status['is_paid'] ? '✅ پرداخت شده' : '⏳ در انتظار پرداخت'; ?></div>
|
||||
<?php if (!empty($data['net_dirham'])): ?><div style="font-size:12px;color:#94a3b8;margin-top:4px"><?php echo number_format((float)$data['net_dirham']); ?> AED</div><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ifnex-od-card">
|
||||
<h3>📄 دانلود مدارک</h3>
|
||||
<div class="ifnex-od-dl">
|
||||
<a href="<?php echo esc_url($dl_base . 'awb'); ?>" class="ifnex-od-dl-btn" target="_blank"><span class="ifnex-od-dl-icon">📦</span>AWB</a>
|
||||
<a href="<?php echo esc_url($dl_base . 'label'); ?>" class="ifnex-od-dl-btn" target="_blank"><span class="ifnex-od-dl-icon">🏷️</span>لیبل</a>
|
||||
<?php if (!empty($data['items']) || ($data['type'] ?? '') === 'PARCEL'): ?>
|
||||
<a href="<?php echo esc_url($dl_base . 'invoice'); ?>" class="ifnex-od-dl-btn" target="_blank"><span class="ifnex-od-dl-icon">🧾</span>فاکتور</a>
|
||||
<?php endif; ?>
|
||||
<?php if (($data['direction'] ?? '') === 'import'): ?>
|
||||
<a href="<?php echo esc_url($dl_base . 'import-invoice'); ?>" class="ifnex-od-dl-btn" target="_blank"><span class="ifnex-od-dl-icon">📋</span>فاکتور خدمات</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ifnex-od-card">
|
||||
<h3>📝 تعهدنامهها</h3>
|
||||
<div id="ifnex-commitment-forms"><p style="color:#94a3b8">در حال بارگذاری...</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ifnex-od-card ifnex-od-full">
|
||||
<h3>📍 تاریخچه رهگیری</h3>
|
||||
<?php if (!empty($data['tracking_events'])): ?>
|
||||
<div class="ifnex-od-timeline">
|
||||
<?php foreach ($data['tracking_events'] as $ev): ?>
|
||||
<div class="ifnex-od-tl-item">
|
||||
<div class="ifnex-od-tl-dot"></div>
|
||||
<div class="ifnex-od-tl-body">
|
||||
<strong><?php echo esc_html($ev['description'] ?? ''); ?></strong>
|
||||
<div class="ifnex-od-tl-date"><?php echo esc_html($ev['date'] ?? ''); ?></div>
|
||||
<?php if (!empty($ev['location'])): ?><div class="ifnex-od-tl-loc">📍 <?php echo esc_html($ev['location']); ?></div><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<p style="color:#94a3b8;font-size:13px">هنوز رویدادی ثبت نشده است.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('.ifnex-cancel-order-detail').on('click', function() {
|
||||
if (!confirm('آیا از لغو این سفارش اطمینان دارید؟')) return;
|
||||
var btn = $(this);
|
||||
var orderId = btn.data('order-id');
|
||||
btn.prop('disabled', true).text('در حال لغو...');
|
||||
$.ajax({
|
||||
url: ifnex_ajax.ajax_url, method: 'POST',
|
||||
data: { action: 'ifnex_cancel_order', order_id: orderId, nonce: ifnex_ajax.nonce },
|
||||
success: function(r) { if (r.success) { alert('سفارش لغو شد.'); location.reload(); } else { alert('خطا: ' + r.data); btn.prop('disabled', false).text('❌ لغو'); } },
|
||||
error: function() { alert('خطا در ارتباط با سرور.'); btn.prop('disabled', false).text('❌ لغو'); }
|
||||
});
|
||||
});
|
||||
|
||||
function uploadCommitmentForm(orderId, formId, input) {
|
||||
var file = input.files[0];
|
||||
if (!file) return;
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('action', 'ifnex_upload_commitment_form');
|
||||
formData.append('order_id', orderId);
|
||||
formData.append('form_id', formId);
|
||||
formData.append('file', file);
|
||||
formData.append('nonce', ifnex_ajax.nonce);
|
||||
|
||||
var btn = $(input).closest('.ifnex-form-actions');
|
||||
var originalHtml = btn.html();
|
||||
btn.html('<span class=\"ifnex-loading\">در حال آپلود...</span>');
|
||||
|
||||
$.ajax({
|
||||
url: ifnex_ajax.ajax_url,
|
||||
method: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
if (res.success) {
|
||||
alert('فایل با موفقیت آپلود شد.');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('خطا: ' + (res.data || 'نامشخص'));
|
||||
btn.html(originalHtml);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('خطا در ارتباط با سرور.');
|
||||
btn.html(originalHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
});
|
||||
function uploadCommitmentForm(orderId, formId, input) {
|
||||
var file = input.files[0]; if (!file) return;
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'ifnex_upload_commitment_form');
|
||||
fd.append('order_id', orderId); fd.append('form_id', formId);
|
||||
fd.append('file', file); fd.append('nonce', ifnex_ajax.nonce);
|
||||
var btn = $(input).closest('.ifnex-form-actions'); var orig = btn.html();
|
||||
btn.html('<span>در حال آپلود...</span>');
|
||||
$.ajax({
|
||||
url: ifnex_ajax.ajax_url, method: 'POST', data: fd, processData: false, contentType: false,
|
||||
success: function(r) { if (r.success) { alert('آپلود شد.'); location.reload(); } else { alert('خطا: ' + (r.data||'')); btn.html(orig); } },
|
||||
error: function() { alert('خطا در ارتباط با سرور.'); btn.html(orig); }
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user