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.0.9 6.2.0-rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / reports / class-wc-report-downloads.php
woocommerce / includes / admin / reports Last commit date
class-wc-admin-report.php 1 year ago class-wc-report-coupon-usage.php 5 years ago class-wc-report-customer-list.php 9 months ago class-wc-report-customers.php 9 months ago class-wc-report-downloads.php 5 years ago class-wc-report-low-in-stock.php 5 years ago class-wc-report-most-stocked.php 5 years ago class-wc-report-out-of-stock.php 5 years ago class-wc-report-sales-by-category.php 2 years ago class-wc-report-sales-by-date.php 1 year ago class-wc-report-sales-by-product.php 3 months ago class-wc-report-stock.php 1 year ago class-wc-report-taxes-by-code.php 1 year ago class-wc-report-taxes-by-date.php 1 year ago
class-wc-report-downloads.php
337 lines
1 <?php
2 /**
3 * Download report.
4 *
5 * @author WooThemes
6 * @category Admin
7 * @package WooCommerce\Admin\Reports
8 * @version 3.3.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 if ( ! class_exists( 'WP_List_Table' ) ) {
16 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17 }
18
19 /**
20 * WC_Report_Downloads.
21 */
22 class WC_Report_Downloads extends WP_List_Table {
23
24 /**
25 * Max items.
26 *
27 * @var int
28 */
29 protected $max_items;
30
31 /**
32 * Constructor.
33 */
34 public function __construct() {
35
36 parent::__construct(
37 array(
38 'singular' => 'download',
39 'plural' => 'downloads',
40 'ajax' => false,
41 )
42 );
43 }
44
45 /**
46 * Don't need this.
47 *
48 * @param string $position Top or bottom.
49 */
50 public function display_tablenav( $position ) {
51 if ( 'top' !== $position ) {
52 parent::display_tablenav( $position );
53 }
54 }
55
56 /**
57 * Output the report.
58 */
59 public function output_report() {
60
61 $this->prepare_items();
62
63 // Subtitle for permission if set.
64 if ( ! empty( $_GET['permission_id'] ) ) { // WPCS: input var ok.
65 $permission_id = absint( $_GET['permission_id'] ); // WPCS: input var ok.
66
67 // Load the permission, order, etc. so we can render more information.
68 $permission = null;
69 $product = null;
70
71 try {
72 $permission = new WC_Customer_Download( $permission_id );
73 $product = wc_get_product( $permission->product_id );
74 } catch ( Exception $e ) {
75 wp_die( sprintf( esc_html__( 'Permission #%d not found.', 'woocommerce' ), esc_html( $permission_id ) ) );
76 }
77 }
78
79 echo '<h1>' . esc_html__( 'Customer downloads', 'woocommerce' );
80
81 $filters = $this->get_filter_vars();
82 $filter_list = array();
83 $filter_names = array(
84 'product_id' => __( 'Product', 'woocommerce' ),
85 'download_id' => __( 'File ID', 'woocommerce' ),
86 'permission_id' => __( 'Permission ID', 'woocommerce' ),
87 'order_id' => __( 'Order', 'woocommerce' ),
88 'user_id' => __( 'User', 'woocommerce' ),
89 'user_ip_address' => __( 'IP address', 'woocommerce' ),
90 );
91
92 foreach ( $filters as $key => $value ) {
93 if ( is_null( $value ) ) {
94 continue;
95 }
96 switch ( $key ) {
97 case 'order_id':
98 $order = wc_get_order( $value );
99 if ( $order ) {
100 $display_value = _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number();
101 } else {
102 break 2;
103 }
104 break;
105 case 'product_id':
106 $product = wc_get_product( $value );
107 if ( $product ) {
108 $display_value = $product->get_formatted_name();
109 } else {
110 break 2;
111 }
112 break;
113 default:
114 $display_value = $value;
115 break;
116 }
117 $filter_list[] = $filter_names[ $key ] . ' ' . $display_value . ' <a href="' . esc_url( remove_query_arg( $key ) ) . '" class="woocommerce-reports-remove-filter">&times;</a>';
118 }
119
120 echo '</h1>';
121
122 echo '<div id="active-filters" class="woocommerce-reports-wide"><h2>';
123 echo esc_html__( 'Active filters', 'woocommerce' ) . ': ';
124 echo $filter_list ? wp_kses_post( implode( ', ', $filter_list ) ) : '';
125 echo '</h2></div>';
126
127 echo '<div id="poststuff" class="woocommerce-reports-wide">';
128 $this->display();
129 echo '</div>';
130 }
131
132 /**
133 * Get column value.
134 *
135 * @param mixed $item Item being displayed.
136 * @param string $column_name Column name.
137 */
138 public function column_default( $item, $column_name ) {
139 $permission = null;
140 $product = null;
141 try {
142 $permission = new WC_Customer_Download( $item->permission_id );
143 $product = wc_get_product( $permission->product_id );
144 } catch ( Exception $e ) {
145 // Ok to continue rendering other information even if permission and/or product is not found.
146 return;
147 }
148
149 switch ( $column_name ) {
150 case 'timestamp':
151 echo esc_html( $item->timestamp );
152 break;
153 case 'product':
154 if ( ! empty( $product ) ) {
155 edit_post_link( esc_html( $product->get_formatted_name() ), '', '', $product->get_id(), 'view-link' );
156
157 echo '<div class="row-actions">';
158 echo '<a href="' . esc_url( add_query_arg( 'product_id', $product->get_id() ) ) . '">' . esc_html__( 'Filter by product', 'woocommerce' ) . '</a>';
159 echo '</div>';
160 }
161 break;
162 case 'file':
163 if ( ! empty( $permission ) && ! empty( $product ) ) {
164 // File information.
165 $file = $product->get_file( $permission->get_download_id() );
166
167 if ( false === $file ) {
168 echo esc_html__( 'File does not exist', 'woocommerce' );
169 } else {
170 echo esc_html( $file->get_name() . ' - ' . basename( $file->get_file() ) );
171
172 echo '<div class="row-actions">';
173 echo '<a href="' . esc_url( add_query_arg( 'download_id', $permission->get_download_id() ) ) . '">' . esc_html__( 'Filter by file', 'woocommerce' ) . '</a>';
174 echo '</div>';
175 }
176 }
177 break;
178 case 'order':
179 if ( ! empty( $permission ) && ( $order = wc_get_order( $permission->order_id ) ) ) {
180 edit_post_link( esc_html( _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number() ), '', '', $permission->order_id, 'view-link' );
181
182 echo '<div class="row-actions">';
183 echo '<a href="' . esc_url( add_query_arg( 'order_id', $order->get_id() ) ) . '">' . esc_html__( 'Filter by order', 'woocommerce' ) . '</a>';
184 echo '</div>';
185 }
186 break;
187 case 'user':
188 if ( $item->user_id > 0 ) {
189 $user = get_user_by( 'id', $item->user_id );
190
191 if ( ! empty( $user ) ) {
192 echo '<a href="' . esc_url( get_edit_user_link( $item->user_id ) ) . '">' . esc_html( $user->display_name ) . '</a>';
193 echo '<div class="row-actions">';
194 echo '<a href="' . esc_url( add_query_arg( 'user_id', $item->user_id ) ) . '">' . esc_html__( 'Filter by user', 'woocommerce' ) . '</a>';
195 echo '</div>';
196 }
197 } else {
198 esc_html_e( 'Guest', 'woocommerce' );
199 }
200 break;
201 case 'user_ip_address':
202 echo esc_html( $item->user_ip_address );
203
204 echo '<div class="row-actions">';
205 echo '<a href="' . esc_url( add_query_arg( 'user_ip_address', $item->user_ip_address ) ) . '">' . esc_html__( 'Filter by IP address', 'woocommerce' ) . '</a>';
206 echo '</div>';
207 break;
208 }
209 }
210
211 /**
212 * Get columns.
213 *
214 * @return array
215 */
216 public function get_columns() {
217 $columns = array(
218 'timestamp' => __( 'Timestamp', 'woocommerce' ),
219 'product' => __( 'Product', 'woocommerce' ),
220 'file' => __( 'File', 'woocommerce' ),
221 'order' => __( 'Order', 'woocommerce' ),
222 'user' => __( 'User', 'woocommerce' ),
223 'user_ip_address' => __( 'IP address', 'woocommerce' ),
224 );
225
226 return $columns;
227 }
228
229 /**
230 * Prepare download list items.
231 */
232 public function prepare_items() {
233
234 $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
235 $current_page = absint( $this->get_pagenum() );
236 // Allow filtering per_page value, but ensure it's at least 1.
237 $per_page = max( 1, apply_filters( 'woocommerce_admin_downloads_report_downloads_per_page', 20 ) );
238
239 $this->get_items( $current_page, $per_page );
240
241 /**
242 * Pagination.
243 */
244 $this->set_pagination_args(
245 array(
246 'total_items' => $this->max_items,
247 'per_page' => $per_page,
248 'total_pages' => ceil( $this->max_items / $per_page ),
249 )
250 );
251 }
252
253 /**
254 * No items found text.
255 */
256 public function no_items() {
257 esc_html_e( 'No customer downloads found.', 'woocommerce' );
258 }
259
260 /**
261 * Get filters from querystring.
262 *
263 * @return object
264 */
265 protected function get_filter_vars() {
266 $product_id = ! empty( $_GET['product_id'] ) ? absint( wp_unslash( $_GET['product_id'] ) ) : null; // WPCS: input var ok.
267 $download_id = ! empty( $_GET['download_id'] ) ? wc_clean( wp_unslash( $_GET['download_id'] ) ) : null; // WPCS: input var ok.
268 $permission_id = ! empty( $_GET['permission_id'] ) ? absint( wp_unslash( $_GET['permission_id'] ) ) : null; // WPCS: input var ok.
269 $order_id = ! empty( $_GET['order_id'] ) ? absint( wp_unslash( $_GET['order_id'] ) ) : null; // WPCS: input var ok.
270 $user_id = ! empty( $_GET['user_id'] ) ? absint( wp_unslash( $_GET['user_id'] ) ) : null; // WPCS: input var ok.
271 $user_ip_address = ! empty( $_GET['user_ip_address'] ) ? wc_clean( wp_unslash( $_GET['user_ip_address'] ) ) : null; // WPCS: input var ok.
272
273 return (object) array(
274 'product_id' => $product_id,
275 'download_id' => $download_id,
276 'permission_id' => $permission_id,
277 'order_id' => $order_id,
278 'user_id' => $user_id,
279 'user_ip_address' => $user_ip_address,
280 );
281 }
282
283 /**
284 * Get downloads matching criteria.
285 *
286 * @param int $current_page Current viewed page.
287 * @param int $per_page How many results to show per page.
288 */
289 public function get_items( $current_page, $per_page ) {
290 global $wpdb;
291
292 $this->max_items = 0;
293 $this->items = array();
294 $filters = $this->get_filter_vars();
295
296 // Get downloads from database.
297 $table = $wpdb->prefix . WC_Customer_Download_Log_Data_Store::get_table_name();
298 $query_from = " FROM {$table} as downloads ";
299
300 if ( ! is_null( $filters->product_id ) || ! is_null( $filters->download_id ) || ! is_null( $filters->order_id ) ) {
301 $query_from .= " LEFT JOIN {$wpdb->prefix}woocommerce_downloadable_product_permissions as permissions on downloads.permission_id = permissions.permission_id ";
302 }
303
304 $query_from .= ' WHERE 1=1 ';
305
306 if ( ! is_null( $filters->product_id ) ) {
307 $query_from .= $wpdb->prepare( ' AND product_id = %d ', $filters->product_id );
308 }
309
310 if ( ! is_null( $filters->download_id ) ) {
311 $query_from .= $wpdb->prepare( ' AND download_id = %s ', $filters->download_id );
312 }
313
314 if ( ! is_null( $filters->order_id ) ) {
315 $query_from .= $wpdb->prepare( ' AND order_id = %d ', $filters->order_id );
316 }
317
318 if ( ! is_null( $filters->permission_id ) ) {
319 $query_from .= $wpdb->prepare( ' AND downloads.permission_id = %d ', $filters->permission_id );
320 }
321
322 if ( ! is_null( $filters->user_id ) ) {
323 $query_from .= $wpdb->prepare( ' AND downloads.user_id = %d ', $filters->user_id );
324 }
325
326 if ( ! is_null( $filters->user_ip_address ) ) {
327 $query_from .= $wpdb->prepare( ' AND user_ip_address = %s ', $filters->user_ip_address );
328 }
329
330 $query_from = apply_filters( 'woocommerce_report_downloads_query_from', $query_from );
331 $query_order = $wpdb->prepare( 'ORDER BY timestamp DESC LIMIT %d, %d;', ( $current_page - 1 ) * $per_page, $per_page );
332
333 $this->items = $wpdb->get_results( "SELECT * {$query_from} {$query_order}" ); // WPCS: cache ok, db call ok, unprepared SQL ok.
334 $this->max_items = $wpdb->get_var( "SELECT COUNT( DISTINCT download_log_id ) {$query_from};" ); // WPCS: cache ok, db call ok, unprepared SQL ok.
335 }
336 }
337