PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.0
GiveWP – Donation Plugin and Fundraising Platform v2.2.0
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / reports / class-gateways-reports-table.php
give / includes / admin / reports Last commit date
class-donor-reports-table.php 8 years ago class-earnings-report.php 8 years ago class-form-reports-table.php 8 years ago class-forms-report.php 8 years ago class-gateways-report.php 8 years ago class-gateways-reports-table.php 8 years ago class-give-graph.php 8 years ago graphing.php 8 years ago reports.php 8 years ago
class-gateways-reports-table.php
299 lines
1 <?php
2 /**
3 * Gateways Reports Table Class
4 *
5 * @package Give
6 * @subpackage Admin/Reports
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 // Load WP_List_Table if not loaded
18 if ( ! class_exists( 'WP_List_Table' ) ) {
19 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
20 }
21
22 /**
23 * Give_Gateway_Reports_Table Class
24 *
25 * Renders the Download Reports table
26 *
27 * @since 1.0
28 */
29 class Give_Gateway_Reports_Table extends WP_List_Table {
30
31 /**
32 * @var int Number of items per page
33 * @since 1.0
34 */
35 public $per_page = 30;
36
37
38 /**
39 * Get things started
40 *
41 * @since 1.0
42 * @see WP_List_Table::__construct()
43 */
44 public function __construct() {
45 global $status, $page;
46
47 // Set parent defaults
48 parent::__construct( array(
49 'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50 'plural' => give_get_forms_label_plural(), // Plural name of the listed records
51 'ajax' => false // Does this table support ajax?
52 ) );
53
54 }
55
56 /**
57 * This function renders most of the columns in the list table.
58 *
59 * @access public
60 * @since 1.0
61 *
62 * @param array $item Contains all the data of the form
63 * @param string $column_name The name of the column
64 *
65 * @return string Column Name
66 */
67 public function column_default( $item, $column_name ) {
68 $donation_list_page_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
69
70 switch ( $column_name ) {
71 case 'complete_sales':
72 $value = $item[ $column_name ] ?
73 sprintf(
74 '<a href="%s">%s</a>',
75 add_query_arg(
76 array(
77 'status' => 'publish',
78 'gateway' => $item['ID']
79 ),
80 $donation_list_page_url
81 ),
82 $item[ $column_name ]
83 ) :
84 $item[ $column_name ];
85 break;
86
87 case 'pending_sales':
88 $value = $item[ $column_name ] ?
89 sprintf(
90 '<a href="%s">%s</a>',
91 add_query_arg(
92 array(
93 'status' => 'pending',
94 'gateway' => $item['ID']
95 ),
96 $donation_list_page_url
97 ),
98 $item[ $column_name ]
99 ) :
100 $item[ $column_name ];
101 break;
102
103 case 'total_sales':
104 $value = $item[ $column_name ] ?
105 sprintf(
106 '<a href="%s">%s</a>',
107 add_query_arg(
108 array(
109 'gateway' => $item['ID']
110 ),
111 $donation_list_page_url
112 ),
113 $item[ $column_name ]
114 ) :
115 $item[ $column_name ];
116
117 break;
118
119 default:
120 $value = $item[ $column_name ];
121 }
122
123 return $value;
124 }
125
126 /**
127 * Retrieve the table columns
128 *
129 * @access public
130 * @since 1.0
131 * @return array $columns Array of all the list table columns
132 */
133 public function get_columns() {
134 $columns = array(
135 'label' => esc_attr__( 'Gateway', 'give' ),
136 'complete_sales' => esc_attr__( 'Complete Payments', 'give' ),
137 'pending_sales' => esc_attr__( 'Pending / Failed Payments', 'give' ),
138 'total_sales' => esc_attr__( 'Total Payments', 'give' ),
139 'total_donations' => esc_attr__( 'Total Donated', 'give' )
140 );
141
142 return $columns;
143 }
144
145 /**
146 * Get the sortable columns
147 *
148 * @access public
149 * @since 1.8.12
150 * @return array Array of all the sortable columns
151 */
152 public function get_sortable_columns() {
153 return array(
154 'total_donations' => array( 'total_donations', false )
155 );
156 }
157
158
159 /**
160 * Retrieve the current page number
161 *
162 * @access public
163 * @since 1.0
164 * @return int Current page number
165 */
166 public function get_paged() {
167 return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
168 }
169
170
171 /**
172 * Outputs the reporting views
173 *
174 * @access public
175 * @since 1.0
176 * @return void
177 */
178 public function bulk_actions( $which = '' ) {
179
180 }
181
182 /**
183 * Generate the table navigation above or below the table
184 *
185 * @since 1.0
186 * @access protected
187 *
188 * @param string $which
189 */
190 protected function display_tablenav( $which ) {
191
192 if ( 'top' === $which ) {
193 wp_nonce_field( 'bulk-' . $this->_args['plural'] );
194 }
195 ?>
196 <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
197
198 <?php if ( 'top' === $which ) { ?>
199 <h2 class="alignleft reports-earnings-title screen-reader-text">
200 <?php _e( 'Donation Methods Report', 'give' ); ?>
201 </h2>
202 <?php } ?>
203
204 <div class="alignright tablenav-right">
205 <div class="actions bulkactions">
206 <?php $this->bulk_actions( $which ); ?>
207 </div>
208 <?php
209 $this->extra_tablenav( $which );
210 $this->pagination( $which );
211 ?>
212 </div>
213
214
215 <br class="clear" />
216
217 </div>
218 <?php
219 }
220
221 /**
222 * Reorder User Defined Array
223 *
224 * @param $old_value
225 * @param $new_value
226 *
227 * @access public
228 * @since 1.8.12
229 *
230 * @return int
231 */
232 public function give_sort_total_donations( $old_value, $new_value ) {
233 // If no sort, default to label.
234 $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label';
235
236 //If no order, default to asc.
237 $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
238
239 //Determine sort order.
240 $result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] );
241
242 return ( $order === 'asc' ) ? $result : -$result;
243 }
244
245
246 /**
247 * Build all the reports data
248 *
249 * @access public
250 * @since 1.0
251 * @return array $reports_data All the data for donor reports
252 */
253 public function reports_data() {
254
255 $reports_data = array();
256 $gateways = give_get_payment_gateways();
257 $stats = new Give_Payment_Stats();
258
259 foreach ( $gateways as $gateway_id => $gateway ) {
260
261 $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
262 $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
263
264 $reports_data[] = array(
265 'ID' => $gateway_id,
266 'label' => $gateway['admin_label'],
267 'complete_sales' => $complete_count,
268 'pending_sales' => $pending_count,
269 'total_sales' => $complete_count + $pending_count,
270 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, strtotime('04/13/2015' ), current_time('timestamp' ), $gateway_id ), array( 'sanitize' => false ) ) ),
271 );
272 }
273
274 return $reports_data;
275 }
276
277 /**
278 * Setup the final data for the table
279 *
280 * @access public
281 * @since 1.0
282 * @uses Give_Gateway_Reports_Table::get_columns()
283 * @uses Give_Gateway_Reports_Table::get_sortable_columns()
284 * @uses Give_Gateway_Reports_Table::reports_data()
285 * @return void
286 */
287 public function prepare_items() {
288 $columns = $this->get_columns();
289 $hidden = array(); // No hidden columns
290 $sortable = $this->get_sortable_columns();
291 $this->_column_headers = array( $columns, $hidden, $sortable );
292 $this->items = $this->reports_data();
293
294 // Sort Array when we are sorting data in array.
295 usort( $this->items, array( $this, 'give_sort_total_donations' ) );
296
297 }
298 }
299