0, 'total_amount' => 0, 'completed_payments' => 0, 'pending_payments' => 0, 'failed_payments' => 0 ], $stats); // Initialize amounts_by_currency array $amounts_by_currency = []; // Calculate stats from the payments array foreach ($payments as $payment) { $amount = floatval($payment->getAmount()); $status = $payment->getStatus(); $stats['total_amount'] += $amount; switch ($status) { case 'completed': $stats['completed_payments']++; break; case 'pending': $stats['pending_payments']++; break; case 'failed': $stats['failed_payments']++; break; } // Calculate currency breakdown $payment_currency = $payment->getCurrency(); // If currency is empty or "global", get the actual currency that was used if (empty($payment_currency) || $payment_currency === 'global') { $actual_currency = get_post_meta($payment->getId(), '_currency', true); $payment_currency = !empty($actual_currency) ? $actual_currency : get_option('easy_invoice_currency_code', 'USD'); } // If currency is still "global", use the global setting if ($payment_currency === 'global') { $payment_currency = get_option('easy_invoice_currency_code', 'USD'); } $payment_currency_symbol = $payment->getCurrencySymbol() ?: \EasyInvoice\Helpers\CurrencyHelper::getCurrencySymbol($payment_currency); // Normalize currency code to uppercase for consistent grouping $payment_currency = strtoupper($payment_currency); // Group amounts by currency if (!isset($amounts_by_currency[$payment_currency])) { $amounts_by_currency[$payment_currency] = [ 'amount' => 0, 'symbol' => $payment_currency_symbol ]; } $amounts_by_currency[$payment_currency]['amount'] += $amount; } // Check for bulk action notifications $notification = false; if (isset($_GET['bulk_trashed']) && $_GET['bulk_trashed'] > 0) { $count = intval($_GET['bulk_trashed']); easy_invoice_display_notification('success', sprintf(_n('%s payment moved to trash.', '%s payments moved to trash.', $count, 'easy-invoice'), $count)); $notification = true; } if (isset($_GET['bulk_restored']) && $_GET['bulk_restored'] > 0) { $count = intval($_GET['bulk_restored']); easy_invoice_display_notification('success', sprintf(_n('%s payment restored from trash.', '%s payments restored from trash.', $count, 'easy-invoice'), $count)); $notification = true; } if (isset($_GET['bulk_deleted']) && $_GET['bulk_deleted'] > 0) { $count = intval($_GET['bulk_deleted']); easy_invoice_display_notification('success', sprintf(_n('%s payment permanently deleted.', '%s payments permanently deleted.', $count, 'easy-invoice'), $count)); $notification = true; } if (isset($_GET['bulk_error'])) { $error = sanitize_text_field($_GET['bulk_error']); $error_message = 'An error occurred while processing the bulk action.'; if ($error === 'no_selection') { $error_message = 'Please select at least one payment to perform this action.'; } elseif ($error === 'invalid_action') { $error_message = 'Please select a valid bulk action.'; } easy_invoice_display_notification('error', $error_message); $notification = true; } ?>
|
Payment ID
|
Invoice
|
Amount
|
Method
|
Status
|
Date
|
Actions | ||
|---|---|---|---|---|---|---|---|---|
| #getId(); ?> |
post_type === 'easy_invoice'):
$invoice = new \EasyInvoice\Models\Invoice($invoice_id);
?>
getNumber(); ?>
getTitle() ?: __('Untitled Invoice', 'easy-invoice')); ?>
ID: (Type: post_type : 'null'; ?>) |
getCurrencySymbol() . number_format($payment->getAmount(), 2); ?> | getPaymentMethod(); $gateway_manager = \EasyInvoice\EasyInvoice::getInstance()->getGatewayManager(); $gateways = $gateway_manager->getGateways(); // Try to get the gateway title from registered gateways $method_label = ucfirst(easy_invoice_str_replace('_', ' ', $payment_method)); // Default fallback foreach ($gateways as $gateway) { if ($gateway->getName() === $payment_method) { $method_label = $gateway_manager->getGatewayDisplayName($gateway->getName()); break; } } // Special case for manual payments if ($payment_method === 'manual') { $method_label = __('Manual', 'easy-invoice'); } echo esc_html($method_label); ?> | getStatus(); $status_class = ''; $status_text = ''; switch ($status) { case 'completed': $status_class = 'bg-green-100 text-green-800'; $status_text = __('Completed', 'easy-invoice'); break; case 'pending': $status_class = 'bg-yellow-100 text-yellow-800'; $status_text = __('Pending', 'easy-invoice'); break; case 'failed': $status_class = 'bg-red-100 text-red-800'; $status_text = __('Failed', 'easy-invoice'); break; default: $status_class = 'bg-gray-100 text-gray-800'; $status_text = ucfirst($status); } ?> | getPaymentDate() ? date('M j, Y', strtotime($payment->getPaymentDate())) : date('M j, Y', strtotime($payment->getPost()->post_date)); ?> | |||