PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.1
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.1
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 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / templates / pdf / statement.php

statement.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.1, at templates/pdf/statement.php

141 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Statement of account, laid out for the server-side PDF renderer.
4 *
5 * Receives from StatementController::handlePdf():
6 * $client (WP_User), $client_id, $statement
7 *
8 * Tables, not flexbox — dompdf implements CSS 2.1 and ignores `display: flex`.
9 *
10 * @package Easy_Invoice
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 $company = \EasyInvoice\Helpers\TemplateTextHelper::getCompanyInfo();
18 $name = $client->display_name ?: $client->user_login;
19 $ei_rec = \EasyInvoice\Providers\ClientServiceProvider::getClientRepository()->find( (int) $client_id );
20 if ( $ei_rec ) {
21 $ei_person = trim( (string) $ei_rec->getFirstName() . ' ' . (string) $ei_rec->getLastName() );
22 $name = (string) $ei_rec->getBusinessClientName() ?: ( $ei_person ?: $name );
23 }
24 $ei_sym = \EasyInvoice\Helpers\CurrencyHelper::getCurrencySymbol( (string) get_option( 'easy_invoice_currency_code', 'USD' ) );
25 $period = '';
26
27 if ( '' !== $statement['from'] || '' !== $statement['to'] ) {
28 $period = sprintf(
29 /* translators: 1: start date, 2: end date. */
30 __( '%1$s to %2$s', 'easy-invoice' ),
31 $statement['from'] !== '' ? $statement['from'] : __( 'the beginning', 'easy-invoice' ),
32 $statement['to'] !== '' ? $statement['to'] : __( 'today', 'easy-invoice' )
33 );
34 }
35 ?>
36 <!DOCTYPE html>
37 <html>
38 <head>
39 <meta charset="utf-8">
40 <style>
41 @page { margin: 18mm 15mm; }
42 body { font-family: "DejaVu Sans", sans-serif; font-size: 10pt; color: #1f2937; }
43 .head { width: 100%; border-collapse: collapse; margin-bottom: 14pt; }
44 .head td { vertical-align: top; }
45 .company { font-size: 13pt; font-weight: bold; }
46 .muted { color: #6b7280; font-size: 9pt; }
47 .doc-type { font-size: 20pt; font-weight: bold; letter-spacing: 1pt; text-align: right; }
48 .rule { border-bottom: 1pt solid #e5e7eb; margin: 10pt 0 12pt; }
49 table.rows { width: 100%; border-collapse: collapse; }
50 table.rows th {
51 text-align: left; font-size: 8pt; text-transform: uppercase;
52 letter-spacing: 0.5pt; color: #6b7280; border-bottom: 1pt solid #e5e7eb;
53 padding: 5pt 4pt;
54 }
55 table.rows td { padding: 5pt 4pt; border-bottom: 0.5pt solid #f3f4f6; }
56 .num { text-align: right; }
57 .totals { width: 45%; border-collapse: collapse; margin-top: 12pt; }
58 .totals td { padding: 4pt 4pt; }
59 .totals .label { color: #6b7280; }
60 .grand td { border-top: 1pt solid #e5e7eb; font-weight: bold; font-size: 11pt; }
61 </style>
62 </head>
63 <body>
64
65 <table class="head">
66 <tr>
67 <td style="width:55%">
68 <div class="company"><?php echo esc_html( $company['name'] ?? '' ); ?></div>
69 <?php
70 // getCompanyInfo() returns the address as one string, newlines and
71 // all, so it is split here rather than assumed to be a list.
72 $address_lines = array_filter( array_map( 'trim', preg_split( '/\r\n|\r|\n/', (string) ( $company['address'] ?? '' ) ) ?: [] ), 'strlen' );
73 foreach ( $address_lines as $line ) :
74 ?>
75 <div class="muted"><?php echo esc_html( $line ); ?></div>
76 <?php endforeach; ?>
77 </td>
78 <td style="width:45%">
79 <div class="doc-type"><?php esc_html_e( 'STATEMENT', 'easy-invoice' ); ?></div>
80 <div class="muted" style="text-align:right">
81 <div><?php echo esc_html( $name ); ?></div>
82 <?php if ( '' !== $period ) : ?>
83 <div><?php echo esc_html( $period ); ?></div>
84 <?php endif; ?>
85 <div><?php echo esc_html( date_i18n( get_option( 'date_format' ) ) ); ?></div>
86 </div>
87 </td>
88 </tr>
89 </table>
90
91 <div class="rule"></div>
92
93 <table class="rows">
94 <tr>
95 <th><?php esc_html_e( 'Date', 'easy-invoice' ); ?></th>
96 <th><?php esc_html_e( 'Document', 'easy-invoice' ); ?></th>
97 <th class="num"><?php esc_html_e( 'Charge', 'easy-invoice' ); ?></th>
98 <th class="num"><?php esc_html_e( 'Credit', 'easy-invoice' ); ?></th>
99 <th class="num"><?php esc_html_e( 'Balance', 'easy-invoice' ); ?></th>
100 </tr>
101
102 <?php if ( abs( (float) $statement['opening'] ) > 0.001 ) : ?>
103 <tr>
104 <td>&mdash;</td>
105 <td class="muted"><?php esc_html_e( 'Brought forward', 'easy-invoice' ); ?></td>
106 <td></td>
107 <td></td>
108 <td class="num"><?php echo esc_html( easy_invoice_format_money( (float) $statement['opening'] ) ); ?></td>
109 </tr>
110 <?php endif; ?>
111
112 <?php if ( empty( $statement['rows'] ) ) : ?>
113 <tr><td colspan="5" class="muted"><?php esc_html_e( 'Nothing on this account in this period.', 'easy-invoice' ); ?></td></tr>
114 <?php else : ?>
115 <?php foreach ( $statement['rows'] as $row ) : ?>
116 <tr>
117 <td><?php echo esc_html( $row['date'] ); ?></td>
118 <td>
119 <?php echo esc_html( $row['label'] ); ?>
120 <?php if ( '' !== $row['number'] ) : ?>
121 <span class="muted"><?php echo esc_html( $row['number'] ); ?></span>
122 <?php endif; ?>
123 </td>
124 <td class="num"><?php echo $row['charge'] > 0 ? esc_html( easy_invoice_format_money( (float) $row['charge'] ) ) : ''; ?></td>
125 <td class="num"><?php echo $row['credit'] > 0 ? esc_html( easy_invoice_format_money( (float) $row['credit'] ) ) : ''; ?></td>
126 <td class="num"><?php echo esc_html( easy_invoice_format_money( (float) $row['balance'] ) ); ?></td>
127 </tr>
128 <?php endforeach; ?>
129 <?php endif; ?>
130 </table>
131
132 <table class="totals" align="right">
133 <tr><td class="label"><?php esc_html_e( 'Invoiced', 'easy-invoice' ); ?></td><td class="num"><?php echo esc_html( easy_invoice_format_money( (float) $statement['invoiced'] ) ); ?></td></tr>
134 <tr><td class="label"><?php esc_html_e( 'Paid', 'easy-invoice' ); ?></td><td class="num"><?php echo esc_html( easy_invoice_format_money( (float) $statement['paid'] ) ); ?></td></tr>
135 <tr><td class="label"><?php esc_html_e( 'Credited', 'easy-invoice' ); ?></td><td class="num"><?php echo esc_html( easy_invoice_format_money( (float) $statement['credited'] ) ); ?></td></tr>
136 <tr class="grand"><td><?php esc_html_e( 'Balance due', 'easy-invoice' ); ?></td><td class="num"><?php echo esc_html( easy_invoice_format_money( (float) $statement['balance'] ) ); ?></td></tr>
137 </table>
138
139 </body>
140 </html>
141