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