PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.19.4
GiveWP – Donation Plugin and Fundraising Platform v3.19.4
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 6 years ago class-earnings-report.php 5 years ago class-form-reports-table.php 5 years ago class-forms-report.php 7 years ago class-gateways-report.php 7 years ago class-gateways-reports-table.php 4 years ago class-give-graph.php 4 years ago graphing.php 4 years ago reports.php 5 years ago
class-gateways-reports-table.php
307 lines
1 <?php
2 /**
3 * Gateways Reports Table Class
4 *
5 * @package Give
6 * @subpackage Admin/Reports
7 * @copyright Copyright (c) 2016, GiveWP
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(
49 array(
50 'singular' => give_get_forms_label_singular(), // Singular name of the listed records
51 'plural' => give_get_forms_label_plural(), // Plural name of the listed records
52 'ajax' => false, // Does this table support ajax?
53 )
54 );
55
56 }
57
58 /**
59 * This function renders most of the columns in the list table.
60 *
61 * @access public
62 * @since 1.0
63 *
64 * @param array $item Contains all the data of the form
65 * @param string $column_name The name of the column
66 *
67 * @return string Column Name
68 */
69 public function column_default( $item, $column_name ) {
70 $donation_list_page_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
71
72 switch ( $column_name ) {
73 case 'complete_sales':
74 $value = $item[ $column_name ] ?
75 sprintf(
76 '<a href="%s">%s</a>',
77 esc_url(
78 add_query_arg(
79 array(
80 'status' => 'publish',
81 'gateway' => $item['ID'],
82 ),
83 $donation_list_page_url
84 )
85 ),
86 $item[ $column_name ]
87 ) :
88 $item[ $column_name ];
89 break;
90
91 case 'pending_sales':
92 $value = $item[ $column_name ] ?
93 sprintf(
94 '<a href="%s">%s</a>',
95 esc_url(
96 add_query_arg(
97 array(
98 'status' => 'pending',
99 'gateway' => $item['ID'],
100 ),
101 $donation_list_page_url
102 )
103 ),
104 $item[ $column_name ]
105 ) :
106 $item[ $column_name ];
107 break;
108
109 case 'total_sales':
110 $value = $item[ $column_name ] ?
111 sprintf(
112 '<a href="%s">%s</a>',
113 esc_url(
114 add_query_arg(
115 array(
116 'gateway' => $item['ID'],
117 ),
118 $donation_list_page_url
119 )
120 ),
121 $item[ $column_name ]
122 ) :
123 $item[ $column_name ];
124
125 break;
126
127 default:
128 $value = $item[ $column_name ];
129 }
130
131 return $value;
132 }
133
134 /**
135 * Retrieve the table columns
136 *
137 * @access public
138 * @since 1.0
139 * @return array $columns Array of all the list table columns
140 */
141 public function get_columns() {
142 $columns = array(
143 'label' => esc_attr__( 'Gateway', 'give' ),
144 'complete_sales' => esc_attr__( 'Complete Payments', 'give' ),
145 'pending_sales' => esc_attr__( 'Pending / Failed Payments', 'give' ),
146 'total_sales' => esc_attr__( 'Total Payments', 'give' ),
147 'total_donations' => esc_attr__( 'Total Donated', 'give' ),
148 );
149
150 return $columns;
151 }
152
153 /**
154 * Get the sortable columns
155 *
156 * @access public
157 * @since 1.8.12
158 * @return array Array of all the sortable columns
159 */
160 public function get_sortable_columns() {
161 return array(
162 'total_donations' => array( 'total_donations', false ),
163 );
164 }
165
166
167 /**
168 * Retrieve the current page number
169 *
170 * @access public
171 * @since 1.0
172 * @return int Current page number
173 */
174 public function get_paged() {
175 return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
176 }
177
178
179 /**
180 * Outputs the reporting views
181 *
182 * @access public
183 * @since 1.0
184 * @return void
185 */
186 public function bulk_actions( $which = '' ) {
187
188 }
189
190 /**
191 * Generate the table navigation above or below the table
192 *
193 * @since 1.0
194 * @access protected
195 *
196 * @param string $which
197 */
198 protected function display_tablenav( $which ) {
199
200 if ( 'top' === $which ) {
201 wp_nonce_field( 'bulk-' . $this->_args['plural'] );
202 }
203 ?>
204 <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
205
206 <?php if ( 'top' === $which ) { ?>
207 <h2 class="alignleft reports-earnings-title screen-reader-text">
208 <?php _e( 'Donation Methods Report', 'give' ); ?>
209 </h2>
210 <?php } ?>
211
212 <div class="alignright tablenav-right">
213 <div class="actions bulkactions">
214 <?php $this->bulk_actions( $which ); ?>
215 </div>
216 <?php
217 $this->extra_tablenav( $which );
218 $this->pagination( $which );
219 ?>
220 </div>
221
222
223 <br class="clear" />
224
225 </div>
226 <?php
227 }
228
229 /**
230 * Reorder User Defined Array
231 *
232 * @param $old_value
233 * @param $new_value
234 *
235 * @access public
236 * @since 1.8.12
237 *
238 * @return int
239 */
240 public function give_sort_total_donations( $old_value, $new_value ) {
241 // If no sort, default to label.
242 $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label';
243
244 // If no order, default to asc.
245 $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
246
247 // Determine sort order.
248 $result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] );
249
250 return ( $order === 'asc' ) ? $result : -$result;
251 }
252
253
254 /**
255 * Build all the reports data
256 *
257 * @access public
258 * @since 1.0
259 * @return array $reports_data All the data for donor reports
260 */
261 public function reports_data() {
262
263 $reports_data = array();
264 $gateways = give_get_payment_gateways();
265 $stats = new Give_Payment_Stats();
266
267 foreach ( $gateways as $gateway_id => $gateway ) {
268
269 $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
270 $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
271
272 $reports_data[] = array(
273 'ID' => $gateway_id,
274 'label' => $gateway['admin_label'],
275 'complete_sales' => $complete_count,
276 'pending_sales' => $pending_count,
277 'total_sales' => $complete_count + $pending_count,
278 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, strtotime( '04/13/2015' ), current_time( 'timestamp' ), $gateway_id ), array( 'sanitize' => false ) ) ),
279 );
280 }
281
282 return $reports_data;
283 }
284
285 /**
286 * Setup the final data for the table
287 *
288 * @access public
289 * @since 1.0
290 * @uses Give_Gateway_Reports_Table::get_columns()
291 * @uses Give_Gateway_Reports_Table::get_sortable_columns()
292 * @uses Give_Gateway_Reports_Table::reports_data()
293 * @return void
294 */
295 public function prepare_items() {
296 $columns = $this->get_columns();
297 $hidden = array(); // No hidden columns
298 $sortable = $this->get_sortable_columns();
299 $this->_column_headers = array( $columns, $hidden, $sortable );
300 $this->items = $this->reports_data();
301
302 // Sort Array when we are sorting data in array.
303 usort( $this->items, array( $this, 'give_sort_total_donations' ) );
304
305 }
306 }
307