1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Invoice Items |
5
|
|
|
* |
6
|
|
|
* Display the invoice items meta box. |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
11
|
|
|
exit; // Exit if accessed directly |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* GetPaid_Meta_Box_Invoice_Items Class. |
16
|
|
|
*/ |
17
|
|
|
class GetPaid_Meta_Box_Invoice_Items { |
18
|
|
|
|
19
|
|
|
public static function get_columns( $invoice ) { |
20
|
|
|
$use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21
|
|
|
$columns = array( |
22
|
|
|
'id' => __( 'ID', 'invoicing' ), |
23
|
|
|
'title' => __( 'Item', 'invoicing' ), |
24
|
|
|
'price' => sprintf( |
25
|
|
|
'<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26
|
|
|
<span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27
|
|
|
<span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28
|
|
|
__( 'Amount', 'invoicing' ), |
29
|
|
|
__( 'Price', 'invoicing' ), |
30
|
|
|
__( 'Rate', 'invoicing' ) |
31
|
|
|
), |
32
|
|
|
'qty' => sprintf( |
33
|
|
|
'<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34
|
|
|
__( 'Quantity', 'invoicing' ), |
35
|
|
|
__( 'Hours', 'invoicing' ) |
36
|
|
|
), |
37
|
|
|
'total' => __( 'Total', 'invoicing' ), |
38
|
|
|
'tax' => __( 'Tax (%)', 'invoicing' ), |
39
|
|
|
'action' => '', |
40
|
|
|
); |
41
|
|
|
|
42
|
|
|
if ( ! $use_taxes ) { |
43
|
|
|
unset( $columns['tax'] ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $columns; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public static function output( $post, $invoice = false ) { |
50
|
|
|
|
51
|
|
|
if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
52
|
|
|
return self::output2( $post ); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$post_id = !empty( $post->ID ) ? $post->ID : 0; |
56
|
|
|
$invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
57
|
|
|
$use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58
|
|
|
$item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
59
|
|
|
$columns = self::get_columns( $invoice ); |
60
|
|
|
$cols = count( $columns ); |
61
|
|
|
$class = ''; |
62
|
|
|
|
63
|
|
|
unset( $item_types['adv'] ); |
64
|
|
|
unset( $item_types['package'] ); |
65
|
|
|
|
66
|
|
|
if ( $invoice->is_paid() ) { |
67
|
|
|
$class .= ' wpinv-paid'; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if ( $invoice->is_refunded() ) { |
71
|
|
|
$class .= ' wpinv-refunded'; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if ( $invoice->is_recurring() ) { |
75
|
|
|
$class .= ' wpi-recurring'; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
?> |
79
|
|
|
|
80
|
|
|
<div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
81
|
|
|
<table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
82
|
|
|
|
83
|
|
|
<thead> |
84
|
|
|
<tr> |
85
|
|
|
<?php foreach ( $columns as $key => $label ) : ?> |
86
|
|
|
<th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th> |
87
|
|
|
<?php endforeach; ?> |
88
|
|
|
</tr> |
89
|
|
|
</thead> |
90
|
|
|
|
91
|
|
|
<tbody class="wpinv-line-items"> |
92
|
|
|
<?php |
93
|
|
|
foreach ( $invoice->get_items() as $int => $item ) { |
94
|
|
|
self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
95
|
|
|
} |
96
|
|
|
?> |
97
|
|
|
</tbody> |
98
|
|
|
|
99
|
|
|
<tfoot class="wpinv-totals"> |
100
|
|
|
<tr> |
101
|
|
|
<td colspan="<?php echo $cols; ?>" style="padding:0;border:0"> |
102
|
|
|
<div id="wpinv-quick-add"> |
103
|
|
|
<table cellspacing="0" cellpadding="0"> |
104
|
|
|
<tr> |
105
|
|
|
<td class="id"> </td> |
106
|
|
|
<td class="title"> |
107
|
|
|
|
108
|
|
|
<div class="wp-clearfix"> |
109
|
|
|
<label class="wpi-item-name"> |
110
|
|
|
<span class="input-text-wrap"> |
111
|
|
|
<input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
112
|
|
|
</span> |
113
|
|
|
</label> |
114
|
|
|
</div> |
115
|
|
|
|
116
|
|
|
<div class="wp-clearfix"> |
117
|
|
|
<label class="wpi-item-price"> |
118
|
|
|
<span class="input-text-wrap"> |
119
|
|
|
<input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
120
|
|
|
× <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
121
|
|
|
</span> |
122
|
|
|
</label> |
123
|
|
|
</div> |
124
|
|
|
|
125
|
|
|
<div class="wp-clearfix"> |
126
|
|
|
<label class="wpi-item-name"> |
127
|
|
|
<span class="input-text-wrap"> |
128
|
|
|
<textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
129
|
|
|
</span> |
130
|
|
|
</label> |
131
|
|
|
</div> |
132
|
|
|
|
133
|
|
|
<div class="wp-clearfix"> |
134
|
|
|
<label class="wpi-item-type"> |
135
|
|
|
<span class="input-text-wrap"> |
136
|
|
|
<?php echo wpinv_html_select( array( |
137
|
|
|
'options' => $item_types, |
138
|
|
|
'name' => '_wpinv_quick[type]', |
139
|
|
|
'id' => '_wpinv_quick_type', |
140
|
|
|
'selected' => 'custom', |
141
|
|
|
'show_option_all' => false, |
142
|
|
|
'show_option_none' => false, |
143
|
|
|
'class' => 'gdmbx2-text-medium wpinv-quick-type', |
144
|
|
|
) ); ?> |
145
|
|
|
</span> |
146
|
|
|
</label> |
147
|
|
|
</div> |
148
|
|
|
|
149
|
|
|
<?php if ( $use_taxes ) : ?> |
150
|
|
|
<div class="wp-clearfix"> |
151
|
|
|
<label class="wpi-vat-rule"> |
152
|
|
|
<span class="input-text-wrap"> |
153
|
|
|
<?php |
154
|
|
|
echo wpinv_html_select( array( |
155
|
|
|
'options' => array_merge( |
156
|
|
|
array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
157
|
|
|
getpaid_get_tax_rules() |
158
|
|
|
), |
159
|
|
|
'name' => '_wpinv_quick[vat_rule]', |
160
|
|
|
'id' => '_wpinv_quick_vat_rule', |
161
|
|
|
'show_option_all' => false, |
162
|
|
|
'show_option_none' => false, |
163
|
|
|
'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
164
|
|
|
) ); |
165
|
|
|
?> |
166
|
|
|
</span> |
167
|
|
|
</label> |
168
|
|
|
</div> |
169
|
|
|
<div class="wp-clearfix"> |
170
|
|
|
<label class="wpi-vat-class"> |
171
|
|
|
<span class="input-text-wrap"> |
172
|
|
|
<?php |
173
|
|
|
echo wpinv_html_select( array( |
174
|
|
|
'options' => array_merge( |
175
|
|
|
array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
176
|
|
|
getpaid_get_tax_classes() |
177
|
|
|
), |
178
|
|
|
'name' => '_wpinv_quick[vat_class]', |
179
|
|
|
'id' => '_wpinv_quick_vat_class', |
180
|
|
|
'show_option_all' => false, |
181
|
|
|
'show_option_none' => false, |
182
|
|
|
'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
183
|
|
|
) ); |
184
|
|
|
?> |
185
|
|
|
</span> |
186
|
|
|
</label> |
187
|
|
|
</div> |
188
|
|
|
<?php endif; ?> |
189
|
|
|
|
190
|
|
|
<div class="wp-clearfix"> |
191
|
|
|
<label class="wpi-item-actions"> |
192
|
|
|
<span class="input-text-wrap"> |
193
|
|
|
<input type="button" value="Save" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
194
|
|
|
</span> |
195
|
|
|
</label> |
196
|
|
|
</div> |
197
|
|
|
</td> |
198
|
|
|
</tr> |
199
|
|
|
</table> |
200
|
|
|
</div> |
201
|
|
|
</td> |
202
|
|
|
</tr> |
203
|
|
|
<tr class="totals"> |
204
|
|
|
<td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
205
|
|
|
<td colspan="4"> |
206
|
|
|
<table cellspacing="0" cellpadding="0"> |
207
|
|
|
<tr class="subtotal"> |
208
|
|
|
<td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
209
|
|
|
<td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
210
|
|
|
<td class="action"></td> |
211
|
|
|
</tr> |
212
|
|
|
<tr class="discount"> |
213
|
|
|
<td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td> |
214
|
|
|
<td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
215
|
|
|
<td class="action"></td> |
216
|
|
|
</tr> |
217
|
|
|
<?php if ( $use_taxes ) : ?> |
218
|
|
|
<tr class="tax"> |
219
|
|
|
<td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
220
|
|
|
<td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
221
|
|
|
<td class="action"></td> |
222
|
|
|
</tr> |
223
|
|
|
<?php endif; ?> |
224
|
|
|
<tr class="total"> |
225
|
|
|
<td class="name"><?php _e( 'Total:', 'invoicing' );?></td> |
226
|
|
|
<td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
227
|
|
|
<td class="action"></td> |
228
|
|
|
</tr> |
229
|
|
|
</table> |
230
|
|
|
</td> |
231
|
|
|
</tr> |
232
|
|
|
</tfoot> |
233
|
|
|
|
234
|
|
|
</table> |
235
|
|
|
<div class="wpinv-actions"> |
236
|
|
|
<?php |
237
|
|
|
if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
238
|
|
|
echo wpinv_item_dropdown( |
239
|
|
|
array( |
240
|
|
|
'name' => 'wpinv_invoice_item', |
241
|
|
|
'id' => 'wpinv_invoice_item', |
242
|
|
|
'show_recurring' => true, |
243
|
|
|
'class' => 'wpi_select2', |
244
|
|
|
) |
245
|
|
|
); |
246
|
|
|
|
247
|
|
|
echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>'; |
248
|
|
|
echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
249
|
|
|
echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
250
|
|
|
|
251
|
|
|
} |
252
|
|
|
?> |
253
|
|
|
<?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
254
|
|
|
</div> |
255
|
|
|
</div> |
256
|
|
|
<?php |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
public static function output_row( $columns, $item, $invoice, $class='even' ) { |
260
|
|
|
|
261
|
|
|
?> |
262
|
|
|
<tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
263
|
|
|
<?php foreach ( array_keys( $columns ) as $column ) : ?> |
264
|
|
|
<td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
265
|
|
|
<?php |
266
|
|
|
switch ( $column ) { |
267
|
|
|
case 'id': |
268
|
|
|
echo (int) $item->get_id(); |
269
|
|
|
break; |
270
|
|
|
case 'title': |
271
|
|
|
printf( |
272
|
|
|
'<a href="%s" target="_blank">%s</a>', |
273
|
|
|
get_edit_post_link( $item->get_id() ), |
274
|
|
|
esc_html( $item->get_raw_name() ) |
275
|
|
|
); |
276
|
|
|
|
277
|
|
|
$summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
278
|
|
|
if ( $summary !== '' ) { |
279
|
|
|
printf( |
280
|
|
|
'<span class="meta">%s</span>', |
281
|
|
|
wpautop( wp_kses_post( $summary ) ) |
282
|
|
|
); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
printf( |
286
|
|
|
'<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
287
|
|
|
esc_attr( $item->get_raw_name() ), |
288
|
|
|
(int) $item->get_id() |
289
|
|
|
); |
290
|
|
|
|
291
|
|
|
printf( |
292
|
|
|
'<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
293
|
|
|
(int) $item->get_id(), |
294
|
|
|
esc_attr( $item->get_description() ) |
295
|
|
|
); |
296
|
|
|
|
297
|
|
|
break; |
298
|
|
|
case 'price': |
299
|
|
|
printf( |
300
|
|
|
'<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
301
|
|
|
esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
302
|
|
|
(int) $item->get_id() |
303
|
|
|
); |
304
|
|
|
|
305
|
|
|
break; |
306
|
|
|
case 'qty': |
307
|
|
|
printf( |
308
|
|
|
'<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
309
|
|
|
floatval( $item->get_quantity() ), |
310
|
|
|
(int) $item->get_id() |
311
|
|
|
); |
312
|
|
|
|
313
|
|
|
break; |
314
|
|
|
case 'total': |
315
|
|
|
echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
316
|
|
|
|
317
|
|
|
break; |
318
|
|
|
case 'tax': |
319
|
|
|
echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
320
|
|
|
|
321
|
|
|
break; |
322
|
|
|
case 'action': |
323
|
|
|
if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
324
|
|
|
echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
325
|
|
|
} |
326
|
|
|
break; |
327
|
|
|
} |
328
|
|
|
do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
329
|
|
|
?> |
330
|
|
|
</td> |
331
|
|
|
<?php endforeach; ?> |
332
|
|
|
</tr> |
333
|
|
|
<?php |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Output the metabox. |
338
|
|
|
* |
339
|
|
|
* @param WP_Post $post |
340
|
|
|
*/ |
341
|
|
|
public static function output2( $post ) { |
342
|
|
|
|
343
|
|
|
// Prepare the invoice. |
344
|
|
|
$invoice = new WPInv_Invoice( $post ); |
345
|
|
|
|
346
|
|
|
// Invoice items. |
347
|
|
|
$items = $invoice->get_items(); |
348
|
|
|
|
349
|
|
|
$totals = array( |
350
|
|
|
|
351
|
|
|
'subtotal' => array( |
352
|
|
|
'label' => __( 'Items Subtotal', 'invoicing' ), |
353
|
|
|
'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
354
|
|
|
), |
355
|
|
|
|
356
|
|
|
'discount' => array( |
357
|
|
|
'label' => __( 'Total Discount', 'invoicing' ), |
358
|
|
|
'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
359
|
|
|
), |
360
|
|
|
|
361
|
|
|
'tax' => array( |
362
|
|
|
'label' => __( 'Total Tax', 'invoicing' ), |
363
|
|
|
'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
364
|
|
|
), |
365
|
|
|
|
366
|
|
|
'total' => array( |
367
|
|
|
'label' => __( 'Invoice Total', 'invoicing' ), |
368
|
|
|
'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
369
|
|
|
) |
370
|
|
|
); |
371
|
|
|
|
372
|
|
|
if ( ! wpinv_use_taxes() ) { |
373
|
|
|
unset( $totals['tax'] ); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
$item_args = array( |
377
|
|
|
'post_type' => 'wpi_item', |
378
|
|
|
'orderby' => 'title', |
379
|
|
|
'order' => 'ASC', |
380
|
|
|
'posts_per_page' => -1, |
381
|
|
|
'post_status' => array( 'publish' ), |
382
|
|
|
'meta_query' => array( |
383
|
|
|
array( |
384
|
|
|
'key' => '_wpinv_type', |
385
|
|
|
'compare' => '!=', |
386
|
|
|
'value' => 'package' |
387
|
|
|
) |
388
|
|
|
) |
389
|
|
|
); |
390
|
|
|
|
391
|
|
|
?> |
392
|
|
|
|
393
|
|
|
<style> |
394
|
|
|
#poststuff .input-group-text, |
395
|
|
|
#poststuff .form-control { |
396
|
|
|
border-color: #7e8993; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
#wpinv-details label { |
400
|
|
|
margin-bottom: 3px; |
401
|
|
|
font-weight: 600; |
402
|
|
|
} |
403
|
|
|
</style> |
404
|
|
|
|
405
|
|
|
<div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
406
|
|
|
|
407
|
|
|
<?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
408
|
|
|
<?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
409
|
|
|
|
410
|
|
|
<div class="row"> |
411
|
|
|
<div class="col-12 col-sm-6"> |
412
|
|
|
<?php |
413
|
|
|
echo aui()->select( |
414
|
|
|
array( |
415
|
|
|
'id' => 'wpinv_template', |
416
|
|
|
'name' => 'wpinv_template', |
417
|
|
|
'label' => __( 'Template', 'invoicing' ), |
418
|
|
|
'label_type' => 'vertical', |
419
|
|
|
'placeholder' => __( 'Choose a template', 'invoicing' ), |
420
|
|
|
'class' => 'form-control-sm', |
421
|
|
|
'value' => $invoice->get_template( 'edit' ), |
422
|
|
|
'options' => array( |
423
|
|
|
'quantity' => __( 'Quantity', 'invoicing' ), |
424
|
|
|
'hours' => __( 'Hours', 'invoicing' ), |
425
|
|
|
'amount' => __( 'Amount Only', 'invoicing' ), |
426
|
|
|
), |
427
|
|
|
'data-allow-clear' => 'false', |
428
|
|
|
'select2' => true, |
429
|
|
|
) |
430
|
|
|
); |
431
|
|
|
?> |
432
|
|
|
</div> |
433
|
|
|
<div class="col-12 col-sm-6"> |
434
|
|
|
<?php |
435
|
|
|
|
436
|
|
|
// Set currency. |
437
|
|
|
echo aui()->select( |
438
|
|
|
array( |
439
|
|
|
'id' => 'wpinv_currency', |
440
|
|
|
'name' => 'wpinv_currency', |
441
|
|
|
'label' => __( 'Currency', 'invoicing' ), |
442
|
|
|
'label_type' => 'vertical', |
443
|
|
|
'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
444
|
|
|
'class' => 'form-control-sm', |
445
|
|
|
'value' => $invoice->get_currency( 'edit' ), |
446
|
|
|
'required' => false, |
447
|
|
|
'data-allow-clear' => 'false', |
448
|
|
|
'select2' => true, |
449
|
|
|
'options' => wpinv_get_currencies(), |
450
|
|
|
) |
451
|
|
|
); |
452
|
|
|
|
453
|
|
|
?> |
454
|
|
|
</div> |
455
|
|
|
</div> |
456
|
|
|
|
457
|
|
|
<?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
458
|
|
|
<?php endif; ?> |
459
|
|
|
|
460
|
|
|
<table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
461
|
|
|
<thead> |
462
|
|
|
<tr> |
463
|
|
|
<th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th> |
464
|
|
|
<th class="getpaid-quantity hide-if-amount text-right"> |
465
|
|
|
<span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
466
|
|
|
<span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
467
|
|
|
</th> |
468
|
|
|
<th class="getpaid-price hide-if-amount text-right"> |
469
|
|
|
<span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span> |
470
|
|
|
<span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span> |
471
|
|
|
</th> |
472
|
|
|
<th class="getpaid-item-subtotal text-right"> |
473
|
|
|
<span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span> |
474
|
|
|
<span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span> |
475
|
|
|
</th> |
476
|
|
|
<th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
477
|
|
|
</tr> |
478
|
|
|
</thead> |
479
|
|
|
<tbody class="getpaid_invoice_line_items"> |
480
|
|
|
<tr class="hide-if-has-items hide-if-not-editable"> |
481
|
|
|
<td colspan="2" class="pt-4 pb-4"> |
482
|
|
|
<button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button> |
483
|
|
|
<button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button> |
484
|
|
|
</td> |
485
|
|
|
<td class="hide-if-amount"> </th> |
486
|
|
|
<td class="hide-if-amount"> </th> |
487
|
|
|
<td> </th> |
488
|
|
|
<td width="1%"> </th> |
489
|
|
|
</tr> |
490
|
|
|
<tr class="getpaid-invoice-item-template d-none"> |
491
|
|
|
<td class="getpaid-item" colspan="2"> |
492
|
|
|
<span class='item-name'></span> |
493
|
|
|
<small class="form-text text-muted item-description"></small> |
494
|
|
|
</td> |
495
|
|
|
<td class="getpaid-quantity hide-if-amount text-right item-quantity"></td> |
496
|
|
|
<td class="getpaid-price hide-if-amount text-right item-price"></td> |
497
|
|
|
<td class="getpaid-item-subtotal text-right"> |
498
|
|
|
<span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"></span> |
499
|
|
|
<span class="hide-if-amount item-total"></span> |
500
|
|
|
</td> |
501
|
|
|
<td class="getpaid-item-actions hide-if-not-editable" width="70px"> |
502
|
|
|
<span class="dashicons dashicons-edit"></span> |
503
|
|
|
<span class="dashicons dashicons-trash"></span> |
504
|
|
|
</td> |
505
|
|
|
</tr> |
506
|
|
|
|
507
|
|
|
</tbody> |
508
|
|
|
</table> |
509
|
|
|
|
510
|
|
|
<div class="getpaid-invoice-totals-row"> |
511
|
|
|
<div class="row"> |
512
|
|
|
<div class="col-12 col-sm-6 offset-sm-6"> |
513
|
|
|
<table class="getpaid-invoice-totals text-right w-100"> |
514
|
|
|
<tbody> |
515
|
|
|
<?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
516
|
|
|
<tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>"> |
517
|
|
|
<td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td> |
518
|
|
|
<td width="1%"></td> |
519
|
|
|
<td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
520
|
|
|
</tr> |
521
|
|
|
<?php endforeach; ?> |
522
|
|
|
</tbody> |
523
|
|
|
</table> |
524
|
|
|
</div> |
525
|
|
|
</div> |
526
|
|
|
</div> |
527
|
|
|
|
528
|
|
|
<!-- Actions --> |
529
|
|
|
<div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
530
|
|
|
<div class="row"> |
531
|
|
|
<div class="text-left col-12 col-sm-8"> |
532
|
|
|
<button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button> |
533
|
|
|
<button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button> |
534
|
|
|
<?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
535
|
|
|
</div> |
536
|
|
|
<div class="text-right col-12 col-sm-4"> |
537
|
|
|
<button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button> |
538
|
|
|
</div> |
539
|
|
|
</div> |
540
|
|
|
</div> |
541
|
|
|
|
542
|
|
|
<div class="getpaid-invoice-item-actions hide-if-editable"> |
543
|
|
|
<p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
544
|
|
|
</div> |
545
|
|
|
|
546
|
|
|
<!-- Add items to an invoice --> |
547
|
|
|
<div class="modal fade" id="getpaid-add-items-to-invoice" tabindex="-1" role="dialog" aria-labelledby="getpaid-add-item-to-invoice-label" aria-hidden="true"> |
548
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document"> |
549
|
|
|
<div class="modal-content"> |
550
|
|
|
<div class="modal-header"> |
551
|
|
|
<h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5> |
552
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
553
|
|
|
<span aria-hidden="true">×</span> |
554
|
|
|
</button> |
555
|
|
|
</div> |
556
|
|
|
<div class="modal-body"> |
557
|
|
|
<table class="widefat"> |
558
|
|
|
<thead> |
559
|
|
|
<tr> |
560
|
|
|
<th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th> |
561
|
|
|
<th class="pr-0 text-right hide-if-amount"> |
562
|
|
|
<span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
563
|
|
|
<span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
564
|
|
|
</th> |
565
|
|
|
</tr> |
566
|
|
|
</thead> |
567
|
|
|
<tbody> |
568
|
|
|
<tr> |
569
|
|
|
<td class="pl-0 text-left"> |
570
|
|
|
<select class="regular-text getpaid-add-invoice-item-select"> |
571
|
|
|
<option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
572
|
|
|
<?php foreach ( get_posts( $item_args ) as $item ) : ?> |
573
|
|
|
<option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option> |
574
|
|
|
<?php endforeach; ?> |
575
|
|
|
</select> |
576
|
|
|
</td> |
577
|
|
|
<td class="pr-0 text-right hide-if-amount"> |
578
|
|
|
<input type="number" class="w100" step="1" min="1" autocomplete="off" value="1" placeholder="1"> |
579
|
|
|
</td> |
580
|
|
|
</tr> |
581
|
|
|
</tbody> |
582
|
|
|
</table> |
583
|
|
|
</div> |
584
|
|
|
<div class="modal-footer"> |
585
|
|
|
<button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
586
|
|
|
<button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button> |
587
|
|
|
</div> |
588
|
|
|
</div> |
589
|
|
|
</div> |
590
|
|
|
</div> |
591
|
|
|
|
592
|
|
|
<!-- Create invoice item --> |
593
|
|
|
<div class="modal fade" id="getpaid-create-invoice-item" tabindex="-1" role="dialog" aria-labelledby="getpaid-create-invoice-item-label" aria-hidden="true"> |
594
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document"> |
595
|
|
|
<div class="modal-content"> |
596
|
|
|
<div class="modal-header"> |
597
|
|
|
<h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5> |
598
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
599
|
|
|
<span aria-hidden="true">×</span> |
600
|
|
|
</button> |
601
|
|
|
</div> |
602
|
|
|
<div class="modal-body"> |
603
|
|
|
<div class="getpaid-create-item-div"> |
604
|
|
|
<input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
605
|
|
|
<label class="form-group w-100"> |
606
|
|
|
<span><?php _e( 'Name', 'invoicing' ); ?></span> |
607
|
|
|
<input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
608
|
|
|
</label> |
609
|
|
|
<label class="form-group w-100"> |
610
|
|
|
<span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
611
|
|
|
<span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
612
|
|
|
<input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
613
|
|
|
</label> |
614
|
|
|
<label class="form-group w-100 hide-if-amount"> |
615
|
|
|
<span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
616
|
|
|
<input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
617
|
|
|
</label> |
618
|
|
|
<label class="form-group w-100"> |
619
|
|
|
<span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
620
|
|
|
<textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
621
|
|
|
</label> |
622
|
|
|
</div> |
623
|
|
|
</div> |
624
|
|
|
<div class="modal-footer"> |
625
|
|
|
<button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
626
|
|
|
<button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button> |
627
|
|
|
</div> |
628
|
|
|
</div> |
629
|
|
|
</div> |
630
|
|
|
</div> |
631
|
|
|
|
632
|
|
|
<!-- Edit invoice item --> |
633
|
|
|
<div class="modal fade" id="getpaid-edit-invoice-item" tabindex="-1" role="dialog" aria-labelledby="getpaid-edit-invoice-item-label" aria-hidden="true"> |
634
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document"> |
635
|
|
|
<div class="modal-content"> |
636
|
|
|
<div class="modal-header"> |
637
|
|
|
<h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5> |
638
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
639
|
|
|
<span aria-hidden="true">×</span> |
640
|
|
|
</button> |
641
|
|
|
</div> |
642
|
|
|
<div class="modal-body"> |
643
|
|
|
<div class="getpaid-edit-item-div"> |
644
|
|
|
<input type="hidden" name="id" class="form-control form-control-sm item-id"> |
645
|
|
|
<label class="form-group w-100"> |
646
|
|
|
<span><?php _e( 'Name', 'invoicing' ); ?></span> |
647
|
|
|
<input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
648
|
|
|
</label> |
649
|
|
|
<label class="form-group w-100"> |
650
|
|
|
<span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
651
|
|
|
<span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
652
|
|
|
<input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
653
|
|
|
</label> |
654
|
|
|
<label class="form-group w-100 hide-if-amount"> |
655
|
|
|
<span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
656
|
|
|
<input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
657
|
|
|
</label> |
658
|
|
|
<label class="form-group w-100"> |
659
|
|
|
<span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
660
|
|
|
<textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
661
|
|
|
</label> |
662
|
|
|
</div> |
663
|
|
|
</div> |
664
|
|
|
<div class="modal-footer"> |
665
|
|
|
<button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
666
|
|
|
<button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button> |
667
|
|
|
</div> |
668
|
|
|
</div> |
669
|
|
|
</div> |
670
|
|
|
</div> |
671
|
|
|
</div> |
672
|
|
|
|
673
|
|
|
<?php |
674
|
|
|
} |
675
|
|
|
} |
676
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.