@@ -12,47 +12,47 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports_Export { |
14 | 14 | |
15 | - /** |
|
16 | - * Displays the reports tab. |
|
17 | - * |
|
18 | - */ |
|
19 | - public function display() { |
|
20 | - |
|
21 | - echo "<div class='row mt-4' style='max-width: 920px;' >"; |
|
22 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
23 | - $this->display_post_type_export( $post_type ); |
|
24 | - } |
|
25 | - $this->display_subscription_export(); |
|
26 | - echo "</div>"; |
|
27 | - |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * Retrieves the download url. |
|
32 | - * |
|
33 | - */ |
|
34 | - public function get_download_url( $post_type ) { |
|
35 | - |
|
36 | - return wp_nonce_url( |
|
37 | - add_query_arg( |
|
38 | - array( |
|
39 | - 'getpaid-admin-action' => 'export_invoices', |
|
40 | - 'post_type' => urlencode( $post_type ), |
|
41 | - ) |
|
42 | - ), |
|
43 | - 'getpaid-nonce', |
|
44 | - 'getpaid-nonce' |
|
45 | - ); |
|
46 | - |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Displays a single post type export card. |
|
51 | - * |
|
52 | - */ |
|
53 | - public function display_post_type_export( $post_type ) { |
|
54 | - |
|
55 | - ?> |
|
15 | + /** |
|
16 | + * Displays the reports tab. |
|
17 | + * |
|
18 | + */ |
|
19 | + public function display() { |
|
20 | + |
|
21 | + echo "<div class='row mt-4' style='max-width: 920px;' >"; |
|
22 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
23 | + $this->display_post_type_export( $post_type ); |
|
24 | + } |
|
25 | + $this->display_subscription_export(); |
|
26 | + echo "</div>"; |
|
27 | + |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * Retrieves the download url. |
|
32 | + * |
|
33 | + */ |
|
34 | + public function get_download_url( $post_type ) { |
|
35 | + |
|
36 | + return wp_nonce_url( |
|
37 | + add_query_arg( |
|
38 | + array( |
|
39 | + 'getpaid-admin-action' => 'export_invoices', |
|
40 | + 'post_type' => urlencode( $post_type ), |
|
41 | + ) |
|
42 | + ), |
|
43 | + 'getpaid-nonce', |
|
44 | + 'getpaid-nonce' |
|
45 | + ); |
|
46 | + |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Displays a single post type export card. |
|
51 | + * |
|
52 | + */ |
|
53 | + public function display_post_type_export( $post_type ) { |
|
54 | + |
|
55 | + ?> |
|
56 | 56 | |
57 | 57 | <div class="col-12 col-md-6"> |
58 | 58 | <div class="card m-0 p-0" style="max-width:100%"> |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | <div class="card-header"> |
61 | 61 | <strong> |
62 | 62 | <?php |
63 | - printf( |
|
64 | - __( 'Export %s', 'invoicing' ), |
|
65 | - sanitize_text_field( getpaid_get_post_type_label( $post_type ) ) |
|
66 | - ); |
|
67 | - ?> |
|
63 | + printf( |
|
64 | + __( 'Export %s', 'invoicing' ), |
|
65 | + sanitize_text_field( getpaid_get_post_type_label( $post_type ) ) |
|
66 | + ); |
|
67 | + ?> |
|
68 | 68 | </strong> |
69 | 69 | </div> |
70 | 70 | |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | <form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>"> |
74 | 74 | |
75 | 75 | <?php |
76 | - $this->display_markup( $this->generate_from_date( $post_type ) ); |
|
77 | - $this->display_markup( $this->generate_to_date( $post_type ) ); |
|
78 | - $this->display_markup( $this->generate_post_status_select( $post_type ) ); |
|
79 | - $this->display_markup( $this->generate_file_type_select( $post_type ) ); |
|
80 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
81 | - ?> |
|
76 | + $this->display_markup( $this->generate_from_date( $post_type ) ); |
|
77 | + $this->display_markup( $this->generate_to_date( $post_type ) ); |
|
78 | + $this->display_markup( $this->generate_post_status_select( $post_type ) ); |
|
79 | + $this->display_markup( $this->generate_file_type_select( $post_type ) ); |
|
80 | + submit_button( __( 'Download', 'invoicing' ) ); |
|
81 | + ?> |
|
82 | 82 | |
83 | 83 | </form> |
84 | 84 | |
@@ -89,122 +89,122 @@ discard block |
||
89 | 89 | |
90 | 90 | <?php |
91 | 91 | |
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Generates the from date input field. |
|
96 | - * |
|
97 | - */ |
|
98 | - public function generate_from_date( $post_type ) { |
|
99 | - |
|
100 | - return aui()->input( |
|
101 | - array( |
|
102 | - 'name' => 'from_date', |
|
103 | - 'id' => esc_attr( "$post_type-from_date" ), |
|
104 | - 'placeholder'=> 'yy-mm-dd', |
|
105 | - 'label' => __( 'From Date', 'invoicing' ), |
|
106 | - 'label_type' => 'vertical', |
|
107 | - 'label_class' => 'd-block', |
|
108 | - 'type' => 'datepicker', |
|
109 | - ) |
|
110 | - ); |
|
111 | - |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Generates the to date input field. |
|
116 | - * |
|
117 | - */ |
|
118 | - public function generate_to_date( $post_type ) { |
|
119 | - |
|
120 | - return aui()->input( |
|
121 | - array( |
|
122 | - 'name' => 'to_date', |
|
123 | - 'id' => esc_attr( "$post_type-to_date" ), |
|
124 | - 'placeholder'=> 'yy-mm-dd', |
|
125 | - 'label' => __( 'To Date', 'invoicing' ), |
|
126 | - 'label_type' => 'vertical', |
|
127 | - 'label_class' => 'd-block', |
|
128 | - 'type' => 'datepicker', |
|
129 | - ) |
|
130 | - ); |
|
131 | - |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Generates the to post status select field. |
|
136 | - * |
|
137 | - */ |
|
138 | - public function generate_post_status_select( $post_type ) { |
|
139 | - |
|
140 | - if ( 'subscriptions' === $post_type ) { |
|
141 | - $options = getpaid_get_subscription_statuses(); |
|
142 | - } else { |
|
143 | - $options = wpinv_get_invoice_statuses( true, false, $post_type ); |
|
144 | - } |
|
145 | - |
|
146 | - return aui()->select( |
|
147 | - array( |
|
148 | - 'name' => 'status', |
|
149 | - 'id' => esc_attr( "$post_type-status" ), |
|
150 | - 'placeholder' => __( 'All Statuses', 'invoicing' ), |
|
151 | - 'label' => __( 'Status', 'invoicing' ), |
|
152 | - 'label_type' => 'vertical', |
|
153 | - 'label_class' => 'd-block', |
|
154 | - 'options' => $options, |
|
155 | - ) |
|
156 | - ); |
|
157 | - |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Generates the to file type select field. |
|
162 | - * |
|
163 | - */ |
|
164 | - public function generate_file_type_select( $post_type ) { |
|
165 | - |
|
166 | - return aui()->select( |
|
167 | - array( |
|
168 | - 'name' => 'file_type', |
|
169 | - 'id' => esc_attr( "$post_type-file_type" ), |
|
170 | - 'placeholder' => __( 'Select File Type', 'invoicing' ), |
|
171 | - 'label' => __( 'Export File', 'invoicing' ), |
|
172 | - 'label_type' => 'vertical', |
|
173 | - 'label_class' => 'd-block', |
|
174 | - 'options' => array( |
|
175 | - 'csv' => __( 'CSV', 'invoicing' ), |
|
176 | - 'xml' => __( 'XML', 'invoicing' ), |
|
177 | - 'json' => __( 'JSON', 'invoicing' ), |
|
178 | - ), |
|
179 | - ) |
|
180 | - ); |
|
181 | - |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Displays a field's markup. |
|
186 | - * |
|
187 | - */ |
|
188 | - public function display_markup( $markup ) { |
|
189 | - |
|
190 | - echo str_replace( |
|
191 | - array( |
|
192 | - 'form-control', |
|
193 | - 'custom-select' |
|
194 | - ), |
|
195 | - 'regular-text', |
|
196 | - $markup |
|
197 | - ); |
|
198 | - |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Displays a subscription export card. |
|
203 | - * |
|
204 | - */ |
|
205 | - public function display_subscription_export() { |
|
206 | - |
|
207 | - ?> |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Generates the from date input field. |
|
96 | + * |
|
97 | + */ |
|
98 | + public function generate_from_date( $post_type ) { |
|
99 | + |
|
100 | + return aui()->input( |
|
101 | + array( |
|
102 | + 'name' => 'from_date', |
|
103 | + 'id' => esc_attr( "$post_type-from_date" ), |
|
104 | + 'placeholder'=> 'yy-mm-dd', |
|
105 | + 'label' => __( 'From Date', 'invoicing' ), |
|
106 | + 'label_type' => 'vertical', |
|
107 | + 'label_class' => 'd-block', |
|
108 | + 'type' => 'datepicker', |
|
109 | + ) |
|
110 | + ); |
|
111 | + |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Generates the to date input field. |
|
116 | + * |
|
117 | + */ |
|
118 | + public function generate_to_date( $post_type ) { |
|
119 | + |
|
120 | + return aui()->input( |
|
121 | + array( |
|
122 | + 'name' => 'to_date', |
|
123 | + 'id' => esc_attr( "$post_type-to_date" ), |
|
124 | + 'placeholder'=> 'yy-mm-dd', |
|
125 | + 'label' => __( 'To Date', 'invoicing' ), |
|
126 | + 'label_type' => 'vertical', |
|
127 | + 'label_class' => 'd-block', |
|
128 | + 'type' => 'datepicker', |
|
129 | + ) |
|
130 | + ); |
|
131 | + |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Generates the to post status select field. |
|
136 | + * |
|
137 | + */ |
|
138 | + public function generate_post_status_select( $post_type ) { |
|
139 | + |
|
140 | + if ( 'subscriptions' === $post_type ) { |
|
141 | + $options = getpaid_get_subscription_statuses(); |
|
142 | + } else { |
|
143 | + $options = wpinv_get_invoice_statuses( true, false, $post_type ); |
|
144 | + } |
|
145 | + |
|
146 | + return aui()->select( |
|
147 | + array( |
|
148 | + 'name' => 'status', |
|
149 | + 'id' => esc_attr( "$post_type-status" ), |
|
150 | + 'placeholder' => __( 'All Statuses', 'invoicing' ), |
|
151 | + 'label' => __( 'Status', 'invoicing' ), |
|
152 | + 'label_type' => 'vertical', |
|
153 | + 'label_class' => 'd-block', |
|
154 | + 'options' => $options, |
|
155 | + ) |
|
156 | + ); |
|
157 | + |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Generates the to file type select field. |
|
162 | + * |
|
163 | + */ |
|
164 | + public function generate_file_type_select( $post_type ) { |
|
165 | + |
|
166 | + return aui()->select( |
|
167 | + array( |
|
168 | + 'name' => 'file_type', |
|
169 | + 'id' => esc_attr( "$post_type-file_type" ), |
|
170 | + 'placeholder' => __( 'Select File Type', 'invoicing' ), |
|
171 | + 'label' => __( 'Export File', 'invoicing' ), |
|
172 | + 'label_type' => 'vertical', |
|
173 | + 'label_class' => 'd-block', |
|
174 | + 'options' => array( |
|
175 | + 'csv' => __( 'CSV', 'invoicing' ), |
|
176 | + 'xml' => __( 'XML', 'invoicing' ), |
|
177 | + 'json' => __( 'JSON', 'invoicing' ), |
|
178 | + ), |
|
179 | + ) |
|
180 | + ); |
|
181 | + |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Displays a field's markup. |
|
186 | + * |
|
187 | + */ |
|
188 | + public function display_markup( $markup ) { |
|
189 | + |
|
190 | + echo str_replace( |
|
191 | + array( |
|
192 | + 'form-control', |
|
193 | + 'custom-select' |
|
194 | + ), |
|
195 | + 'regular-text', |
|
196 | + $markup |
|
197 | + ); |
|
198 | + |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Displays a subscription export card. |
|
203 | + * |
|
204 | + */ |
|
205 | + public function display_subscription_export() { |
|
206 | + |
|
207 | + ?> |
|
208 | 208 | |
209 | 209 | <div class="col-12 col-md-6"> |
210 | 210 | <div class="card m-0 p-0" style="max-width:100%"> |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | <form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>"> |
221 | 221 | |
222 | 222 | <?php |
223 | - $this->display_markup( $this->generate_from_date( 'subscriptions' ) ); |
|
224 | - $this->display_markup( $this->generate_to_date( 'subscriptions' ) ); |
|
225 | - $this->display_markup( $this->generate_post_status_select( 'subscriptions' ) ); |
|
226 | - $this->display_markup( $this->generate_file_type_select( 'subscriptions' ) ); |
|
227 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
228 | - ?> |
|
223 | + $this->display_markup( $this->generate_from_date( 'subscriptions' ) ); |
|
224 | + $this->display_markup( $this->generate_to_date( 'subscriptions' ) ); |
|
225 | + $this->display_markup( $this->generate_post_status_select( 'subscriptions' ) ); |
|
226 | + $this->display_markup( $this->generate_file_type_select( 'subscriptions' ) ); |
|
227 | + submit_button( __( 'Download', 'invoicing' ) ); |
|
228 | + ?> |
|
229 | 229 | |
230 | 230 | </form> |
231 | 231 | |
@@ -236,6 +236,6 @@ discard block |
||
236 | 236 | |
237 | 237 | <?php |
238 | 238 | |
239 | - } |
|
239 | + } |
|
240 | 240 | |
241 | 241 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports_Export Class. |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | public function display() { |
20 | 20 | |
21 | 21 | echo "<div class='row mt-4' style='max-width: 920px;' >"; |
22 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
23 | - $this->display_post_type_export( $post_type ); |
|
22 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
23 | + $this->display_post_type_export($post_type); |
|
24 | 24 | } |
25 | 25 | $this->display_subscription_export(); |
26 | 26 | echo "</div>"; |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | * Retrieves the download url. |
32 | 32 | * |
33 | 33 | */ |
34 | - public function get_download_url( $post_type ) { |
|
34 | + public function get_download_url($post_type) { |
|
35 | 35 | |
36 | 36 | return wp_nonce_url( |
37 | 37 | add_query_arg( |
38 | 38 | array( |
39 | 39 | 'getpaid-admin-action' => 'export_invoices', |
40 | - 'post_type' => urlencode( $post_type ), |
|
40 | + 'post_type' => urlencode($post_type), |
|
41 | 41 | ) |
42 | 42 | ), |
43 | 43 | 'getpaid-nonce', |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Displays a single post type export card. |
51 | 51 | * |
52 | 52 | */ |
53 | - public function display_post_type_export( $post_type ) { |
|
53 | + public function display_post_type_export($post_type) { |
|
54 | 54 | |
55 | 55 | ?> |
56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | <strong> |
62 | 62 | <?php |
63 | 63 | printf( |
64 | - __( 'Export %s', 'invoicing' ), |
|
65 | - sanitize_text_field( getpaid_get_post_type_label( $post_type ) ) |
|
64 | + __('Export %s', 'invoicing'), |
|
65 | + sanitize_text_field(getpaid_get_post_type_label($post_type)) |
|
66 | 66 | ); |
67 | 67 | ?> |
68 | 68 | </strong> |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | |
71 | 71 | <div class="card-body"> |
72 | 72 | |
73 | - <form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>"> |
|
73 | + <form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>"> |
|
74 | 74 | |
75 | 75 | <?php |
76 | - $this->display_markup( $this->generate_from_date( $post_type ) ); |
|
77 | - $this->display_markup( $this->generate_to_date( $post_type ) ); |
|
78 | - $this->display_markup( $this->generate_post_status_select( $post_type ) ); |
|
79 | - $this->display_markup( $this->generate_file_type_select( $post_type ) ); |
|
80 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
76 | + $this->display_markup($this->generate_from_date($post_type)); |
|
77 | + $this->display_markup($this->generate_to_date($post_type)); |
|
78 | + $this->display_markup($this->generate_post_status_select($post_type)); |
|
79 | + $this->display_markup($this->generate_file_type_select($post_type)); |
|
80 | + submit_button(__('Download', 'invoicing')); |
|
81 | 81 | ?> |
82 | 82 | |
83 | 83 | </form> |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * Generates the from date input field. |
96 | 96 | * |
97 | 97 | */ |
98 | - public function generate_from_date( $post_type ) { |
|
98 | + public function generate_from_date($post_type) { |
|
99 | 99 | |
100 | 100 | return aui()->input( |
101 | 101 | array( |
102 | 102 | 'name' => 'from_date', |
103 | - 'id' => esc_attr( "$post_type-from_date" ), |
|
103 | + 'id' => esc_attr("$post_type-from_date"), |
|
104 | 104 | 'placeholder'=> 'yy-mm-dd', |
105 | - 'label' => __( 'From Date', 'invoicing' ), |
|
105 | + 'label' => __('From Date', 'invoicing'), |
|
106 | 106 | 'label_type' => 'vertical', |
107 | 107 | 'label_class' => 'd-block', |
108 | 108 | 'type' => 'datepicker', |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * Generates the to date input field. |
116 | 116 | * |
117 | 117 | */ |
118 | - public function generate_to_date( $post_type ) { |
|
118 | + public function generate_to_date($post_type) { |
|
119 | 119 | |
120 | 120 | return aui()->input( |
121 | 121 | array( |
122 | 122 | 'name' => 'to_date', |
123 | - 'id' => esc_attr( "$post_type-to_date" ), |
|
123 | + 'id' => esc_attr("$post_type-to_date"), |
|
124 | 124 | 'placeholder'=> 'yy-mm-dd', |
125 | - 'label' => __( 'To Date', 'invoicing' ), |
|
125 | + 'label' => __('To Date', 'invoicing'), |
|
126 | 126 | 'label_type' => 'vertical', |
127 | 127 | 'label_class' => 'd-block', |
128 | 128 | 'type' => 'datepicker', |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | * Generates the to post status select field. |
136 | 136 | * |
137 | 137 | */ |
138 | - public function generate_post_status_select( $post_type ) { |
|
138 | + public function generate_post_status_select($post_type) { |
|
139 | 139 | |
140 | - if ( 'subscriptions' === $post_type ) { |
|
140 | + if ('subscriptions' === $post_type) { |
|
141 | 141 | $options = getpaid_get_subscription_statuses(); |
142 | 142 | } else { |
143 | - $options = wpinv_get_invoice_statuses( true, false, $post_type ); |
|
143 | + $options = wpinv_get_invoice_statuses(true, false, $post_type); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return aui()->select( |
147 | 147 | array( |
148 | 148 | 'name' => 'status', |
149 | - 'id' => esc_attr( "$post_type-status" ), |
|
150 | - 'placeholder' => __( 'All Statuses', 'invoicing' ), |
|
151 | - 'label' => __( 'Status', 'invoicing' ), |
|
149 | + 'id' => esc_attr("$post_type-status"), |
|
150 | + 'placeholder' => __('All Statuses', 'invoicing'), |
|
151 | + 'label' => __('Status', 'invoicing'), |
|
152 | 152 | 'label_type' => 'vertical', |
153 | 153 | 'label_class' => 'd-block', |
154 | 154 | 'options' => $options, |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | * Generates the to file type select field. |
162 | 162 | * |
163 | 163 | */ |
164 | - public function generate_file_type_select( $post_type ) { |
|
164 | + public function generate_file_type_select($post_type) { |
|
165 | 165 | |
166 | 166 | return aui()->select( |
167 | 167 | array( |
168 | 168 | 'name' => 'file_type', |
169 | - 'id' => esc_attr( "$post_type-file_type" ), |
|
170 | - 'placeholder' => __( 'Select File Type', 'invoicing' ), |
|
171 | - 'label' => __( 'Export File', 'invoicing' ), |
|
169 | + 'id' => esc_attr("$post_type-file_type"), |
|
170 | + 'placeholder' => __('Select File Type', 'invoicing'), |
|
171 | + 'label' => __('Export File', 'invoicing'), |
|
172 | 172 | 'label_type' => 'vertical', |
173 | 173 | 'label_class' => 'd-block', |
174 | 174 | 'options' => array( |
175 | - 'csv' => __( 'CSV', 'invoicing' ), |
|
176 | - 'xml' => __( 'XML', 'invoicing' ), |
|
177 | - 'json' => __( 'JSON', 'invoicing' ), |
|
175 | + 'csv' => __('CSV', 'invoicing'), |
|
176 | + 'xml' => __('XML', 'invoicing'), |
|
177 | + 'json' => __('JSON', 'invoicing'), |
|
178 | 178 | ), |
179 | 179 | ) |
180 | 180 | ); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * Displays a field's markup. |
186 | 186 | * |
187 | 187 | */ |
188 | - public function display_markup( $markup ) { |
|
188 | + public function display_markup($markup) { |
|
189 | 189 | |
190 | 190 | echo str_replace( |
191 | 191 | array( |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | |
212 | 212 | <div class="card-header"> |
213 | 213 | <strong> |
214 | - <?php _e( 'Export Subscriptions', 'invoicing' ); ?> |
|
214 | + <?php _e('Export Subscriptions', 'invoicing'); ?> |
|
215 | 215 | </strong> |
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div class="card-body"> |
219 | 219 | |
220 | - <form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>"> |
|
220 | + <form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>"> |
|
221 | 221 | |
222 | 222 | <?php |
223 | - $this->display_markup( $this->generate_from_date( 'subscriptions' ) ); |
|
224 | - $this->display_markup( $this->generate_to_date( 'subscriptions' ) ); |
|
225 | - $this->display_markup( $this->generate_post_status_select( 'subscriptions' ) ); |
|
226 | - $this->display_markup( $this->generate_file_type_select( 'subscriptions' ) ); |
|
227 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
223 | + $this->display_markup($this->generate_from_date('subscriptions')); |
|
224 | + $this->display_markup($this->generate_to_date('subscriptions')); |
|
225 | + $this->display_markup($this->generate_post_status_select('subscriptions')); |
|
226 | + $this->display_markup($this->generate_file_type_select('subscriptions')); |
|
227 | + submit_button(__('Download', 'invoicing')); |
|
228 | 228 | ?> |
229 | 229 | |
230 | 230 | </form> |
@@ -12,177 +12,177 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Subscription_Exporter extends GetPaid_Graph_Downloader { |
14 | 14 | |
15 | - /** |
|
16 | - * Retrieves subscription query args. |
|
17 | - * |
|
18 | - * @param array $args Args to search for. |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public function get_subscription_query_args( $args ) { |
|
22 | - |
|
23 | - $query_args = array( |
|
24 | - 'status' => 'all', |
|
25 | - 'number' => -1, |
|
26 | - 'count_total' => false, |
|
27 | - 'fields' => 'all', |
|
28 | - ); |
|
29 | - |
|
30 | - if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) { |
|
31 | - $query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
32 | - } |
|
33 | - |
|
34 | - $date_query = array(); |
|
35 | - if ( ! empty( $args['to_date'] ) ) { |
|
36 | - $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
37 | - } |
|
38 | - |
|
39 | - if ( ! empty( $args['from_date'] ) ) { |
|
40 | - $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
41 | - } |
|
42 | - |
|
43 | - if ( ! empty( $date_query ) ) { |
|
44 | - $date_query['inclusive'] = true; |
|
45 | - $query_args['date_created_query'] = array( $date_query ); |
|
46 | - } |
|
47 | - |
|
48 | - return $query_args; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Retrieves subscriptions. |
|
53 | - * |
|
54 | - * @param array $query_args GetPaid_Subscriptions_Query args. |
|
55 | - * @return WPInv_Subscription[] |
|
56 | - */ |
|
57 | - public function get_subscriptions( $query_args ) { |
|
58 | - |
|
59 | - // Get subscriptions. |
|
60 | - $subscriptions = new GetPaid_Subscriptions_Query( $query_args ); |
|
61 | - |
|
62 | - // Prepare the results. |
|
63 | - return $subscriptions->get_results(); |
|
64 | - |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Handles the actual download. |
|
69 | - * |
|
70 | - */ |
|
71 | - public function export( $post_type, $args ) { |
|
72 | - |
|
73 | - $subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) ); |
|
74 | - $stream = $this->prepare_output(); |
|
75 | - $headers = $this->get_export_fields(); |
|
76 | - $file_type = $this->prepare_file_type( 'subscriptions' ); |
|
77 | - |
|
78 | - if ( 'csv' == $file_type ) { |
|
79 | - $this->download_csv( $subscriptions, $stream, $headers ); |
|
80 | - } else if( 'xml' == $file_type ) { |
|
81 | - $this->download_xml( $subscriptions, $stream, $headers ); |
|
82 | - } else { |
|
83 | - $this->download_json( $subscriptions, $stream, $headers ); |
|
84 | - } |
|
85 | - |
|
86 | - fclose( $stream ); |
|
87 | - exit; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Prepares a single subscription for download. |
|
92 | - * |
|
93 | - * @param WPInv_Subscription $subscription The subscription to prepare.. |
|
94 | - * @param array $fields The fields to stream. |
|
95 | - * @since 1.0.19 |
|
96 | - * @return array |
|
97 | - */ |
|
98 | - public function prepare_row( $subscription, $fields ) { |
|
99 | - |
|
100 | - $prepared = array(); |
|
101 | - $amount_fields = $this->get_amount_fields(); |
|
102 | - $invoice = $subscription->get_parent_payment(); |
|
103 | - |
|
104 | - foreach ( $fields as $field ) { |
|
105 | - |
|
106 | - $value = ''; |
|
107 | - $method = "get_$field"; |
|
108 | - |
|
109 | - if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) { |
|
110 | - |
|
111 | - if ( method_exists( $invoice, $method ) ) { |
|
112 | - $value = $invoice->$method(); |
|
113 | - } |
|
114 | - |
|
115 | - } else if ( method_exists( $subscription, $method ) ) { |
|
116 | - $value = $subscription->$method(); |
|
117 | - } |
|
118 | - |
|
119 | - if ( in_array( $field, $amount_fields ) ) { |
|
120 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
121 | - } |
|
122 | - |
|
123 | - $prepared[ $field ] = wpinv_clean( $value ); |
|
124 | - |
|
125 | - } |
|
126 | - |
|
127 | - return $prepared; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Retrieves export fields. |
|
132 | - * |
|
133 | - * @since 1.0.19 |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function get_export_fields() { |
|
137 | - |
|
138 | - $fields = array( |
|
139 | - 'id', |
|
140 | - 'currency', |
|
141 | - 'initial_amount', |
|
142 | - 'recurring_amount', |
|
143 | - 'trial_period', |
|
144 | - 'frequency', |
|
145 | - 'period', |
|
146 | - 'bill_times', |
|
147 | - 'parent_payment_id', |
|
148 | - 'profile_id', |
|
149 | - 'product_id', |
|
150 | - 'status', |
|
151 | - 'date_created', |
|
152 | - 'date_expires', |
|
153 | - |
|
154 | - 'customer_id', |
|
155 | - 'customer_first_name', |
|
156 | - 'customer_last_name', |
|
157 | - 'customer_phone', |
|
158 | - 'customer_email', |
|
159 | - 'customer_country', |
|
160 | - 'customer_city', |
|
161 | - 'customer_state', |
|
162 | - 'customer_zip', |
|
163 | - 'customer_company', |
|
164 | - 'customer_vat_number', |
|
165 | - 'customer_address', |
|
166 | - |
|
167 | - ); |
|
168 | - |
|
169 | - return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields ); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Retrieves amount fields. |
|
174 | - * |
|
175 | - * @since 1.0.19 |
|
176 | - * @return array |
|
177 | - */ |
|
178 | - public function get_amount_fields() { |
|
179 | - |
|
180 | - $fields = array( |
|
181 | - 'initial_amount', |
|
182 | - 'recurring_amount' |
|
183 | - ); |
|
184 | - |
|
185 | - return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields ); |
|
186 | - } |
|
15 | + /** |
|
16 | + * Retrieves subscription query args. |
|
17 | + * |
|
18 | + * @param array $args Args to search for. |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public function get_subscription_query_args( $args ) { |
|
22 | + |
|
23 | + $query_args = array( |
|
24 | + 'status' => 'all', |
|
25 | + 'number' => -1, |
|
26 | + 'count_total' => false, |
|
27 | + 'fields' => 'all', |
|
28 | + ); |
|
29 | + |
|
30 | + if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) { |
|
31 | + $query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
32 | + } |
|
33 | + |
|
34 | + $date_query = array(); |
|
35 | + if ( ! empty( $args['to_date'] ) ) { |
|
36 | + $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
37 | + } |
|
38 | + |
|
39 | + if ( ! empty( $args['from_date'] ) ) { |
|
40 | + $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
41 | + } |
|
42 | + |
|
43 | + if ( ! empty( $date_query ) ) { |
|
44 | + $date_query['inclusive'] = true; |
|
45 | + $query_args['date_created_query'] = array( $date_query ); |
|
46 | + } |
|
47 | + |
|
48 | + return $query_args; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Retrieves subscriptions. |
|
53 | + * |
|
54 | + * @param array $query_args GetPaid_Subscriptions_Query args. |
|
55 | + * @return WPInv_Subscription[] |
|
56 | + */ |
|
57 | + public function get_subscriptions( $query_args ) { |
|
58 | + |
|
59 | + // Get subscriptions. |
|
60 | + $subscriptions = new GetPaid_Subscriptions_Query( $query_args ); |
|
61 | + |
|
62 | + // Prepare the results. |
|
63 | + return $subscriptions->get_results(); |
|
64 | + |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Handles the actual download. |
|
69 | + * |
|
70 | + */ |
|
71 | + public function export( $post_type, $args ) { |
|
72 | + |
|
73 | + $subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) ); |
|
74 | + $stream = $this->prepare_output(); |
|
75 | + $headers = $this->get_export_fields(); |
|
76 | + $file_type = $this->prepare_file_type( 'subscriptions' ); |
|
77 | + |
|
78 | + if ( 'csv' == $file_type ) { |
|
79 | + $this->download_csv( $subscriptions, $stream, $headers ); |
|
80 | + } else if( 'xml' == $file_type ) { |
|
81 | + $this->download_xml( $subscriptions, $stream, $headers ); |
|
82 | + } else { |
|
83 | + $this->download_json( $subscriptions, $stream, $headers ); |
|
84 | + } |
|
85 | + |
|
86 | + fclose( $stream ); |
|
87 | + exit; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Prepares a single subscription for download. |
|
92 | + * |
|
93 | + * @param WPInv_Subscription $subscription The subscription to prepare.. |
|
94 | + * @param array $fields The fields to stream. |
|
95 | + * @since 1.0.19 |
|
96 | + * @return array |
|
97 | + */ |
|
98 | + public function prepare_row( $subscription, $fields ) { |
|
99 | + |
|
100 | + $prepared = array(); |
|
101 | + $amount_fields = $this->get_amount_fields(); |
|
102 | + $invoice = $subscription->get_parent_payment(); |
|
103 | + |
|
104 | + foreach ( $fields as $field ) { |
|
105 | + |
|
106 | + $value = ''; |
|
107 | + $method = "get_$field"; |
|
108 | + |
|
109 | + if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) { |
|
110 | + |
|
111 | + if ( method_exists( $invoice, $method ) ) { |
|
112 | + $value = $invoice->$method(); |
|
113 | + } |
|
114 | + |
|
115 | + } else if ( method_exists( $subscription, $method ) ) { |
|
116 | + $value = $subscription->$method(); |
|
117 | + } |
|
118 | + |
|
119 | + if ( in_array( $field, $amount_fields ) ) { |
|
120 | + $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
121 | + } |
|
122 | + |
|
123 | + $prepared[ $field ] = wpinv_clean( $value ); |
|
124 | + |
|
125 | + } |
|
126 | + |
|
127 | + return $prepared; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Retrieves export fields. |
|
132 | + * |
|
133 | + * @since 1.0.19 |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function get_export_fields() { |
|
137 | + |
|
138 | + $fields = array( |
|
139 | + 'id', |
|
140 | + 'currency', |
|
141 | + 'initial_amount', |
|
142 | + 'recurring_amount', |
|
143 | + 'trial_period', |
|
144 | + 'frequency', |
|
145 | + 'period', |
|
146 | + 'bill_times', |
|
147 | + 'parent_payment_id', |
|
148 | + 'profile_id', |
|
149 | + 'product_id', |
|
150 | + 'status', |
|
151 | + 'date_created', |
|
152 | + 'date_expires', |
|
153 | + |
|
154 | + 'customer_id', |
|
155 | + 'customer_first_name', |
|
156 | + 'customer_last_name', |
|
157 | + 'customer_phone', |
|
158 | + 'customer_email', |
|
159 | + 'customer_country', |
|
160 | + 'customer_city', |
|
161 | + 'customer_state', |
|
162 | + 'customer_zip', |
|
163 | + 'customer_company', |
|
164 | + 'customer_vat_number', |
|
165 | + 'customer_address', |
|
166 | + |
|
167 | + ); |
|
168 | + |
|
169 | + return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields ); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Retrieves amount fields. |
|
174 | + * |
|
175 | + * @since 1.0.19 |
|
176 | + * @return array |
|
177 | + */ |
|
178 | + public function get_amount_fields() { |
|
179 | + |
|
180 | + $fields = array( |
|
181 | + 'initial_amount', |
|
182 | + 'recurring_amount' |
|
183 | + ); |
|
184 | + |
|
185 | + return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields ); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Subscription_Exporter Class. |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param array $args Args to search for. |
19 | 19 | * @return array |
20 | 20 | */ |
21 | - public function get_subscription_query_args( $args ) { |
|
21 | + public function get_subscription_query_args($args) { |
|
22 | 22 | |
23 | 23 | $query_args = array( |
24 | 24 | 'status' => 'all', |
@@ -27,22 +27,22 @@ discard block |
||
27 | 27 | 'fields' => 'all', |
28 | 28 | ); |
29 | 29 | |
30 | - if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) { |
|
31 | - $query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
30 | + if (!empty($args['status']) && in_array($args['status'], array_keys(getpaid_get_subscription_statuses()), true)) { |
|
31 | + $query_args['status'] = wpinv_clean(wpinv_parse_list($args['status'])); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | $date_query = array(); |
35 | - if ( ! empty( $args['to_date'] ) ) { |
|
36 | - $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
35 | + if (!empty($args['to_date'])) { |
|
36 | + $date_query['before'] = wpinv_clean($args['to_date']); |
|
37 | 37 | } |
38 | 38 | |
39 | - if ( ! empty( $args['from_date'] ) ) { |
|
40 | - $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
39 | + if (!empty($args['from_date'])) { |
|
40 | + $date_query['after'] = wpinv_clean($args['from_date']); |
|
41 | 41 | } |
42 | 42 | |
43 | - if ( ! empty( $date_query ) ) { |
|
43 | + if (!empty($date_query)) { |
|
44 | 44 | $date_query['inclusive'] = true; |
45 | - $query_args['date_created_query'] = array( $date_query ); |
|
45 | + $query_args['date_created_query'] = array($date_query); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return $query_args; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * @param array $query_args GetPaid_Subscriptions_Query args. |
55 | 55 | * @return WPInv_Subscription[] |
56 | 56 | */ |
57 | - public function get_subscriptions( $query_args ) { |
|
57 | + public function get_subscriptions($query_args) { |
|
58 | 58 | |
59 | 59 | // Get subscriptions. |
60 | - $subscriptions = new GetPaid_Subscriptions_Query( $query_args ); |
|
60 | + $subscriptions = new GetPaid_Subscriptions_Query($query_args); |
|
61 | 61 | |
62 | 62 | // Prepare the results. |
63 | 63 | return $subscriptions->get_results(); |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | * Handles the actual download. |
69 | 69 | * |
70 | 70 | */ |
71 | - public function export( $post_type, $args ) { |
|
71 | + public function export($post_type, $args) { |
|
72 | 72 | |
73 | - $subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) ); |
|
73 | + $subscriptions = $this->get_subscriptions($this->get_subscription_query_args($args)); |
|
74 | 74 | $stream = $this->prepare_output(); |
75 | 75 | $headers = $this->get_export_fields(); |
76 | - $file_type = $this->prepare_file_type( 'subscriptions' ); |
|
76 | + $file_type = $this->prepare_file_type('subscriptions'); |
|
77 | 77 | |
78 | - if ( 'csv' == $file_type ) { |
|
79 | - $this->download_csv( $subscriptions, $stream, $headers ); |
|
80 | - } else if( 'xml' == $file_type ) { |
|
81 | - $this->download_xml( $subscriptions, $stream, $headers ); |
|
78 | + if ('csv' == $file_type) { |
|
79 | + $this->download_csv($subscriptions, $stream, $headers); |
|
80 | + } else if ('xml' == $file_type) { |
|
81 | + $this->download_xml($subscriptions, $stream, $headers); |
|
82 | 82 | } else { |
83 | - $this->download_json( $subscriptions, $stream, $headers ); |
|
83 | + $this->download_json($subscriptions, $stream, $headers); |
|
84 | 84 | } |
85 | 85 | |
86 | - fclose( $stream ); |
|
86 | + fclose($stream); |
|
87 | 87 | exit; |
88 | 88 | } |
89 | 89 | |
@@ -95,32 +95,32 @@ discard block |
||
95 | 95 | * @since 1.0.19 |
96 | 96 | * @return array |
97 | 97 | */ |
98 | - public function prepare_row( $subscription, $fields ) { |
|
98 | + public function prepare_row($subscription, $fields) { |
|
99 | 99 | |
100 | 100 | $prepared = array(); |
101 | 101 | $amount_fields = $this->get_amount_fields(); |
102 | 102 | $invoice = $subscription->get_parent_payment(); |
103 | 103 | |
104 | - foreach ( $fields as $field ) { |
|
104 | + foreach ($fields as $field) { |
|
105 | 105 | |
106 | 106 | $value = ''; |
107 | 107 | $method = "get_$field"; |
108 | 108 | |
109 | - if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) { |
|
109 | + if (0 === stripos($field, 'customer') || 'currency' === $field) { |
|
110 | 110 | |
111 | - if ( method_exists( $invoice, $method ) ) { |
|
112 | - $value = $invoice->$method(); |
|
111 | + if (method_exists($invoice, $method)) { |
|
112 | + $value = $invoice->$method(); |
|
113 | 113 | } |
114 | 114 | |
115 | - } else if ( method_exists( $subscription, $method ) ) { |
|
116 | - $value = $subscription->$method(); |
|
115 | + } else if (method_exists($subscription, $method)) { |
|
116 | + $value = $subscription->$method(); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( in_array( $field, $amount_fields ) ) { |
|
120 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
119 | + if (in_array($field, $amount_fields)) { |
|
120 | + $value = wpinv_round_amount(wpinv_sanitize_amount($value)); |
|
121 | 121 | } |
122 | 122 | |
123 | - $prepared[ $field ] = wpinv_clean( $value ); |
|
123 | + $prepared[$field] = wpinv_clean($value); |
|
124 | 124 | |
125 | 125 | } |
126 | 126 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | ); |
168 | 168 | |
169 | - return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields ); |
|
169 | + return apply_filters('getpaid_subscription_exporter_get_fields', $fields); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'recurring_amount' |
183 | 183 | ); |
184 | 184 | |
185 | - return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields ); |
|
185 | + return apply_filters('getpaid_subscription_exporter_get_amount_fields', $fields); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
@@ -12,49 +12,49 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports { |
14 | 14 | |
15 | - /** |
|
16 | - * Class constructor. |
|
17 | - * |
|
18 | - */ |
|
19 | - public function __construct() { |
|
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | - |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Registers the reports page. |
|
30 | - * |
|
31 | - */ |
|
32 | - public function register_reports_page() { |
|
33 | - |
|
34 | - add_submenu_page( |
|
15 | + /** |
|
16 | + * Class constructor. |
|
17 | + * |
|
18 | + */ |
|
19 | + public function __construct() { |
|
20 | + add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | + add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | + add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | + add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | + add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | + |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Registers the reports page. |
|
30 | + * |
|
31 | + */ |
|
32 | + public function register_reports_page() { |
|
33 | + |
|
34 | + add_submenu_page( |
|
35 | 35 | 'wpinv', |
36 | 36 | __( 'Reports', 'invoicing' ), |
37 | 37 | __( 'Reports', 'invoicing' ), |
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | 40 | array( $this, 'display_reports_page' ) |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Displays the reports page. |
|
47 | - * |
|
48 | - */ |
|
49 | - public function display_reports_page() { |
|
45 | + /** |
|
46 | + * Displays the reports page. |
|
47 | + * |
|
48 | + */ |
|
49 | + public function display_reports_page() { |
|
50 | 50 | |
51 | - // Prepare variables. |
|
52 | - $tabs = $this->get_tabs(); |
|
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
51 | + // Prepare variables. |
|
52 | + $tabs = $this->get_tabs(); |
|
53 | + $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | + $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | - // Display the current tab. |
|
57 | - ?> |
|
56 | + // Display the current tab. |
|
57 | + ?> |
|
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach( $tabs as $key => $label ) { |
|
66 | + foreach( $tabs as $key => $label ) { |
|
67 | 67 | |
68 | - $key = sanitize_text_field( $key ); |
|
69 | - $label = sanitize_text_field( $label ); |
|
70 | - $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | - $url = esc_url( |
|
72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
73 | - ); |
|
68 | + $key = sanitize_text_field( $key ); |
|
69 | + $label = sanitize_text_field( $label ); |
|
70 | + $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | + $url = esc_url( |
|
72 | + add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
73 | + ); |
|
74 | 74 | |
75 | - echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
75 | + echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
76 | 76 | |
77 | - } |
|
78 | - ?> |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
@@ -86,83 +86,83 @@ discard block |
||
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | - // Wordfence loads an unsupported version of chart js on our page. |
|
90 | - wp_deregister_style( 'chart-js' ); |
|
91 | - wp_deregister_script( 'chart-js' ); |
|
92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
93 | - wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
89 | + // Wordfence loads an unsupported version of chart js on our page. |
|
90 | + wp_deregister_style( 'chart-js' ); |
|
91 | + wp_deregister_script( 'chart-js' ); |
|
92 | + wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
93 | + wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
94 | 94 | |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Retrieves reports page tabs. |
|
99 | - * |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function get_tabs() { |
|
97 | + /** |
|
98 | + * Retrieves reports page tabs. |
|
99 | + * |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function get_tabs() { |
|
103 | 103 | |
104 | - $tabs = array( |
|
105 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
106 | - 'export' => __( 'Export', 'invoicing' ), |
|
107 | - ); |
|
104 | + $tabs = array( |
|
105 | + 'reports' => __( 'Reports', 'invoicing' ), |
|
106 | + 'export' => __( 'Export', 'invoicing' ), |
|
107 | + ); |
|
108 | 108 | |
109 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
110 | - } |
|
109 | + return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * Displays the reports tab. |
|
114 | - * |
|
115 | - */ |
|
116 | - public function display_reports_tab() { |
|
112 | + /** |
|
113 | + * Displays the reports tab. |
|
114 | + * |
|
115 | + */ |
|
116 | + public function display_reports_tab() { |
|
117 | 117 | |
118 | - $reports = new GetPaid_Reports_Report(); |
|
119 | - $reports->display(); |
|
118 | + $reports = new GetPaid_Reports_Report(); |
|
119 | + $reports->display(); |
|
120 | 120 | |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Displays the exports tab. |
|
125 | - * |
|
126 | - */ |
|
127 | - public function display_exports_tab() { |
|
123 | + /** |
|
124 | + * Displays the exports tab. |
|
125 | + * |
|
126 | + */ |
|
127 | + public function display_exports_tab() { |
|
128 | 128 | |
129 | - $exports = new GetPaid_Reports_Export(); |
|
130 | - $exports->display(); |
|
129 | + $exports = new GetPaid_Reports_Export(); |
|
130 | + $exports->display(); |
|
131 | 131 | |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * Donwnloads a graph. |
|
136 | - * |
|
137 | - * @param array $args |
|
138 | - */ |
|
139 | - public function download_graph( $args ) { |
|
134 | + /** |
|
135 | + * Donwnloads a graph. |
|
136 | + * |
|
137 | + * @param array $args |
|
138 | + */ |
|
139 | + public function download_graph( $args ) { |
|
140 | 140 | |
141 | - if ( ! empty( $args['graph'] ) ) { |
|
142 | - $downloader = new GetPaid_Graph_Downloader(); |
|
143 | - $downloader->download( $args['graph'] ); |
|
144 | - } |
|
141 | + if ( ! empty( $args['graph'] ) ) { |
|
142 | + $downloader = new GetPaid_Graph_Downloader(); |
|
143 | + $downloader->download( $args['graph'] ); |
|
144 | + } |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Exports invoices. |
|
150 | - * |
|
151 | - * @param array $args |
|
152 | - */ |
|
153 | - public function export_invoices( $args ) { |
|
148 | + /** |
|
149 | + * Exports invoices. |
|
150 | + * |
|
151 | + * @param array $args |
|
152 | + */ |
|
153 | + public function export_invoices( $args ) { |
|
154 | 154 | |
155 | - if ( ! empty( $args['post_type'] ) ) { |
|
155 | + if ( ! empty( $args['post_type'] ) ) { |
|
156 | 156 | |
157 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
158 | - $downloader = new GetPaid_Subscription_Exporter(); |
|
159 | - } else { |
|
160 | - $downloader = new GetPaid_Invoice_Exporter(); |
|
161 | - } |
|
157 | + if ( 'subscriptions' === $args['post_type'] ) { |
|
158 | + $downloader = new GetPaid_Subscription_Exporter(); |
|
159 | + } else { |
|
160 | + $downloader = new GetPaid_Invoice_Exporter(); |
|
161 | + } |
|
162 | 162 | |
163 | - $downloader->export( $args['post_type'], $args ); |
|
164 | - } |
|
163 | + $downloader->export( $args['post_type'], $args ); |
|
164 | + } |
|
165 | 165 | |
166 | - } |
|
166 | + } |
|
167 | 167 | |
168 | 168 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports Class. |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | * |
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
20 | + add_action('admin_menu', array($this, 'register_reports_page'), 20); |
|
21 | + add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab')); |
|
22 | + add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab')); |
|
23 | + add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph')); |
|
24 | + add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices')); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | add_submenu_page( |
35 | 35 | 'wpinv', |
36 | - __( 'Reports', 'invoicing' ), |
|
37 | - __( 'Reports', 'invoicing' ), |
|
36 | + __('Reports', 'invoicing'), |
|
37 | + __('Reports', 'invoicing'), |
|
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | - array( $this, 'display_reports_page' ) |
|
40 | + array($this, 'display_reports_page') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | } |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | |
51 | 51 | // Prepare variables. |
52 | 52 | $tabs = $this->get_tabs(); |
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
53 | + $current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports'; |
|
54 | + $current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | 56 | // Display the current tab. |
57 | 57 | ?> |
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
61 | - <h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1> |
|
61 | + <h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1> |
|
62 | 62 | |
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach( $tabs as $key => $label ) { |
|
66 | + foreach ($tabs as $key => $label) { |
|
67 | 67 | |
68 | - $key = sanitize_text_field( $key ); |
|
69 | - $label = sanitize_text_field( $label ); |
|
68 | + $key = sanitize_text_field($key); |
|
69 | + $label = sanitize_text_field($label); |
|
70 | 70 | $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
71 | 71 | $url = esc_url( |
72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
72 | + add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports')) |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
82 | - <div class="bsui <?php echo esc_attr( $current_tab ); ?>"> |
|
83 | - <?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?> |
|
82 | + <div class="bsui <?php echo esc_attr($current_tab); ?>"> |
|
83 | + <?php do_action("wpinv_reports_tab_{$current_tab}"); ?> |
|
84 | 84 | </div> |
85 | 85 | |
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | 89 | // Wordfence loads an unsupported version of chart js on our page. |
90 | - wp_deregister_style( 'chart-js' ); |
|
91 | - wp_deregister_script( 'chart-js' ); |
|
92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
93 | - wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
90 | + wp_deregister_style('chart-js'); |
|
91 | + wp_deregister_script('chart-js'); |
|
92 | + wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array('jquery'), '2.9.4', true); |
|
93 | + wp_enqueue_style('chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4'); |
|
94 | 94 | |
95 | 95 | } |
96 | 96 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | public function get_tabs() { |
103 | 103 | |
104 | 104 | $tabs = array( |
105 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
106 | - 'export' => __( 'Export', 'invoicing' ), |
|
105 | + 'reports' => __('Reports', 'invoicing'), |
|
106 | + 'export' => __('Export', 'invoicing'), |
|
107 | 107 | ); |
108 | 108 | |
109 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
109 | + return apply_filters('getpaid_report_tabs', $tabs); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @param array $args |
138 | 138 | */ |
139 | - public function download_graph( $args ) { |
|
139 | + public function download_graph($args) { |
|
140 | 140 | |
141 | - if ( ! empty( $args['graph'] ) ) { |
|
141 | + if (!empty($args['graph'])) { |
|
142 | 142 | $downloader = new GetPaid_Graph_Downloader(); |
143 | - $downloader->download( $args['graph'] ); |
|
143 | + $downloader->download($args['graph']); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param array $args |
152 | 152 | */ |
153 | - public function export_invoices( $args ) { |
|
153 | + public function export_invoices($args) { |
|
154 | 154 | |
155 | - if ( ! empty( $args['post_type'] ) ) { |
|
155 | + if (!empty($args['post_type'])) { |
|
156 | 156 | |
157 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
157 | + if ('subscriptions' === $args['post_type']) { |
|
158 | 158 | $downloader = new GetPaid_Subscription_Exporter(); |
159 | 159 | } else { |
160 | 160 | $downloader = new GetPaid_Invoice_Exporter(); |
161 | 161 | } |
162 | 162 | |
163 | - $downloader->export( $args['post_type'], $args ); |
|
163 | + $downloader->export($args['post_type'], $args); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } |