@@ -12,23 +12,23 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports_Report_Items extends GetPaid_Reports_Abstract_Report { |
14 | 14 | |
15 | - /** |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - public $field = 'item_name'; |
|
19 | - |
|
20 | - /** |
|
21 | - * Retrieves the earning sql. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function get_sql( $range ) { |
|
25 | - global $wpdb; |
|
26 | - |
|
27 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
28 | - $table2 = $wpdb->prefix . 'getpaid_invoice_items'; |
|
29 | - $clauses = $this->get_range_sql( $range ); |
|
30 | - |
|
31 | - $sql = "SELECT |
|
15 | + /** |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + public $field = 'item_name'; |
|
19 | + |
|
20 | + /** |
|
21 | + * Retrieves the earning sql. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function get_sql( $range ) { |
|
25 | + global $wpdb; |
|
26 | + |
|
27 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
28 | + $table2 = $wpdb->prefix . 'getpaid_invoice_items'; |
|
29 | + $clauses = $this->get_range_sql( $range ); |
|
30 | + |
|
31 | + $sql = "SELECT |
|
32 | 32 | item.item_name AS item_name, |
33 | 33 | item.item_id AS item_id, |
34 | 34 | SUM(price) as total |
@@ -43,91 +43,91 @@ discard block |
||
43 | 43 | ORDER BY total DESC |
44 | 44 | "; |
45 | 45 | |
46 | - return apply_filters( 'getpaid_items_graphs_get_sql', $sql, $range ); |
|
46 | + return apply_filters( 'getpaid_items_graphs_get_sql', $sql, $range ); |
|
47 | 47 | |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Prepares the report stats. |
|
52 | - * |
|
53 | - */ |
|
54 | - public function prepare_stats() { |
|
55 | - global $wpdb; |
|
56 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
57 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
58 | - } |
|
50 | + /** |
|
51 | + * Prepares the report stats. |
|
52 | + * |
|
53 | + */ |
|
54 | + public function prepare_stats() { |
|
55 | + global $wpdb; |
|
56 | + $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
57 | + $this->stats = $this->normalize_stats( $this->stats ); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Normalizes the report stats. |
|
62 | - * |
|
63 | - */ |
|
64 | - public function normalize_stats( $stats ) { |
|
65 | - $normalized = array(); |
|
66 | - $others = 0; |
|
67 | - $did = 0; |
|
60 | + /** |
|
61 | + * Normalizes the report stats. |
|
62 | + * |
|
63 | + */ |
|
64 | + public function normalize_stats( $stats ) { |
|
65 | + $normalized = array(); |
|
66 | + $others = 0; |
|
67 | + $did = 0; |
|
68 | 68 | |
69 | - foreach ( $stats as $stat ) { |
|
69 | + foreach ( $stats as $stat ) { |
|
70 | 70 | |
71 | - if ( $did > 4 ) { |
|
71 | + if ( $did > 4 ) { |
|
72 | 72 | |
73 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
73 | + $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
74 | 74 | |
75 | - } else { |
|
75 | + } else { |
|
76 | 76 | |
77 | - $normalized[] = array( |
|
78 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
79 | - 'item_name' => strip_tags( $stat->item_name ), |
|
80 | - ); |
|
77 | + $normalized[] = array( |
|
78 | + 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
79 | + 'item_name' => strip_tags( $stat->item_name ), |
|
80 | + ); |
|
81 | 81 | |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | - $did++; |
|
85 | - } |
|
84 | + $did++; |
|
85 | + } |
|
86 | 86 | |
87 | - if ( $others > 0 ) { |
|
87 | + if ( $others > 0 ) { |
|
88 | 88 | |
89 | - $normalized[] = array( |
|
90 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
91 | - 'item_name' => esc_html__( 'Others', 'invoicing' ), |
|
92 | - ); |
|
89 | + $normalized[] = array( |
|
90 | + 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
91 | + 'item_name' => esc_html__( 'Others', 'invoicing' ), |
|
92 | + ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | - return $normalized; |
|
97 | - } |
|
96 | + return $normalized; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Retrieves report data. |
|
101 | - * |
|
102 | - */ |
|
103 | - public function get_data() { |
|
99 | + /** |
|
100 | + * Retrieves report data. |
|
101 | + * |
|
102 | + */ |
|
103 | + public function get_data() { |
|
104 | 104 | |
105 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
106 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
105 | + $data = wp_list_pluck( $this->stats, 'total' ); |
|
106 | + $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
107 | 107 | |
108 | - shuffle( $colors ); |
|
108 | + shuffle( $colors ); |
|
109 | 109 | |
110 | - return array( |
|
111 | - 'data' => $data, |
|
112 | - 'backgroundColor' => $colors, |
|
113 | - ); |
|
110 | + return array( |
|
111 | + 'data' => $data, |
|
112 | + 'backgroundColor' => $colors, |
|
113 | + ); |
|
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Retrieves report labels. |
|
119 | - * |
|
120 | - */ |
|
121 | - public function get_labels() { |
|
122 | - return wp_list_pluck( $this->stats, 'item_name' ); |
|
123 | - } |
|
117 | + /** |
|
118 | + * Retrieves report labels. |
|
119 | + * |
|
120 | + */ |
|
121 | + public function get_labels() { |
|
122 | + return wp_list_pluck( $this->stats, 'item_name' ); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Displays the actual report. |
|
127 | - * |
|
128 | - */ |
|
129 | - public function display_stats() { |
|
130 | - ?> |
|
125 | + /** |
|
126 | + * Displays the actual report. |
|
127 | + * |
|
128 | + */ |
|
129 | + public function display_stats() { |
|
130 | + ?> |
|
131 | 131 | |
132 | 132 | <canvas id="getpaid-chartjs-earnings-items"></canvas> |
133 | 133 | |
@@ -156,6 +156,6 @@ discard block |
||
156 | 156 | </script> |
157 | 157 | |
158 | 158 | <?php |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | 161 | } |
@@ -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_Items Class. |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * Retrieves the earning sql. |
22 | 22 | * |
23 | 23 | */ |
24 | - public function get_sql( $range ) { |
|
24 | + public function get_sql($range) { |
|
25 | 25 | global $wpdb; |
26 | 26 | |
27 | 27 | $table = $wpdb->prefix . 'getpaid_invoices'; |
28 | 28 | $table2 = $wpdb->prefix . 'getpaid_invoice_items'; |
29 | - $clauses = $this->get_range_sql( $range ); |
|
29 | + $clauses = $this->get_range_sql($range); |
|
30 | 30 | |
31 | 31 | $sql = "SELECT |
32 | 32 | item.item_name AS item_name, |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ORDER BY total DESC |
44 | 44 | "; |
45 | 45 | |
46 | - return apply_filters( 'getpaid_items_graphs_get_sql', $sql, $range ); |
|
46 | + return apply_filters('getpaid_items_graphs_get_sql', $sql, $range); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | |
@@ -53,30 +53,30 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function prepare_stats() { |
55 | 55 | global $wpdb; |
56 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
57 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
56 | + $this->stats = $wpdb->get_results($this->get_sql($this->get_range())); |
|
57 | + $this->stats = $this->normalize_stats($this->stats); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Normalizes the report stats. |
62 | 62 | * |
63 | 63 | */ |
64 | - public function normalize_stats( $stats ) { |
|
64 | + public function normalize_stats($stats) { |
|
65 | 65 | $normalized = array(); |
66 | 66 | $others = 0; |
67 | 67 | $did = 0; |
68 | 68 | |
69 | - foreach ( $stats as $stat ) { |
|
69 | + foreach ($stats as $stat) { |
|
70 | 70 | |
71 | - if ( $did > 4 ) { |
|
71 | + if ($did > 4) { |
|
72 | 72 | |
73 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
73 | + $others += wpinv_round_amount(wpinv_sanitize_amount($stat->total)); |
|
74 | 74 | |
75 | 75 | } else { |
76 | 76 | |
77 | 77 | $normalized[] = array( |
78 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
79 | - 'item_name' => strip_tags( $stat->item_name ), |
|
78 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($stat->total)), |
|
79 | + 'item_name' => strip_tags($stat->item_name), |
|
80 | 80 | ); |
81 | 81 | |
82 | 82 | } |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | $did++; |
85 | 85 | } |
86 | 86 | |
87 | - if ( $others > 0 ) { |
|
87 | + if ($others > 0) { |
|
88 | 88 | |
89 | 89 | $normalized[] = array( |
90 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
91 | - 'item_name' => esc_html__( 'Others', 'invoicing' ), |
|
90 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($others)), |
|
91 | + 'item_name' => esc_html__('Others', 'invoicing'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function get_data() { |
104 | 104 | |
105 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
106 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
105 | + $data = wp_list_pluck($this->stats, 'total'); |
|
106 | + $colors = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3'); |
|
107 | 107 | |
108 | - shuffle( $colors ); |
|
108 | + shuffle($colors); |
|
109 | 109 | |
110 | 110 | return array( |
111 | 111 | 'data' => $data, |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | */ |
121 | 121 | public function get_labels() { |
122 | - return wp_list_pluck( $this->stats, 'item_name' ); |
|
122 | + return wp_list_pluck($this->stats, 'item_name'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | { |
141 | 141 | type: 'doughnut', |
142 | 142 | data: { |
143 | - 'labels': <?php echo wp_json_encode( wp_kses_post_deep( $this->get_labels() ) ); ?>, |
|
144 | - 'datasets': [ <?php echo wp_json_encode( wp_kses_post_deep( $this->get_data() ) ); ?> ] |
|
143 | + 'labels': <?php echo wp_json_encode(wp_kses_post_deep($this->get_labels())); ?>, |
|
144 | + 'datasets': [ <?php echo wp_json_encode(wp_kses_post_deep($this->get_data())); ?> ] |
|
145 | 145 | }, |
146 | 146 | options: { |
147 | 147 | legend: { |
@@ -12,22 +12,22 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports_Report_Gateways extends GetPaid_Reports_Abstract_Report { |
14 | 14 | |
15 | - /** |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - public $field = 'gateway'; |
|
19 | - |
|
20 | - /** |
|
21 | - * Retrieves the earning sql. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function get_sql( $range ) { |
|
25 | - global $wpdb; |
|
26 | - |
|
27 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
28 | - $clauses = $this->get_range_sql( $range ); |
|
29 | - |
|
30 | - $sql = "SELECT |
|
15 | + /** |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + public $field = 'gateway'; |
|
19 | + |
|
20 | + /** |
|
21 | + * Retrieves the earning sql. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function get_sql( $range ) { |
|
25 | + global $wpdb; |
|
26 | + |
|
27 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
28 | + $clauses = $this->get_range_sql( $range ); |
|
29 | + |
|
30 | + $sql = "SELECT |
|
31 | 31 | meta.gateway AS gateway, |
32 | 32 | SUM(total) as total |
33 | 33 | FROM $wpdb->posts |
@@ -40,91 +40,91 @@ discard block |
||
40 | 40 | ORDER BY total DESC |
41 | 41 | "; |
42 | 42 | |
43 | - return apply_filters( 'getpaid_gateways_graphs_get_sql', $sql, $range ); |
|
43 | + return apply_filters( 'getpaid_gateways_graphs_get_sql', $sql, $range ); |
|
44 | 44 | |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Prepares the report stats. |
|
49 | - * |
|
50 | - */ |
|
51 | - public function prepare_stats() { |
|
52 | - global $wpdb; |
|
53 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
54 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
55 | - } |
|
47 | + /** |
|
48 | + * Prepares the report stats. |
|
49 | + * |
|
50 | + */ |
|
51 | + public function prepare_stats() { |
|
52 | + global $wpdb; |
|
53 | + $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
54 | + $this->stats = $this->normalize_stats( $this->stats ); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Normalizes the report stats. |
|
59 | - * |
|
60 | - */ |
|
61 | - public function normalize_stats( $stats ) { |
|
62 | - $normalized = array(); |
|
63 | - $others = 0; |
|
64 | - $did = 0; |
|
57 | + /** |
|
58 | + * Normalizes the report stats. |
|
59 | + * |
|
60 | + */ |
|
61 | + public function normalize_stats( $stats ) { |
|
62 | + $normalized = array(); |
|
63 | + $others = 0; |
|
64 | + $did = 0; |
|
65 | 65 | |
66 | - foreach ( $stats as $stat ) { |
|
66 | + foreach ( $stats as $stat ) { |
|
67 | 67 | |
68 | - if ( $did > 4 ) { |
|
68 | + if ( $did > 4 ) { |
|
69 | 69 | |
70 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
70 | + $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
71 | 71 | |
72 | - } else { |
|
72 | + } else { |
|
73 | 73 | |
74 | - $normalized[] = array( |
|
75 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
76 | - 'gateway' => strip_tags( wpinv_get_gateway_admin_label( $stat->gateway ) ), |
|
77 | - ); |
|
74 | + $normalized[] = array( |
|
75 | + 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
76 | + 'gateway' => strip_tags( wpinv_get_gateway_admin_label( $stat->gateway ) ), |
|
77 | + ); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - $did++; |
|
82 | - } |
|
81 | + $did++; |
|
82 | + } |
|
83 | 83 | |
84 | - if ( $others > 0 ) { |
|
84 | + if ( $others > 0 ) { |
|
85 | 85 | |
86 | - $normalized[] = array( |
|
87 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
88 | - 'gateway' => esc_html__( 'Others', 'invoicing' ), |
|
89 | - ); |
|
86 | + $normalized[] = array( |
|
87 | + 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
88 | + 'gateway' => esc_html__( 'Others', 'invoicing' ), |
|
89 | + ); |
|
90 | 90 | |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - return $normalized; |
|
94 | - } |
|
93 | + return $normalized; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Retrieves report data. |
|
98 | - * |
|
99 | - */ |
|
100 | - public function get_data() { |
|
96 | + /** |
|
97 | + * Retrieves report data. |
|
98 | + * |
|
99 | + */ |
|
100 | + public function get_data() { |
|
101 | 101 | |
102 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
103 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
102 | + $data = wp_list_pluck( $this->stats, 'total' ); |
|
103 | + $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
104 | 104 | |
105 | - shuffle( $colors ); |
|
105 | + shuffle( $colors ); |
|
106 | 106 | |
107 | - return array( |
|
108 | - 'data' => $data, |
|
109 | - 'backgroundColor' => $colors, |
|
110 | - ); |
|
107 | + return array( |
|
108 | + 'data' => $data, |
|
109 | + 'backgroundColor' => $colors, |
|
110 | + ); |
|
111 | 111 | |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Retrieves report labels. |
|
116 | - * |
|
117 | - */ |
|
118 | - public function get_labels() { |
|
119 | - return wp_list_pluck( $this->stats, 'gateway' ); |
|
120 | - } |
|
114 | + /** |
|
115 | + * Retrieves report labels. |
|
116 | + * |
|
117 | + */ |
|
118 | + public function get_labels() { |
|
119 | + return wp_list_pluck( $this->stats, 'gateway' ); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Displays the actual report. |
|
124 | - * |
|
125 | - */ |
|
126 | - public function display_stats() { |
|
127 | - ?> |
|
122 | + /** |
|
123 | + * Displays the actual report. |
|
124 | + * |
|
125 | + */ |
|
126 | + public function display_stats() { |
|
127 | + ?> |
|
128 | 128 | |
129 | 129 | <canvas id="getpaid-chartjs-earnings-gateways"></canvas> |
130 | 130 | |
@@ -153,6 +153,6 @@ discard block |
||
153 | 153 | </script> |
154 | 154 | |
155 | 155 | <?php |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | 158 | } |
@@ -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_Items Class. |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * Retrieves the earning sql. |
22 | 22 | * |
23 | 23 | */ |
24 | - public function get_sql( $range ) { |
|
24 | + public function get_sql($range) { |
|
25 | 25 | global $wpdb; |
26 | 26 | |
27 | 27 | $table = $wpdb->prefix . 'getpaid_invoices'; |
28 | - $clauses = $this->get_range_sql( $range ); |
|
28 | + $clauses = $this->get_range_sql($range); |
|
29 | 29 | |
30 | 30 | $sql = "SELECT |
31 | 31 | meta.gateway AS gateway, |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | ORDER BY total DESC |
41 | 41 | "; |
42 | 42 | |
43 | - return apply_filters( 'getpaid_gateways_graphs_get_sql', $sql, $range ); |
|
43 | + return apply_filters('getpaid_gateways_graphs_get_sql', $sql, $range); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -50,30 +50,30 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function prepare_stats() { |
52 | 52 | global $wpdb; |
53 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
54 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
53 | + $this->stats = $wpdb->get_results($this->get_sql($this->get_range())); |
|
54 | + $this->stats = $this->normalize_stats($this->stats); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Normalizes the report stats. |
59 | 59 | * |
60 | 60 | */ |
61 | - public function normalize_stats( $stats ) { |
|
61 | + public function normalize_stats($stats) { |
|
62 | 62 | $normalized = array(); |
63 | 63 | $others = 0; |
64 | 64 | $did = 0; |
65 | 65 | |
66 | - foreach ( $stats as $stat ) { |
|
66 | + foreach ($stats as $stat) { |
|
67 | 67 | |
68 | - if ( $did > 4 ) { |
|
68 | + if ($did > 4) { |
|
69 | 69 | |
70 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
70 | + $others += wpinv_round_amount(wpinv_sanitize_amount($stat->total)); |
|
71 | 71 | |
72 | 72 | } else { |
73 | 73 | |
74 | 74 | $normalized[] = array( |
75 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
76 | - 'gateway' => strip_tags( wpinv_get_gateway_admin_label( $stat->gateway ) ), |
|
75 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($stat->total)), |
|
76 | + 'gateway' => strip_tags(wpinv_get_gateway_admin_label($stat->gateway)), |
|
77 | 77 | ); |
78 | 78 | |
79 | 79 | } |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | $did++; |
82 | 82 | } |
83 | 83 | |
84 | - if ( $others > 0 ) { |
|
84 | + if ($others > 0) { |
|
85 | 85 | |
86 | 86 | $normalized[] = array( |
87 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
88 | - 'gateway' => esc_html__( 'Others', 'invoicing' ), |
|
87 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($others)), |
|
88 | + 'gateway' => esc_html__('Others', 'invoicing'), |
|
89 | 89 | ); |
90 | 90 | |
91 | 91 | } |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function get_data() { |
101 | 101 | |
102 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
103 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
102 | + $data = wp_list_pluck($this->stats, 'total'); |
|
103 | + $colors = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3'); |
|
104 | 104 | |
105 | - shuffle( $colors ); |
|
105 | + shuffle($colors); |
|
106 | 106 | |
107 | 107 | return array( |
108 | 108 | 'data' => $data, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | */ |
118 | 118 | public function get_labels() { |
119 | - return wp_list_pluck( $this->stats, 'gateway' ); |
|
119 | + return wp_list_pluck($this->stats, 'gateway'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | { |
138 | 138 | type: 'doughnut', |
139 | 139 | data: { |
140 | - 'labels': <?php echo wp_json_encode( wp_kses_post_deep( $this->get_labels() ) ); ?>, |
|
141 | - 'datasets': [ <?php echo wp_json_encode( wp_kses_post_deep( $this->get_data() ) ); ?> ] |
|
140 | + 'labels': <?php echo wp_json_encode(wp_kses_post_deep($this->get_labels())); ?>, |
|
141 | + 'datasets': [ <?php echo wp_json_encode(wp_kses_post_deep($this->get_data())); ?> ] |
|
142 | 142 | }, |
143 | 143 | options: { |
144 | 144 | legend: { |
@@ -12,219 +12,219 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Graph_Downloader { |
14 | 14 | |
15 | - /** |
|
16 | - * @var GetPaid_Reports_Report |
|
17 | - */ |
|
18 | - public $handler; |
|
19 | - |
|
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - $this->handler = new GetPaid_Reports_Report(); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Prepares the datastore handler. |
|
30 | - * |
|
31 | - * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts |
|
32 | - */ |
|
33 | - public function prepare_handler( $graph ) { |
|
34 | - |
|
35 | - if ( empty( $this->handler->views[ $graph ] ) ) { |
|
36 | - wp_die( __( 'Invalid Graph', 'invoicing' ), 400 ); |
|
37 | - } |
|
38 | - |
|
39 | - return new $this->handler->views[ $graph ]['class'](); |
|
40 | - |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Prepares the output stream. |
|
45 | - * |
|
46 | - * @return resource |
|
47 | - */ |
|
48 | - public function prepare_output() { |
|
49 | - |
|
50 | - $output = fopen( 'php://output', 'w' ); |
|
51 | - |
|
52 | - if ( false === $output ) { |
|
53 | - wp_die( __( 'Unsupported server', 'invoicing' ), 500 ); |
|
54 | - } |
|
55 | - |
|
56 | - return $output; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Prepares the file type. |
|
61 | - * |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function prepare_file_type( $graph ) { |
|
65 | - |
|
66 | - $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] ); |
|
67 | - $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) ); |
|
68 | - |
|
69 | - header( "Content-Type:application/$file_type" ); |
|
70 | - header( "Content-Disposition:attachment;filename=$file_name.$file_type" ); |
|
71 | - |
|
72 | - return $file_type; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Handles the actual download. |
|
77 | - * |
|
78 | - */ |
|
79 | - public function download( $graph ) { |
|
80 | - global $wpdb; |
|
81 | - |
|
82 | - $handler = $this->prepare_handler( $graph ); |
|
83 | - $stream = $this->prepare_output(); |
|
84 | - $stats = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) ); |
|
85 | - $headers = array( $handler->field, 'total', 'total_raw' ); |
|
86 | - $file_type = $this->prepare_file_type( $graph ); |
|
87 | - |
|
88 | - if ( 'csv' == $file_type ) { |
|
89 | - $this->download_csv( $stats, $stream, $headers ); |
|
90 | - } else if( 'xml' == $file_type ) { |
|
91 | - $this->download_xml( $stats, $stream, $headers ); |
|
92 | - } else { |
|
93 | - $this->download_json( $stats, $stream, $headers ); |
|
94 | - } |
|
95 | - |
|
96 | - fclose( $stream ); |
|
97 | - exit; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Downloads graph as csv |
|
102 | - * |
|
103 | - * @param array $stats The stats being downloaded. |
|
104 | - * @param resource $stream The stream to output to. |
|
105 | - * @param array $headers The fields to stream. |
|
106 | - * @since 1.0.19 |
|
107 | - */ |
|
108 | - public function download_csv( $stats, $stream, $headers ) { |
|
109 | - |
|
110 | - // Output the csv column headers. |
|
111 | - fputcsv( $stream, $headers ); |
|
112 | - |
|
113 | - // Loop through |
|
114 | - foreach ( $stats as $stat ) { |
|
115 | - $row = array_values( $this->prepare_row( $stat, $headers ) ); |
|
116 | - $row = array_map( 'maybe_serialize', $row ); |
|
117 | - fputcsv( $stream, $row ); |
|
118 | - } |
|
119 | - |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Downloads graph as json |
|
124 | - * |
|
125 | - * @param array $stats The stats being downloaded. |
|
126 | - * @param resource $stream The stream to output to. |
|
127 | - * @param array $headers The fields to stream. |
|
128 | - * @since 1.0.19 |
|
129 | - */ |
|
130 | - public function download_json( $stats, $stream, $headers ) { |
|
131 | - |
|
132 | - $prepared = array(); |
|
133 | - |
|
134 | - // Loop through |
|
135 | - foreach ( $stats as $stat ) { |
|
136 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
137 | - } |
|
138 | - |
|
139 | - fwrite( $stream, wp_json_encode( $prepared ) ); |
|
140 | - |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Downloads graph as xml |
|
145 | - * |
|
146 | - * @param array $stats The stats being downloaded. |
|
147 | - * @param resource $stream The stream to output to. |
|
148 | - * @param array $headers The fields to stream. |
|
149 | - * @since 1.0.19 |
|
150 | - */ |
|
151 | - public function download_xml( $stats, $stream, $headers ) { |
|
152 | - |
|
153 | - $prepared = array(); |
|
154 | - |
|
155 | - // Loop through |
|
156 | - foreach ( $stats as $stat ) { |
|
157 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
158 | - } |
|
159 | - |
|
160 | - $xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>'); |
|
161 | - $this->convert_array_xml( $prepared, $xml ); |
|
162 | - |
|
163 | - fwrite( $stream, $xml->asXML() ); |
|
164 | - |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Converts stats array to xml |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @since 1.0.19 |
|
172 | - */ |
|
173 | - public function convert_array_xml( $data, $xml ) { |
|
174 | - |
|
175 | - // Loop through |
|
176 | - foreach ( $data as $key => $value ) { |
|
177 | - |
|
178 | - $key = preg_replace( "/[^A-Za-z0-9_\-]/", '', $key ); |
|
179 | - |
|
180 | - if ( is_array( $value ) ) { |
|
181 | - |
|
182 | - if ( is_numeric( $key ) ){ |
|
183 | - $key = 'item'.$key; //dealing with <0/>..<n/> issues |
|
184 | - } |
|
185 | - |
|
186 | - $subnode = $xml->addChild( $key ); |
|
187 | - $this->convert_array_xml( $value, $subnode ); |
|
188 | - |
|
189 | - } else { |
|
190 | - $xml->addChild( $key, htmlspecialchars( $value ) ); |
|
191 | - } |
|
192 | - |
|
193 | - } |
|
15 | + /** |
|
16 | + * @var GetPaid_Reports_Report |
|
17 | + */ |
|
18 | + public $handler; |
|
19 | + |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + $this->handler = new GetPaid_Reports_Report(); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Prepares the datastore handler. |
|
30 | + * |
|
31 | + * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts |
|
32 | + */ |
|
33 | + public function prepare_handler( $graph ) { |
|
34 | + |
|
35 | + if ( empty( $this->handler->views[ $graph ] ) ) { |
|
36 | + wp_die( __( 'Invalid Graph', 'invoicing' ), 400 ); |
|
37 | + } |
|
38 | + |
|
39 | + return new $this->handler->views[ $graph ]['class'](); |
|
40 | + |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Prepares the output stream. |
|
45 | + * |
|
46 | + * @return resource |
|
47 | + */ |
|
48 | + public function prepare_output() { |
|
49 | + |
|
50 | + $output = fopen( 'php://output', 'w' ); |
|
51 | + |
|
52 | + if ( false === $output ) { |
|
53 | + wp_die( __( 'Unsupported server', 'invoicing' ), 500 ); |
|
54 | + } |
|
55 | + |
|
56 | + return $output; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Prepares the file type. |
|
61 | + * |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function prepare_file_type( $graph ) { |
|
65 | + |
|
66 | + $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] ); |
|
67 | + $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) ); |
|
68 | + |
|
69 | + header( "Content-Type:application/$file_type" ); |
|
70 | + header( "Content-Disposition:attachment;filename=$file_name.$file_type" ); |
|
71 | + |
|
72 | + return $file_type; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Handles the actual download. |
|
77 | + * |
|
78 | + */ |
|
79 | + public function download( $graph ) { |
|
80 | + global $wpdb; |
|
81 | + |
|
82 | + $handler = $this->prepare_handler( $graph ); |
|
83 | + $stream = $this->prepare_output(); |
|
84 | + $stats = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) ); |
|
85 | + $headers = array( $handler->field, 'total', 'total_raw' ); |
|
86 | + $file_type = $this->prepare_file_type( $graph ); |
|
87 | + |
|
88 | + if ( 'csv' == $file_type ) { |
|
89 | + $this->download_csv( $stats, $stream, $headers ); |
|
90 | + } else if( 'xml' == $file_type ) { |
|
91 | + $this->download_xml( $stats, $stream, $headers ); |
|
92 | + } else { |
|
93 | + $this->download_json( $stats, $stream, $headers ); |
|
94 | + } |
|
95 | + |
|
96 | + fclose( $stream ); |
|
97 | + exit; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Downloads graph as csv |
|
102 | + * |
|
103 | + * @param array $stats The stats being downloaded. |
|
104 | + * @param resource $stream The stream to output to. |
|
105 | + * @param array $headers The fields to stream. |
|
106 | + * @since 1.0.19 |
|
107 | + */ |
|
108 | + public function download_csv( $stats, $stream, $headers ) { |
|
109 | + |
|
110 | + // Output the csv column headers. |
|
111 | + fputcsv( $stream, $headers ); |
|
112 | + |
|
113 | + // Loop through |
|
114 | + foreach ( $stats as $stat ) { |
|
115 | + $row = array_values( $this->prepare_row( $stat, $headers ) ); |
|
116 | + $row = array_map( 'maybe_serialize', $row ); |
|
117 | + fputcsv( $stream, $row ); |
|
118 | + } |
|
119 | + |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Downloads graph as json |
|
124 | + * |
|
125 | + * @param array $stats The stats being downloaded. |
|
126 | + * @param resource $stream The stream to output to. |
|
127 | + * @param array $headers The fields to stream. |
|
128 | + * @since 1.0.19 |
|
129 | + */ |
|
130 | + public function download_json( $stats, $stream, $headers ) { |
|
131 | + |
|
132 | + $prepared = array(); |
|
133 | + |
|
134 | + // Loop through |
|
135 | + foreach ( $stats as $stat ) { |
|
136 | + $prepared[] = $this->prepare_row( $stat, $headers ); |
|
137 | + } |
|
138 | + |
|
139 | + fwrite( $stream, wp_json_encode( $prepared ) ); |
|
140 | + |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Downloads graph as xml |
|
145 | + * |
|
146 | + * @param array $stats The stats being downloaded. |
|
147 | + * @param resource $stream The stream to output to. |
|
148 | + * @param array $headers The fields to stream. |
|
149 | + * @since 1.0.19 |
|
150 | + */ |
|
151 | + public function download_xml( $stats, $stream, $headers ) { |
|
152 | + |
|
153 | + $prepared = array(); |
|
154 | + |
|
155 | + // Loop through |
|
156 | + foreach ( $stats as $stat ) { |
|
157 | + $prepared[] = $this->prepare_row( $stat, $headers ); |
|
158 | + } |
|
159 | + |
|
160 | + $xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>'); |
|
161 | + $this->convert_array_xml( $prepared, $xml ); |
|
162 | + |
|
163 | + fwrite( $stream, $xml->asXML() ); |
|
164 | + |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Converts stats array to xml |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @since 1.0.19 |
|
172 | + */ |
|
173 | + public function convert_array_xml( $data, $xml ) { |
|
174 | + |
|
175 | + // Loop through |
|
176 | + foreach ( $data as $key => $value ) { |
|
177 | + |
|
178 | + $key = preg_replace( "/[^A-Za-z0-9_\-]/", '', $key ); |
|
179 | + |
|
180 | + if ( is_array( $value ) ) { |
|
181 | + |
|
182 | + if ( is_numeric( $key ) ){ |
|
183 | + $key = 'item'.$key; //dealing with <0/>..<n/> issues |
|
184 | + } |
|
185 | + |
|
186 | + $subnode = $xml->addChild( $key ); |
|
187 | + $this->convert_array_xml( $value, $subnode ); |
|
188 | + |
|
189 | + } else { |
|
190 | + $xml->addChild( $key, htmlspecialchars( $value ) ); |
|
191 | + } |
|
192 | + |
|
193 | + } |
|
194 | 194 | |
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Prepares a single row for download. |
|
199 | - * |
|
200 | - * @param stdClass|array $row The row to prepare.. |
|
201 | - * @param array $fields The fields to stream. |
|
202 | - * @since 1.0.19 |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - public function prepare_row( $row, $fields ) { |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Prepares a single row for download. |
|
199 | + * |
|
200 | + * @param stdClass|array $row The row to prepare.. |
|
201 | + * @param array $fields The fields to stream. |
|
202 | + * @since 1.0.19 |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + public function prepare_row( $row, $fields ) { |
|
206 | 206 | |
207 | - $prepared = array(); |
|
208 | - $row = (array) $row; |
|
207 | + $prepared = array(); |
|
208 | + $row = (array) $row; |
|
209 | 209 | |
210 | - foreach ( $fields as $field ) { |
|
210 | + foreach ( $fields as $field ) { |
|
211 | 211 | |
212 | - if ( $field === 'total' ) { |
|
213 | - $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES ); |
|
214 | - continue; |
|
215 | - } |
|
212 | + if ( $field === 'total' ) { |
|
213 | + $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES ); |
|
214 | + continue; |
|
215 | + } |
|
216 | 216 | |
217 | - if ( $field === 'total_raw' ) { |
|
218 | - $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) ); |
|
219 | - continue; |
|
220 | - } |
|
217 | + if ( $field === 'total_raw' ) { |
|
218 | + $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) ); |
|
219 | + continue; |
|
220 | + } |
|
221 | 221 | |
222 | - $prepared[ $field ] = strip_tags( $row[ $field ] ); |
|
222 | + $prepared[ $field ] = strip_tags( $row[ $field ] ); |
|
223 | 223 | |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | - return $prepared; |
|
227 | - } |
|
226 | + return $prepared; |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | 230 | } |
@@ -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_Graph_Downloader Class. |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts |
32 | 32 | */ |
33 | - public function prepare_handler( $graph ) { |
|
33 | + public function prepare_handler($graph) { |
|
34 | 34 | |
35 | - if ( empty( $this->handler->views[ $graph ] ) ) { |
|
36 | - wp_die( __( 'Invalid Graph', 'invoicing' ), 400 ); |
|
35 | + if (empty($this->handler->views[$graph])) { |
|
36 | + wp_die(__('Invalid Graph', 'invoicing'), 400); |
|
37 | 37 | } |
38 | 38 | |
39 | - return new $this->handler->views[ $graph ]['class'](); |
|
39 | + return new $this->handler->views[$graph]['class'](); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function prepare_output() { |
49 | 49 | |
50 | - $output = fopen( 'php://output', 'w' ); |
|
50 | + $output = fopen('php://output', 'w'); |
|
51 | 51 | |
52 | - if ( false === $output ) { |
|
53 | - wp_die( __( 'Unsupported server', 'invoicing' ), 500 ); |
|
52 | + if (false === $output) { |
|
53 | + wp_die(__('Unsupported server', 'invoicing'), 500); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return $output; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - public function prepare_file_type( $graph ) { |
|
64 | + public function prepare_file_type($graph) { |
|
65 | 65 | |
66 | - $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] ); |
|
67 | - $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) ); |
|
66 | + $file_type = empty($_REQUEST['file_type']) ? 'csv' : sanitize_text_field($_REQUEST['file_type']); |
|
67 | + $file_name = wpinv_sanitize_key("getpaid-$graph-" . current_time('Y-m-d')); |
|
68 | 68 | |
69 | - header( "Content-Type:application/$file_type" ); |
|
70 | - header( "Content-Disposition:attachment;filename=$file_name.$file_type" ); |
|
69 | + header("Content-Type:application/$file_type"); |
|
70 | + header("Content-Disposition:attachment;filename=$file_name.$file_type"); |
|
71 | 71 | |
72 | 72 | return $file_type; |
73 | 73 | } |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | * Handles the actual download. |
77 | 77 | * |
78 | 78 | */ |
79 | - public function download( $graph ) { |
|
79 | + public function download($graph) { |
|
80 | 80 | global $wpdb; |
81 | 81 | |
82 | - $handler = $this->prepare_handler( $graph ); |
|
82 | + $handler = $this->prepare_handler($graph); |
|
83 | 83 | $stream = $this->prepare_output(); |
84 | - $stats = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) ); |
|
85 | - $headers = array( $handler->field, 'total', 'total_raw' ); |
|
86 | - $file_type = $this->prepare_file_type( $graph ); |
|
87 | - |
|
88 | - if ( 'csv' == $file_type ) { |
|
89 | - $this->download_csv( $stats, $stream, $headers ); |
|
90 | - } else if( 'xml' == $file_type ) { |
|
91 | - $this->download_xml( $stats, $stream, $headers ); |
|
84 | + $stats = $wpdb->get_results($handler->get_sql($handler->get_range())); |
|
85 | + $headers = array($handler->field, 'total', 'total_raw'); |
|
86 | + $file_type = $this->prepare_file_type($graph); |
|
87 | + |
|
88 | + if ('csv' == $file_type) { |
|
89 | + $this->download_csv($stats, $stream, $headers); |
|
90 | + } else if ('xml' == $file_type) { |
|
91 | + $this->download_xml($stats, $stream, $headers); |
|
92 | 92 | } else { |
93 | - $this->download_json( $stats, $stream, $headers ); |
|
93 | + $this->download_json($stats, $stream, $headers); |
|
94 | 94 | } |
95 | 95 | |
96 | - fclose( $stream ); |
|
96 | + fclose($stream); |
|
97 | 97 | exit; |
98 | 98 | } |
99 | 99 | |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * @param array $headers The fields to stream. |
106 | 106 | * @since 1.0.19 |
107 | 107 | */ |
108 | - public function download_csv( $stats, $stream, $headers ) { |
|
108 | + public function download_csv($stats, $stream, $headers) { |
|
109 | 109 | |
110 | 110 | // Output the csv column headers. |
111 | - fputcsv( $stream, $headers ); |
|
111 | + fputcsv($stream, $headers); |
|
112 | 112 | |
113 | 113 | // Loop through |
114 | - foreach ( $stats as $stat ) { |
|
115 | - $row = array_values( $this->prepare_row( $stat, $headers ) ); |
|
116 | - $row = array_map( 'maybe_serialize', $row ); |
|
117 | - fputcsv( $stream, $row ); |
|
114 | + foreach ($stats as $stat) { |
|
115 | + $row = array_values($this->prepare_row($stat, $headers)); |
|
116 | + $row = array_map('maybe_serialize', $row); |
|
117 | + fputcsv($stream, $row); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | } |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | * @param array $headers The fields to stream. |
128 | 128 | * @since 1.0.19 |
129 | 129 | */ |
130 | - public function download_json( $stats, $stream, $headers ) { |
|
130 | + public function download_json($stats, $stream, $headers) { |
|
131 | 131 | |
132 | 132 | $prepared = array(); |
133 | 133 | |
134 | 134 | // Loop through |
135 | - foreach ( $stats as $stat ) { |
|
136 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
135 | + foreach ($stats as $stat) { |
|
136 | + $prepared[] = $this->prepare_row($stat, $headers); |
|
137 | 137 | } |
138 | 138 | |
139 | - fwrite( $stream, wp_json_encode( $prepared ) ); |
|
139 | + fwrite($stream, wp_json_encode($prepared)); |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | |
@@ -148,19 +148,19 @@ discard block |
||
148 | 148 | * @param array $headers The fields to stream. |
149 | 149 | * @since 1.0.19 |
150 | 150 | */ |
151 | - public function download_xml( $stats, $stream, $headers ) { |
|
151 | + public function download_xml($stats, $stream, $headers) { |
|
152 | 152 | |
153 | 153 | $prepared = array(); |
154 | 154 | |
155 | 155 | // Loop through |
156 | - foreach ( $stats as $stat ) { |
|
157 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
156 | + foreach ($stats as $stat) { |
|
157 | + $prepared[] = $this->prepare_row($stat, $headers); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>'); |
161 | - $this->convert_array_xml( $prepared, $xml ); |
|
161 | + $this->convert_array_xml($prepared, $xml); |
|
162 | 162 | |
163 | - fwrite( $stream, $xml->asXML() ); |
|
163 | + fwrite($stream, $xml->asXML()); |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
@@ -170,24 +170,24 @@ discard block |
||
170 | 170 | * @access public |
171 | 171 | * @since 1.0.19 |
172 | 172 | */ |
173 | - public function convert_array_xml( $data, $xml ) { |
|
173 | + public function convert_array_xml($data, $xml) { |
|
174 | 174 | |
175 | 175 | // Loop through |
176 | - foreach ( $data as $key => $value ) { |
|
176 | + foreach ($data as $key => $value) { |
|
177 | 177 | |
178 | - $key = preg_replace( "/[^A-Za-z0-9_\-]/", '', $key ); |
|
178 | + $key = preg_replace("/[^A-Za-z0-9_\-]/", '', $key); |
|
179 | 179 | |
180 | - if ( is_array( $value ) ) { |
|
180 | + if (is_array($value)) { |
|
181 | 181 | |
182 | - if ( is_numeric( $key ) ){ |
|
183 | - $key = 'item'.$key; //dealing with <0/>..<n/> issues |
|
182 | + if (is_numeric($key)) { |
|
183 | + $key = 'item' . $key; //dealing with <0/>..<n/> issues |
|
184 | 184 | } |
185 | 185 | |
186 | - $subnode = $xml->addChild( $key ); |
|
187 | - $this->convert_array_xml( $value, $subnode ); |
|
186 | + $subnode = $xml->addChild($key); |
|
187 | + $this->convert_array_xml($value, $subnode); |
|
188 | 188 | |
189 | 189 | } else { |
190 | - $xml->addChild( $key, htmlspecialchars( $value ) ); |
|
190 | + $xml->addChild($key, htmlspecialchars($value)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | } |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return array |
204 | 204 | */ |
205 | - public function prepare_row( $row, $fields ) { |
|
205 | + public function prepare_row($row, $fields) { |
|
206 | 206 | |
207 | 207 | $prepared = array(); |
208 | 208 | $row = (array) $row; |
209 | 209 | |
210 | - foreach ( $fields as $field ) { |
|
210 | + foreach ($fields as $field) { |
|
211 | 211 | |
212 | - if ( $field === 'total' ) { |
|
213 | - $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES ); |
|
212 | + if ($field === 'total') { |
|
213 | + $prepared[$field] = html_entity_decode(strip_tags(wpinv_price($row['total'])), ENT_QUOTES); |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | - if ( $field === 'total_raw' ) { |
|
218 | - $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) ); |
|
217 | + if ($field === 'total_raw') { |
|
218 | + $prepared[$field] = wpinv_round_amount(wpinv_sanitize_amount($row['total'])); |
|
219 | 219 | continue; |
220 | 220 | } |
221 | 221 | |
222 | - $prepared[ $field ] = strip_tags( $row[ $field ] ); |
|
222 | + $prepared[$field] = strip_tags($row[$field]); |
|
223 | 223 | |
224 | 224 | } |
225 | 225 |
@@ -7,20 +7,20 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class ); |
|
13 | -$label = empty( $label ) ? esc_attr__( 'Pay %price% »', 'invoicing' ) : esc_attr( $label ); |
|
14 | -$free = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free ); |
|
12 | +$class = empty($class) ? 'btn-primary' : sanitize_html_class($class); |
|
13 | +$label = empty($label) ? esc_attr__('Pay %price% »', 'invoicing') : esc_attr($label); |
|
14 | +$free = empty($free) ? esc_attr__('Continue »', 'invoicing') : esc_attr($free); |
|
15 | 15 | |
16 | -do_action( 'getpaid_before_payment_form_pay_button', $form ); |
|
16 | +do_action('getpaid_before_payment_form_pay_button', $form); |
|
17 | 17 | |
18 | 18 | echo aui()->input( |
19 | 19 | array( |
20 | - 'name' => esc_attr( $id ), |
|
21 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
20 | + 'name' => esc_attr($id), |
|
21 | + 'id' => esc_attr($id) . uniqid('_'), |
|
22 | 22 | 'value' => $label, |
23 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
23 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
24 | 24 | 'type' => 'submit', |
25 | 25 | 'class' => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class, |
26 | 26 | 'extra_attributes' => array( |
@@ -30,4 +30,4 @@ discard block |
||
30 | 30 | ) |
31 | 31 | ); |
32 | 32 | |
33 | -do_action( 'getpaid_after_payment_form_pay_button', $form ); |
|
34 | 33 | \ No newline at end of file |
34 | +do_action('getpaid_after_payment_form_pay_button', $form); |
|
35 | 35 | \ No newline at end of file |
@@ -256,8 +256,9 @@ |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | function wpinv_cart_needs_tax_address_fields() { |
259 | - if( !wpinv_is_cart_taxed() ) |
|
260 | - return false; |
|
259 | + if( !wpinv_is_cart_taxed() ) { |
|
260 | + return false; |
|
261 | + } |
|
261 | 262 | |
262 | 263 | return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
263 | 264 | } |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
216 | 216 | |
217 | 217 | $initial_tax = $tax_amount; |
218 | - $recurring_tax = 0; |
|
218 | + $recurring_tax = 0; |
|
219 | 219 | |
220 | 220 | if ( $item->is_recurring() ) { |
221 | - $recurring_tax = $recurring_tax_amount; |
|
222 | - } |
|
221 | + $recurring_tax = $recurring_tax_amount; |
|
222 | + } |
|
223 | 223 | |
224 | - return array( |
|
225 | - 'name' => sanitize_text_field( $tax_name ), |
|
226 | - 'initial_tax' => $initial_tax, |
|
227 | - 'recurring_tax' => $recurring_tax, |
|
224 | + return array( |
|
225 | + 'name' => sanitize_text_field( $tax_name ), |
|
226 | + 'initial_tax' => $initial_tax, |
|
227 | + 'recurring_tax' => $recurring_tax, |
|
228 | 228 | ); |
229 | 229 | |
230 | 230 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function wpinv_should_validate_vat_number() { |
330 | 330 | $validate = wpinv_get_option( 'validate_vat_number' ); |
331 | - return ! empty( $validate ); |
|
331 | + return ! empty( $validate ); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | function wpinv_sales_tax_for_year( $year = null ) { |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Returns an array of eu states. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function getpaid_get_eu_states() { |
15 | - return wpinv_get_data( 'eu-states' ); |
|
15 | + return wpinv_get_data('eu-states'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false; |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | function getpaid_get_gst_states() { |
33 | - return array( 'AU', 'NZ', 'CA', 'CN' ); |
|
33 | + return array('AU', 'NZ', 'CA', 'CN'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | -function getpaid_is_gst_country( $country ) { |
|
42 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false; |
|
41 | +function getpaid_is_gst_country($country) { |
|
42 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = ! $is_eu && wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = !$is_eu && wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' != $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function wpinv_use_store_address_as_tax_base() { |
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base'; |
|
98 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base ); |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') == 'base'; |
|
98 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function wpinv_prices_include_tax() { |
107 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes'; |
|
108 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
107 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes'; |
|
108 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | function wpinv_round_tax_per_tax_rate() { |
117 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
118 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
117 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
118 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @return bool |
125 | 125 | */ |
126 | 126 | function wpinv_display_individual_tax_rates() { |
127 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual'; |
|
128 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
127 | + $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual'; |
|
128 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return float |
135 | 135 | */ |
136 | 136 | function wpinv_get_default_tax_rate() { |
137 | - $rate = wpinv_get_option( 'tax_rate', 0 ); |
|
138 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
137 | + $rate = wpinv_get_option('tax_rate', 0); |
|
138 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | function wpinv_same_country_exempt_vat() { |
147 | - return 'no' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ); |
|
147 | + return 'no' == wpinv_get_option('vat_same_country_rule', 'vat_too'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | * @param string $state |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
167 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
168 | 168 | |
169 | 169 | // Abort if the item is not taxable. |
170 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
170 | + if (!wpinv_is_item_taxable($item)) { |
|
171 | 171 | return array(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Maybe use the store address. |
175 | - if ( wpinv_use_store_address_as_tax_base() ) { |
|
175 | + if (wpinv_use_store_address_as_tax_base()) { |
|
176 | 176 | $country = wpinv_get_default_country(); |
177 | 177 | $state = wpinv_get_default_state(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Retrieve tax rates. |
181 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
181 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
182 | 182 | |
183 | 183 | // Fallback to the default tax rates if non were found. |
184 | - if ( empty( $tax_rates ) ) { |
|
184 | + if (empty($tax_rates)) { |
|
185 | 185 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
186 | 186 | } |
187 | 187 | |
188 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
188 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | * @param array $rates |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function getpaid_filter_item_tax_rates( $item, $rates ) { |
|
198 | +function getpaid_filter_item_tax_rates($item, $rates) { |
|
199 | 199 | |
200 | 200 | $tax_class = $item->get_vat_class(); |
201 | 201 | |
202 | - foreach ( $rates as $i => $rate ) { |
|
202 | + foreach ($rates as $i => $rate) { |
|
203 | 203 | |
204 | - if ( $tax_class == '_reduced' ) { |
|
205 | - $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate']; |
|
204 | + if ($tax_class == '_reduced') { |
|
205 | + $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate']; |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $tax_class == '_exempt' ) { |
|
209 | - $rates[ $i ]['rate'] = 0; |
|
208 | + if ($tax_class == '_exempt') { |
|
209 | + $rates[$i]['rate'] = 0; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
213 | 213 | |
214 | - return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item ); |
|
214 | + return apply_filters('getpaid_filter_item_tax_rates', $rates, $item); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | * @param array $rates |
222 | 222 | * @return array |
223 | 223 | */ |
224 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
224 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
225 | 225 | |
226 | 226 | $is_inclusive = wpinv_prices_include_tax(); |
227 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
227 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
229 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param float $recurring_tax_amount |
239 | 239 | * @return array |
240 | 240 | */ |
241 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
241 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
242 | 242 | |
243 | - $initial_tax = $tax_amount; |
|
243 | + $initial_tax = $tax_amount; |
|
244 | 244 | $recurring_tax = 0; |
245 | 245 | |
246 | - if ( $item->is_recurring() ) { |
|
246 | + if ($item->is_recurring()) { |
|
247 | 247 | $recurring_tax = $recurring_tax_amount; |
248 | 248 | } |
249 | 249 | |
250 | 250 | return array( |
251 | - 'name' => sanitize_text_field( $tax_name ), |
|
251 | + 'name' => sanitize_text_field($tax_name), |
|
252 | 252 | 'initial_tax' => $initial_tax, |
253 | 253 | 'recurring_tax' => $recurring_tax, |
254 | 254 | ); |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @param string $vat_number |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
265 | - return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
264 | +function wpinv_sanitize_vat_number($vat_number) { |
|
265 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -271,22 +271,22 @@ discard block |
||
271 | 271 | * @param string $vat_number |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
274 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
275 | 275 | |
276 | - $country = substr( $vat_number, 0, 2 ); |
|
277 | - $vatin = substr( $vat_number, 2 ); |
|
278 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
276 | + $country = substr($vat_number, 0, 2); |
|
277 | + $vatin = substr($vat_number, 2); |
|
278 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
279 | 279 | |
280 | - if ( isset( $regexes[ $country ] ) ) { |
|
280 | + if (isset($regexes[$country])) { |
|
281 | 281 | |
282 | - $regex = $regexes[ $country ]; |
|
282 | + $regex = $regexes[$country]; |
|
283 | 283 | $regex = '/^(?:' . $regex . ')$/'; |
284 | - return 1 === preg_match( $regex, $vatin ); |
|
284 | + return 1 === preg_match($regex, $vatin); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Not an EU state, use filters to validate the number. |
289 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
289 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | * @param string $vat_number |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
298 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
299 | 299 | |
300 | - $country = substr( $vat_number, 0, 2 ); |
|
301 | - $vatin = substr( $vat_number, 2 ); |
|
300 | + $country = substr($vat_number, 0, 2); |
|
301 | + $vatin = substr($vat_number, 2); |
|
302 | 302 | |
303 | 303 | $url = add_query_arg( |
304 | 304 | array( |
305 | - 'ms' => urlencode( $country ), |
|
306 | - 'iso' => urlencode( $country ), |
|
307 | - 'vat' => urlencode( $vatin ), |
|
305 | + 'ms' => urlencode($country), |
|
306 | + 'iso' => urlencode($country), |
|
307 | + 'vat' => urlencode($vatin), |
|
308 | 308 | ), |
309 | 309 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
310 | 310 | ); |
311 | 311 | |
312 | - $response = wp_remote_get( $url ); |
|
313 | - $response = wp_remote_retrieve_body( $response ); |
|
312 | + $response = wp_remote_get($url); |
|
313 | + $response = wp_remote_retrieve_body($response); |
|
314 | 314 | |
315 | 315 | // Fallback gracefully if the VIES website is down. |
316 | - if ( empty( $response ) ) { |
|
316 | + if (empty($response)) { |
|
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | |
320 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
320 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | * @param string $country |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
331 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
332 | 332 | |
333 | 333 | // In case the vat number does not have a country code... |
334 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
335 | - $_country = substr( $vat_number, 0, 2 ); |
|
336 | - $_country = $_country == wpinv_country_name( $_country ); |
|
334 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
335 | + $_country = substr($vat_number, 0, 2); |
|
336 | + $_country = $_country == wpinv_country_name($_country); |
|
337 | 337 | |
338 | - if ( $_country ) { |
|
339 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
338 | + if ($_country) { |
|
339 | + $vat_number = strtoupper($country) . $vat_number; |
|
340 | 340 | } |
341 | 341 | |
342 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
342 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -348,40 +348,40 @@ discard block |
||
348 | 348 | * @return bool |
349 | 349 | */ |
350 | 350 | function wpinv_should_validate_vat_number() { |
351 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
352 | - return ! empty( $validate ); |
|
351 | + $validate = wpinv_get_option('validate_vat_number'); |
|
352 | + return !empty($validate); |
|
353 | 353 | } |
354 | 354 | |
355 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
356 | - return wpinv_price( wpinv_get_sales_tax_for_year( $year ) ); |
|
355 | +function wpinv_sales_tax_for_year($year = null) { |
|
356 | + return wpinv_price(wpinv_get_sales_tax_for_year($year)); |
|
357 | 357 | } |
358 | 358 | |
359 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
359 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
360 | 360 | global $wpdb; |
361 | 361 | |
362 | 362 | // Start at zero |
363 | 363 | $tax = 0; |
364 | 364 | |
365 | - if ( ! empty( $year ) ) { |
|
365 | + if (!empty($year)) { |
|
366 | 366 | $args = array( |
367 | 367 | 'post_type' => 'wpi_invoice', |
368 | - 'post_status' => array( 'publish' ), |
|
368 | + 'post_status' => array('publish'), |
|
369 | 369 | 'posts_per_page' => -1, |
370 | 370 | 'year' => $year, |
371 | 371 | 'fields' => 'ids' |
372 | 372 | ); |
373 | 373 | |
374 | - $payments = get_posts( $args ); |
|
375 | - $payment_ids = implode( ',', $payments ); |
|
374 | + $payments = get_posts($args); |
|
375 | + $payment_ids = implode(',', $payments); |
|
376 | 376 | |
377 | - if ( count( $payments ) > 0 ) { |
|
377 | + if (count($payments) > 0) { |
|
378 | 378 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
379 | - $tax = $wpdb->get_var( $sql ); |
|
379 | + $tax = $wpdb->get_var($sql); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
384 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | function wpinv_is_cart_taxed() { |
@@ -390,33 +390,33 @@ discard block |
||
390 | 390 | |
391 | 391 | function wpinv_prices_show_tax_on_checkout() { |
392 | 392 | return false; // TODO |
393 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
393 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
394 | 394 | |
395 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
395 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_display_tax_rate() { |
399 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
399 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
400 | 400 | |
401 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
401 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function wpinv_cart_needs_tax_address_fields() { |
405 | - if( !wpinv_is_cart_taxed() ) |
|
405 | + if (!wpinv_is_cart_taxed()) |
|
406 | 406 | return false; |
407 | 407 | |
408 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
408 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
409 | 409 | } |
410 | 410 | |
411 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
412 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
413 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
411 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
412 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
413 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
414 | 414 | } |
415 | 415 | |
416 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
416 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
417 | 417 | $currency = wpinv_get_currency(); |
418 | 418 | |
419 | - switch ( $currency ) { |
|
419 | + switch ($currency) { |
|
420 | 420 | case 'RIAL' : |
421 | 421 | case 'JPY' : |
422 | 422 | case 'TWD' : |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | break; |
426 | 426 | } |
427 | 427 | |
428 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
428 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | function wpinv_tax_amount() { |
432 | 432 | $output = 0.00; |
433 | 433 | |
434 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
434 | + return apply_filters('wpinv_tax_amount', $output); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -439,25 +439,25 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param string|bool|null $vat_rule |
441 | 441 | */ |
442 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
442 | +function getpaid_filter_vat_rule($vat_rule) { |
|
443 | 443 | |
444 | - if ( empty( $vat_rule ) ) { |
|
444 | + if (empty($vat_rule)) { |
|
445 | 445 | return 'digital'; |
446 | 446 | } |
447 | 447 | |
448 | 448 | return $vat_rule; |
449 | 449 | } |
450 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
450 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * Filters the VAT class to ensure that each item has a VAT class. |
454 | 454 | * |
455 | 455 | * @param string|bool|null $vat_rule |
456 | 456 | */ |
457 | -function getpaid_filter_vat_class( $vat_class ) { |
|
458 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
457 | +function getpaid_filter_vat_class($vat_class) { |
|
458 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
459 | 459 | } |
460 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
460 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Returns a list of all tax classes. |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | return apply_filters( |
470 | 470 | 'getpaid_tax_classes', |
471 | 471 | array( |
472 | - '_standard' => __( 'Standard Tax Rate', 'invoicing' ), |
|
473 | - '_reduced' => __( 'Reduced Tax Rate', 'invoicing' ), |
|
474 | - '_exempt' => __( 'Tax Exempt', 'invoicing' ), |
|
472 | + '_standard' => __('Standard Tax Rate', 'invoicing'), |
|
473 | + '_reduced' => __('Reduced Tax Rate', 'invoicing'), |
|
474 | + '_exempt' => __('Tax Exempt', 'invoicing'), |
|
475 | 475 | ) |
476 | 476 | ); |
477 | 477 | |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | return apply_filters( |
488 | 488 | 'getpaid_tax_rules', |
489 | 489 | array( |
490 | - 'physical' => __( 'Physical Item', 'invoicing' ), |
|
491 | - 'digital' => __( 'Digital Item', 'invoicing' ), |
|
490 | + 'physical' => __('Physical Item', 'invoicing'), |
|
491 | + 'digital' => __('Digital Item', 'invoicing'), |
|
492 | 492 | ) |
493 | 493 | ); |
494 | 494 | |
@@ -500,15 +500,15 @@ discard block |
||
500 | 500 | * @param string $tax_class |
501 | 501 | * @return string |
502 | 502 | */ |
503 | -function getpaid_get_tax_class_label( $tax_class ) { |
|
503 | +function getpaid_get_tax_class_label($tax_class) { |
|
504 | 504 | |
505 | 505 | $classes = getpaid_get_tax_classes(); |
506 | 506 | |
507 | - if ( isset( $classes[ $tax_class ] ) ) { |
|
508 | - return sanitize_text_field( $classes[ $tax_class ] ); |
|
507 | + if (isset($classes[$tax_class])) { |
|
508 | + return sanitize_text_field($classes[$tax_class]); |
|
509 | 509 | } |
510 | 510 | |
511 | - return sanitize_text_field( $tax_class ); |
|
511 | + return sanitize_text_field($tax_class); |
|
512 | 512 | |
513 | 513 | } |
514 | 514 | |
@@ -518,15 +518,15 @@ discard block |
||
518 | 518 | * @param string $tax_rule |
519 | 519 | * @return string |
520 | 520 | */ |
521 | -function getpaid_get_tax_rule_label( $tax_rule ) { |
|
521 | +function getpaid_get_tax_rule_label($tax_rule) { |
|
522 | 522 | |
523 | 523 | $rules = getpaid_get_tax_rules(); |
524 | 524 | |
525 | - if ( isset( $rules[ $tax_rule ] ) ) { |
|
526 | - return sanitize_text_field( $rules[ $tax_rule ] ); |
|
525 | + if (isset($rules[$tax_rule])) { |
|
526 | + return sanitize_text_field($rules[$tax_rule]); |
|
527 | 527 | } |
528 | 528 | |
529 | - return sanitize_text_field( $tax_rule ); |
|
529 | + return sanitize_text_field($tax_rule); |
|
530 | 530 | |
531 | 531 | } |
532 | 532 | |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | * @param string $recurring |
538 | 538 | * @return string |
539 | 539 | */ |
540 | -function getpaid_get_taxable_amount( $item, $recurring = false ) { |
|
540 | +function getpaid_get_taxable_amount($item, $recurring = false) { |
|
541 | 541 | |
542 | 542 | $taxable_amount = $recurring ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
543 | 543 | $taxable_amount -= $recurring ? $item->recurring_item_discount : $item->item_discount; |
544 | - $taxable_amount = max( 0, $taxable_amount ); |
|
545 | - return apply_filters( 'getpaid_taxable_amount', $taxable_amount, $item, $recurring ); |
|
544 | + $taxable_amount = max(0, $taxable_amount); |
|
545 | + return apply_filters('getpaid_taxable_amount', $taxable_amount, $item, $recurring); |
|
546 | 546 | |
547 | 547 | } |
@@ -12,194 +12,194 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Invoice_Exporter extends GetPaid_Graph_Downloader { |
14 | 14 | |
15 | - /** |
|
16 | - * Retrieves invoices query args. |
|
17 | - * |
|
18 | - * @param string $post_type post type to retrieve. |
|
19 | - * @param array $args Args to search for. |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public function get_invoice_query_args( $post_type, $args ) { |
|
23 | - |
|
24 | - $query_args = array( |
|
25 | - 'post_type' => $post_type, |
|
26 | - 'post_status' => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ), |
|
27 | - 'posts_per_page' => -1, |
|
28 | - 'no_found_rows' => true, |
|
29 | - 'update_post_term_cache' => false, |
|
30 | - 'fields' => 'ids', |
|
31 | - ); |
|
32 | - |
|
33 | - if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) { |
|
34 | - $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
35 | - } |
|
36 | - |
|
37 | - $date_query = array(); |
|
38 | - if ( ! empty( $args['to_date'] ) ) { |
|
39 | - $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
40 | - } |
|
41 | - |
|
42 | - if ( ! empty( $args['from_date'] ) ) { |
|
43 | - $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
44 | - } |
|
45 | - |
|
46 | - if ( ! empty( $date_query ) ) { |
|
47 | - $date_query['inclusive'] = true; |
|
48 | - $query_args['date_query'] = array( $date_query ); |
|
49 | - } |
|
50 | - |
|
51 | - return $query_args; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Retrieves invoices. |
|
56 | - * |
|
57 | - * @param array $query_args WP_Query args. |
|
58 | - * @return WPInv_Invoice[] |
|
59 | - */ |
|
60 | - public function get_invoices( $query_args ) { |
|
61 | - |
|
62 | - // Get invoices. |
|
63 | - $invoices = new WP_Query( $query_args ); |
|
64 | - |
|
65 | - // Prepare the results. |
|
66 | - return array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
67 | - |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Handles the actual download. |
|
72 | - * |
|
73 | - */ |
|
74 | - public function export( $post_type, $args ) { |
|
75 | - |
|
76 | - $invoices = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) ); |
|
77 | - $stream = $this->prepare_output(); |
|
78 | - $headers = $this->get_export_fields( $post_type ); |
|
79 | - $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) ); |
|
80 | - |
|
81 | - if ( 'csv' == $file_type ) { |
|
82 | - $this->download_csv( $invoices, $stream, $headers ); |
|
83 | - } else if( 'xml' == $file_type ) { |
|
84 | - $this->download_xml( $invoices, $stream, $headers ); |
|
85 | - } else { |
|
86 | - $this->download_json( $invoices, $stream, $headers ); |
|
87 | - } |
|
88 | - |
|
89 | - fclose( $stream ); |
|
90 | - exit; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Prepares a single invoice for download. |
|
95 | - * |
|
96 | - * @param WPInv_Invoice $invoice The invoice to prepare.. |
|
97 | - * @param array $fields The fields to stream. |
|
98 | - * @since 1.0.19 |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function prepare_row( $invoice, $fields ) { |
|
102 | - |
|
103 | - $prepared = array(); |
|
104 | - $amount_fields = $this->get_amount_fields( $invoice->get_post_type() ); |
|
105 | - |
|
106 | - foreach ( $fields as $field ) { |
|
107 | - |
|
108 | - $value = ''; |
|
109 | - $method = "get_$field"; |
|
110 | - |
|
111 | - if ( method_exists( $invoice, $method ) ) { |
|
112 | - $value = $invoice->$method(); |
|
113 | - } |
|
114 | - |
|
115 | - if ( in_array( $field, $amount_fields ) ) { |
|
116 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
117 | - } |
|
118 | - |
|
119 | - $prepared[ $field ] = wpinv_clean( $value ); |
|
120 | - |
|
121 | - } |
|
122 | - |
|
123 | - return $prepared; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Retrieves export fields. |
|
128 | - * |
|
129 | - * @param string $post_type |
|
130 | - * @since 1.0.19 |
|
131 | - * @return array |
|
132 | - */ |
|
133 | - public function get_export_fields( $post_type ) { |
|
134 | - |
|
135 | - $fields = array( |
|
136 | - 'id', |
|
137 | - 'parent_id', |
|
138 | - 'status', |
|
139 | - 'date_created', |
|
140 | - 'date_modified', |
|
141 | - 'date_due', |
|
142 | - 'date_completed', |
|
143 | - 'number', |
|
144 | - 'key', |
|
145 | - 'description', |
|
146 | - 'post_type', |
|
147 | - 'mode', |
|
148 | - 'customer_id', |
|
149 | - 'customer_first_name', |
|
150 | - 'customer_last_name', |
|
151 | - 'customer_phone', |
|
152 | - 'customer_email', |
|
153 | - 'customer_country', |
|
154 | - 'customer_city', |
|
155 | - 'customer_state', |
|
156 | - 'customer_zip', |
|
157 | - 'customer_company', |
|
158 | - 'customer_vat_number', |
|
159 | - 'customer_address', |
|
160 | - 'subtotal', |
|
161 | - 'total_discount', |
|
162 | - 'total_tax', |
|
163 | - 'total_fees', |
|
164 | - 'fees', |
|
165 | - 'discounts', |
|
166 | - 'taxes', |
|
167 | - 'cart_details', |
|
168 | - 'item_ids', |
|
169 | - 'payment_form', |
|
170 | - 'discount_code', |
|
171 | - 'gateway', |
|
172 | - 'transaction_id', |
|
173 | - 'currency', |
|
174 | - 'disable_taxes', |
|
175 | - 'subscription_id', |
|
176 | - 'remote_subscription_id', |
|
177 | - 'is_viewed', |
|
178 | - 'email_cc', |
|
179 | - 'template', |
|
180 | - 'created_via' |
|
181 | - ); |
|
182 | - |
|
183 | - return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type ); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Retrieves amount fields. |
|
188 | - * |
|
189 | - * @param string $post_type |
|
190 | - * @since 1.0.19 |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function get_amount_fields( $post_type ) { |
|
194 | - |
|
195 | - $fields = array( |
|
196 | - 'subtotal', |
|
197 | - 'total_discount', |
|
198 | - 'total_tax', |
|
199 | - 'total_fees' |
|
200 | - ); |
|
201 | - |
|
202 | - return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type ); |
|
203 | - } |
|
15 | + /** |
|
16 | + * Retrieves invoices query args. |
|
17 | + * |
|
18 | + * @param string $post_type post type to retrieve. |
|
19 | + * @param array $args Args to search for. |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public function get_invoice_query_args( $post_type, $args ) { |
|
23 | + |
|
24 | + $query_args = array( |
|
25 | + 'post_type' => $post_type, |
|
26 | + 'post_status' => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ), |
|
27 | + 'posts_per_page' => -1, |
|
28 | + 'no_found_rows' => true, |
|
29 | + 'update_post_term_cache' => false, |
|
30 | + 'fields' => 'ids', |
|
31 | + ); |
|
32 | + |
|
33 | + if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) { |
|
34 | + $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
35 | + } |
|
36 | + |
|
37 | + $date_query = array(); |
|
38 | + if ( ! empty( $args['to_date'] ) ) { |
|
39 | + $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
40 | + } |
|
41 | + |
|
42 | + if ( ! empty( $args['from_date'] ) ) { |
|
43 | + $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
44 | + } |
|
45 | + |
|
46 | + if ( ! empty( $date_query ) ) { |
|
47 | + $date_query['inclusive'] = true; |
|
48 | + $query_args['date_query'] = array( $date_query ); |
|
49 | + } |
|
50 | + |
|
51 | + return $query_args; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Retrieves invoices. |
|
56 | + * |
|
57 | + * @param array $query_args WP_Query args. |
|
58 | + * @return WPInv_Invoice[] |
|
59 | + */ |
|
60 | + public function get_invoices( $query_args ) { |
|
61 | + |
|
62 | + // Get invoices. |
|
63 | + $invoices = new WP_Query( $query_args ); |
|
64 | + |
|
65 | + // Prepare the results. |
|
66 | + return array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
67 | + |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Handles the actual download. |
|
72 | + * |
|
73 | + */ |
|
74 | + public function export( $post_type, $args ) { |
|
75 | + |
|
76 | + $invoices = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) ); |
|
77 | + $stream = $this->prepare_output(); |
|
78 | + $headers = $this->get_export_fields( $post_type ); |
|
79 | + $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) ); |
|
80 | + |
|
81 | + if ( 'csv' == $file_type ) { |
|
82 | + $this->download_csv( $invoices, $stream, $headers ); |
|
83 | + } else if( 'xml' == $file_type ) { |
|
84 | + $this->download_xml( $invoices, $stream, $headers ); |
|
85 | + } else { |
|
86 | + $this->download_json( $invoices, $stream, $headers ); |
|
87 | + } |
|
88 | + |
|
89 | + fclose( $stream ); |
|
90 | + exit; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Prepares a single invoice for download. |
|
95 | + * |
|
96 | + * @param WPInv_Invoice $invoice The invoice to prepare.. |
|
97 | + * @param array $fields The fields to stream. |
|
98 | + * @since 1.0.19 |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function prepare_row( $invoice, $fields ) { |
|
102 | + |
|
103 | + $prepared = array(); |
|
104 | + $amount_fields = $this->get_amount_fields( $invoice->get_post_type() ); |
|
105 | + |
|
106 | + foreach ( $fields as $field ) { |
|
107 | + |
|
108 | + $value = ''; |
|
109 | + $method = "get_$field"; |
|
110 | + |
|
111 | + if ( method_exists( $invoice, $method ) ) { |
|
112 | + $value = $invoice->$method(); |
|
113 | + } |
|
114 | + |
|
115 | + if ( in_array( $field, $amount_fields ) ) { |
|
116 | + $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
117 | + } |
|
118 | + |
|
119 | + $prepared[ $field ] = wpinv_clean( $value ); |
|
120 | + |
|
121 | + } |
|
122 | + |
|
123 | + return $prepared; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Retrieves export fields. |
|
128 | + * |
|
129 | + * @param string $post_type |
|
130 | + * @since 1.0.19 |
|
131 | + * @return array |
|
132 | + */ |
|
133 | + public function get_export_fields( $post_type ) { |
|
134 | + |
|
135 | + $fields = array( |
|
136 | + 'id', |
|
137 | + 'parent_id', |
|
138 | + 'status', |
|
139 | + 'date_created', |
|
140 | + 'date_modified', |
|
141 | + 'date_due', |
|
142 | + 'date_completed', |
|
143 | + 'number', |
|
144 | + 'key', |
|
145 | + 'description', |
|
146 | + 'post_type', |
|
147 | + 'mode', |
|
148 | + 'customer_id', |
|
149 | + 'customer_first_name', |
|
150 | + 'customer_last_name', |
|
151 | + 'customer_phone', |
|
152 | + 'customer_email', |
|
153 | + 'customer_country', |
|
154 | + 'customer_city', |
|
155 | + 'customer_state', |
|
156 | + 'customer_zip', |
|
157 | + 'customer_company', |
|
158 | + 'customer_vat_number', |
|
159 | + 'customer_address', |
|
160 | + 'subtotal', |
|
161 | + 'total_discount', |
|
162 | + 'total_tax', |
|
163 | + 'total_fees', |
|
164 | + 'fees', |
|
165 | + 'discounts', |
|
166 | + 'taxes', |
|
167 | + 'cart_details', |
|
168 | + 'item_ids', |
|
169 | + 'payment_form', |
|
170 | + 'discount_code', |
|
171 | + 'gateway', |
|
172 | + 'transaction_id', |
|
173 | + 'currency', |
|
174 | + 'disable_taxes', |
|
175 | + 'subscription_id', |
|
176 | + 'remote_subscription_id', |
|
177 | + 'is_viewed', |
|
178 | + 'email_cc', |
|
179 | + 'template', |
|
180 | + 'created_via' |
|
181 | + ); |
|
182 | + |
|
183 | + return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type ); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Retrieves amount fields. |
|
188 | + * |
|
189 | + * @param string $post_type |
|
190 | + * @since 1.0.19 |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function get_amount_fields( $post_type ) { |
|
194 | + |
|
195 | + $fields = array( |
|
196 | + 'subtotal', |
|
197 | + 'total_discount', |
|
198 | + 'total_tax', |
|
199 | + 'total_fees' |
|
200 | + ); |
|
201 | + |
|
202 | + return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type ); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | } |
@@ -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_Invoice_Exporter Class. |
@@ -19,33 +19,33 @@ discard block |
||
19 | 19 | * @param array $args Args to search for. |
20 | 20 | * @return array |
21 | 21 | */ |
22 | - public function get_invoice_query_args( $post_type, $args ) { |
|
22 | + public function get_invoice_query_args($post_type, $args) { |
|
23 | 23 | |
24 | 24 | $query_args = array( |
25 | 25 | 'post_type' => $post_type, |
26 | - 'post_status' => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ), |
|
26 | + 'post_status' => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)), |
|
27 | 27 | 'posts_per_page' => -1, |
28 | 28 | 'no_found_rows' => true, |
29 | 29 | 'update_post_term_cache' => false, |
30 | 30 | 'fields' => 'ids', |
31 | 31 | ); |
32 | 32 | |
33 | - if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) { |
|
34 | - $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
33 | + if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) { |
|
34 | + $query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status'])); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $date_query = array(); |
38 | - if ( ! empty( $args['to_date'] ) ) { |
|
39 | - $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
38 | + if (!empty($args['to_date'])) { |
|
39 | + $date_query['before'] = wpinv_clean($args['to_date']); |
|
40 | 40 | } |
41 | 41 | |
42 | - if ( ! empty( $args['from_date'] ) ) { |
|
43 | - $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
42 | + if (!empty($args['from_date'])) { |
|
43 | + $date_query['after'] = wpinv_clean($args['from_date']); |
|
44 | 44 | } |
45 | 45 | |
46 | - if ( ! empty( $date_query ) ) { |
|
46 | + if (!empty($date_query)) { |
|
47 | 47 | $date_query['inclusive'] = true; |
48 | - $query_args['date_query'] = array( $date_query ); |
|
48 | + $query_args['date_query'] = array($date_query); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $query_args; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @param array $query_args WP_Query args. |
58 | 58 | * @return WPInv_Invoice[] |
59 | 59 | */ |
60 | - public function get_invoices( $query_args ) { |
|
60 | + public function get_invoices($query_args) { |
|
61 | 61 | |
62 | 62 | // Get invoices. |
63 | - $invoices = new WP_Query( $query_args ); |
|
63 | + $invoices = new WP_Query($query_args); |
|
64 | 64 | |
65 | 65 | // Prepare the results. |
66 | - return array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
66 | + return array_map('wpinv_get_invoice', $invoices->posts); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -71,22 +71,22 @@ discard block |
||
71 | 71 | * Handles the actual download. |
72 | 72 | * |
73 | 73 | */ |
74 | - public function export( $post_type, $args ) { |
|
74 | + public function export($post_type, $args) { |
|
75 | 75 | |
76 | - $invoices = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) ); |
|
76 | + $invoices = $this->get_invoices($this->get_invoice_query_args($post_type, $args)); |
|
77 | 77 | $stream = $this->prepare_output(); |
78 | - $headers = $this->get_export_fields( $post_type ); |
|
79 | - $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) ); |
|
78 | + $headers = $this->get_export_fields($post_type); |
|
79 | + $file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type))); |
|
80 | 80 | |
81 | - if ( 'csv' == $file_type ) { |
|
82 | - $this->download_csv( $invoices, $stream, $headers ); |
|
83 | - } else if( 'xml' == $file_type ) { |
|
84 | - $this->download_xml( $invoices, $stream, $headers ); |
|
81 | + if ('csv' == $file_type) { |
|
82 | + $this->download_csv($invoices, $stream, $headers); |
|
83 | + } else if ('xml' == $file_type) { |
|
84 | + $this->download_xml($invoices, $stream, $headers); |
|
85 | 85 | } else { |
86 | - $this->download_json( $invoices, $stream, $headers ); |
|
86 | + $this->download_json($invoices, $stream, $headers); |
|
87 | 87 | } |
88 | 88 | |
89 | - fclose( $stream ); |
|
89 | + fclose($stream); |
|
90 | 90 | exit; |
91 | 91 | } |
92 | 92 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | * @since 1.0.19 |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - public function prepare_row( $invoice, $fields ) { |
|
101 | + public function prepare_row($invoice, $fields) { |
|
102 | 102 | |
103 | 103 | $prepared = array(); |
104 | - $amount_fields = $this->get_amount_fields( $invoice->get_post_type() ); |
|
104 | + $amount_fields = $this->get_amount_fields($invoice->get_post_type()); |
|
105 | 105 | |
106 | - foreach ( $fields as $field ) { |
|
106 | + foreach ($fields as $field) { |
|
107 | 107 | |
108 | 108 | $value = ''; |
109 | 109 | $method = "get_$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 | - if ( in_array( $field, $amount_fields ) ) { |
|
116 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
115 | + if (in_array($field, $amount_fields)) { |
|
116 | + $value = wpinv_round_amount(wpinv_sanitize_amount($value)); |
|
117 | 117 | } |
118 | 118 | |
119 | - $prepared[ $field ] = wpinv_clean( $value ); |
|
119 | + $prepared[$field] = wpinv_clean($value); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @since 1.0.19 |
131 | 131 | * @return array |
132 | 132 | */ |
133 | - public function get_export_fields( $post_type ) { |
|
133 | + public function get_export_fields($post_type) { |
|
134 | 134 | |
135 | 135 | $fields = array( |
136 | 136 | 'id', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'created_via' |
181 | 181 | ); |
182 | 182 | |
183 | - return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type ); |
|
183 | + return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @since 1.0.19 |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - public function get_amount_fields( $post_type ) { |
|
193 | + public function get_amount_fields($post_type) { |
|
194 | 194 | |
195 | 195 | $fields = array( |
196 | 196 | 'subtotal', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'total_fees' |
200 | 200 | ); |
201 | 201 | |
202 | - return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type ); |
|
202 | + return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The Subscriptions DB Class |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | 'transaction_id' => '', |
73 | 73 | 'parent_payment_id' => 0, |
74 | 74 | 'product_id' => 0, |
75 | - 'created' => date( 'Y-m-d H:i:s' ), |
|
76 | - 'expiration' => date( 'Y-m-d H:i:s' ), |
|
75 | + 'created' => date('Y-m-d H:i:s'), |
|
76 | + 'expiration' => date('Y-m-d H:i:s'), |
|
77 | 77 | 'trial_period' => '', |
78 | 78 | 'status' => '', |
79 | 79 | 'profile_id' => '', |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @access public |
87 | 87 | * @since 1.0.0 |
88 | 88 | */ |
89 | - public function get_subscriptions( $args = array() ) { |
|
90 | - return getpaid_get_subscriptions( $args ); |
|
89 | + public function get_subscriptions($args = array()) { |
|
90 | + return getpaid_get_subscriptions($args); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * @access public |
97 | 97 | * @since 1.0.0 |
98 | 98 | */ |
99 | - public function count( $args = array() ) { |
|
100 | - return getpaid_get_subscriptions( $args, 'count' ); |
|
99 | + public function count($args = array()) { |
|
100 | + return getpaid_get_subscriptions($args, 'count'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function create_table() { |
110 | 110 | |
111 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
111 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
112 | 112 | |
113 | 113 | $sql = "CREATE TABLE " . $this->table_name . " ( |
114 | 114 | id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | KEY customer_and_status ( customer_id, status) |
134 | 134 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
135 | 135 | |
136 | - dbDelta( $sql ); |
|
136 | + dbDelta($sql); |
|
137 | 137 | |
138 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
138 | + update_option($this->table_name . '_db_version', $this->version); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
142 | 142 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Item_VAT { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the item. |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | - * Output the VAT rules settings. |
|
50 | - * |
|
51 | - * @param WPInv_Item $item |
|
52 | - */ |
|
49 | + * Output the VAT rules settings. |
|
50 | + * |
|
51 | + * @param WPInv_Item $item |
|
52 | + */ |
|
53 | 53 | public static function output_vat_rules( $item ) { |
54 | 54 | ?> |
55 | 55 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Output the VAT class settings. |
|
91 | - * |
|
92 | - * @param WPInv_Item $item |
|
93 | - */ |
|
90 | + * Output the VAT class settings. |
|
91 | + * |
|
92 | + * @param WPInv_Item $item |
|
93 | + */ |
|
94 | 94 | public static function output_vat_classes( $item ) { |
95 | 95 | ?> |
96 | 96 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>"; |
30 | 30 | |
31 | - do_action( 'wpinv_item_before_vat_metabox', $item ); |
|
31 | + do_action('wpinv_item_before_vat_metabox', $item); |
|
32 | 32 | |
33 | 33 | // Output the vat rules settings. |
34 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
35 | - self::output_vat_rules( $item ); |
|
36 | - do_action( 'wpinv_item_vat_metabox_vat_rules', $item ); |
|
34 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
35 | + self::output_vat_rules($item); |
|
36 | + do_action('wpinv_item_vat_metabox_vat_rules', $item); |
|
37 | 37 | |
38 | 38 | // Output vat class settings. |
39 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
40 | - self::output_vat_classes( $item ); |
|
41 | - do_action( 'wpinv_item_vat_metabox_vat_class', $item ); |
|
39 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
40 | + self::output_vat_classes($item); |
|
41 | + do_action('wpinv_item_vat_metabox_vat_class', $item); |
|
42 | 42 | |
43 | - do_action( 'wpinv_item_vat_metabox', $item ); |
|
43 | + do_action('wpinv_item_vat_metabox', $item); |
|
44 | 44 | |
45 | 45 | echo '</div>'; |
46 | 46 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param WPInv_Item $item |
52 | 52 | */ |
53 | - public static function output_vat_rules( $item ) { |
|
53 | + public static function output_vat_rules($item) { |
|
54 | 54 | ?> |
55 | 55 | |
56 | 56 | <div class="wpinv_vat_rules"> |
57 | 57 | |
58 | 58 | <div class="form-group row"> |
59 | 59 | <label for="wpinv_vat_rules" class="col-sm-3 col-form-label"> |
60 | - <?php _e( 'Tax Rule', 'invoicing' );?> |
|
60 | + <?php _e('Tax Rule', 'invoicing'); ?> |
|
61 | 61 | </label> |
62 | 62 | <div class="col-sm-8"> |
63 | 63 | <?php |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | array( |
66 | 66 | 'id' => 'wpinv_vat_rules', |
67 | 67 | 'name' => 'wpinv_vat_rules', |
68 | - 'placeholder' => __( 'Select tax rule', 'invoicing' ), |
|
69 | - 'value' => $item->get_vat_rule( 'edit' ), |
|
68 | + 'placeholder' => __('Select tax rule', 'invoicing'), |
|
69 | + 'value' => $item->get_vat_rule('edit'), |
|
70 | 70 | 'select2' => true, |
71 | 71 | 'data-allow-clear' => 'false', |
72 | 72 | 'no_wrap' => true, |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param WPInv_Item $item |
90 | 90 | */ |
91 | - public static function output_vat_classes( $item ) { |
|
91 | + public static function output_vat_classes($item) { |
|
92 | 92 | ?> |
93 | 93 | |
94 | 94 | <div class="wpinv_vat_classes"> |
95 | 95 | |
96 | 96 | <div class="form-group row"> |
97 | 97 | <label for="wpinv_vat_class" class="col-sm-3 col-form-label"> |
98 | - <?php _e( 'Tax Class', 'invoicing' );?> |
|
98 | + <?php _e('Tax Class', 'invoicing'); ?> |
|
99 | 99 | </label> |
100 | 100 | <div class="col-sm-8"> |
101 | 101 | <?php |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | array( |
104 | 104 | 'id' => 'wpinv_vat_class', |
105 | 105 | 'name' => 'wpinv_vat_class', |
106 | - 'placeholder' => __( 'Select tax class', 'invoicing' ), |
|
107 | - 'value' => $item->get_vat_class( 'edit' ), |
|
106 | + 'placeholder' => __('Select tax class', 'invoicing'), |
|
107 | + 'value' => $item->get_vat_class('edit'), |
|
108 | 108 | 'select2' => true, |
109 | 109 | 'data-allow-clear' => 'false', |
110 | 110 | 'no_wrap' => true, |
@@ -55,27 +55,27 @@ |
||
55 | 55 | public static function vat_rates_settings() {} |
56 | 56 | |
57 | 57 | /** |
58 | - * |
|
59 | - * @deprecated |
|
60 | - */ |
|
58 | + * |
|
59 | + * @deprecated |
|
60 | + */ |
|
61 | 61 | public static function vat_settings() {} |
62 | 62 | |
63 | 63 | /** |
64 | - * |
|
65 | - * @deprecated |
|
66 | - */ |
|
64 | + * |
|
65 | + * @deprecated |
|
66 | + */ |
|
67 | 67 | public static function maxmind_folder() {} |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @deprecated |
|
72 | - */ |
|
70 | + * |
|
71 | + * @deprecated |
|
72 | + */ |
|
73 | 73 | public static function geoip2_download_database() {} |
74 | 74 | |
75 | 75 | /** |
76 | - * |
|
77 | - * @deprecated |
|
78 | - */ |
|
76 | + * |
|
77 | + * @deprecated |
|
78 | + */ |
|
79 | 79 | public static function geoip2_download_file() {} |
80 | 80 | |
81 | 81 | /** |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @deprecated |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @deprecated |
40 | 40 | */ |
41 | - public static function is_eu_state( $country_code ) { |
|
42 | - return getpaid_is_eu_state( $country_code ); |
|
41 | + public static function is_eu_state($country_code) { |
|
42 | + return getpaid_is_eu_state($country_code); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @deprecated |
47 | 47 | */ |
48 | - public static function is_gst_country( $country_code ) { |
|
49 | - return getpaid_is_gst_country( $country_code ); |
|
48 | + public static function is_gst_country($country_code) { |
|
49 | + return getpaid_is_gst_country($country_code); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |