PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.3
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.3
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
← All changes | templates/payments/view.php +97 -31 2.2.0 → 2.4.3 View file →
@@ -6,13 +6,17 @@
6 6 */
7 7
8 8 namespace EasyInvoice\Templates\Payments;
9 9
10 +
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
10 14 use EasyInvoice\Models\Payment;
11 15 use EasyInvoice\Models\Invoice;
12 16
13 17 if (!isset($payment) || !($payment instanceof Payment)) {
14 - wp_die(__('Invalid payment', 'easy-invoice'));
18 + wp_die(esc_html__('Invalid payment', 'easy-invoice'));
15 19 }
16 20
17 21 $invoice_post = get_post($payment->getInvoiceId());
18 22 $invoice = $invoice_post ? new Invoice($invoice_post) : null;
@@ -22,48 +26,47 @@
22 26
23 27 <div class="p-8">
24 28 <div class="flex justify-between items-center mb-6">
25 29 <h1 class="text-2xl font-bold text-gray-900">
26 - <?php printf(__('Payment #%s', 'easy-invoice'), $payment->getId()); ?>
30 + <?php /* translators: %s: payment id. */ printf(esc_html__('Payment #%s', 'easy-invoice'), (int) $payment->getId()); ?>
27 31 </h1>
28 - <a href="<?php echo admin_url('admin.php?page=easy-invoice-payments'); ?>"
32 + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments')); ?>"
29 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">
30 - <?php _e('Back to Payments', 'easy-invoice'); ?>
34 + <?php esc_html_e('Back to Payments', 'easy-invoice'); ?>
31 35 </a>
32 36 </div>
33 37
34 38 <div class="bg-white shadow overflow-hidden sm:rounded-lg">
35 - <!-- Payment Information -->
36 39 <div class="px-4 py-5 sm:px-6 border-b border-gray-200">
37 - <h2 class="text-lg font-medium text-gray-900"><?php _e('Payment Information', 'easy-invoice'); ?></h2>
40 + <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Payment Information', 'easy-invoice'); ?></h2>
38 41 </div>
39 42 <div class="border-t border-gray-200">
40 43 <dl>
41 44 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
42 - <dt class="text-sm font-medium text-gray-500"><?php _e('Payment ID', 'easy-invoice'); ?></dt>
43 - <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">#<?php echo $payment->getId(); ?></dd>
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>
44 47 </div>
45 48 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
46 - <dt class="text-sm font-medium text-gray-500"><?php _e('Invoice', 'easy-invoice'); ?></dt>
49 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Invoice', 'easy-invoice'); ?></dt>
47 50 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
48 51 <?php if ($invoice): ?>
49 - <a href="<?php echo admin_url('admin.php?page=easy-invoice&action=edit&id=' . $invoice->getId()); ?>"
52 + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice&action=edit&id=' . $invoice->getId())); ?>"
50 53 class="text-indigo-600 hover:text-indigo-900">
51 - <?php echo $invoice->getNumber(); ?>
54 + <?php echo esc_html($invoice->getNumber()); ?>
52 55 </a>
53 56 <?php else: ?>
54 - <span class="text-gray-400"><?php _e('Invoice not found', 'easy-invoice'); ?></span>
57 + <span class="text-gray-400"><?php esc_html_e('Invoice not found', 'easy-invoice'); ?></span>
55 58 <?php endif; ?>
56 59 </dd>
57 60 </div>
58 61 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
59 - <dt class="text-sm font-medium text-gray-500"><?php _e('Amount', 'easy-invoice'); ?></dt>
62 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Amount', 'easy-invoice'); ?></dt>
60 63 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
61 - <?php echo $payment->getCurrencySymbol() . number_format($payment->getAmount(), 2); ?>
64 + <?php echo esc_html($payment->getCurrencySymbol() . number_format((float) $payment->getAmount(), 2)); ?>
62 65 </dd>
63 66 </div>
64 67 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
65 - <dt class="text-sm font-medium text-gray-500"><?php _e('Payment Method', 'easy-invoice'); ?></dt>
68 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment Method', 'easy-invoice'); ?></dt>
66 69 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
67 70 <?php
68 71 $payment_method = $payment->getPaymentMethod();
69 72 if (empty($payment_method)) {
@@ -76,14 +79,14 @@
76 79 }
77 80
78 81
79 82
80 - echo ucfirst($payment_method ?: __('Not specified', 'easy-invoice'));
83 + echo esc_html(ucfirst($payment_method ?: __('Not specified', 'easy-invoice')));
81 84 ?>
82 85 </dd>
83 86 </div>
84 87 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
85 - <dt class="text-sm font-medium text-gray-500"><?php _e('Status', 'easy-invoice'); ?></dt>
88 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Status', 'easy-invoice'); ?></dt>
86 89 <dd class="mt-1 text-sm sm:mt-0 sm:col-span-2">
87 90 <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
88 91 <?php
89 92 switch ($payment->getStatus()) {
@@ -90,8 +93,11 @@
90 93 case 'completed':
91 94 echo 'bg-green-100 text-green-800';
92 95 break;
93 96 case 'pending':
97 + case 'pending-bank':
98 + case 'pending-cheque':
99 + case 'pending_verification':
94 100 echo 'bg-yellow-100 text-yellow-800';
95 101 break;
96 102 case 'failed':
97 103 echo 'bg-red-100 text-red-800';
@@ -99,39 +105,48 @@
99 105 default:
100 106 echo 'bg-gray-100 text-gray-800';
101 107 }
102 108 ?>">
103 - <?php echo ucfirst($payment->getStatus()); ?>
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 + ?>
104 119 </span>
105 120 </dd>
106 121 </div>
107 122 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
108 - <dt class="text-sm font-medium text-gray-500"><?php _e('Date', 'easy-invoice'); ?></dt>
123 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Date', 'easy-invoice'); ?></dt>
109 124 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
110 - <?php echo date_i18n(get_option('date_format'), strtotime($payment->getPaymentDate())); ?>
125 + <?php echo esc_html(date_i18n(get_option('date_format'), strtotime($payment->getPaymentDate()))); ?>
111 126 </dd>
112 127 </div>
113 128 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
114 - <dt class="text-sm font-medium text-gray-500"><?php _e('Type', 'easy-invoice'); ?></dt>
129 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Type', 'easy-invoice'); ?></dt>
115 130 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
116 - <?php echo ucfirst($payment->getPaymentType()); ?>
131 + <?php echo esc_html(ucfirst($payment->getPaymentType())); ?>
117 132 </dd>
118 133 </div>
119 134 <?php if ($payment->getRecurringId()) : ?>
120 135 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
121 - <dt class="text-sm font-medium text-gray-500"><?php _e('Recurring ID', 'easy-invoice'); ?></dt>
136 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Recurring ID', 'easy-invoice'); ?></dt>
122 137 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
123 - <?php echo $payment->getRecurringId(); ?>
138 + <?php echo esc_html($payment->getRecurringId()); ?>
124 139 </dd>
125 140 </div>
126 141 <?php endif; ?>
127 142 <?php if ($payment->getParentPaymentId()) : ?>
128 143 <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 _e('Parent Payment', 'easy-invoice'); ?></dt>
144 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Parent Payment', 'easy-invoice'); ?></dt>
130 145 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
131 - <a href="<?php echo admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . $payment->getParentPaymentId()); ?>"
146 + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . $payment->getParentPaymentId())); ?>"
132 147 class="text-indigo-600 hover:text-indigo-900">
133 - #<?php echo $payment->getParentPaymentId(); ?>
148 + #<?php echo (int) $payment->getParentPaymentId(); ?>
134 149 </a>
135 150 </dd>
136 151 </div>
137 152 <?php endif; ?>
@@ -136,14 +151,66 @@
136 151 </div>
137 152 <?php endif; ?>
138 153 <?php if ($payment->getNotes()) : ?>
139 154 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
140 - <dt class="text-sm font-medium text-gray-500"><?php _e('Notes', 'easy-invoice'); ?></dt>
155 + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Notes', 'easy-invoice'); ?></dt>
141 156 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
142 157 <?php echo nl2br(esc_html($payment->getNotes())); ?>
143 158 </dd>
144 159 </div>
145 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; ?>
146 213 </dl>
147 214 </div>
148 215
149 216 <?php
@@ -160,11 +227,10 @@
160 227 }
161 228
162 229 if ($gateway_response && is_array($gateway_response)) :
163 230 ?>
164 - <!-- Gateway Response -->
165 231 <div class="px-4 py-5 sm:px-6 border-t border-gray-200">
166 - <h2 class="text-lg font-medium text-gray-900"><?php _e('Gateway Response', 'easy-invoice'); ?></h2>
232 + <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Gateway Response', 'easy-invoice'); ?></h2>
167 233 </div>
168 234 <div class="border-t border-gray-200">
169 235 <dl>
170 236 <?php
@@ -172,9 +238,9 @@
172 238 foreach ($gateway_response as $key => $value) :
173 239 $loop++;
174 240 ?>
175 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">
176 - <dt class="text-sm font-medium text-gray-500"><?php echo ucwords(str_replace('_', ' ', $key)); ?></dt>
242 + <dt class="text-sm font-medium text-gray-500"><?php echo esc_html(ucwords(str_replace('_', ' ', $key))); ?></dt>
177 243 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
178 244 <?php
179 245 if (is_array($value)) {
180 246 echo '<pre class="text-xs bg-gray-100 p-2 rounded overflow-x-auto">' . esc_html(json_encode($value, JSON_PRETTY_PRINT)) . '</pre>';