Passed
Push — master ( ee81c6...9867ed )
by Brian
19:07 queued 03:15
created
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@  discard block
 block discarded – undo
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_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $wpinv_euvat;
10 10
 
11 11
         $currency_symbol    = wpinv_currency_symbol();
12
-        $statuses           = wpinv_get_invoice_statuses( true );
12
+        $statuses           = wpinv_get_invoice_statuses(true);
13 13
 
14
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
15
-        $invoice            = new WPInv_Invoice( $post_id );
16
-        $status             = $invoice->get_status( false ); // Current status    
14
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
15
+        $invoice            = new WPInv_Invoice($post_id);
16
+        $status             = $invoice->get_status(false); // Current status    
17 17
         $discount           = $invoice->get_discount();
18 18
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
19 19
         $invoice_number     = $invoice->get_number();
20 20
         $taxable            = $invoice->is_taxable();
21 21
 
22 22
         $date_created       = $invoice->get_created_date();
23
-        $datetime_created   = strtotime( $date_created );
24
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
23
+        $datetime_created   = strtotime($date_created);
24
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
25 25
         $date_completed     = $invoice->get_completed_date();
26
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
27
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
28
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
29
-        $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
26
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
27
+        $title['status'] = __('Invoice Status:', 'invoicing');
28
+        $title['number'] = __('Invoice Number:', 'invoicing');
29
+        $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
30 30
 
31 31
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
32 32
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -37,39 +37,39 @@  discard block
 block discarded – undo
37 37
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
38 38
 
39 39
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-date-created table-layout">
40
-            <div class="gdmbx-th"><label for="wpinv_date_created"><?php _e( 'Date Created:', 'invoicing' );?></label></div>
40
+            <div class="gdmbx-th"><label for="wpinv_date_created"><?php _e('Date Created:', 'invoicing'); ?></label></div>
41 41
             <div class="gdmbx-td">
42
-                <input type="datetime-local" value="<?php echo esc_attr( date( 'Y-m-d\TH:i:s', $datetime_created ) );?>" id="wpinv_date_created" name="date_created" class="regular-text">
42
+                <input type="datetime-local" value="<?php echo esc_attr(date('Y-m-d\TH:i:s', $datetime_created)); ?>" id="wpinv_date_created" name="date_created" class="regular-text">
43 43
             </div>
44 44
         </div>
45 45
 
46
-        <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft', 'draft' ) ) ) ) { ?>
46
+        <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft', 'draft')))) { ?>
47 47
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
48
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
48
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
49 49
             <div class="gdmbx-td">
50
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
51
-                <p class="wpi-meta-row wpi-meta-desc"><?php _e( 'Leave blank to disable sending auto reminder for this invoice.', 'invoicing' );?></p>
50
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
51
+                <p class="wpi-meta-row wpi-meta-desc"><?php _e('Leave blank to disable sending auto reminder for this invoice.', 'invoicing'); ?></p>
52 52
             </div>
53 53
         </div>
54 54
         <?php } ?>
55
-        <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?>
56
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
55
+        <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?>
56
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
57 57
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
58
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
59
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
58
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
59
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
60 60
         </div>
61 61
         <?php } ?>
62
-        <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?>
62
+        <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?>
63 63
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed">
64
-            <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div>
65
-            <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div>
64
+            <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div>
65
+            <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div>
66 66
         </div>
67 67
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
68 68
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
69 69
             <div class="gdmbx-td">
70 70
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select wpi_select2">
71
-                    <?php foreach ( $statuses as $value => $label ) { ?>
72
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
71
+                    <?php foreach ($statuses as $value => $label) { ?>
72
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
73 73
                     <?php } ?>
74 74
                 </select>
75 75
             </div>
@@ -78,129 +78,129 @@  discard block
 block discarded – undo
78 78
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
79 79
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
80 80
             <div class="gdmbx-td">
81
-                <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
81
+                <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
82 82
             </div>
83 83
         </div>
84
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id );
84
+        <?php do_action('wpinv_meta_box_details_inner', $post_id);
85 85
         $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id);
