Changeset 2526 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php
- Timestamp:
- 02/18/2016 10:22:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php
r2519 r2526 5 5 defined( 'WPINC' ) or die(); 6 6 7 const LATEST_DATABASE_VERSION = 1;7 const LATEST_DATABASE_VERSION = 2; 8 8 9 9 if ( defined( 'DOING_AJAX' ) ) { … … 165 165 blog_id int( 11 ) unsigned NOT NULL default '0', 166 166 invoice_id int( 11 ) unsigned NOT NULL default '0', 167 qbo_invoice_id int( 11 ) unsigned NOT NULL default '0', 167 168 invoice_title varchar( 75 ) NOT NULL default '', 168 169 status varchar( 30 ) NOT NULL default '', … … 214 215 } 215 216 217 switch_to_blog( $site_id ); 218 216 219 $quickbooks_result = send_invoice_to_quickbooks( $site_id, $invoice_id ); 217 220 218 if ( 'sent' === $quickbooks_result ) { 221 if ( is_int( $quickbooks_result ) ) { 222 update_post_meta( $invoice_id, '_wcbsi_qbo_invoice_id', absint( $quickbooks_result ) ); 219 223 update_invoice_status( $site_id, $invoice_id, 'approved' ); 220 224 notify_organizer_status_changed( $site_id, $invoice_id, 'approved' ); 221 wp_send_json_success( array( 'message' => 'The invoice has been approved.' ) ); 225 226 $result = array( 'success' => 'The invoice has been approved and e-mailed to the sponsor.' ); 222 227 } else { 223 wp_send_json_error( array( 'error' => $quickbooks_result ) ); 228 $result = array( 'error' => $quickbooks_result ); 229 } 230 231 restore_current_blog(); 232 233 if ( isset( $result['success'] ) ) { 234 wp_send_json_success( $result ); 235 } else { 236 wp_send_json_error( $result ); 224 237 } 225 238 } … … 231 244 * @param int $invoice_id 232 245 * 233 * @return string246 * @return int|string 234 247 */ 235 248 function send_invoice_to_quickbooks( $site_id, $invoice_id ) { … … 262 275 263 276 $sent = 'QuickBooks integration is not complete yet.'; 264 // todo return 'sent' (string)on success, or an error message string on failure277 // todo return QBO invoice ID on success, or an error message string on failure 265 278 266 279 restore_current_blog(); … … 420 433 'blog_id' => get_current_blog_id(), 421 434 'invoice_id' => $invoice_id, 435 'qbo_invoice_id' => get_post_meta( $invoice_id, '_wcbsi_qbo_invoice_id', true ), 422 436 'invoice_title' => $invoice->post_title, 423 437 'status' => $invoice->post_status, … … 430 444 ); 431 445 432 $formats = array( '%d', '%d', '% s', '%s', '%s', '%s', '%s', '%s', '%d', '%f' );446 $formats = array( '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%f' ); 433 447 434 448 $wpdb->replace( get_index_table_name(), $index_row, $formats );
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)