Passed
Push — master ( 6c33bf...2e88d0 )
by Brian
15:54
created
includes/admin/class-wpinv-items-report-table.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,129 +21,129 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Items_Report_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'item';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'item'     => __( 'Item', 'invoicing' ),
84
-			'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
88
-		);
89
-
90
-	}
91
-
92
-	/**
93
-	 * Retrieve the current page number
94
-	 *
95
-	 * @since 1.0.19
96
-	 * @return int Current page number
97
-	 */
98
-	public function get_paged() {
99
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
-	}
101
-
102
-	/**
103
-	 * Outputs the reporting views
104
-	 *
105
-	 * @since 1.0.19
106
-	 * @return void
107
-	 */
108
-	public function bulk_actions( $which = '' ) {
109
-		return array();
110
-	}
111
-
112
-	/**
113
-	 * Build all the reports data
114
-	 *
115
-	 * @since 1.0.19
116
-	 * @return array $reports_data All the data for gateway reports
117
-	 */
118
-	public function reports_data() {
119
-
120
-		$reports_data = $this->revenue_reports_data();
121
-
122
-		$prepared = array();
123
-		foreach ( $reports_data as $report_data ) {
124
-			$prepared[] = array(
125
-				'item'     => $report_data['item_name'],
126
-				'sales'    => $report_data['sales'],
127
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
130
-			);
131
-		}
132
-
133
-		return $prepared;
134
-	}
135
-
136
-	/**
137
-	 * Retrieves report data.
138
-	 *
139
-	 * @since 1.0.19
140
-	 */
141
-	public function revenue_reports_data() {
142
-		global $wpdb;
143
-
144
-		$table =  $wpdb->prefix . 'getpaid_invoice_items';
145
-		return $wpdb->get_results(
146
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'item';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'item'     => __( 'Item', 'invoicing' ),
84
+            'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
+            'total'    => __( 'Total Earnings', 'invoicing' ),
86
+            'discount' => __( 'Total Discounts', 'invoicing' ),
87
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
88
+        );
89
+
90
+    }
91
+
92
+    /**
93
+     * Retrieve the current page number
94
+     *
95
+     * @since 1.0.19
96
+     * @return int Current page number
97
+     */
98
+    public function get_paged() {
99
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
+    }
101
+
102
+    /**
103
+     * Outputs the reporting views
104
+     *
105
+     * @since 1.0.19
106
+     * @return void
107
+     */
108
+    public function bulk_actions( $which = '' ) {
109
+        return array();
110
+    }
111
+
112
+    /**
113
+     * Build all the reports data
114
+     *
115
+     * @since 1.0.19
116
+     * @return array $reports_data All the data for gateway reports
117
+     */
118
+    public function reports_data() {
119
+
120
+        $reports_data = $this->revenue_reports_data();
121
+
122
+        $prepared = array();
123
+        foreach ( $reports_data as $report_data ) {
124
+            $prepared[] = array(
125
+                'item'     => $report_data['item_name'],
126
+                'sales'    => $report_data['sales'],
127
+                'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
+                'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
+                'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
130
+            );
131
+        }
132
+
133
+        return $prepared;
134
+    }
135
+
136
+    /**
137
+     * Retrieves report data.
138
+     *
139
+     * @since 1.0.19
140
+     */
141
+    public function revenue_reports_data() {
142
+        global $wpdb;
143
+
144
+        $table =  $wpdb->prefix . 'getpaid_invoice_items';
145
+        return $wpdb->get_results(
146
+            "SELECT
147 147
 				SUM(quantity) as sales,
148 148
 				item_name,
149 149
 				SUM(tax) as tax,
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 			GROUP BY item_id
158 158
 			ORDER BY item_name ASC", ARRAY_A);
159 159
 
160
-	}
161
-
162
-	/**
163
-	 * Setup the final data for the table
164
-	 *
165
-	 * @since 1.0.19
166
-	 * @return void
167
-	 */
168
-	public function prepare_items() {
169
-		$columns               = $this->get_columns();
170
-		$hidden                = array(); // No hidden columns
171
-		$sortable              = $this->get_sortable_columns();
172
-		$this->_column_headers = array( $columns, $hidden, $sortable );
173
-		$this->items           = $this->reports_data();
174
-	}
160
+    }
161
+
162
+    /**
163
+     * Setup the final data for the table
164
+     *
165
+     * @since 1.0.19
166
+     * @return void
167
+     */
168
+    public function prepare_items() {
169
+        $columns               = $this->get_columns();
170
+        $hidden                = array(); // No hidden columns
171
+        $sortable              = $this->get_sortable_columns();
172
+        $this->_column_headers = array( $columns, $hidden, $sortable );
173
+        $this->items           = $this->reports_data();
174
+    }
175 175
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-gateways-report-table.php 1 patch
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,148 +21,148 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Gateways_Report_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'gateway';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'gateway'  => __( 'Gateway', 'invoicing' ),
84
-			'sales'    => __( 'Total Sales', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
88
-			'fees'     => __( 'Total Fees', 'invoicing' ),
89
-		);
90
-
91
-	}
92
-
93
-	/**
94
-	 * Retrieve the current page number
95
-	 *
96
-	 * @since 1.0.19
97
-	 * @return int Current page number
98
-	 */
99
-	public function get_paged() {
100
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
101
-	}
102
-
103
-	/**
104
-	 * Outputs the reporting views
105
-	 *
106
-	 * @since 1.0.19
107
-	 * @return void
108
-	 */
109
-	public function bulk_actions( $which = '' ) {
110
-		return array();
111
-	}
112
-
113
-	/**
114
-	 * Build all the reports data
115
-	 *
116
-	 * @since 1.0.19
117
-	 * @return array $reports_data All the data for gateway reports
118
-	 */
119
-	public function reports_data() {
120
-
121
-		$reports_data = $this->revenue_reports_data();
122
-		$gateways     = wpinv_get_payment_gateways();
123
-
124
-		foreach ( $gateways as $gateway_id => $gateway ) {
125
-
126
-			if ( ! empty( $reports_data[ $gateway_id ] ) ) {
127
-				continue;
128
-			}
129
-
130
-			$reports_data[] = array(
131
-				'gateway'  => $gateway_id,
132
-				'sales'    => 0,
133
-				'total'    => 0,
134
-				'discount' => 0,
135
-				'tax'      => 0,
136
-				'fees'     => 0,
137
-			);
138
-		}
139
-
140
-		$prepared = array();
141
-		foreach ( $reports_data as $report_data ) {
142
-			$prepared[] = array(
143
-				'gateway'  => wpinv_get_gateway_admin_label( $report_data['gateway'] ),
144
-				'sales'    => $report_data['sales'],
145
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
146
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
147
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
148
-				'fees'     => wpinv_price( wpinv_format_amount( $report_data['fees'] ) ),
149
-			);
150
-		}
151
-
152
-		return $prepared;
153
-	}
154
-
155
-	/**
156
-	 * Retrieves report data.
157
-	 *
158
-	 * @since 1.0.19
159
-	 */
160
-	public function revenue_reports_data() {
161
-		global $wpdb;
162
-
163
-		$table =  $wpdb->prefix . 'getpaid_invoices';
164
-		$data  = $wpdb->get_results(
165
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'gateway';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'gateway'  => __( 'Gateway', 'invoicing' ),
84
+            'sales'    => __( 'Total Sales', 'invoicing' ),
85
+            'total'    => __( 'Total Earnings', 'invoicing' ),
86
+            'discount' => __( 'Total Discounts', 'invoicing' ),
87
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
88
+            'fees'     => __( 'Total Fees', 'invoicing' ),
89
+        );
90
+
91
+    }
92
+
93
+    /**
94
+     * Retrieve the current page number
95
+     *
96
+     * @since 1.0.19
97
+     * @return int Current page number
98
+     */
99
+    public function get_paged() {
100
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
101
+    }
102
+
103
+    /**
104
+     * Outputs the reporting views
105
+     *
106
+     * @since 1.0.19
107
+     * @return void
108
+     */
109
+    public function bulk_actions( $which = '' ) {
110
+        return array();
111
+    }
112
+
113
+    /**
114
+     * Build all the reports data
115
+     *
116
+     * @since 1.0.19
117
+     * @return array $reports_data All the data for gateway reports
118
+     */
119
+    public function reports_data() {
120
+
121
+        $reports_data = $this->revenue_reports_data();
122
+        $gateways     = wpinv_get_payment_gateways();
123
+
124
+        foreach ( $gateways as $gateway_id => $gateway ) {
125
+
126
+            if ( ! empty( $reports_data[ $gateway_id ] ) ) {
127
+                continue;
128
+            }
129
+
130
+            $reports_data[] = array(
131
+                'gateway'  => $gateway_id,
132
+                'sales'    => 0,
133
+                'total'    => 0,
134
+                'discount' => 0,
135
+                'tax'      => 0,
136
+                'fees'     => 0,
137
+            );
138
+        }
139
+
140
+        $prepared = array();
141
+        foreach ( $reports_data as $report_data ) {
142
+            $prepared[] = array(
143
+                'gateway'  => wpinv_get_gateway_admin_label( $report_data['gateway'] ),
144
+                'sales'    => $report_data['sales'],
145
+                'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
146
+                'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
147
+                'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
148
+                'fees'     => wpinv_price( wpinv_format_amount( $report_data['fees'] ) ),
149
+            );
150
+        }
151
+
152
+        return $prepared;
153
+    }
154
+
155
+    /**
156
+     * Retrieves report data.
157
+     *
158
+     * @since 1.0.19
159
+     */
160
+    public function revenue_reports_data() {
161
+        global $wpdb;
162
+
163
+        $table =  $wpdb->prefix . 'getpaid_invoices';
164
+        $data  = $wpdb->get_results(
165
+            "SELECT
166 166
 				COUNT(posts.ID) as sales,
167 167
 				meta.gateway as gateway,
168 168
 				SUM(meta.total) as total,
@@ -177,27 +177,27 @@  discard block
 block discarded – undo
177 177
                 AND ( posts.post_status = 'publish' OR posts.post_status = 'renewal' )
178 178
 			GROUP BY meta.gateway", ARRAY_A);
179 179
 		
180
-		$return = array();
181
-
182
-		foreach ( $data as $gateway ) {
183
-			$return[ $gateway ['gateway']] = $gateway;
184
-		}
185
-
186
-		return $return;
187
-
188
-	}
189
-
190
-	/**
191
-	 * Setup the final data for the table
192
-	 *
193
-	 * @since 1.0.19
194
-	 * @return void
195
-	 */
196
-	public function prepare_items() {
197
-		$columns               = $this->get_columns();
198
-		$hidden                = array(); // No hidden columns
199
-		$sortable              = $this->get_sortable_columns();
200
-		$this->_column_headers = array( $columns, $hidden, $sortable );
201
-		$this->items           = $this->reports_data();
202
-	}
180
+        $return = array();
181
+
182
+        foreach ( $data as $gateway ) {
183
+            $return[ $gateway ['gateway']] = $gateway;
184
+        }
185
+
186
+        return $return;
187
+
188
+    }
189
+
190
+    /**
191
+     * Setup the final data for the table
192
+     *
193
+     * @since 1.0.19
194
+     * @return void
195
+     */
196
+    public function prepare_items() {
197
+        $columns               = $this->get_columns();
198
+        $hidden                = array(); // No hidden columns
199
+        $sortable              = $this->get_sortable_columns();
200
+        $this->_column_headers = array( $columns, $hidden, $sortable );
201
+        $this->items           = $this->reports_data();
202
+    }
203 203
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-taxes-report-table.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,145 +21,145 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Taxes_Reports_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'month';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'month'    => __( 'Month', 'invoicing' ),
84
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
85
-		);
86
-
87
-	}
88
-
89
-	/**
90
-	 * Retrieve the current page number
91
-	 *
92
-	 * @since 1.0.19
93
-	 * @return int Current page number
94
-	 */
95
-	public function get_paged() {
96
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
97
-	}
98
-
99
-	/**
100
-	 * Outputs the reporting views
101
-	 *
102
-	 * @since 1.0.19
103
-	 * @return void
104
-	 */
105
-	public function bulk_actions( $which = '' ) {
106
-		return array();
107
-	}
108
-
109
-	/**
110
-	 * Build all the reports data
111
-	 *
112
-	 * @since 1.0.19
113
-	 * @return array $reports_data All the data for taxes reports
114
-	 */
115
-	public function reports_data() {
116
-
117
-		$reports_data = $this->taxes_reports_data();
118
-		$months       = array(
119
-			'1' => __( 'January', 'invoicing' ),
120
-			'2' => __( 'February', 'invoicing' ),
121
-			'3' => __( 'March', 'invoicing' ),
122
-			'4' => __( 'April', 'invoicing' ),
123
-			'5' => __( 'May', 'invoicing' ),
124
-			'6' => __( 'June', 'invoicing' ),
125
-			'7' => __( 'July', 'invoicing' ),
126
-			'8' => __( 'August', 'invoicing' ),
127
-			'9' => __( 'September', 'invoicing' ),
128
-			'10' => __( 'October', 'invoicing' ),
129
-			'11' => __( 'November', 'invoicing' ),
130
-			'12' => __( 'December', 'invoicing' ),
131
-		);
132
-
133
-		$prepared = array();
134
-		foreach ( $months as $month => $label ) {
135
-
136
-			$tax = wpinv_price( 0 );
137
-			if ( ! empty( $reports_data[ $month ] ) ) {
138
-				$tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
139
-			}
140
-
141
-			$prepared[] = array(
142
-				'month'    => $label,
143
-				'tax'      => $tax,
144
-			);
145
-
146
-		}
147
-
148
-		return $prepared;
149
-	}
150
-
151
-	/**
152
-	 * Retrieves taxes data.
153
-	 *
154
-	 * @since 1.0.19
155
-	 */
156
-	public function taxes_reports_data() {
157
-		global $wpdb;
158
-
159
-		$table =  $wpdb->prefix . 'getpaid_invoices';
160
-		$year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
161
-		$data  = $wpdb->get_results(
162
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'month';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'month'    => __( 'Month', 'invoicing' ),
84
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
85
+        );
86
+
87
+    }
88
+
89
+    /**
90
+     * Retrieve the current page number
91
+     *
92
+     * @since 1.0.19
93
+     * @return int Current page number
94
+     */
95
+    public function get_paged() {
96
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
97
+    }
98
+
99
+    /**
100
+     * Outputs the reporting views
101
+     *
102
+     * @since 1.0.19
103
+     * @return void
104
+     */
105
+    public function bulk_actions( $which = '' ) {
106
+        return array();
107
+    }
108
+
109
+    /**
110
+     * Build all the reports data
111
+     *
112
+     * @since 1.0.19
113
+     * @return array $reports_data All the data for taxes reports
114
+     */
115
+    public function reports_data() {
116
+
117
+        $reports_data = $this->taxes_reports_data();
118
+        $months       = array(
119
+            '1' => __( 'January', 'invoicing' ),
120
+            '2' => __( 'February', 'invoicing' ),
121
+            '3' => __( 'March', 'invoicing' ),
122
+            '4' => __( 'April', 'invoicing' ),
123
+            '5' => __( 'May', 'invoicing' ),
124
+            '6' => __( 'June', 'invoicing' ),
125
+            '7' => __( 'July', 'invoicing' ),
126
+            '8' => __( 'August', 'invoicing' ),
127
+            '9' => __( 'September', 'invoicing' ),
128
+            '10' => __( 'October', 'invoicing' ),
129
+            '11' => __( 'November', 'invoicing' ),
130
+            '12' => __( 'December', 'invoicing' ),
131
+        );
132
+
133
+        $prepared = array();
134
+        foreach ( $months as $month => $label ) {
135
+
136
+            $tax = wpinv_price( 0 );
137
+            if ( ! empty( $reports_data[ $month ] ) ) {
138
+                $tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
139
+            }
140
+
141
+            $prepared[] = array(
142
+                'month'    => $label,
143
+                'tax'      => $tax,
144
+            );
145
+
146
+        }
147
+
148
+        return $prepared;
149
+    }
150
+
151
+    /**
152
+     * Retrieves taxes data.
153
+     *
154
+     * @since 1.0.19
155
+     */
156
+    public function taxes_reports_data() {
157
+        global $wpdb;
158
+
159
+        $table =  $wpdb->prefix . 'getpaid_invoices';
160
+        $year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
161
+        $data  = $wpdb->get_results(
162
+            "SELECT
163 163
 				MONTH(meta.completed_date) as _month,
164 164
 				SUM(meta.tax) as tax
165 165
 			FROM $wpdb->posts as posts
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 				AND ( YEAR(meta.completed_date) = '$year' )
172 172
 			GROUP BY MONTH(meta.completed_date)");
173 173
 
174
-		return wp_list_pluck( $data, 'tax', '_month' );
175
-
176
-	}
177
-
178
-	/**
179
-	 * Setup the final data for the table
180
-	 *
181
-	 * @since 1.0.19
182
-	 * @return void
183
-	 */
184
-	public function prepare_items() {
185
-		$columns               = $this->get_columns();
186
-		$hidden                = array(); // No hidden columns
187
-		$sortable              = $this->get_sortable_columns();
188
-		$this->_column_headers = array( $columns, $hidden, $sortable );
189
-		$this->items           = $this->reports_data();
190
-	}
174
+        return wp_list_pluck( $data, 'tax', '_month' );
175
+
176
+    }
177
+
178
+    /**
179
+     * Setup the final data for the table
180
+     *
181
+     * @since 1.0.19
182
+     * @return void
183
+     */
184
+    public function prepare_items() {
185
+        $columns               = $this->get_columns();
186
+        $hidden                = array(); // No hidden columns
187
+        $sortable              = $this->get_sortable_columns();
188
+        $this->_column_headers = array( $columns, $hidden, $sortable );
189
+        $this->items           = $this->reports_data();
190
+    }
191 191
 }
Please login to merge, or discard this patch.