PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.2
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
easy-invoice / templates / payments / view.php

view.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.2, at templates/payments/view.php

262 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Payment View Template
4 *
5 * @package Easy_Invoice
6 */
7
8 namespace EasyInvoice\Templates\Payments;
9
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14 use EasyInvoice\Models\Payment;
15 use EasyInvoice\Models\Invoice;
16
17 if (!isset($payment) || !($payment instanceof Payment)) {
18 wp_die(esc_html__('Invalid payment', 'easy-invoice'));
19 }
20
21 $invoice_post = get_post($payment->getInvoiceId());
22 $invoice = $invoice_post ? new Invoice($invoice_post) : null;
23
24
25 ?>
26
27 <div class="p-8">
28 <div class="flex justify-between items-center mb-6">
29 <h1 class="text-2xl font-bold text-gray-900">
30 <?php /* translators: %s: payment id. */ printf(esc_html__('Payment #%s', 'easy-invoice'), (int) $payment->getId()); ?>
31 </h1>
32 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments')); ?>"
33 class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
34 <?php esc_html_e('Back to Payments', 'easy-invoice'); ?>
35 </a>
36 </div>
37
38 <div class="bg-white shadow overflow-hidden sm:rounded-lg">
39 <div class="px-4 py-5 sm:px-6 border-b border-gray-200">
40 <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Payment Information', 'easy-invoice'); ?></h2>
41 </div>
42 <div class="border-t border-gray-200">
43 <dl>
44 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
45 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment ID', 'easy-invoice'); ?></dt>
46 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">#<?php echo (int) $payment->getId(); ?></dd>
47 </div>
48 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
49 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Invoice', 'easy-invoice'); ?></dt>
50 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
51 <?php if ($invoice): ?>
52 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice&action=edit&id=' . $invoice->getId())); ?>"
53 class="text-indigo-600 hover:text-indigo-900">
54 <?php echo esc_html($invoice->getNumber()); ?>
55 </a>
56 <?php else: ?>
57 <span class="text-gray-400"><?php esc_html_e('Invoice not found', 'easy-invoice'); ?></span>
58 <?php endif; ?>
59 </dd>
60 </div>
61 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
62 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Amount', 'easy-invoice'); ?></dt>
63 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
64 <?php echo esc_html($payment->getCurrencySymbol() . number_format((float) $payment->getAmount(), 2)); ?>
65 </dd>
66 </div>
67 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
68 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment Method', 'easy-invoice'); ?></dt>
69 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
70 <?php
71 $payment_method = $payment->getPaymentMethod();
72 if (empty($payment_method)) {
73 // Try direct property access
74 $payment_method = $payment->payment_method;
75 }
76 if (empty($payment_method)) {
77 // Try direct meta access
78 $payment_method = get_post_meta($payment->getId(), '_payment_method', true);
79 }
80
81
82
83 echo esc_html(ucfirst($payment_method ?: __('Not specified', 'easy-invoice')));
84 ?>
85 </dd>
86 </div>
87 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
88 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Status', 'easy-invoice'); ?></dt>
89 <dd class="mt-1 text-sm sm:mt-0 sm:col-span-2">
90 <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
91 <?php
92 switch ($payment->getStatus()) {
93 case 'completed':
94 echo 'bg-green-100 text-green-800';
95 break;
96 case 'pending':
97 case 'pending-bank':
98 case 'pending-cheque':
99 case 'pending_verification':
100 echo 'bg-yellow-100 text-yellow-800';
101 break;
102 case 'failed':
103 echo 'bg-red-100 text-red-800';
104 break;
105 default:
106 echo 'bg-gray-100 text-gray-800';
107 }
108 ?>">
109 <?php
110 $ei_vs = (string) $payment->getStatus();
111 if (in_array($ei_vs, \EasyInvoice\Services\OfflinePayments::pendingStatuses(), true)) {
112 esc_html_e('Awaiting confirmation', 'easy-invoice');
113 } elseif ('rejected' === $ei_vs) {
114 esc_html_e('Rejected', 'easy-invoice');
115 } else {
116 echo esc_html(ucfirst($ei_vs));
117 }
118 ?>
119 </span>
120 </dd>
121 </div>
122 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
123 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Date', 'easy-invoice'); ?></dt>
124 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
125 <?php echo esc_html(date_i18n(get_option('date_format'), strtotime($payment->getPaymentDate()))); ?>
126 </dd>
127 </div>
128 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
129 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Type', 'easy-invoice'); ?></dt>
130 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
131 <?php echo esc_html(ucfirst($payment->getPaymentType())); ?>
132 </dd>
133 </div>
134 <?php if ($payment->getRecurringId()) : ?>
135 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
136 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Recurring ID', 'easy-invoice'); ?></dt>
137 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
138 <?php echo esc_html($payment->getRecurringId()); ?>
139 </dd>
140 </div>
141 <?php endif; ?>
142 <?php if ($payment->getParentPaymentId()) : ?>
143 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
144 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Parent Payment', 'easy-invoice'); ?></dt>
145 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
146 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . $payment->getParentPaymentId())); ?>"
147 class="text-indigo-600 hover:text-indigo-900">
148 #<?php echo (int) $payment->getParentPaymentId(); ?>
149 </a>
150 </dd>
151 </div>
152 <?php endif; ?>
153 <?php if ($payment->getNotes()) : ?>
154 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
155 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Notes', 'easy-invoice'); ?></dt>
156 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
157 <?php echo nl2br(esc_html($payment->getNotes())); ?>
158 </dd>
159 </div>
160 <?php endif; ?>
161 <?php
162 // What the client told us when they submitted an offline payment, and what staff did with it.
163 $ei_pid = (int) $payment->getId();
164 $ei_reference = (string) get_post_meta($ei_pid, \EasyInvoice\Services\OfflinePayments::META_REFERENCE, true);
165 $ei_has_proof = \EasyInvoice\Services\OfflinePayments::hasProof($ei_pid);
166 $ei_proof_nm = (string) get_post_meta($ei_pid, \EasyInvoice\Services\OfflinePayments::META_PROOF_NAME, true);
167 $ei_status = (string) $payment->getStatus();
168 $ei_pending = in_array($ei_status, \EasyInvoice\Services\OfflinePayments::pendingStatuses(), true);
169 $ei_verified = (int) get_post_meta($ei_pid, '_verified_by', true);
170 $ei_rejected = (int) get_post_meta($ei_pid, '_rejected_by', true);
171 ?>
172 <?php if ('' !== $ei_reference) : ?>
173 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
174 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Reference given by the client', 'easy-invoice'); ?></dt>
175 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><?php echo esc_html($ei_reference); ?></dd>
176 </div>
177 <?php endif; ?>
178 <?php if ($ei_has_proof) : ?>
179 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
180 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Receipt', 'easy-invoice'); ?></dt>
181 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
182 <a class="inline-flex items-center gap-1 font-medium text-indigo-600 hover:text-indigo-900" target="_blank" rel="noopener" href="<?php echo esc_url(\EasyInvoice\Services\OfflinePayments::proofUrl($ei_pid)); ?>">
183 <?php echo esc_html('' !== $ei_proof_nm ? $ei_proof_nm : __('Open receipt', 'easy-invoice')); ?>
184 </a>
185 <span class="block text-xs text-gray-400"><?php esc_html_e('Only signed-in staff can open this file.', 'easy-invoice'); ?></span>
186 </dd>
187 </div>
188 <?php elseif ($ei_pending) : ?>
189 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
190 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Receipt', 'easy-invoice'); ?></dt>
191 <dd class="mt-1 text-sm text-gray-500 sm:mt-0 sm:col-span-2"><?php esc_html_e('None attached.', 'easy-invoice'); ?></dd>
192 </div>
193 <?php endif; ?>
194 <?php if ($ei_verified || $ei_rejected) : $ei_who = get_userdata($ei_verified ?: $ei_rejected); $ei_when = (string) get_post_meta($ei_pid, $ei_verified ? '_verified_at' : '_rejected_at', true); ?>
195 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
196 <dt class="text-sm font-medium text-gray-500"><?php echo $ei_verified ? esc_html__('Confirmed by', 'easy-invoice') : esc_html__('Rejected by', 'easy-invoice'); ?></dt>
197 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
198 <?php echo esc_html($ei_who ? $ei_who->display_name : __('Unknown user', 'easy-invoice')); ?>
199 <?php if ('' !== $ei_when && strtotime($ei_when)) : ?>
200 <span class="text-gray-500">· <?php echo esc_html(date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($ei_when))); ?></span>
201 <?php endif; ?>
202 </dd>
203 </div>
204 <?php endif; ?>
205 <?php if ($ei_pending && easy_invoice_user_can('ei_record_payment')) : ?>
206 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
207 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Decision', 'easy-invoice'); ?></dt>
208 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
209 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments&status=pending')); ?>" class="font-medium text-indigo-600 hover:text-indigo-900"><?php esc_html_e('Confirm or reject it from the Payments list', 'easy-invoice'); ?></a>
210 </dd>
211 </div>
212 <?php endif; ?>
213 </dl>
214 </div>
215
216 <?php
217 $gateway_response_raw = $payment->getGatewayResponse();
218 $gateway_response = null;
219
220 if ($gateway_response_raw) {
221 // Try to decode JSON if it's a string
222 if (is_string($gateway_response_raw)) {
223 $gateway_response = json_decode($gateway_response_raw, true);
224 } elseif (is_array($gateway_response_raw)) {
225 $gateway_response = $gateway_response_raw;
226 }
227 }
228
229 if ($gateway_response && is_array($gateway_response)) :
230 ?>
231 <div class="px-4 py-5 sm:px-6 border-t border-gray-200">
232 <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Gateway Response', 'easy-invoice'); ?></h2>
233 </div>
234 <div class="border-t border-gray-200">
235 <dl>
236 <?php
237 $loop = 0;
238 foreach ($gateway_response as $key => $value) :
239 $loop++;
240 ?>
241 <div class="<?php echo $loop % 2 === 0 ? 'bg-white' : 'bg-gray-50'; ?> px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
242 <dt class="text-sm font-medium text-gray-500"><?php echo esc_html(ucwords(str_replace('_', ' ', $key))); ?></dt>
243 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
244 <?php
245 if (is_array($value)) {
246 echo '<pre class="text-xs bg-gray-100 p-2 rounded overflow-x-auto">' . esc_html(json_encode($value, JSON_PRETTY_PRINT)) . '</pre>';
247 } elseif (is_bool($value)) {
248 echo $value ? 'Yes' : 'No';
249 } elseif (is_null($value)) {
250 echo '<em>null</em>';
251 } else {
252 echo esc_html($value);
253 }
254 ?>
255 </dd>
256 </div>
257 <?php endforeach; ?>
258 </dl>
259 </div>
260 <?php endif; ?>
261 </div>
262 </div>