@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -74,45 +74,45 @@ discard block |
||
74 | 74 | <td class="id"> |
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | - <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
77 | + <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type wpi_select2', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,90 +183,90 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | 192 | 'class' => 'wpi_select2', |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | ?> |
195 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
196 | 196 | <?php } ?> |
197 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
198 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
197 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
198 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
199 | 199 | </div> |
200 | 200 | </div> |
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | |
204 | - public static function prices( $post ) { |
|
204 | + public static function prices($post) { |
|
205 | 205 | $symbol = wpinv_currency_symbol(); |
206 | 206 | $position = wpinv_currency_position(); |
207 | - $item = new WPInv_Item( $post->ID ); |
|
207 | + $item = new WPInv_Item($post->ID); |
|
208 | 208 | |
209 | 209 | $price = $item->get_price(); |
210 | 210 | $is_dynamic_pricing = $item->get_is_dynamic_pricing(); |
211 | 211 | $minimum_price = $item->get_minimum_price(); |
212 | 212 | $is_recurring = $item->is_recurring(); |
213 | 213 | $period = $item->get_recurring_period(); |
214 | - $interval = absint( $item->get_recurring_interval() ); |
|
215 | - $times = absint( $item->get_recurring_limit() ); |
|
214 | + $interval = absint($item->get_recurring_interval()); |
|
215 | + $times = absint($item->get_recurring_limit()); |
|
216 | 216 | $free_trial = $item->has_free_trial(); |
217 | 217 | $trial_interval = $item->get_trial_interval(); |
218 | 218 | $trial_period = $item->get_trial_period(); |
219 | 219 | |
220 | 220 | $intervals = array(); |
221 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
221 | + for ($i = 1; $i <= 90; $i++) { |
|
222 | 222 | $intervals[$i] = $i; |
223 | 223 | } |
224 | 224 | |
225 | - $interval = $interval > 0 ? $interval : 1; |
|
225 | + $interval = $interval > 0 ? $interval : 1; |
|
226 | 226 | |
227 | 227 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
228 | 228 | |
229 | 229 | $minimum_price_style = 'margin-left: 24px;'; |
230 | - if(! $is_dynamic_pricing ) { |
|
230 | + if (!$is_dynamic_pricing) { |
|
231 | 231 | $minimum_price_style .= 'display: none;'; |
232 | 232 | } |
233 | 233 | |
234 | 234 | ?> |
235 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
236 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
235 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
236 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
237 | 237 | </p> |
238 | 238 | |
239 | - <?php if( $item->supports_dynamic_pricing() ) { ?> |
|
239 | + <?php if ($item->supports_dynamic_pricing()) { ?> |
|
240 | 240 | |
241 | 241 | <p class="wpinv-row-name-your-price"> |
242 | 242 | <label> |
243 | - <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> /> |
|
244 | - <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?> |
|
243 | + <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> /> |
|
244 | + <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?> |
|
245 | 245 | </label> |
246 | - <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?> |
|
246 | + <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?> |
|
247 | 247 | </p> |
248 | 248 | |
249 | 249 | <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>"> |
250 | 250 | <label> |
251 | - <?php _e( 'Minimum Price', 'invoicing' ); ?> |
|
252 | - <?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?> |
|
251 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
252 | + <?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?> |
|
253 | 253 | </label> |
254 | 254 | |
255 | - <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?> |
|
255 | + <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?> |
|
256 | 256 | </p> |
257 | 257 | |
258 | 258 | <?php } ?> |
259 | 259 | |
260 | 260 | <p class="wpinv-row-is-recurring"> |
261 | 261 | <label for="wpinv_is_recurring"> |
262 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
263 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
262 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
263 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
264 | 264 | </label> |
265 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
265 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
266 | 266 | </p> |
267 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
268 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
269 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
267 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
268 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
269 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
270 | 270 | 'options' => $intervals, |
271 | 271 | 'name' => 'wpinv_recurring_interval', |
272 | 272 | 'id' => 'wpinv_recurring_interval', |
@@ -274,30 +274,30 @@ discard block |
||
274 | 274 | 'show_option_all' => false, |
275 | 275 | 'show_option_none' => false, |
276 | 276 | 'class' => 'wpi_select2', |
277 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
278 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
277 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
278 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
279 | 279 | <span class="clear wpi-trial-clr"></span> |
280 | 280 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
281 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
282 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
281 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
282 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
283 | 283 | </label> |
284 | 284 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
285 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
285 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
286 | 286 | </label> |
287 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
287 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
288 | 288 | </p> |
289 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
290 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
289 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
290 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
291 | 291 | <?php |
292 | 292 | } |
293 | 293 | |
294 | - public static function vat_rules( $post ) { |
|
294 | + public static function vat_rules($post) { |
|
295 | 295 | global $wpinv_euvat; |
296 | 296 | |
297 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
297 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
298 | 298 | ?> |
299 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
300 | - <?php echo wpinv_html_select( array( |
|
299 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
300 | + <?php echo wpinv_html_select(array( |
|
301 | 301 | 'options' => $wpinv_euvat->get_rules(), |
302 | 302 | 'name' => 'wpinv_vat_rules', |
303 | 303 | 'id' => 'wpinv_vat_rules', |
@@ -305,19 +305,19 @@ discard block |
||
305 | 305 | 'show_option_all' => false, |
306 | 306 | 'show_option_none' => false, |
307 | 307 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2', |
308 | - ) ); ?> |
|
308 | + )); ?> |
|
309 | 309 | </p> |
310 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
311 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
310 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
311 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
312 | 312 | <?php |
313 | 313 | } |
314 | 314 | |
315 | - public static function vat_classes( $post ) { |
|
315 | + public static function vat_classes($post) { |
|
316 | 316 | global $wpinv_euvat; |
317 | 317 | |
318 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
318 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
319 | 319 | ?> |
320 | - <p><?php echo wpinv_html_select( array( |
|
320 | + <p><?php echo wpinv_html_select(array( |
|
321 | 321 | 'options' => $wpinv_euvat->get_all_classes(), |
322 | 322 | 'name' => 'wpinv_vat_class', |
323 | 323 | 'id' => 'wpinv_vat_class', |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | 'show_option_all' => false, |
326 | 326 | 'show_option_none' => false, |
327 | 327 | 'class' => 'gdmbx2-text-medium wpinv-vat-class wpi_select2', |
328 | - ) ); ?> |
|
328 | + )); ?> |
|
329 | 329 | </p> |
330 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
330 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
331 | 331 | <?php |
332 | 332 | } |
333 | 333 | |
334 | - public static function item_info( $post ) { |
|
335 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
336 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
334 | + public static function item_info($post) { |
|
335 | + $item_type = wpinv_get_item_type($post->ID); |
|
336 | + do_action('wpinv_item_info_metabox_before', $post); |
|
337 | 337 | ?> |
338 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
339 | - <?php echo wpinv_html_select( array( |
|
338 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
339 | + <?php echo wpinv_html_select(array( |
|
340 | 340 | 'options' => wpinv_get_item_types(), |
341 | 341 | 'name' => 'wpinv_item_type', |
342 | 342 | 'id' => 'wpinv_item_type', |
@@ -344,114 +344,114 @@ discard block |
||
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false, |
346 | 346 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
347 | - ) ); ?> |
|
347 | + )); ?> |
|
348 | 348 | </p> |
349 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
349 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
350 | 350 | <?php |
351 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
351 | + do_action('wpinv_item_info_metabox_after', $post); |
|
352 | 352 | } |
353 | 353 | |
354 | - public static function meta_values( $post ) { |
|
355 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
354 | + public static function meta_values($post) { |
|
355 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
356 | 356 | 'type', |
357 | 357 | 'custom_id' |
358 | - ) ); |
|
358 | + )); |
|
359 | 359 | |
360 | - if ( empty( $meta_keys ) ) { |
|
360 | + if (empty($meta_keys)) { |
|
361 | 361 | return; |
362 | 362 | } |
363 | 363 | |
364 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
364 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
365 | 365 | |
366 | - foreach ( $meta_keys as $meta_key ) { |
|
366 | + foreach ($meta_keys as $meta_key) { |
|
367 | 367 | ?> |
368 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
368 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
369 | 369 | <?php |
370 | 370 | } |
371 | 371 | |
372 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
372 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
373 | 373 | } |
374 | 374 | |
375 | - public static function save( $post_id, $data, $post ) { |
|
376 | - $invoice = new WPInv_Invoice( $post_id ); |
|
375 | + public static function save($post_id, $data, $post) { |
|
376 | + $invoice = new WPInv_Invoice($post_id); |
|
377 | 377 | |
378 | 378 | // Billing |
379 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
380 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
381 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
382 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
383 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
384 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
385 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
386 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
387 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
388 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
379 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
380 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
381 | + $company = sanitize_text_field($data['wpinv_company']); |
|
382 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
383 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
384 | + $address = sanitize_text_field($data['wpinv_address']); |
|
385 | + $city = sanitize_text_field($data['wpinv_city']); |
|
386 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
387 | + $country = sanitize_text_field($data['wpinv_country']); |
|
388 | + $state = sanitize_text_field($data['wpinv_state']); |
|
389 | 389 | |
390 | 390 | // Details |
391 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
392 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
393 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
394 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
391 | + $status = sanitize_text_field($data['wpinv_status']); |
|
392 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
393 | + $number = sanitize_text_field($data['wpinv_number']); |
|
394 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
395 | 395 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
396 | 396 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
397 | 397 | |
398 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
399 | - |
|
400 | - $invoice->set( 'due_date', $due_date ); |
|
401 | - $invoice->set( 'first_name', $first_name ); |
|
402 | - $invoice->set( 'last_name', $last_name ); |
|
403 | - $invoice->set( 'company', $company ); |
|
404 | - $invoice->set( 'vat_number', $vat_number ); |
|
405 | - $invoice->set( 'phone', $phone ); |
|
406 | - $invoice->set( 'address', $address ); |
|
407 | - $invoice->set( 'city', $city ); |
|
408 | - $invoice->set( 'zip', $zip ); |
|
409 | - $invoice->set( 'country', $country ); |
|
410 | - $invoice->set( 'state', $state ); |
|
411 | - $invoice->set( 'status', $status ); |
|
398 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
399 | + |
|
400 | + $invoice->set('due_date', $due_date); |
|
401 | + $invoice->set('first_name', $first_name); |
|
402 | + $invoice->set('last_name', $last_name); |
|
403 | + $invoice->set('company', $company); |
|
404 | + $invoice->set('vat_number', $vat_number); |
|
405 | + $invoice->set('phone', $phone); |
|
406 | + $invoice->set('address', $address); |
|
407 | + $invoice->set('city', $city); |
|
408 | + $invoice->set('zip', $zip); |
|
409 | + $invoice->set('country', $country); |
|
410 | + $invoice->set('state', $state); |
|
411 | + $invoice->set('status', $status); |
|
412 | 412 | //$invoice->set( 'number', $number ); |
413 | 413 | //$invoice->set( 'discounts', $discounts ); |
414 | 414 | //$invoice->set( 'discount', $discount ); |
415 | - $invoice->set( 'ip', $ip ); |
|
415 | + $invoice->set('ip', $ip); |
|
416 | 416 | $invoice->old_status = $_POST['original_post_status']; |
417 | 417 | $invoice->currency = wpinv_get_currency(); |
418 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
419 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
418 | + if (!empty($data['wpinv_gateway'])) { |
|
419 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
420 | 420 | } |
421 | 421 | $saved = $invoice->save(); |
422 | 422 | |
423 | 423 | // Check for payment notes |
424 | - if ( !empty( $data['invoice_note'] ) ) { |
|
425 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
426 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
424 | + if (!empty($data['invoice_note'])) { |
|
425 | + $note = wp_kses($data['invoice_note'], array()); |
|
426 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
427 | 427 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
428 | 428 | |
429 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
429 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // Update user address if empty. |
433 | - if ( $saved && !empty( $invoice ) ) { |
|
434 | - if ( $user_id = $invoice->get_user_id() ) { |
|
435 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
433 | + if ($saved && !empty($invoice)) { |
|
434 | + if ($user_id = $invoice->get_user_id()) { |
|
435 | + $user_address = wpinv_get_user_address($user_id, false); |
|
436 | 436 | |
437 | 437 | if (empty($user_address['first_name'])) { |
438 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
439 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
438 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
439 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
440 | 440 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
441 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
441 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
445 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
446 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
447 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
448 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
449 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
450 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
445 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
446 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
447 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
448 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
449 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
450 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
454 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | return $saved; |