| 1 |
<?php |
| 2 |
|
| 3 |
use SyncBasalam\Admin\FinancialManagement\FinancialManagementHistory; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
?> |
| 7 |
<div |
| 8 |
class="basalam-status-card basalam-history-section" |
| 9 |
data-active-page="<?php echo esc_attr((string) $activePage); ?>" |
| 10 |
data-history-page="<?php echo esc_attr((string) $historyCurrentPage); ?>" |
| 11 |
aria-live="polite" |
| 12 |
> |
| 13 |
<div class="basalam-status-header"> |
| 14 |
<h2 class="basalam-h"> |
| 15 |
<span class="dashicons dashicons-backup"></span> |
| 16 |
<?php echo esc_html($historyTitle); ?> |
| 17 |
</h2> |
| 18 |
<?php if (!empty($historyResult['success']) && !empty($historyItems)): ?> |
| 19 |
<span class="basalam-badge-success"> |
| 20 |
<?php echo esc_html(sprintf('صفحه %s از %s', number_format_i18n($historyCurrentPage), number_format_i18n($historyTotalPages))); ?> |
| 21 |
</span> |
| 22 |
<?php endif; ?> |
| 23 |
</div> |
| 24 |
|
| 25 |
<?php if (empty($historyResult['success'])): ?> |
| 26 |
<?php FinancialManagementHistory::renderApiError($historyResult); ?> |
| 27 |
<?php elseif (empty($historyItems)): ?> |
| 28 |
<div class="basalam-empty-state"> |
| 29 |
<span class="dashicons dashicons-info-outline"></span> |
| 30 |
<p>تاریخچه تسویهای برای ن� |
| 31 |
ایش وجود ندارد.</p> |
| 32 |
</div> |
| 33 |
<?php else: ?> |
| 34 |
<div class="basalam-history-table-wrap"> |
| 35 |
<table class="basalam-history-table"> |
| 36 |
<thead> |
| 37 |
<tr> |
| 38 |
<th>عنوان</th> |
| 39 |
<th>تاریخ و ساعت</th> |
| 40 |
<th>نوع پرداخت</th> |
| 41 |
<th>� |
| 42 |
بلغ(تو� |
| 43 |
ان)</th> |
| 44 |
<th>توضیحات</th> |
| 45 |
</tr> |
| 46 |
</thead> |
| 47 |
<tbody> |
| 48 |
<?php foreach ($historyItems as $item): ?> |
| 49 |
<?php if (!is_array($item)) { |
| 50 |
continue; |
| 51 |
} ?> |
| 52 |
<?php $statusClass = FinancialManagementHistory::getStatusClass($item); ?> |
| 53 |
<tr> |
| 54 |
<td class="basalam-history-table__title"> |
| 55 |
<div class="basalam-history-item-info"> |
| 56 |
<div><strong>شناسه:</strong> <?php echo esc_html((string) ($item['id'] ?? '-')); ?></div> |
| 57 |
<?php if (!empty($item['payment_request']['payment_tracking_code'])): ?> |
| 58 |
<div><strong>پیگیری:</strong> <?php echo esc_html((string) $item['payment_request']['payment_tracking_code']); ?></div> |
| 59 |
<?php endif; ?> |
| 60 |
<?php if (!empty($item['payment_request']['iban'])): ?> |
| 61 |
<div><strong>شبا:</strong> <?php echo esc_html((string) $item['payment_request']['iban']); ?></div> |
| 62 |
<?php endif; ?> |
| 63 |
</div> |
| 64 |
</td> |
| 65 |
<td class="basalam-history-table__date"> |
| 66 |
<div class="basalam-history-item-date"> |
| 67 |
<div><strong>ثبت:</strong> <?php echo esc_html(FinancialManagementHistory::formatJalaliTimestamp($item['created_at'] ?? null)); ?></div> |
| 68 |
<div><strong>پرداخت:</strong> <?php echo esc_html(FinancialManagementHistory::formatJalaliTimestamp($item['paid_at'] ?? null)); ?></div> |
| 69 |
</div> |
| 70 |
</td> |
| 71 |
<td> |
| 72 |
<div class="basalam-history-item-method"> |
| 73 |
<div><?php echo esc_html(FinancialManagementHistory::getMethodLabel($item)); ?></div> |
| 74 |
<span class="basalam-status-badge basalam-status-badge--<?php echo esc_attr($statusClass); ?>"> |
| 75 |
<?php echo esc_html(FinancialManagementHistory::getStatusLabel($item)); ?> |
| 76 |
</span> |
| 77 |
</div> |
| 78 |
</td> |
| 79 |
<td class="basalam-history-table__amount"> |
| 80 |
<?php echo esc_html(FinancialManagementHistory::formatAmount($item['amount'] ?? null)); ?> |
| 81 |
</td> |
| 82 |
<td class="basalam-history-table__description"> |
| 83 |
<?php echo esc_html((string) ($item['status_description'] ?? '-')); ?> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
<?php endforeach; ?> |
| 87 |
</tbody> |
| 88 |
</table> |
| 89 |
</div> |
| 90 |
|
| 91 |
<?php if ($historyTotalPages > 1): ?> |
| 92 |
<div class="basalam-pagination" role="navigation" aria-label="صفحهبندی تاریخچه تسویه"> |
| 93 |
<?php if ($historyCurrentPage > 1): ?> |
| 94 |
<a |
| 95 |
class="page-numbers prev-next" |
| 96 |
href="<?php echo esc_url(FinancialManagementHistory::buildPageUrl($activePage, $historyCurrentPage - 1)); ?>" |
| 97 |
data-history-page="<?php echo esc_attr((string) ($historyCurrentPage - 1)); ?>" |
| 98 |
> |
| 99 |
قبلی |
| 100 |
</a> |
| 101 |
<?php endif; ?> |
| 102 |
|
| 103 |
<?php $historyStart = max(1, $historyCurrentPage - 2); ?> |
| 104 |
<?php $historyEnd = min($historyTotalPages, $historyCurrentPage + 2); ?> |
| 105 |
<?php for ($i = $historyStart; $i <= $historyEnd; $i++): ?> |
| 106 |
<a |
| 107 |
class="page-numbers <?php echo $i === $historyCurrentPage ? 'current' : ''; ?>" |
| 108 |
href="<?php echo esc_url(FinancialManagementHistory::buildPageUrl($activePage, $i)); ?>" |
| 109 |
data-history-page="<?php echo esc_attr((string) $i); ?>" |
| 110 |
> |
| 111 |
<?php echo esc_html(number_format_i18n($i)); ?> |
| 112 |
</a> |
| 113 |
<?php endfor; ?> |
| 114 |
|
| 115 |
<?php if ($historyCurrentPage < $historyTotalPages): ?> |
| 116 |
<a |
| 117 |
class="page-numbers prev-next" |
| 118 |
href="<?php echo esc_url(FinancialManagementHistory::buildPageUrl($activePage, $historyCurrentPage + 1)); ?>" |
| 119 |
data-history-page="<?php echo esc_attr((string) ($historyCurrentPage + 1)); ?>" |
| 120 |
> |
| 121 |
بعدی |
| 122 |
</a> |
| 123 |
<?php endif; ?> |
| 124 |
</div> |
| 125 |
<?php endif; ?> |
| 126 |
<?php endif; ?> |
| 127 |
</div> |
| 128 |
|