| @@ -159,8 +159,36 @@ | ||
| 159 | 159 | <?php echo esc_html( $quote_closed_reason ); ?> |
| 160 | 160 | </div> |
| 161 | 161 | <?php endif; ?> |
| 162 | 162 | |
| 163 | + <?php | |
| 164 | + // An offline payment the client told us about and staff have not yet | |
| 165 | + // confirmed: say so, so they do not pay twice or wonder where it went. | |
| 166 | + $ei_pending = ! $is_quote ? \EasyInvoice\Services\OfflinePayments::pendingForInvoice( (int) $document_id ) : []; | |
| 167 | + if ( $ei_pending ) : | |
| 168 | + $ei_p_fmt = new \EasyInvoice\Helpers\InvoiceFormatter( $invoice ); | |
| 169 | + foreach ( $ei_pending as $ei_p ) : | |
| 170 | + $ei_p_when = (string) get_post_meta( $ei_p->ID, '_payment_date', true ); | |
| 171 | + $ei_p_amount = (float) get_post_meta( $ei_p->ID, '_amount', true ); | |
| 172 | + $ei_p_method = \EasyInvoice\Services\OfflinePayments::label( (string) get_post_meta( $ei_p->ID, '_payment_method', true ) ); | |
| 173 | + ?> | |
| 174 | + <div class="ei-document__notice ei-document__notice--pending" data-ei-pending-payment="<?php echo (int) $ei_p->ID; ?>"> | |
| 175 | + <strong><?php esc_html_e( 'Payment noted — awaiting confirmation.', 'easy-invoice' ); ?></strong> | |
| 176 | + <?php | |
| 177 | + printf( | |
| 178 | + /* translators: 1: amount, 2: payment method, 3: date. */ | |
| 179 | + esc_html__( 'You told us on %3$s that you paid %1$s by %2$s. It will show as paid once we have confirmed it; nothing more is needed from you.', 'easy-invoice' ), | |
| 180 | + esc_html( $ei_p_fmt->format( $ei_p_amount ) ), | |
| 181 | + esc_html( $ei_p_method ), | |
| 182 | + esc_html( '' !== $ei_p_when && strtotime( $ei_p_when ) ? date_i18n( get_option( 'date_format' ), strtotime( $ei_p_when ) ) : date_i18n( get_option( 'date_format' ) ) ) | |
| 183 | + ); | |
| 184 | + ?> | |
| 185 | + </div> | |
| 186 | + <?php | |
| 187 | + endforeach; | |
| 188 | + endif; | |
| 189 | + ?> | |
| 190 | + | |
| 163 | 191 | <div class="ei-document__actions <?php echo esc_attr( $document_type ); ?>-actions"> |
| 164 | 192 | <?php if ( $can_act ) : ?> |
| 165 | 193 | <button type="button" class="ei-btn ei-btn--accept accept" data-ei-action="accept" |
| 166 | 194 | data-description="<?php echo esc_attr( $accept_description ); ?>"> |
| @@ -180,11 +208,27 @@ | ||
| 180 | 208 | <a class="ei-btn ei-btn--pdf" href="<?php echo esc_url( $pdf_url ); ?>" data-ei-action="pdf"> |
| 181 | 209 | <?php echo esc_html( $text_settings['download_pdf'] ); ?> |
| 182 | 210 | </a> |
| 183 | 211 | |
| 184 | - <button type="button" class="ei-btn ei-btn--email send-email-button" data-ei-action="email"> | |
| 185 | - <?php echo esc_html( $text_settings['send_email'] ); ?> | |
| 186 | - </button> | |
| 212 | + <?php | |
| 213 | + // "Send Email" is a staff action — it emails the document to the | |
| 214 | + // client. A client looking at their own invoice was shown it too, | |
| 215 | + // which reads as if they are about to email someone; they have Print | |
| 216 | + // and Download instead. The endpoint's own authorisation is unchanged. | |
| 217 | + $ei_can_send = is_user_logged_in() && ( current_user_can( 'manage_options' ) || easy_invoice_user_can( 'ei_send_invoice' ) || easy_invoice_user_can( 'ei_view_invoices' ) ); | |
| 218 | + /** | |
| 219 | + * Filter whether the document page offers "Send Email". | |
| 220 | + * | |
| 221 | + * @param bool $show Default: staff only. | |
| 222 | + * @param object $document Invoice or quote. | |
| 223 | + * @param string $document_type 'invoice' or 'quote'. | |
| 224 | + */ | |
| 225 | + if ( apply_filters( 'easy_invoice_show_send_email_button', $ei_can_send, $document, $document_type ) ) : | |
| 226 | + ?> | |
| 227 | + <button type="button" class="ei-btn ei-btn--email send-email-button" data-ei-action="email"> | |
| 228 | + <?php echo esc_html( $text_settings['send_email'] ); ?> | |
| 229 | + </button> | |
| 230 | + <?php endif; ?> | |
| 187 | 231 | |
| 188 | 232 | <?php if ( $can_pay ) : ?> |
| 189 | 233 | <button type="button" id="toggle-payment-panel" class="ei-btn ei-btn--pay pay" data-ei-action="pay" data-label="<?php echo esc_attr( $text_settings['pay_now'] ); ?>"> |
| 190 | 234 | <?php echo esc_html( $text_settings['pay_now'] ); ?> |