Changeset 2622
- Timestamp:
- 02/25/2016 11:15:39 PM (10 years ago)
- Location:
- sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
includes/payment-requests-dashboard.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network
- Property svn:mergeinfo changed (with no actual effect on merging)
-
sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-dashboard.php
r2617 r2622 335 335 } 336 336 337 $approved_only = ! empty( $_POST['wcpn_approved_only'] ); 337 338 $start_date = strtotime( $_POST['wcpn_export_start_date'] . ' 00:00:00' ); 338 339 $end_date = strtotime( $_POST['wcpn_export_end_date'] . ' 23:59:59' ); … … 340 341 $filename = sanitize_file_name( $filename ); 341 342 342 $report = self::generate_payment_report( $_POST['wcpn_date_type'], $start_date, $end_date, $export_type );343 $report = self::generate_payment_report( $_POST['wcpn_date_type'], $start_date, $end_date, $export_type, $approved_only ); 343 344 344 345 if ( is_wp_error( $report ) ) { … … 366 367 * @return string | WP_Error 367 368 */ 368 protected static function generate_payment_report( $date_type, $start_date, $end_date, $export_type ) {369 protected static function generate_payment_report( $date_type, $start_date, $end_date, $export_type, $approved_only ) { 369 370 global $wpdb; 370 371 … … 396 397 'end_date' => $end_date, 397 398 'export_type' => $export_type, 399 'approved_only' => $approved_only, 398 400 ); 399 401 … … 411 413 $args = wp_parse_args( $args, array( 412 414 'request_indexes' => array(), 415 'approved_only' => false, 413 416 ) ); 414 417 … … 425 428 426 429 foreach( $args['request_indexes'] as $index ) { 427 fputcsv( $report, self::get_report_row( $index ) ); 430 $row = self::get_report_row( $index, $args ); 431 if ( ! empty( $row ) ) { 432 fputcsv( $report, $row ); 433 } 428 434 } 429 435 … … 442 448 $args = wp_parse_args( $args, array( 443 449 'request_indexes' => array(), 450 'approved_only' => false, 444 451 ) ); 445 452 … … 463 470 switch_to_blog( $index->blog_id ); 464 471 $post = get_post( $index->post_id ); 472 473 if ( $args['approved_only'] && $post->post_status != 'wcb-approved' ) 474 continue; 465 475 466 476 if ( get_post_meta( $post->ID, '_camppayments_payment_method', true ) != 'Check' ) … … 550 560 $args = wp_parse_args( $args, array( 551 561 'request_indexes' => array(), 562 'approved_only' => false, 552 563 ) ); 553 564 … … 616 627 $post = get_post( $index->post_id ); 617 628 629 if ( $args['approved_only'] && $post->post_status != 'wcb-approved' ) 630 continue; 631 618 632 if ( get_post_meta( $post->ID, '_camppayments_payment_method', true ) != 'Direct Deposit' ) 619 633 continue; … … 749 763 $args = wp_parse_args( $args, array( 750 764 'request_indexes' => array(), 765 'approved_only' => false, 751 766 ) ); 752 767 … … 763 778 switch_to_blog( $index->blog_id ); 764 779 $post = get_post( $index->post_id ); 780 781 if ( $args['approved_only'] && $post->post_status != 'wcb-approved' ) 782 continue; 765 783 766 784 // Only wires here. … … 966 984 * 967 985 * @param stdClass $index 986 * @param array $args 968 987 * 969 988 * @return array 970 989 */ 971 protected static function get_report_row( $index ) {990 protected static function get_report_row( $index, $args ) { 972 991 switch_to_blog( $index->blog_id ); 973 992 974 $request = get_post( $index->post_id ); 993 $request = get_post( $index->post_id ); 994 if ( $args['approved_only'] && $request->post_status != 'wcb-approved' ) 995 return null; 996 975 997 $currency = get_post_meta( $index->post_id, '_camppayments_currency', true ); 976 998 $category = get_post_meta( $index->post_id, '_camppayments_payment_category', true ); … … 1043 1065 <?php wp_nonce_field( 'export', 'wcpn_request_export' ); ?> 1044 1066 1045 <p> 1046 This form will supply a CSV file with payment requests matching the parameters you select below. 1047 For example, all requests that were <code>paid</code> between <code><?php echo esc_html( $last_month ); ?></code> and <code><?php echo esc_html( $today ); ?></code>. 1048 </p> 1049 1050 <p> 1051 <label> 1052 Date type: 1053 <select name="wcpn_date_type"> 1054 <option value="created">created</option> 1055 <option value="paid" selected>paid</option> 1056 </select> 1057 </label> 1058 </p> 1059 1060 <p> 1061 <label> 1062 Start date: 1063 <input type="date" name="wcpn_export_start_date" class="medium-text" value="<?php echo esc_attr( $last_month ); ?>" /> 1064 </label> 1065 </p> 1066 1067 <p> 1068 <label> 1069 End date: 1070 <input type="date" name="wcpn_export_end_date" class="medium-text" value="<?php echo esc_attr( $today ); ?>" /> 1071 </label> 1072 </p> 1073 1074 <p> 1075 <label>Export Type: 1076 <select name="wcpn_export_type"> 1077 <?php foreach ( self::get_export_types() as $key => $export_type ) : ?> 1078 <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $export_type['label'] ); ?></option> 1079 <?php endforeach; ?> 1080 </select> 1081 </label> 1082 1083 <?php submit_button( 'Export' ); ?> 1067 <h2>Export Settings</h2> 1068 1069 <table class="form-table"> 1070 <tr> 1071 <th><label>Approved Only</label></th> 1072 <td><label><input type="checkbox" name="wcpn_approved_only" value="1" checked> Export only requests marked as approved</label></td> 1073 </tr> 1074 <tr> 1075 <th><label>Date Type</label></th> 1076 <td> 1077 <select name="wcpn_date_type"> 1078 <option value="created" selected>created</option> 1079 <option value="paid">paid</option> 1080 </select> 1081 </td> 1082 </tr> 1083 <tr> 1084 <th><label>Date Range</label></th> 1085 <td> 1086 <input type="date" name="wcpn_export_start_date" class="medium-text" value="<?php echo esc_attr( $last_month ); ?>" /> to 1087 <input type="date" name="wcpn_export_end_date" class="medium-text" value="<?php echo esc_attr( $today ); ?>" /> 1088 </td> 1089 </tr> 1090 <tr> 1091 <th><label>Format</label></th> 1092 <td> 1093 <select name="wcpn_export_type"> 1094 <?php foreach ( self::get_export_types() as $key => $export_type ) : ?> 1095 <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $export_type['label'] ); ?></option> 1096 <?php endforeach; ?> 1097 </select> 1098 </td> 1099 </tr> 1100 </table> 1101 1102 <?php submit_button( 'Download Export' ); ?> 1084 1103 </form> 1085 1104
Note: See TracChangeset
for help on using the changeset viewer.