You appear to be a bot. Output may be restricted
Description
Get the Export Data.
Usage
$array = EDD_Batch_Earnings_Report_Export::get_data();
Parameters
Returns
array $data The data for the CSV file
Source
File name: easy-digital-downloads/includes/admin/reporting/export/class-batch-export-earnings-report.php
Lines:
1 to 59 of 59
public function get_data() { global $wpdb; $data = array(); $start_date = date( 'Y-m-d 00:00:00', strtotime( $this->start ) ); $end_date = date( 'Y-m-t 23:59:59', strtotime( $this->start ) ); if ( $this->step > 1 ) { $start_timestamp = strtotime( 'first day of +' . ( $this->step - 1 ) . ' month', strtotime( $start_date ) ); $start_date = date( 'Y-m-d 00:00:00', $start_timestamp ); $end_date = date( 'Y-m-t 23:59:59', $start_timestamp ); } if ( strtotime( $start_date ) > strtotime( $this->end ) ) { return false; } $statuses = $this->get_supported_statuses(); $totals = $wpdb->get_results( $wpdb->prepare( "SELECT SUM(meta_value) AS total, COUNT(DISTINCT posts.ID) AS count, posts.post_status AS status FROM {$wpdb->posts} AS posts INNER JOIN {$wpdb->postmeta} ON posts.ID = {$wpdb->postmeta}.post_ID WHERE posts.post_type IN ('edd_payment') AND {$wpdb->postmeta}.meta_key = '_edd_payment_total' AND posts.post_date >= %s AND posts.post_date <= %s GROUP BY YEAR(posts.post_date), MONTH(posts.post_date), posts.post_status ORDER by posts.post_date ASC", $start_date, $end_date ), ARRAY_A ); $total_data = array(); foreach ( $totals as $row ) { $total_data[ $row['status'] ] = array( 'count' => $row['count'], 'amount' => $row['total'] ); } foreach ( $statuses as $status ) { if ( ! isset( $total_data[ $status ] ) ) { $data[ $status ] = array( 'count' => 0, 'amount' => 0, ); } else { $data[ $status ] = array( 'count' => $total_data[ $status ]['count'], 'amount' => $total_data[ $status ]['amount'], ); } } $data = apply_filters( 'edd_export_get_data', $data ); $data = apply_filters( 'edd_export_get_data_' . $this->export_type, $data, $start_date, $end_date ); return $data; }