Changeset 2771
- Timestamp:
- 03/21/2016 06:24:04 PM (10 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network
- Files:
-
- 2 edited
-
css/wordcamp-budgets-dashboard.css (modified) (1 diff)
-
includes/wordcamp-budgets-dashboard.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/css/wordcamp-budgets-dashboard.css
r2356 r2771 21 21 display: none; 22 22 } 23 24 .wcb-import-message svg { 25 width: 18px; 26 height: 18px; 27 float: left; 28 } 29 30 .wcb-import-message svg.sucess { 31 fill: #46b450; 32 } 33 34 .wcb-import-message svg.error { 35 fill: #dc3232; 36 } 37 38 .wcb-import-message span { 39 display: block; 40 margin-left: 24px; 41 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/wordcamp-budgets-dashboard.php
r2770 r2771 134 134 <?php if ( isset( WCB_Import_Results::$data ) ) : ?> 135 135 <h2>Import Results</h2> 136 <pre><?php echo esc_html( print_r( WCB_Import_Results::$data, true ) ); ?></pre> 136 <table class="wp-list-table widefat"> 137 <thead> 138 <tr> 139 <th>Request</th> 140 <th>Amount</th> 141 <th>Blog ID</th> 142 <th>Post ID</th> 143 <th>Message</th> 144 </tr> 145 </thead> 146 <tbody> 147 <?php foreach ( WCB_Import_Results::$data as $entry ) : ?> 148 <tr> 149 <td><?php 150 $labels = array( 151 'wcp_payment_request' => 'Vendor', 152 'wcb_reimbursement' => 'Reimbursement', 153 ); 154 $label = ! empty( $labels[ $entry['post_type'] ] ) ? $labels[ $entry['post_type'] ] : 'Unknown'; 155 printf( '%s: %s', $label, esc_html( $entry['post_title'] ) ); 156 ?></td> 157 <td><?php 158 printf( '%s %s', number_format( $entry['amount'], 2 ), esc_html( $entry['currency'] ) ); 159 ?></td> 160 <td><?php 161 if ( ! empty( $entry['blog_id'] ) ) { 162 printf( '<a href="%s" target="_blank">%d</a>', esc_url( $entry['edit_all_url'] ), $entry['blog_id'] ); 163 } 164 ?></td> 165 <td><?php 166 if ( ! empty( $entry['post_id'] ) ) { 167 printf( '<a href="%s" target="_blank">%d</a>', esc_url( $entry['edit_post_url'] ), $entry['post_id'] ); 168 } 169 ?></td> 170 <td class="wcb-import-message"> 171 <?php if ( $entry['processed'] ) : ?> 172 <svg class="success" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1472 930v318q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q63 0 117 25 15 7 18 23 3 17-9 29l-49 49q-10 10-23 10-3 0-9-2-23-6-45-6h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113v-254q0-13 9-22l64-64q10-10 23-10 6 0 12 3 20 8 20 29zm231-489l-814 814q-24 24-57 24t-57-24l-430-430q-24-24-24-57t24-57l110-110q24-24 57-24t57 24l263 263 647-647q24-24 57-24t57 24l110 110q24 24 24 57t-24 57z"/></svg> 173 <?php else : ?> 174 <svg class="error" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M896 128q209 0 385.5 103t279.5 279.5 103 385.5-103 385.5-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103zm128 1247v-190q0-14-9-23.5t-22-9.5h-192q-13 0-23 10t-10 23v190q0 13 10 23t23 10h192q13 0 22-9.5t9-23.5zm-2-344l18-621q0-12-10-18-10-8-24-8h-220q-14 0-24 8-10 6-10 18l17 621q0 10 10 17.5t24 7.5h185q14 0 23.5-7.5t10.5-17.5z"/></svg> 175 <?php endif; ?> 176 <span><?php echo esc_html( $entry['message'] ); ?></span> 177 </td> 178 </tr> 179 <?php endforeach; ?> 180 </tbody> 181 </table> 137 182 <?php endif; ?> 138 183 … … 474 519 plugins_url( 'css/wordcamp-budgets-dashboard.css', __DIR__ ), 475 520 array(), 476 1521 2 477 522 ); 478 523 … … 672 717 $entry = array( 673 718 'type' => strtolower( $line[11] ), 674 'status' => strtolower( $line[7] ), 675 'amount' => round( floatval( $line[13] ), 2 ), 676 'currency' => strtoupper( $line[14] ), 719 'title' => null, 720 'post_type' => null, 721 'post_title' => null, 722 'status' => null, 723 'amount' => null, 724 'currency' => null, 677 725 'blog_id' => null, 678 726 'post_id' => null, 679 727 'processed' => false, 680 'data' => null, 728 'message' => null, 729 730 'edit_all_url' => null, 731 'edit_post_url' => null, 681 732 ); 682 733 … … 686 737 $entry['blog_id'] = $matches[1]; 687 738 $entry['post_id'] = $matches[2]; 739 $entry['status'] = strtolower( $line[7] ); 740 $entry['amount'] = round( floatval( $line[13] ), 2 ); 741 $entry['currency'] = strtoupper( $line[14] ); 688 742 } 689 743 break; … … 692 746 $entry['blog_id'] = $matches[1]; 693 747 $entry['post_id'] = $matches[2]; 748 $entry['status'] = strtolower( $line[7] ); 749 $entry['amount'] = round( floatval( $line[13] ), 2 ); 750 $entry['currency'] = strtoupper( $line[14] ); 694 751 } 695 752 break; 753 default: 754 $entry['message'] = 'Unknown payment type.'; 755 $results[] = $entry; 756 continue; 696 757 } 697 758 698 759 if ( empty( $entry['blog_id'] ) || empty( $entry['post_id'] ) ) { 760 $entry['message'] = 'Blog ID or post ID is empty.'; 699 761 $results[] = $entry; 700 762 continue; … … 727 789 $post = get_post( $entry['post_id'] ); 728 790 if ( ! $post || ! in_array( $post->post_type, array( 'wcp_payment_request', 'wcb_reimbursement' ) ) ) { 729 $entry[' data'] = 'Post not found or post type mismatch';791 $entry['message'] = 'Post not found or post type mismatch'; 730 792 return $entry; 731 793 } 794 795 $entry['title'] = $post->post_title; 796 $entry['post_type'] = $post->post_type; 797 $entry['edit_all_url'] = admin_url( 'edit.php?post_type=' . $post->post_type ); 798 $entry['edit_post_url'] = get_edit_post_link( $post->ID ); 732 799 733 800 $currency = false; … … 749 816 750 817 if ( empty( $entry['currency'] ) || $entry['currency'] != $currency ) { 751 $entry[' data'] = 'Currency mismatch';818 $entry['message'] = 'Currency mismatch'; 752 819 return $entry; 753 820 } … … 757 824 758 825 if ( $entry['amount'] !== $amount ) { 759 $entry[' data'] = 'Payment amount mismatch';826 $entry['message'] = 'Payment amount mismatch'; 760 827 return $entry; 761 828 } 762 829 763 // @todo Do some magic here. 830 if ( $entry['type'] == 'wire' ) { 831 832 if ( $entry['status'] != 'completed' ) { 833 $entry['message'] = 'Unknown wire status.'; 834 return $entry; 835 } 836 837 $post->post_status = 'wcb-paid'; 838 wp_insert_post( $post ); 839 $entry['message'] = 'Wire request marked as paid.'; 840 841 \WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'Wire marked as paid via an import in Network Admin', array( 842 'action' => 'paid-via-import', 843 ) ); 844 845 } elseif ( $entry['type'] == 'ach' ) { 846 847 if ( $entry['status'] != 'delivered' ) { 848 $entry['message'] = 'Unknown ACH status.'; 849 return $entry; 850 } 851 852 $post->post_status = 'wcb-paid'; 853 wp_insert_post( $post ); 854 $entry['message'] = 'ACH request marked as paid.'; 855 856 \WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'ACH marked as paid via an import in Network Admin', array( 857 'action' => 'paid-via-import', 858 ) ); 859 860 } else { 861 $entry['message'] = 'Unknown payment method.'; 862 return $entry; 863 } 764 864 765 865 // All good.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)