@@ -12,88 +12,88 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports_Report { |
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - public $views; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + public $views; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function __construct() { |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | 25 | |
26 | - $this->views = array( |
|
26 | + $this->views = array( |
|
27 | 27 | |
28 | 28 | 'items' => array( |
29 | - 'label' => __( 'Items', 'invoicing' ), |
|
30 | - 'class' => 'GetPaid_Reports_Report_Items', |
|
31 | - ), |
|
29 | + 'label' => __( 'Items', 'invoicing' ), |
|
30 | + 'class' => 'GetPaid_Reports_Report_Items', |
|
31 | + ), |
|
32 | 32 | |
33 | - 'gateways' => array( |
|
34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
35 | - 'class' => 'GetPaid_Reports_Report_Gateways', |
|
36 | - ), |
|
33 | + 'gateways' => array( |
|
34 | + 'label' => __( 'Payment Methods', 'invoicing' ), |
|
35 | + 'class' => 'GetPaid_Reports_Report_Gateways', |
|
36 | + ), |
|
37 | 37 | |
38 | - 'discounts' => array( |
|
39 | - 'label' => __( 'Discount Codes', 'invoicing' ), |
|
40 | - 'class' => 'GetPaid_Reports_Report_Discounts', |
|
41 | - ), |
|
38 | + 'discounts' => array( |
|
39 | + 'label' => __( 'Discount Codes', 'invoicing' ), |
|
40 | + 'class' => 'GetPaid_Reports_Report_Discounts', |
|
41 | + ), |
|
42 | 42 | |
43 | 43 | ); |
44 | 44 | |
45 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
46 | - |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Retrieves the current range. |
|
51 | - * |
|
52 | - */ |
|
53 | - public function get_range() { |
|
54 | - $valid_ranges = $this->get_periods(); |
|
55 | - |
|
56 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
57 | - return sanitize_key( $_GET['date_range'] ); |
|
58 | - } |
|
59 | - |
|
60 | - return '7_days'; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Returns an array of date ranges. |
|
65 | - * |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function get_periods() { |
|
69 | - |
|
70 | - $periods = array( |
|
71 | - 'today' => __( 'Today', 'invoicing' ), |
|
72 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
73 | - 'week' => __( 'This week', 'invoicing' ), |
|
74 | - 'last_week' => __( 'Last week', 'invoicing' ), |
|
75 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
76 | - 'month' => __( 'This month', 'invoicing' ), |
|
77 | - 'last_month' => __( 'Last month', 'invoicing' ), |
|
78 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
79 | - 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
80 | - 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
81 | - 'year' => __( 'This year', 'invoicing' ), |
|
82 | - 'last_year' => __( 'Last Year', 'invoicing' ), |
|
83 | - 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
84 | - ); |
|
85 | - |
|
86 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Displays the range selector. |
|
91 | - * |
|
92 | - */ |
|
93 | - public function display_range_selector() { |
|
94 | - |
|
95 | - $range = $this->get_range(); |
|
96 | - ?> |
|
45 | + $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
46 | + |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Retrieves the current range. |
|
51 | + * |
|
52 | + */ |
|
53 | + public function get_range() { |
|
54 | + $valid_ranges = $this->get_periods(); |
|
55 | + |
|
56 | + if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
57 | + return sanitize_key( $_GET['date_range'] ); |
|
58 | + } |
|
59 | + |
|
60 | + return '7_days'; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Returns an array of date ranges. |
|
65 | + * |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function get_periods() { |
|
69 | + |
|
70 | + $periods = array( |
|
71 | + 'today' => __( 'Today', 'invoicing' ), |
|
72 | + 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
73 | + 'week' => __( 'This week', 'invoicing' ), |
|
74 | + 'last_week' => __( 'Last week', 'invoicing' ), |
|
75 | + '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
76 | + 'month' => __( 'This month', 'invoicing' ), |
|
77 | + 'last_month' => __( 'Last month', 'invoicing' ), |
|
78 | + '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
79 | + 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
80 | + 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
81 | + 'year' => __( 'This year', 'invoicing' ), |
|
82 | + 'last_year' => __( 'Last Year', 'invoicing' ), |
|
83 | + 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
84 | + ); |
|
85 | + |
|
86 | + return apply_filters( 'getpaid_earning_periods', $periods ); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Displays the range selector. |
|
91 | + * |
|
92 | + */ |
|
93 | + public function display_range_selector() { |
|
94 | + |
|
95 | + $range = $this->get_range(); |
|
96 | + ?> |
|
97 | 97 | |
98 | 98 | <form method="get" class="getpaid-filter-earnings float-right"> |
99 | 99 | <?php getpaid_hidden_field( 'page', isset( $_GET['page'] ) ? wpinv_clean( $_GET['page'] ) : 'wpinv-reports' ); ?> |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | </form> |
116 | 116 | |
117 | 117 | <?php |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Displays the reports tab. |
|
122 | - * |
|
123 | - */ |
|
124 | - public function display() { |
|
125 | - ?> |
|
120 | + /** |
|
121 | + * Displays the reports tab. |
|
122 | + * |
|
123 | + */ |
|
124 | + public function display() { |
|
125 | + ?> |
|
126 | 126 | |
127 | 127 | <div class="mt-4"> |
128 | 128 | |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | |
203 | 203 | <?php |
204 | 204 | |
205 | - } |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Displays the left side. |
|
209 | - * |
|
210 | - */ |
|
211 | - public function display_left() { |
|
212 | - $graphs = wpinv_get_report_graphs(); |
|
207 | + /** |
|
208 | + * Displays the left side. |
|
209 | + * |
|
210 | + */ |
|
211 | + public function display_left() { |
|
212 | + $graphs = wpinv_get_report_graphs(); |
|
213 | 213 | |
214 | - ?> |
|
214 | + ?> |
|
215 | 215 | |
216 | 216 | <?php foreach ( $graphs as $key => $graph ) : ?> |
217 | 217 | <div class="row mb-4"> |
@@ -230,35 +230,35 @@ discard block |
||
230 | 230 | |
231 | 231 | <?php |
232 | 232 | |
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Retrieves the download url. |
|
237 | - * |
|
238 | - */ |
|
239 | - public function get_download_url( $graph, $file_type ) { |
|
240 | - |
|
241 | - return wp_nonce_url( |
|
242 | - add_query_arg( |
|
243 | - array( |
|
244 | - 'getpaid-admin-action' => 'download_graph', |
|
245 | - 'file_type' => urlencode( $file_type ), |
|
246 | - 'graph' => urlencode( $graph ), |
|
247 | - ) |
|
248 | - ), |
|
249 | - 'getpaid-nonce', |
|
250 | - 'getpaid-nonce' |
|
251 | - ); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Retrieves the download url. |
|
237 | + * |
|
238 | + */ |
|
239 | + public function get_download_url( $graph, $file_type ) { |
|
240 | + |
|
241 | + return wp_nonce_url( |
|
242 | + add_query_arg( |
|
243 | + array( |
|
244 | + 'getpaid-admin-action' => 'download_graph', |
|
245 | + 'file_type' => urlencode( $file_type ), |
|
246 | + 'graph' => urlencode( $graph ), |
|
247 | + ) |
|
248 | + ), |
|
249 | + 'getpaid-nonce', |
|
250 | + 'getpaid-nonce' |
|
251 | + ); |
|
252 | 252 | |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - /** |
|
256 | - * Displays the right side. |
|
257 | - * |
|
258 | - */ |
|
259 | - public function display_right() { |
|
255 | + /** |
|
256 | + * Displays the right side. |
|
257 | + * |
|
258 | + */ |
|
259 | + public function display_right() { |
|
260 | 260 | |
261 | - ?> |
|
261 | + ?> |
|
262 | 262 | |
263 | 263 | <?php foreach ( $this->views as $key => $view ) : ?> |
264 | 264 | <div class="row mb-4"> |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | </div> |
288 | 288 | <div class="card-body"> |
289 | 289 | <?php |
290 | - $class = $view['class']; |
|
291 | - $class = new $class(); |
|
292 | - $class->display_stats(); |
|
293 | - ?> |
|
290 | + $class = $view['class']; |
|
291 | + $class = new $class(); |
|
292 | + $class->display_stats(); |
|
293 | + ?> |
|
294 | 294 | </div> |
295 | 295 | </div> |
296 | 296 | </div> |
@@ -299,68 +299,68 @@ discard block |
||
299 | 299 | |
300 | 300 | <?php |
301 | 301 | |
302 | - do_action( 'getpaid_reports_display_right', $this ); |
|
303 | - } |
|
304 | - |
|
305 | - /** |
|
306 | - * Returns a list of report cards. |
|
307 | - * |
|
308 | - */ |
|
309 | - public function get_cards() { |
|
310 | - |
|
311 | - $cards = array( |
|
312 | - 'total_sales' => array( |
|
313 | - 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
314 | - 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
315 | - ), |
|
316 | - 'net_sales' => array( |
|
317 | - 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
318 | - 'label' => __( 'Net Revenue', 'invoicing' ), |
|
319 | - ), |
|
320 | - 'average_sales' => array( |
|
321 | - 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
322 | - 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
323 | - ), |
|
324 | - 'average_total_sales' => array( |
|
325 | - 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
326 | - 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
327 | - ), |
|
328 | - 'total_invoices' => array( |
|
329 | - 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
330 | - 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
331 | - ), |
|
332 | - 'total_items' => array( |
|
333 | - 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
334 | - 'label' => __( 'Purchased Items', 'invoicing' ), |
|
335 | - ), |
|
336 | - 'refunded_items' => array( |
|
337 | - 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
338 | - 'label' => __( 'Refunded Items', 'invoicing' ), |
|
339 | - ), |
|
340 | - 'total_tax' => array( |
|
341 | - 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
342 | - 'label' => __( 'Tax', 'invoicing' ), |
|
343 | - ), |
|
344 | - 'total_refunded_tax' => array( |
|
345 | - 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
346 | - 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
347 | - ), |
|
348 | - 'total_fees' => array( |
|
349 | - 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
350 | - 'label' => __( 'Fees', 'invoicing' ), |
|
351 | - ), |
|
352 | - 'total_refunds' => array( |
|
353 | - 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
354 | - 'label' => __( 'Refunded', 'invoicing' ), |
|
355 | - ), |
|
356 | - 'total_discount' => array( |
|
357 | - 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
358 | - 'label' => __( 'Discounted', 'invoicing' ), |
|
359 | - ), |
|
360 | - ); |
|
361 | - |
|
362 | - return apply_filters( 'wpinv_report_cards', $cards ); |
|
363 | - } |
|
302 | + do_action( 'getpaid_reports_display_right', $this ); |
|
303 | + } |
|
304 | + |
|
305 | + /** |
|
306 | + * Returns a list of report cards. |
|
307 | + * |
|
308 | + */ |
|
309 | + public function get_cards() { |
|
310 | + |
|
311 | + $cards = array( |
|
312 | + 'total_sales' => array( |
|
313 | + 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
314 | + 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
315 | + ), |
|
316 | + 'net_sales' => array( |
|
317 | + 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
318 | + 'label' => __( 'Net Revenue', 'invoicing' ), |
|
319 | + ), |
|
320 | + 'average_sales' => array( |
|
321 | + 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
322 | + 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
323 | + ), |
|
324 | + 'average_total_sales' => array( |
|
325 | + 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
326 | + 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
327 | + ), |
|
328 | + 'total_invoices' => array( |
|
329 | + 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
330 | + 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
331 | + ), |
|
332 | + 'total_items' => array( |
|
333 | + 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
334 | + 'label' => __( 'Purchased Items', 'invoicing' ), |
|
335 | + ), |
|
336 | + 'refunded_items' => array( |
|
337 | + 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
338 | + 'label' => __( 'Refunded Items', 'invoicing' ), |
|
339 | + ), |
|
340 | + 'total_tax' => array( |
|
341 | + 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
342 | + 'label' => __( 'Tax', 'invoicing' ), |
|
343 | + ), |
|
344 | + 'total_refunded_tax' => array( |
|
345 | + 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
346 | + 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
347 | + ), |
|
348 | + 'total_fees' => array( |
|
349 | + 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
350 | + 'label' => __( 'Fees', 'invoicing' ), |
|
351 | + ), |
|
352 | + 'total_refunds' => array( |
|
353 | + 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
354 | + 'label' => __( 'Refunded', 'invoicing' ), |
|
355 | + ), |
|
356 | + 'total_discount' => array( |
|
357 | + 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
358 | + 'label' => __( 'Discounted', 'invoicing' ), |
|
359 | + ), |
|
360 | + ); |
|
361 | + |
|
362 | + return apply_filters( 'wpinv_report_cards', $cards ); |
|
363 | + } |
|
364 | 364 | |
365 | 365 | |
366 | 366 |
@@ -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_Report Class. |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | |
26 | - $this->views = array( |
|
26 | + $this->views = array( |
|
27 | 27 | |
28 | 28 | 'items' => array( |
29 | - 'label' => __( 'Items', 'invoicing' ), |
|
29 | + 'label' => __('Items', 'invoicing'), |
|
30 | 30 | 'class' => 'GetPaid_Reports_Report_Items', |
31 | 31 | ), |
32 | 32 | |
33 | 33 | 'gateways' => array( |
34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
34 | + 'label' => __('Payment Methods', 'invoicing'), |
|
35 | 35 | 'class' => 'GetPaid_Reports_Report_Gateways', |
36 | 36 | ), |
37 | 37 | |
38 | 38 | 'discounts' => array( |
39 | - 'label' => __( 'Discount Codes', 'invoicing' ), |
|
39 | + 'label' => __('Discount Codes', 'invoicing'), |
|
40 | 40 | 'class' => 'GetPaid_Reports_Report_Discounts', |
41 | 41 | ), |
42 | 42 | |
43 | 43 | ); |
44 | 44 | |
45 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
45 | + $this->views = apply_filters('wpinv_report_views', $this->views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | public function get_range() { |
54 | 54 | $valid_ranges = $this->get_periods(); |
55 | 55 | |
56 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
57 | - return sanitize_key( $_GET['date_range'] ); |
|
56 | + if (isset($_GET['date_range']) && array_key_exists($_GET['date_range'], $valid_ranges)) { |
|
57 | + return sanitize_key($_GET['date_range']); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return '7_days'; |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | public function get_periods() { |
69 | 69 | |
70 | 70 | $periods = array( |
71 | - 'today' => __( 'Today', 'invoicing' ), |
|
72 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
73 | - 'week' => __( 'This week', 'invoicing' ), |
|
74 | - 'last_week' => __( 'Last week', 'invoicing' ), |
|
75 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
76 | - 'month' => __( 'This month', 'invoicing' ), |
|
77 | - 'last_month' => __( 'Last month', 'invoicing' ), |
|
78 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
79 | - 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
80 | - 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
81 | - 'year' => __( 'This year', 'invoicing' ), |
|
82 | - 'last_year' => __( 'Last Year', 'invoicing' ), |
|
83 | - 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
71 | + 'today' => __('Today', 'invoicing'), |
|
72 | + 'yesterday' => __('Yesterday', 'invoicing'), |
|
73 | + 'week' => __('This week', 'invoicing'), |
|
74 | + 'last_week' => __('Last week', 'invoicing'), |
|
75 | + '7_days' => __('Last 7 days', 'invoicing'), |
|
76 | + 'month' => __('This month', 'invoicing'), |
|
77 | + 'last_month' => __('Last month', 'invoicing'), |
|
78 | + '30_days' => __('Last 30 days', 'invoicing'), |
|
79 | + 'quarter' => __('This Quarter', 'invoicing'), |
|
80 | + 'last_quarter' => __('Last Quarter', 'invoicing'), |
|
81 | + 'year' => __('This year', 'invoicing'), |
|
82 | + 'last_year' => __('Last Year', 'invoicing'), |
|
83 | + 'custom' => __('Custom Date Range', 'invoicing'), |
|
84 | 84 | ); |
85 | 85 | |
86 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
86 | + return apply_filters('getpaid_earning_periods', $periods); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -96,21 +96,21 @@ discard block |
||
96 | 96 | ?> |
97 | 97 | |
98 | 98 | <form method="get" class="getpaid-filter-earnings float-right"> |
99 | - <?php getpaid_hidden_field( 'page', isset( $_GET['page'] ) ? wpinv_clean( $_GET['page'] ) : 'wpinv-reports' ); ?> |
|
100 | - <?php getpaid_hidden_field( 'tab', 'reports' ); ?> |
|
99 | + <?php getpaid_hidden_field('page', isset($_GET['page']) ? wpinv_clean($_GET['page']) : 'wpinv-reports'); ?> |
|
100 | + <?php getpaid_hidden_field('tab', 'reports'); ?> |
|
101 | 101 | <select name='date_range'> |
102 | - <?php foreach( $this->get_periods() as $key => $label ) :?> |
|
103 | - <option value="<?php echo sanitize_key( $key ); ?>" <?php selected( $key, $range ); ?>><?php echo sanitize_text_field( $label ); ?></option> |
|
104 | - <?php endforeach;?> |
|
102 | + <?php foreach ($this->get_periods() as $key => $label) :?> |
|
103 | + <option value="<?php echo sanitize_key($key); ?>" <?php selected($key, $range); ?>><?php echo sanitize_text_field($label); ?></option> |
|
104 | + <?php endforeach; ?> |
|
105 | 105 | </select> |
106 | 106 | <span class="getpaid-date-range-picker <?php echo 'custom' == $range ? '' : 'd-none'; ?>"> |
107 | 107 | <input type="text" name="from" class="getpaid-from align-middle" /> |
108 | - <?php _e( 'to', 'invoicing' ); ?> |
|
108 | + <?php _e('to', 'invoicing'); ?> |
|
109 | 109 | <input type="text" name="to" class="getpaid-to align-middle" /> |
110 | 110 | </span> |
111 | 111 | <button type="submit" class="button button-primary"> |
112 | 112 | <i class="fa fa-chevron-right fa-lg"></i> |
113 | - <span class="screen-reader-text"><?php _e( 'View Reports', 'invoicing' ); ?></span> |
|
113 | + <span class="screen-reader-text"><?php _e('View Reports', 'invoicing'); ?></span> |
|
114 | 114 | </button> |
115 | 115 | </form> |
116 | 116 | |
@@ -159,17 +159,17 @@ discard block |
||
159 | 159 | |
160 | 160 | <div class="col-12 col-md-4"> |
161 | 161 | <div class="row getpaid-report-cards"> |
162 | - <?php foreach( $this->get_cards() as $key => $card ) : ?> |
|
162 | + <?php foreach ($this->get_cards() as $key => $card) : ?> |
|
163 | 163 | <div class="col-12 mb-4"> |
164 | 164 | |
165 | - <!-- <?php echo sanitize_text_field( $card['label'] ); ?> Card --> |
|
166 | - <div class="card p-0 m-0 shadow-none <?php echo sanitize_html_class( $key ); ?>"> |
|
165 | + <!-- <?php echo sanitize_text_field($card['label']); ?> Card --> |
|
166 | + <div class="card p-0 m-0 shadow-none <?php echo sanitize_html_class($key); ?>"> |
|
167 | 167 | |
168 | 168 | <div class="card-body"> |
169 | 169 | |
170 | 170 | <p class="getpaid-current text-uppercase small mb-2"> |
171 | - <strong><?php echo sanitize_text_field( $card['label'] ); ?></strong> |
|
172 | - <span title="<?php echo esc_attr( $card['description'] ); ?>" class="wpi-help-tip dashicons dashicons-editor-help text-muted" style="margin-top: -2px;"></span> |
|
171 | + <strong><?php echo sanitize_text_field($card['label']); ?></strong> |
|
172 | + <span title="<?php echo esc_attr($card['description']); ?>" class="wpi-help-tip dashicons dashicons-editor-help text-muted" style="margin-top: -2px;"></span> |
|
173 | 173 | </p> |
174 | 174 | <h5 class="font-weight-bold mb-0"> |
175 | 175 | <span class="getpaid-report-card-value"> |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | <hr> |
182 | 182 | |
183 | - <p class="getpaid-previous text-uppercase text-muted small mb-2"><strong><?php _e( 'Previous Period', 'invoicing' ); ?></strong></p> |
|
183 | + <p class="getpaid-previous text-uppercase text-muted small mb-2"><strong><?php _e('Previous Period', 'invoicing'); ?></strong></p> |
|
184 | 184 | <h5 class="getpaid-report-card-previous-value font-weight-bold text-muted mb-0"> |
185 | 185 | <span class="spinner is-active float-none"></span> |
186 | 186 | </h5> |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | </div> |
189 | 189 | |
190 | 190 | </div> |
191 | - <!-- <?php echo sanitize_text_field( $card['label'] ); ?> Card --> |
|
191 | + <!-- <?php echo sanitize_text_field($card['label']); ?> Card --> |
|
192 | 192 | |
193 | 193 | </div> |
194 | 194 | <?php endforeach; ?> |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | |
214 | 214 | ?> |
215 | 215 | |
216 | - <?php foreach ( $graphs as $key => $graph ) : ?> |
|
216 | + <?php foreach ($graphs as $key => $graph) : ?> |
|
217 | 217 | <div class="row mb-4"> |
218 | 218 | <div class="col-12"> |
219 | 219 | <div class="card m-0 p-0 single-report-card" style="max-width:100%"> |
220 | 220 | <div class="card-header"> |
221 | - <strong><?php echo wpinv_clean( $graph ); ?></strong> |
|
221 | + <strong><?php echo wpinv_clean($graph); ?></strong> |
|
222 | 222 | </div> |
223 | 223 | <div class="card-body"> |
224 | - <canvas id="getpaid-chartjs-<?php echo sanitize_key( $key ); ?>"></canvas> |
|
224 | + <canvas id="getpaid-chartjs-<?php echo sanitize_key($key); ?>"></canvas> |
|
225 | 225 | </div> |
226 | 226 | </div> |
227 | 227 | </div> |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * Retrieves the download url. |
237 | 237 | * |
238 | 238 | */ |
239 | - public function get_download_url( $graph, $file_type ) { |
|
239 | + public function get_download_url($graph, $file_type) { |
|
240 | 240 | |
241 | 241 | return wp_nonce_url( |
242 | 242 | add_query_arg( |
243 | 243 | array( |
244 | 244 | 'getpaid-admin-action' => 'download_graph', |
245 | - 'file_type' => urlencode( $file_type ), |
|
246 | - 'graph' => urlencode( $graph ), |
|
245 | + 'file_type' => urlencode($file_type), |
|
246 | + 'graph' => urlencode($graph), |
|
247 | 247 | ) |
248 | 248 | ), |
249 | 249 | 'getpaid-nonce', |
@@ -260,27 +260,27 @@ discard block |
||
260 | 260 | |
261 | 261 | ?> |
262 | 262 | |
263 | - <?php foreach ( $this->views as $key => $view ) : ?> |
|
263 | + <?php foreach ($this->views as $key => $view) : ?> |
|
264 | 264 | <div class="row mb-4"> |
265 | 265 | <div class="col-12"> |
266 | 266 | <div class="card m-0 p-0" style="max-width:100%"> |
267 | 267 | <div class="card-header"> |
268 | 268 | <div class="row"> |
269 | - <div class="<?php echo empty( $view['disable-downloads'] ) ? 'col-9' : 'col-12'; ?>"> |
|
269 | + <div class="<?php echo empty($view['disable-downloads']) ? 'col-9' : 'col-12'; ?>"> |
|
270 | 270 | <strong><?php echo $view['label']; ?></strong> |
271 | 271 | </div> |
272 | - <div class="<?php echo empty( $view['disable-downloads'] ) ? 'col-3' : 'd-none'; ?>"> |
|
273 | - <a title="<?php esc_attr_e( 'Download JSON', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'json' ) ); ?>"> |
|
272 | + <div class="<?php echo empty($view['disable-downloads']) ? 'col-3' : 'd-none'; ?>"> |
|
273 | + <a title="<?php esc_attr_e('Download JSON', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'json')); ?>"> |
|
274 | 274 | <i class="fa fa-download text-dark" style="font-size: 16px" aria-hidden="true"></i> |
275 | - <span class="screen-reader-text"><?php _e( 'Download JSON', 'invoicing' ); ?></span> |
|
275 | + <span class="screen-reader-text"><?php _e('Download JSON', 'invoicing'); ?></span> |
|
276 | 276 | </a> |
277 | - <a title="<?php esc_attr_e( 'Download CSV', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'csv' ) ); ?>"> |
|
277 | + <a title="<?php esc_attr_e('Download CSV', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'csv')); ?>"> |
|
278 | 278 | <i class="fa fa-file-csv text-dark" style="font-size: 16px" aria-hidden="true"></i> |
279 | - <span class="screen-reader-text"><?php _e( 'Download CSV', 'invoicing' ); ?></span> |
|
279 | + <span class="screen-reader-text"><?php _e('Download CSV', 'invoicing'); ?></span> |
|
280 | 280 | </a> |
281 | - <a title="<?php esc_attr_e( 'Download XML', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'xml' ) ); ?>"> |
|
281 | + <a title="<?php esc_attr_e('Download XML', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'xml')); ?>"> |
|
282 | 282 | <i class="fa fa-file-code text-dark" style="font-size: 16px" aria-hidden="true"></i> |
283 | - <span class="screen-reader-text"><?php _e( 'Download XML', 'invoicing' ); ?></span> |
|
283 | + <span class="screen-reader-text"><?php _e('Download XML', 'invoicing'); ?></span> |
|
284 | 284 | </a> |
285 | 285 | </div> |
286 | 286 | </div> |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | <?php |
301 | 301 | |
302 | - do_action( 'getpaid_reports_display_right', $this ); |
|
302 | + do_action('getpaid_reports_display_right', $this); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -310,56 +310,56 @@ discard block |
||
310 | 310 | |
311 | 311 | $cards = array( |
312 | 312 | 'total_sales' => array( |
313 | - 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
314 | - 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
313 | + 'description' => __('Gross sales in the period.', 'invoicing'), |
|
314 | + 'label' => __('Gross Revenue', 'invoicing'), |
|
315 | 315 | ), |
316 | 316 | 'net_sales' => array( |
317 | - 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
318 | - 'label' => __( 'Net Revenue', 'invoicing' ), |
|
317 | + 'description' => __('Net sales in the period.', 'invoicing'), |
|
318 | + 'label' => __('Net Revenue', 'invoicing'), |
|
319 | 319 | ), |
320 | 320 | 'average_sales' => array( |
321 | - 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
322 | - 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
321 | + 'description' => __('Average net daily/monthly sales.', 'invoicing'), |
|
322 | + 'label' => __('Avg. Net Sales', 'invoicing'), |
|
323 | 323 | ), |
324 | 324 | 'average_total_sales' => array( |
325 | - 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
326 | - 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
325 | + 'description' => __('Average gross daily/monthly sales.', 'invoicing'), |
|
326 | + 'label' => __('Avg. Gross Sales', 'invoicing'), |
|
327 | 327 | ), |
328 | 328 | 'total_invoices' => array( |
329 | - 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
330 | - 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
329 | + 'description' => __('Number of paid invoices.', 'invoicing'), |
|
330 | + 'label' => __('Paid Invoices', 'invoicing'), |
|
331 | 331 | ), |
332 | 332 | 'total_items' => array( |
333 | - 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
334 | - 'label' => __( 'Purchased Items', 'invoicing' ), |
|
333 | + 'description' => __('Number of items purchased.', 'invoicing'), |
|
334 | + 'label' => __('Purchased Items', 'invoicing'), |
|
335 | 335 | ), |
336 | 336 | 'refunded_items' => array( |
337 | - 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
338 | - 'label' => __( 'Refunded Items', 'invoicing' ), |
|
337 | + 'description' => __('Number of items refunded.', 'invoicing'), |
|
338 | + 'label' => __('Refunded Items', 'invoicing'), |
|
339 | 339 | ), |
340 | 340 | 'total_tax' => array( |
341 | - 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
342 | - 'label' => __( 'Tax', 'invoicing' ), |
|
341 | + 'description' => __('Total charged for taxes.', 'invoicing'), |
|
342 | + 'label' => __('Tax', 'invoicing'), |
|
343 | 343 | ), |
344 | 344 | 'total_refunded_tax' => array( |
345 | - 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
346 | - 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
345 | + 'description' => __('Total refunded for taxes.', 'invoicing'), |
|
346 | + 'label' => __('Refunded Tax', 'invoicing'), |
|
347 | 347 | ), |
348 | 348 | 'total_fees' => array( |
349 | - 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
350 | - 'label' => __( 'Fees', 'invoicing' ), |
|
349 | + 'description' => __('Total fees charged.', 'invoicing'), |
|
350 | + 'label' => __('Fees', 'invoicing'), |
|
351 | 351 | ), |
352 | 352 | 'total_refunds' => array( |
353 | - 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
354 | - 'label' => __( 'Refunded', 'invoicing' ), |
|
353 | + 'description' => __('Total of refunded invoices.', 'invoicing'), |
|
354 | + 'label' => __('Refunded', 'invoicing'), |
|
355 | 355 | ), |
356 | 356 | 'total_discount' => array( |
357 | - 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
358 | - 'label' => __( 'Discounted', 'invoicing' ), |
|
357 | + 'description' => __('Total of discounts used.', 'invoicing'), |
|
358 | + 'label' => __('Discounted', 'invoicing'), |
|
359 | 359 | ), |
360 | 360 | ); |
361 | 361 | |
362 | - return apply_filters( 'wpinv_report_cards', $cards ); |
|
362 | + return apply_filters('wpinv_report_cards', $cards); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 |
@@ -12,69 +12,69 @@ discard block |
||
12 | 12 | */ |
13 | 13 | abstract class GetPaid_Reports_Abstract_Report { |
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - public $stats; |
|
19 | - |
|
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - $this->prepare_stats(); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Retrieves the current range. |
|
30 | - * |
|
31 | - */ |
|
32 | - public function get_range() { |
|
33 | - $valid_ranges = $this->get_periods(); |
|
34 | - |
|
35 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
36 | - return sanitize_key( $_GET['date_range'] ); |
|
37 | - } |
|
38 | - |
|
39 | - return '7_days'; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Returns an array of date ranges. |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function get_periods() { |
|
48 | - |
|
49 | - $periods = array( |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + public $stats; |
|
19 | + |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + $this->prepare_stats(); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Retrieves the current range. |
|
30 | + * |
|
31 | + */ |
|
32 | + public function get_range() { |
|
33 | + $valid_ranges = $this->get_periods(); |
|
34 | + |
|
35 | + if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
36 | + return sanitize_key( $_GET['date_range'] ); |
|
37 | + } |
|
38 | + |
|
39 | + return '7_days'; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Returns an array of date ranges. |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function get_periods() { |
|
48 | + |
|
49 | + $periods = array( |
|
50 | 50 | 'today' => __( 'Today', 'invoicing' ), |
51 | 51 | 'yesterday' => __( 'Yesterday', 'invoicing' ), |
52 | 52 | '7_days' => __( 'Last 7 days', 'invoicing' ), |
53 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
54 | - '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
55 | - '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
56 | - '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
57 | - '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
58 | - ); |
|
59 | - |
|
60 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Retrieves the current range's sql. |
|
65 | - * |
|
66 | - */ |
|
67 | - public function get_range_sql( $range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date' ) { |
|
53 | + '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
54 | + '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
55 | + '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
56 | + '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
57 | + '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
58 | + ); |
|
59 | + |
|
60 | + return apply_filters( 'getpaid_earning_periods', $periods ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Retrieves the current range's sql. |
|
65 | + * |
|
66 | + */ |
|
67 | + public function get_range_sql( $range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date' ) { |
|
68 | 68 | |
69 | 69 | // Prepare durations. |
70 | 70 | $today = current_time( 'Y-m-d' ); |
71 | - $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
72 | - $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
73 | - $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
74 | - $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
75 | - $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
76 | - $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
77 | - $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
71 | + $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
72 | + $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
73 | + $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
74 | + $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
75 | + $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
76 | + $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
77 | + $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
78 | 78 | |
79 | 79 | $ranges = array( |
80 | 80 | |
@@ -91,130 +91,130 @@ discard block |
||
91 | 91 | '7_days' => array( |
92 | 92 | "DATE($datetime)", |
93 | 93 | "$date BETWEEN '$seven_days_ago' AND '$today'" |
94 | - ), |
|
94 | + ), |
|
95 | 95 | |
96 | - '30_days' => array( |
|
96 | + '30_days' => array( |
|
97 | 97 | "DATE($datetime)", |
98 | 98 | "$date BETWEEN '$thirty_days_ago' AND '$today'" |
99 | - ), |
|
99 | + ), |
|
100 | 100 | |
101 | - '60_days' => array( |
|
101 | + '60_days' => array( |
|
102 | 102 | "DATE($datetime)", |
103 | 103 | "$date BETWEEN '$sixty_days_ago' AND '$today'" |
104 | - ), |
|
104 | + ), |
|
105 | 105 | |
106 | - '90_days' => array( |
|
106 | + '90_days' => array( |
|
107 | 107 | "WEEK($datetime)", |
108 | 108 | "$date BETWEEN '$ninety_days_ago' AND '$today'" |
109 | - ), |
|
109 | + ), |
|
110 | 110 | |
111 | - '180_days' => array( |
|
111 | + '180_days' => array( |
|
112 | 112 | "WEEK($datetime)", |
113 | 113 | "$date BETWEEN '$one_eighty_days_ago' AND '$today'" |
114 | - ), |
|
114 | + ), |
|
115 | 115 | |
116 | - '360_days' => array( |
|
116 | + '360_days' => array( |
|
117 | 117 | "WEEK($datetime)", |
118 | 118 | "$date BETWEEN '$three_sixty_days_ago' AND '$today'" |
119 | 119 | ), |
120 | 120 | |
121 | 121 | ); |
122 | 122 | |
123 | - $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
124 | - return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
125 | - |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Retrieves the hours in a day |
|
130 | - * |
|
131 | - */ |
|
132 | - public function get_hours_in_a_day() { |
|
133 | - |
|
134 | - return array( |
|
135 | - '12AM' => __( '12 AM', 'invoicing'), |
|
136 | - '1AM' => __( '1 AM', 'invoicing'), |
|
137 | - '2AM' => __( '2 AM', 'invoicing'), |
|
138 | - '3AM' => __( '3 AM', 'invoicing'), |
|
139 | - '4AM' => __( '4 AM', 'invoicing'), |
|
140 | - '5AM' => __( '5 AM', 'invoicing'), |
|
141 | - '6AM' => __( '6 AM', 'invoicing'), |
|
142 | - '7AM' => __( '7 AM', 'invoicing'), |
|
143 | - '8AM' => __( '8 AM', 'invoicing'), |
|
144 | - '9AM' => __( '9 AM', 'invoicing'), |
|
145 | - '10AM' => __( '10 AM', 'invoicing'), |
|
146 | - '11AM' => __( '11 AM', 'invoicing'), |
|
147 | - '12pm' => __( '12 PM', 'invoicing'), |
|
148 | - '1PM' => __( '1 PM', 'invoicing'), |
|
149 | - '2PM' => __( '2 PM', 'invoicing'), |
|
150 | - '3PM' => __( '3 PM', 'invoicing'), |
|
151 | - '4PM' => __( '4 PM', 'invoicing'), |
|
152 | - '5PM' => __( '5 PM', 'invoicing'), |
|
153 | - '6PM' => __( '6 PM', 'invoicing'), |
|
154 | - '7PM' => __( '7 PM', 'invoicing'), |
|
155 | - '8PM' => __( '8 PM', 'invoicing'), |
|
156 | - '9PM' => __( '9 PM', 'invoicing'), |
|
157 | - '10PM' => __( '10 PM', 'invoicing'), |
|
158 | - '11PM' => __( '11 PM', 'invoicing'), |
|
159 | - ); |
|
160 | - |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Retrieves the days in a period |
|
165 | - * |
|
166 | - */ |
|
167 | - public function get_days_in_period( $days ) { |
|
168 | - |
|
169 | - $return = array(); |
|
170 | - $format = 'Y-m-d'; |
|
171 | - |
|
172 | - if ( $days < 8 ) { |
|
173 | - $format = 'D'; |
|
174 | - } |
|
175 | - |
|
176 | - if ( $days < 32 ) { |
|
177 | - $format = 'M j'; |
|
178 | - } |
|
179 | - |
|
180 | - while ( $days > 0 ) { |
|
181 | - |
|
182 | - $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
183 | - $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
184 | - $return[ $key ] = $label; |
|
185 | - $days--; |
|
186 | - |
|
187 | - } |
|
188 | - |
|
189 | - return $return; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Retrieves the weeks in a period |
|
194 | - * |
|
195 | - */ |
|
196 | - public function get_weeks_in_period( $days ) { |
|
197 | - |
|
198 | - $return = array(); |
|
199 | - |
|
200 | - while ( $days > 0 ) { |
|
201 | - |
|
202 | - $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
203 | - $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
204 | - $return[ $key ] = $label; |
|
205 | - $days--; |
|
206 | - |
|
207 | - } |
|
208 | - |
|
209 | - return $return; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Displays the report card. |
|
214 | - * |
|
215 | - */ |
|
216 | - public function display() { |
|
217 | - ?> |
|
123 | + $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
124 | + return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
125 | + |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Retrieves the hours in a day |
|
130 | + * |
|
131 | + */ |
|
132 | + public function get_hours_in_a_day() { |
|
133 | + |
|
134 | + return array( |
|
135 | + '12AM' => __( '12 AM', 'invoicing'), |
|
136 | + '1AM' => __( '1 AM', 'invoicing'), |
|
137 | + '2AM' => __( '2 AM', 'invoicing'), |
|
138 | + '3AM' => __( '3 AM', 'invoicing'), |
|
139 | + '4AM' => __( '4 AM', 'invoicing'), |
|
140 | + '5AM' => __( '5 AM', 'invoicing'), |
|
141 | + '6AM' => __( '6 AM', 'invoicing'), |
|
142 | + '7AM' => __( '7 AM', 'invoicing'), |
|
143 | + '8AM' => __( '8 AM', 'invoicing'), |
|
144 | + '9AM' => __( '9 AM', 'invoicing'), |
|
145 | + '10AM' => __( '10 AM', 'invoicing'), |
|
146 | + '11AM' => __( '11 AM', 'invoicing'), |
|
147 | + '12pm' => __( '12 PM', 'invoicing'), |
|
148 | + '1PM' => __( '1 PM', 'invoicing'), |
|
149 | + '2PM' => __( '2 PM', 'invoicing'), |
|
150 | + '3PM' => __( '3 PM', 'invoicing'), |
|
151 | + '4PM' => __( '4 PM', 'invoicing'), |
|
152 | + '5PM' => __( '5 PM', 'invoicing'), |
|
153 | + '6PM' => __( '6 PM', 'invoicing'), |
|
154 | + '7PM' => __( '7 PM', 'invoicing'), |
|
155 | + '8PM' => __( '8 PM', 'invoicing'), |
|
156 | + '9PM' => __( '9 PM', 'invoicing'), |
|
157 | + '10PM' => __( '10 PM', 'invoicing'), |
|
158 | + '11PM' => __( '11 PM', 'invoicing'), |
|
159 | + ); |
|
160 | + |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Retrieves the days in a period |
|
165 | + * |
|
166 | + */ |
|
167 | + public function get_days_in_period( $days ) { |
|
168 | + |
|
169 | + $return = array(); |
|
170 | + $format = 'Y-m-d'; |
|
171 | + |
|
172 | + if ( $days < 8 ) { |
|
173 | + $format = 'D'; |
|
174 | + } |
|
175 | + |
|
176 | + if ( $days < 32 ) { |
|
177 | + $format = 'M j'; |
|
178 | + } |
|
179 | + |
|
180 | + while ( $days > 0 ) { |
|
181 | + |
|
182 | + $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
183 | + $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
184 | + $return[ $key ] = $label; |
|
185 | + $days--; |
|
186 | + |
|
187 | + } |
|
188 | + |
|
189 | + return $return; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Retrieves the weeks in a period |
|
194 | + * |
|
195 | + */ |
|
196 | + public function get_weeks_in_period( $days ) { |
|
197 | + |
|
198 | + $return = array(); |
|
199 | + |
|
200 | + while ( $days > 0 ) { |
|
201 | + |
|
202 | + $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
203 | + $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
204 | + $return[ $key ] = $label; |
|
205 | + $days--; |
|
206 | + |
|
207 | + } |
|
208 | + |
|
209 | + return $return; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Displays the report card. |
|
214 | + * |
|
215 | + */ |
|
216 | + public function display() { |
|
217 | + ?> |
|
218 | 218 | |
219 | 219 | <div class="row"> |
220 | 220 | <div class="col-12"> |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | |
229 | 229 | <?php |
230 | 230 | |
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Prepares the report stats. |
|
235 | - * |
|
236 | - * Extend this in child classes. |
|
237 | - */ |
|
238 | - abstract public function prepare_stats(); |
|
239 | - |
|
240 | - /** |
|
241 | - * Displays the actual report. |
|
242 | - * |
|
243 | - * Extend this in child classes. |
|
244 | - */ |
|
245 | - abstract public function display_stats(); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Prepares the report stats. |
|
235 | + * |
|
236 | + * Extend this in child classes. |
|
237 | + */ |
|
238 | + abstract public function prepare_stats(); |
|
239 | + |
|
240 | + /** |
|
241 | + * Displays the actual report. |
|
242 | + * |
|
243 | + * Extend this in child classes. |
|
244 | + */ |
|
245 | + abstract public function display_stats(); |
|
246 | 246 | |
247 | 247 | } |
@@ -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_Abstract_Report Class. |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | public function get_range() { |
33 | 33 | $valid_ranges = $this->get_periods(); |
34 | 34 | |
35 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
36 | - return sanitize_key( $_GET['date_range'] ); |
|
35 | + if (isset($_GET['date_range']) && array_key_exists($_GET['date_range'], $valid_ranges)) { |
|
36 | + return sanitize_key($_GET['date_range']); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return '7_days'; |
@@ -47,34 +47,34 @@ discard block |
||
47 | 47 | public function get_periods() { |
48 | 48 | |
49 | 49 | $periods = array( |
50 | - 'today' => __( 'Today', 'invoicing' ), |
|
51 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
52 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
53 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
54 | - '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
55 | - '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
56 | - '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
57 | - '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
50 | + 'today' => __('Today', 'invoicing'), |
|
51 | + 'yesterday' => __('Yesterday', 'invoicing'), |
|
52 | + '7_days' => __('Last 7 days', 'invoicing'), |
|
53 | + '30_days' => __('Last 30 days', 'invoicing'), |
|
54 | + '60_days' => __('Last 60 days', 'invoicing'), |
|
55 | + '90_days' => __('Last 90 days', 'invoicing'), |
|
56 | + '180_days' => __('Last 180 days', 'invoicing'), |
|
57 | + '360_days' => __('Last 360 days', 'invoicing'), |
|
58 | 58 | ); |
59 | 59 | |
60 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
60 | + return apply_filters('getpaid_earning_periods', $periods); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Retrieves the current range's sql. |
65 | 65 | * |
66 | 66 | */ |
67 | - public function get_range_sql( $range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date' ) { |
|
67 | + public function get_range_sql($range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date') { |
|
68 | 68 | |
69 | 69 | // Prepare durations. |
70 | - $today = current_time( 'Y-m-d' ); |
|
71 | - $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
72 | - $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
73 | - $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
74 | - $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
75 | - $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
76 | - $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
77 | - $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
70 | + $today = current_time('Y-m-d'); |
|
71 | + $yesterday = date('Y-m-d', strtotime('-1 day', current_time('timestamp'))); |
|
72 | + $seven_days_ago = date('Y-m-d', strtotime('-7 days', current_time('timestamp'))); |
|
73 | + $thirty_days_ago = date('Y-m-d', strtotime('-30 days', current_time('timestamp'))); |
|
74 | + $ninety_days_ago = date('Y-m-d', strtotime('-90 days', current_time('timestamp'))); |
|
75 | + $sixty_days_ago = date('Y-m-d', strtotime('-60 days', current_time('timestamp'))); |
|
76 | + $one_eighty_days_ago = date('Y-m-d', strtotime('-180 days', current_time('timestamp'))); |
|
77 | + $three_sixty_days_ago = date('Y-m-d', strtotime('-360 days', current_time('timestamp'))); |
|
78 | 78 | |
79 | 79 | $ranges = array( |
80 | 80 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | |
121 | 121 | ); |
122 | 122 | |
123 | - $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
124 | - return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
123 | + $sql = isset($ranges[$range]) ? $ranges[$range] : $ranges['7_days']; |
|
124 | + return apply_filters('getpaid_earning_graphs_get_range_sql', $sql, $range); |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
@@ -132,30 +132,30 @@ discard block |
||
132 | 132 | public function get_hours_in_a_day() { |
133 | 133 | |
134 | 134 | return array( |
135 | - '12AM' => __( '12 AM', 'invoicing'), |
|
136 | - '1AM' => __( '1 AM', 'invoicing'), |
|
137 | - '2AM' => __( '2 AM', 'invoicing'), |
|
138 | - '3AM' => __( '3 AM', 'invoicing'), |
|
139 | - '4AM' => __( '4 AM', 'invoicing'), |
|
140 | - '5AM' => __( '5 AM', 'invoicing'), |
|
141 | - '6AM' => __( '6 AM', 'invoicing'), |
|
142 | - '7AM' => __( '7 AM', 'invoicing'), |
|
143 | - '8AM' => __( '8 AM', 'invoicing'), |
|
144 | - '9AM' => __( '9 AM', 'invoicing'), |
|
145 | - '10AM' => __( '10 AM', 'invoicing'), |
|
146 | - '11AM' => __( '11 AM', 'invoicing'), |
|
147 | - '12pm' => __( '12 PM', 'invoicing'), |
|
148 | - '1PM' => __( '1 PM', 'invoicing'), |
|
149 | - '2PM' => __( '2 PM', 'invoicing'), |
|
150 | - '3PM' => __( '3 PM', 'invoicing'), |
|
151 | - '4PM' => __( '4 PM', 'invoicing'), |
|
152 | - '5PM' => __( '5 PM', 'invoicing'), |
|
153 | - '6PM' => __( '6 PM', 'invoicing'), |
|
154 | - '7PM' => __( '7 PM', 'invoicing'), |
|
155 | - '8PM' => __( '8 PM', 'invoicing'), |
|
156 | - '9PM' => __( '9 PM', 'invoicing'), |
|
157 | - '10PM' => __( '10 PM', 'invoicing'), |
|
158 | - '11PM' => __( '11 PM', 'invoicing'), |
|
135 | + '12AM' => __('12 AM', 'invoicing'), |
|
136 | + '1AM' => __('1 AM', 'invoicing'), |
|
137 | + '2AM' => __('2 AM', 'invoicing'), |
|
138 | + '3AM' => __('3 AM', 'invoicing'), |
|
139 | + '4AM' => __('4 AM', 'invoicing'), |
|
140 | + '5AM' => __('5 AM', 'invoicing'), |
|
141 | + '6AM' => __('6 AM', 'invoicing'), |
|
142 | + '7AM' => __('7 AM', 'invoicing'), |
|
143 | + '8AM' => __('8 AM', 'invoicing'), |
|
144 | + '9AM' => __('9 AM', 'invoicing'), |
|
145 | + '10AM' => __('10 AM', 'invoicing'), |
|
146 | + '11AM' => __('11 AM', 'invoicing'), |
|
147 | + '12pm' => __('12 PM', 'invoicing'), |
|
148 | + '1PM' => __('1 PM', 'invoicing'), |
|
149 | + '2PM' => __('2 PM', 'invoicing'), |
|
150 | + '3PM' => __('3 PM', 'invoicing'), |
|
151 | + '4PM' => __('4 PM', 'invoicing'), |
|
152 | + '5PM' => __('5 PM', 'invoicing'), |
|
153 | + '6PM' => __('6 PM', 'invoicing'), |
|
154 | + '7PM' => __('7 PM', 'invoicing'), |
|
155 | + '8PM' => __('8 PM', 'invoicing'), |
|
156 | + '9PM' => __('9 PM', 'invoicing'), |
|
157 | + '10PM' => __('10 PM', 'invoicing'), |
|
158 | + '11PM' => __('11 PM', 'invoicing'), |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | } |
@@ -164,24 +164,24 @@ discard block |
||
164 | 164 | * Retrieves the days in a period |
165 | 165 | * |
166 | 166 | */ |
167 | - public function get_days_in_period( $days ) { |
|
167 | + public function get_days_in_period($days) { |
|
168 | 168 | |
169 | 169 | $return = array(); |
170 | 170 | $format = 'Y-m-d'; |
171 | 171 | |
172 | - if ( $days < 8 ) { |
|
172 | + if ($days < 8) { |
|
173 | 173 | $format = 'D'; |
174 | 174 | } |
175 | 175 | |
176 | - if ( $days < 32 ) { |
|
176 | + if ($days < 32) { |
|
177 | 177 | $format = 'M j'; |
178 | 178 | } |
179 | 179 | |
180 | - while ( $days > 0 ) { |
|
180 | + while ($days > 0) { |
|
181 | 181 | |
182 | - $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
183 | - $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
184 | - $return[ $key ] = $label; |
|
182 | + $key = date('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
183 | + $label = date_i18n($format, strtotime("-$days days", current_time('timestamp'))); |
|
184 | + $return[$key] = $label; |
|
185 | 185 | $days--; |
186 | 186 | |
187 | 187 | } |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | * Retrieves the weeks in a period |
194 | 194 | * |
195 | 195 | */ |
196 | - public function get_weeks_in_period( $days ) { |
|
196 | + public function get_weeks_in_period($days) { |
|
197 | 197 | |
198 | 198 | $return = array(); |
199 | 199 | |
200 | - while ( $days > 0 ) { |
|
200 | + while ($days > 0) { |
|
201 | 201 | |
202 | - $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
203 | - $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
204 | - $return[ $key ] = $label; |
|
202 | + $key = date('W', strtotime("-$days days", current_time('timestamp'))); |
|
203 | + $label = date_i18n('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
204 | + $return[$key] = $label; |
|
205 | 205 | $days--; |
206 | 206 | |
207 | 207 | } |