86 86
         ?>
87 87
 
88
-        <?php if ( $wpinv_euvat->allow_vat_rules() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
88
+        <?php if ($wpinv_euvat->allow_vat_rules() && !($invoice->is_paid() || $invoice->is_refunded())) { ?>
89 89
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-taxable">
90 90
             <div class="gdmbx-th">
91 91
                 <label for="wpinv_taxable">
92
-                    <input type="checkbox" name="disable_taxes" value="1" <?php checked( $taxable, false ); ?> id="wpinv_taxable">
93
-                    <?php _e( 'Disable taxes', 'invoicing' ); ?>
92
+                    <input type="checkbox" name="disable_taxes" value="1" <?php checked($taxable, false); ?> id="wpinv_taxable">
93
+                    <?php _e('Disable taxes', 'invoicing'); ?>
94 94
                 </label>
95 95
             </div>
96 96
         </div>
97 97
         <?php } ?>
98 98
 
99
-        <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?>
99
+        <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?>
100 100
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
101
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
101
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
102 102
             <div class="gdmbx-td">
103
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
103
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
104 104
             </div>
105 105
         </div>
106 106
         <?php } ?>
107 107
     </div>
108 108
 </div>
109 109
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
110
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
110
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
111 111
         <select id="wpi_save_send" name="wpi_save_send" class="wpi_select2">
112
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
113
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
112
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
113
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
114 114
         </select>
115 115
     </p>
116 116
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
117 117
 </div>
118
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
118
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
119 119
         <?php
120 120
     }
121 121
     
122
-    public static function resend_invoice( $post ) {
122
+    public static function resend_invoice($post) {
123 123
         global $wpi_mb_invoice;
124 124
         
125
-        if ( empty( $wpi_mb_invoice ) ) {
125
+        if (empty($wpi_mb_invoice)) {
126 126
             return;
127 127
         }
128 128
         
129 129
         $text = array(
130
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
131
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
130
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
131
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
132 132
         );
133 133
             
134 134
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
135
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
135
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
136 136
         
137
-        if ( $email = $wpi_mb_invoice->get_email() ) {
137
+        if ($email = $wpi_mb_invoice->get_email()) {
138 138
             $email_actions = array();
139
-            $email_actions['email_url']      = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) );
140
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
139
+            $email_actions['email_url']      = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)));
140
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
141 141
             
142
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
142
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
143 143
         ?>
144 144
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
145
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
146
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
147
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
145
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
146
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
147
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
148 148
         <?php } ?>
149 149
         <?php
150 150
         }
151 151
         
152
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
152
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
153 153
     }
154 154
     
