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