155
-    public static function subscriptions( $post ) {
156
-        $invoice = wpinv_get_invoice( $post->ID );
155
+    public static function subscriptions($post) {
156
+        $invoice = wpinv_get_invoice($post->ID);
157 157
 
158
-        if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
159
-            $subscription = wpinv_get_subscription( $invoice );
158
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
159
+            $subscription = wpinv_get_subscription($invoice);
160 160
 
161
-            if ( empty( $subscription ) ) {
161
+            if (empty($subscription)) {
162 162
                 ?>
163
-                <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p>
163
+                <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p>
164 164
                 <?php
165 165
                 return;
166 166
             }
167
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency );
168
-            $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
169
-            $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
167
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
168
+            $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
169
+            $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
170 170
             $payments = $subscription->get_child_payments();
171 171
             ?>
172 172
             <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p>
173
-            <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?>
173
+            <?php if (!empty($subscription) && !empty($subscription->id)) { ?>
174 174
                 <p class="wpi-meta-row wpi-sub-id">
175
-                    <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
175
+                    <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
176 176
             <?php } ?>
177 177
             <p class="wpi-meta-row wpi-bill-cycle">
178
-                <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?>
178
+                <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?>
179 179
             </p>
180 180
             <p class="wpi-meta-row wpi-billed-times">
181
-                <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?>
181
+                <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?>
182 182
             </p>
183 183
             <p class="wpi-meta-row wpi-start-date">
184
-                <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?>
184
+                <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?>
185 185
             </p>
186 186
             <p class="wpi-meta-row wpi-end-date">
187
-                <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?>
187
+                <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?>
188 188
             </p>
189
-            <?php if ( $subscription->status ) { ?>
189
+            <?php if ($subscription->status) { ?>
190 190
                 <p class="wpi-meta-row wpi-sub-status">
191
-                    <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
191
+                    <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
192 192
                 </p>
193 193
             <?php } ?>
194
-            <?php if ( !empty( $payments ) ) { ?>
195
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
194
+            <?php if (!empty($payments)) { ?>
195
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
196 196
                 <ul id="wpi-sub-payments">
197
-                <?php foreach ( $payments as $payment ) {
197
+                <?php foreach ($payments as $payment) {
198 198
                     $invoice_id = $payment->ID;
199 199
                     ?>
200 200
                     <li>
201
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
202
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
203
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
201
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
202
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
203
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
204 204
                     </li>
205 205
                 <?php } ?>
206 206
                 </ul>
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
         }
209 209
     }
210 210
     
211
-    public static function renewals( $post ) {
212
-        $invoice = wpinv_get_invoice( $post->ID );
211
+    public static function renewals($post) {
212
+        $invoice = wpinv_get_invoice($post->ID);
213 213
         
214
-        if ( wpinv_is_subscription_payment( $invoice ) ) {
215
-            $parent_url = get_edit_post_link( $invoice->parent_invoice );
216
-            $parent_id  = wpinv_get_invoice_number( $invoice->parent_invoice );
217
-            $subscription = wpinv_get_subscription( $invoice );
214
+        if (wpinv_is_subscription_payment($invoice)) {
215
+            $parent_url = get_edit_post_link($invoice->parent_invoice);
216
+            $parent_id  = wpinv_get_invoice_number($invoice->parent_invoice);
217
+            $subscription = wpinv_get_subscription($invoice);
218 218
         ?>
219
-        <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
220
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
219
+        <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
220
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
221 221
         <?php
222 222
         }
223 223
     }
@@ -225,47 +225,47 @@  discard block
 block discarded – undo
225 225
     /**
226 226
      * Renders a metabox to edit a payment form.
227 227
      */
228
-    public static function payment_form( $post ) {
229
-        WPInv_Meta_Box_Form_Items::output_options( $post );
228
+    public static function payment_form($post) {
229
+        WPInv_Meta_Box_Form_Items::output_options($post);
230 230
     }
231 231
 
232 232
     /**
233 233
      * Renders a metabox to select items.
234 234
      */
235
-    public static function payment_form_items( $post ) {
236
-        WPInv_Meta_Box_Form_Items::output( $post );
235
+    public static function payment_form_items($post) {
236
+        WPInv_Meta_Box_Form_Items::output($post);
237 237
     }
238 238
     
239
-    public static function payment_meta( $post ) {
239
+    public static function payment_meta($post) {
240 240
         global $wpi_mb_invoice;
241 241
 
242
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
243
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) {
242
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
243
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) {
244 244
             $set_dateway = true;
245 245
         }
246 246
         
247 247
         ?>
248 248
         <p class="wpi-meta-row">
249
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
250
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
249
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
250
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
251 251
             <select required="required" id="wpinv_gateway" class="wpi_select2" name="wpinv_gateway">
252
-                <?php foreach ( $gateways as $name => $gateway ) {
253
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
252
+                <?php foreach ($gateways as $name => $gateway) {
253
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
254 254
                         continue;
255 255
                     }
256 256
                     ?>
257
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
257
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
258 258
                 <?php } ?>
259 259
             </select>
260 260
         <?php } else { 
261
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) );
261
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway));
262 262
         } ?>
263 263
         </p>
264
-        <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?>
265
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p>
264
+        <?php if ($key = $wpi_mb_invoice->get_key()) { ?>
265
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p>
266 266
         <?php } ?>
267
-        <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?>
268
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
267
+        <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?>
268
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
269 269
         <?php } ?>
270 270
         <?php
271 271
     }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,37 +120,37 @@  discard block
 block discarded – undo
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>
127 127
 
128 128
                                             <div class="wp-clearfix">
129 129
                                                 <?php 
130
-                                                    echo wpinv_html_textarea( array(
130
+                                                    echo wpinv_html_textarea(array(
131 131
                                                         'name'  => '_wpinv_quick[excerpt]',
132 132
                                                         'id'    => '_wpinv_quick_excerpt',
133 133
                                                         'value' => '',
134 134
                                                         'class' => 'large-text',
135
-                                                        'label' => __( 'Item description', 'invoicing' ),
136
-                                                    ) ); 
135
+                                                        'label' => __('Item description', 'invoicing'),
136
+                                                    )); 
137 137
                                                 ?>
138 138
                                             </div>
139 139
 
140 140
                                             <div class="wp-clearfix">
141 141
                                                 <label class="wpi-item-actions">
142 142
                                                     <span class="input-text-wrap">
143
-                                                        <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item">
143
+                                                        <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item">
144 144
                                                     </span>
145 145
                                                 </label>
146 146
                                             </div>
147 147
                                         </td>
148 148
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
149
-                                        <?php if ( $item_quantities ) { ?>
149
+                                        <?php if ($item_quantities) { ?>
150 150
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
151 151
                                         <?php } ?>
152 152
                                         <td class="total"></td>
153
-                                        <?php if ( $use_taxes ) { ?>
153
+                                        <?php if ($use_taxes) { ?>
154 154
                                         <td class="tax"></td>
155 155
                                         <?php } ?>
156 156
                                         <td class="action"></td>
@@ -163,29 +163,29 @@  discard block
 block discarded – undo
163 163
                         <td colspan="<?php echo $cols; ?>"></td>
164 164
                     </tr>
165 165
                     <tr class="totals">
166
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
166
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
167 167
                         <td colspan="4">
168 168
                             <table cellspacing="0" cellpadding="0">
169 169
                                 <tr class="subtotal">
170
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
171
-                                    <td class="total"><?php echo $subtotal;?></td>
170
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
171
+                                    <td class="total"><?php echo $subtotal; ?></td>
172 172
                                     <td class="action"></td>
173 173
                                 </tr>
174 174
                                 <tr class="discount">
175
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
176
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
175
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
176
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179
-                                <?php if ( $use_taxes ) { ?>
179
+                                <?php if ($use_taxes) { ?>
180 180
                                 <tr class="tax">
181
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
182
-                                    <td class="total"><?php echo $tax;?></td>
181
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
182
+                                    <td class="total"><?php echo $tax; ?></td>
183 183
                                     <td class="action"></td>
184 184
                                 </tr>
185 185
                                 <?php } ?>
186 186
                                 <tr class="total">
187
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
188
-                                    <td class="total"><?php echo $total;?></td>
187
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
188
+                                    <td class="total"><?php echo $total; ?></td>
189 189
                                     <td class="action"></td>
190 190
                                 </tr>
191 191
                             </table>
@@ -196,90 +196,90 @@  discard block
 block discarded – undo
196 196
             <div class="wpinv-actions">
197 197
                 <?php ob_start(); ?>
198 198
                 <?php
199
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
200
-                        if ( !$invoice->is_recurring() ) {
201
-                            echo wpinv_item_dropdown( array(
199
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
200
+                        if (!$invoice->is_recurring()) {
201
+                            echo wpinv_item_dropdown(array(
202 202
                                 'name'             => 'wpinv_invoice_item',
203 203
                                 'id'               => 'wpinv_invoice_item',
204 204
                                 'show_recurring'   => true,
205 205
                                 'class'            => 'wpi_select2',
206
-                            ) );
206
+                            ));
207 207
                     ?>
208
-                <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">
208
+                <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">
209 209
                     <?php } ?>
210
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
211
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
210
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
211
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
212 212
             </div>
213 213
         </div>
214 214
         <?php
215 215
     }
216 216
 
217
-    public static function prices( $post ) {        
217
+    public static function prices($post) {        
218 218
         $symbol         = wpinv_currency_symbol();
219 219
         $position       = wpinv_currency_position();
220
-        $item           = new WPInv_Item( $post->ID );
220
+        $item           = new WPInv_Item($post->ID);
221 221
 
222 222
         $price                = $item->get_price();
223 223
         $is_dynamic_pricing   = $item->get_is_dynamic_pricing();
224 224
         $minimum_price        = $item->get_minimum_price();
225 225
         $is_recurring         = $item->is_recurring();
226 226
         $period               = $item->get_recurring_period();
227
-        $interval             = absint( $item->get_recurring_interval() );
228
-        $times                = absint( $item->get_recurring_limit() );
227
+        $interval             = absint($item->get_recurring_interval());
228
+        $times                = absint($item->get_recurring_limit());
229 229
         $free_trial           = $item->has_free_trial();
230 230
         $trial_interval       = $item->get_trial_interval();
231 231
         $trial_period         = $item->get_trial_period();
232 232
 
233 233
         $intervals            = array();
234
-        for ( $i = 1; $i <= 90; $i++ ) {
234
+        for ($i = 1; $i <= 90; $i++) {
235 235
             $intervals[$i] = $i;
236 236
         }
237 237
 
238
-        $interval       = $interval > 0 ? $interval : 1;
238
+        $interval = $interval > 0 ? $interval : 1;
239 239
 
240 240
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
241 241
 
242 242
         $minimum_price_style = 'margin-left: 24px;';
243
-        if(! $is_dynamic_pricing ) {
243
+        if (!$is_dynamic_pricing) {
244 244
             $minimum_price_style .= 'display: none;';
245 245
         }
246 246
 
247 247
         ?>
248
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><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' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
249
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
248
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><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' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
249
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
250 250
         </p>
251 251
 
252
-    <?php if( $item->supports_dynamic_pricing() ) { ?>
252
+    <?php if ($item->supports_dynamic_pricing()) { ?>
253 253
 
254 254
         <p class="wpinv-row-name-your-price">
255 255
             <label>
256
-                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> />
257
-                <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?>
256
+                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> />
257
+                <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?>
258 258
             </label>
259
-            <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?>
259
+            <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?>
260 260
         </p>
261 261
 
262 262
         <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>">
263 263
             <label>
264
-                <?php _e( 'Minimum Price', 'invoicing' ); ?>
265
-                <?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><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' ? '&nbsp;' . $symbol : '' );?>
264
+                <?php _e('Minimum Price', 'invoicing'); ?>
265
+                <?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><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' ? '&nbsp;' . $symbol : ''); ?>
266 266
             </label>
267 267
 
268
-            <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?>
268
+            <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?>
269 269
         </p>
270 270
 
271 271
     <?php } ?>
272 272
 
273 273
         <p class="wpinv-row-is-recurring">
274 274
             <label for="wpinv_is_recurring">
275
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
276
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
275
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
276
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
277 277
             </label>
278
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
278
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
279 279
         </p>
280
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
281
-            <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>
282
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
280
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
281
+            <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>
282
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
283 283
                 'options'          => $intervals,
284 284
                 'name'             => 'wpinv_recurring_interval',
285 285
                 'id'               => 'wpinv_recurring_interval',
@@ -287,30 +287,30 @@  discard block
 block discarded – undo
287 287
                 'show_option_all'  => false,
288 288
                 'show_option_none' => false,
289 289
                 'class'            => 'wpi_select2',
290
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
291
-            <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>
290
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
291
+            <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>
292 292
             <span class="clear wpi-trial-clr"></span>
293 293
             <label class="wpinv-free-trial" for="wpinv_free_trial">
294
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
295
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
294
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool) $free_trial); ?> /> 
295
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
296 296
             </label>
297 297
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
298
-                <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>
298
+                <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>
299 299
             </label>
300
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
300
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
301 301
         </p>
302
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
303
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
302
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
303
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
304 304
         <?php
305 305
     }
306 306
 
307
-    public static function vat_rules( $post ) {
307
+    public static function vat_rules($post) {
308 308
         global $wpinv_euvat;
309 309
 
310
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
310
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
311 311
         ?>
312
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
313
-        <?php echo wpinv_html_select( array(
312
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
313
+        <?php echo wpinv_html_select(array(
314 314
                     'options'          => $wpinv_euvat->get_rules(),
315 315
                     'name'             => 'wpinv_vat_rules',
316 316
                     'id'               => 'wpinv_vat_rules',
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
                     'show_option_all'  => false,
319 319
                     'show_option_none' => false,
320 320
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2',
321
-                ) ); ?>
321
+                )); ?>
322 322
         </p>
323
-        <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>
324
-        <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>
325
-        <p class="wpi-m0"><?php _e( 'Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing' ); ?></p>
323
+        <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>
324
+        <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>
325
+        <p class="wpi-m0"><?php _e('Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing'); ?></p>
326 326
         <?php
327 327
     }
328 328
 
329
-    public static function vat_classes( $post ) {
329
+    public static function vat_classes($post) {
330 330
         global $wpinv_euvat;
331 331
         
332
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
332
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
333 333
         ?>
334
-        <p><?php echo wpinv_html_select( array(
334
+        <p><?php echo wpinv_html_select(array(
335 335
                     'options'          => $wpinv_euvat->get_all_classes(),
336 336
                     'name'             => 'wpinv_vat_class',
337 337
                     'id'               => 'wpinv_vat_class',
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
                     'show_option_all'  => false,
340 340
                     'show_option_none' => false,
341 341
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class wpi_select2',
342
-                ) ); ?>
342
+                )); ?>
343 343
         </p>
344
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
344
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
345 345
         <?php
346 346
     }
347 347
 
348
-    public static function item_info( $post ) {
349
-        $item_type = wpinv_get_item_type( $post->ID );
350
-        do_action( 'wpinv_item_info_metabox_before', $post );
348
+    public static function item_info($post) {
349
+        $item_type = wpinv_get_item_type($post->ID);
350
+        do_action('wpinv_item_info_metabox_before', $post);
351 351
         ?>
352
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
353
-        <?php echo wpinv_html_select( array(
352
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
353
+        <?php echo wpinv_html_select(array(
354 354
                     'options'          => wpinv_get_item_types(),
355 355
                     'name'             => 'wpinv_item_type',
356 356
                     'id'               => 'wpinv_item_type',
@@ -358,109 +358,109 @@  discard block
 block discarded – undo
358 358
                     'show_option_all'  => false,
359 359
                     'show_option_none' => false,
360 360
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
361
-                ) ); ?>
361
+                )); ?>
362 362
         </p>
363
-        <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>
363
+        <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>
364 364
         <?php
365
-        do_action( 'wpinv_item_info_metabox_after', $post );
365
+        do_action('wpinv_item_info_metabox_after', $post);
366 366
     }
367 367
 
368
-    public static function meta_values( $post ) {
369
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
368
+    public static function meta_values($post) {
369
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
370 370
             'type',
371 371
             'custom_id'
372
-        ) );
372
+        ));
373 373
 
374
-        if ( empty( $meta_keys ) ) {
374
+        if (empty($meta_keys)) {
375 375
             return;
376 376
         }
377 377
 
378
-        do_action( 'wpinv_meta_values_metabox_before', $post );
378
+        do_action('wpinv_meta_values_metabox_before', $post);
379 379
 
380
-        foreach ( $meta_keys as $meta_key ) {
380
+        foreach ($meta_keys as $meta_key) {
381 381
             ?>
382
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
382
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
383 383
             <?php 
384 384
         }
385 385
 
386
-        do_action( 'wpinv_meta_values_metabox_after', $post );
386
+        do_action('wpinv_meta_values_metabox_after', $post);
387 387
     }
388 388
 
389
-    public static function save( $post_id, $data, $post ) {
390
-        $invoice        = new WPInv_Invoice( $post_id );
389
+    public static function save($post_id, $data, $post) {
390
+        $invoice        = new WPInv_Invoice($post_id);
391 391
 
392 392
         // Billing
393
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
394
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
395
-        $company        = sanitize_text_field( $data['wpinv_company'] );
396
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
397
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
398
-        $address        = sanitize_text_field( $data['wpinv_address'] );
399
-        $city           = sanitize_text_field( $data['wpinv_city'] );
400
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
401
-        $country        = sanitize_text_field( $data['wpinv_country'] );
402
-        $state          = sanitize_text_field( $data['wpinv_state'] );
393
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
394
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
395
+        $company        = sanitize_text_field($data['wpinv_company']);
396
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
397
+        $phone          = sanitize_text_field($data['wpinv_phone']);
398
+        $address        = sanitize_text_field($data['wpinv_address']);
399
+        $city           = sanitize_text_field($data['wpinv_city']);
400
+        $zip            = sanitize_text_field($data['wpinv_zip']);
401
+        $country        = sanitize_text_field($data['wpinv_country']);
402
+        $state          = sanitize_text_field($data['wpinv_state']);
403 403
 
404 404
         // Details
405
-        $status         = sanitize_text_field( $data['wpinv_status'] );
406
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
407
-        $number         = sanitize_text_field( $data['wpinv_number'] );
408
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
409
-        $date_created   = isset( $data['date_created'] ) ? sanitize_text_field( $data['date_created'] ) : '';
405
+        $status         = sanitize_text_field($data['wpinv_status']);
406
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
407
+        $number         = sanitize_text_field($data['wpinv_number']);
408
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
409
+        $date_created   = isset($data['date_created']) ? sanitize_text_field($data['date_created']) : '';
410 410
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
411 411
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
412 412
 
413 413
         $disable_taxes = 0;
414 414
 
415
-        if ( ! empty( $data['disable_taxes'] ) ) {
415
+        if (!empty($data['disable_taxes'])) {
416 416
             $disable_taxes = 1;
417 417
         }
418 418
 
419
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
420
-
421
-        $invoice->set( 'due_date', $due_date );
422
-        $invoice->set( 'first_name', $first_name );
423
-        $invoice->set( 'last_name', $last_name );
424
-        $invoice->set( 'company', $company );
425
-        $invoice->set( 'vat_number', $vat_number );
426
-        $invoice->set( 'phone', $phone );
427
-        $invoice->set( 'address', $address );
428
-        $invoice->set( 'city', $city );
429
-        $invoice->set( 'zip', $zip );
430
-        $invoice->set( 'country', $country );
431
-        $invoice->set( 'state', $state );
432
-        $invoice->set( 'status', $status );
433
-        $invoice->set( 'set', $status );
419
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
420
+
421
+        $invoice->set('due_date', $due_date);
422
+        $invoice->set('first_name', $first_name);
423
+        $invoice->set('last_name', $last_name);
424
+        $invoice->set('company', $company);
425
+        $invoice->set('vat_number', $vat_number);
426
+        $invoice->set('phone', $phone);
427
+        $invoice->set('address', $address);
428
+        $invoice->set('city', $city);
429
+        $invoice->set('zip', $zip);
430
+        $invoice->set('country', $country);
431
+        $invoice->set('state', $state);
432
+        $invoice->set('status', $status);
433
+        $invoice->set('set', $status);
434 434
         //$invoice->set( 'number', $number );
435 435
         //$invoice->set( 'discounts', $discounts );
436 436
         //$invoice->set( 'discount', $discount );
437
-        $invoice->set( 'disable_taxes', $disable_taxes );
438
-        $invoice->set( 'ip', $ip );
437
+        $invoice->set('disable_taxes', $disable_taxes);
438
+        $invoice->set('ip', $ip);
439 439
         $invoice->old_status = $_POST['original_post_status'];
440 440
         
441 441
         $currency = $invoice->get_currency();
442
-        if ( ! empty( $data['wpinv_currency'] ) ) {
443
-            $currency = sanitize_text_field( $data['wpinv_currency'] );
442
+        if (!empty($data['wpinv_currency'])) {
443
+            $currency = sanitize_text_field($data['wpinv_currency']);
444 444
         }
445 445
 
446
-        if ( empty( $currency ) ) {
446
+        if (empty($currency)) {
447 447
             $currency = wpinv_get_currency();
448 448
         }
449 449
 
450
-        if ( ! $invoice->is_paid() ) {
450
+        if (!$invoice->is_paid()) {
451 451
             $invoice->currency = $currency;
452 452
         }
453 453
 
454
-        if ( !empty( $data['wpinv_gateway'] ) ) {
455
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
454
+        if (!empty($data['wpinv_gateway'])) {
455
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
456 456
         }
457 457
         $saved = $invoice->save();
458 458
 
459
-        if ( ! empty( $date_created ) && strtotime( $date_created, current_time( 'timestamp' ) ) ) {
459
+        if (!empty($date_created) && strtotime($date_created, current_time('timestamp'))) {
460 460
 
461
-            $time = strtotime( $date_created, current_time( 'timestamp' ) );
462
-            $date = date( 'Y-m-d H:i:s', $time );
463
-            $date_gmt = get_gmt_from_date( $date );
461
+            $time = strtotime($date_created, current_time('timestamp'));
462
+            $date = date('Y-m-d H:i:s', $time);
463
+            $date_gmt = get_gmt_from_date($date);
464 464
 
465 465
             wp_update_post(
466 466
                 array(
@@ -475,37 +475,37 @@  discard block
 block discarded – undo
475 475
         }
476 476
 
477 477
         // Check for payment notes
478
-        if ( !empty( $data['invoice_note'] ) ) {
479
-            $note               = wp_kses( $data['invoice_note'], array() );
480
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
478
+        if (!empty($data['invoice_note'])) {
479
+            $note               = wp_kses($data['invoice_note'], array());
480
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
481 481
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
482 482
 
483
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
483
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
484 484
         }
485 485
 
486 486
         // Update user address if empty.
487
-        if ( $saved && !empty( $invoice ) ) {
488
-            if ( $user_id = $invoice->get_user_id() ) {
489
-                $user_address = wpinv_get_user_address( $user_id, false );
487
+        if ($saved && !empty($invoice)) {
488
+            if ($user_id = $invoice->get_user_id()) {
489
+                $user_address = wpinv_get_user_address($user_id, false);
490 490
 
491 491
                 if (empty($user_address['first_name'])) {
492
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
493
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
492
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
493
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
494 494
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
495
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
495
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
496 496
                 }
497 497
 
498 498
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
499
-                    update_user_meta( $user_id, '_wpinv_address', $address );
500
-                    update_user_meta( $user_id, '_wpinv_city', $city );
501
-                    update_user_meta( $user_id, '_wpinv_state', $state );
502
-                    update_user_meta( $user_id, '_wpinv_country', $country );
503
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
504
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
499
+                    update_user_meta($user_id, '_wpinv_address', $address);
500
+                    update_user_meta($user_id, '_wpinv_city', $city);
501
+                    update_user_meta($user_id, '_wpinv_state', $state);
502
+                    update_user_meta($user_id, '_wpinv_country', $country);
503
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
504
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
505 505
                 }
506 506
             }
507 507
 
508
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
508
+            do_action('wpinv_invoice_metabox_saved', $invoice);
509 509
         }
510 510
 
511 511
         return $saved;
Please login to merge, or discard this patch.