Changeset 3299
- Timestamp:
- 06/03/2016 11:05:55 PM (9 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/reimbursement-requests-dashboard.php
r2775 r3299 5 5 defined( 'WPINC' ) or die(); 6 6 7 const LATEST_DATABASE_VERSION = 3;7 const LATEST_DATABASE_VERSION = 4; 8 8 9 9 if ( is_network_admin() ) { … … 160 160 currency varchar( 3 ) NOT NULL default '', 161 161 amount numeric( 10, 2 ) unsigned NOT NULL default '0', 162 keywords text NOT NULL default '', 162 163 163 164 PRIMARY KEY (blog_id, request_id), … … 234 235 'currency' => get_post_meta( $request_id, '_wcbrr_currency', true ), 235 236 'amount' => get_amount( $request_id ), 237 'keywords' => wp_json_encode( get_search_keywords( $request ) ), 236 238 ); 237 239 … … 246 248 } 247 249 248 $formats = array( '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f' );250 $formats = array( '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%s' ); 249 251 250 252 $wpdb->replace( get_index_table_name(), $index_row, $formats ); … … 269 271 270 272 return $amount; 273 } 274 275 /** 276 * Get the search keywords for a Reimbursement Request 277 * 278 * @param \WP_Post $request 279 * 280 * @return array 281 */ 282 function get_search_keywords( $request ) { 283 $keywords = array(); 284 $expenses = get_post_meta( $request->ID, '_wcbrr_expenses', true ); 285 $categories = \WordCamp_Budgets::get_payment_categories(); 286 287 if ( ! empty( $request->post_title ) ) { 288 $keywords[] = $request->post_title; 289 } 290 291 $payer_name = get_post_meta( $request->ID, '_wcbrr_name_of_payer', true ); 292 if ( ! empty( $payer_name ) ) { 293 $keywords[] = $payer_name; 294 } 295 296 $payment_method = get_post_meta( $request->ID, '_wcbrr_payment_method', true ); 297 if ( ! empty( $payment_method ) ) { 298 $keywords[] = $payment_method; 299 } 300 301 if ( is_array( $expenses ) ) { 302 $keywords[] = get_amount( $request->ID ); 303 304 foreach ( $expenses as $expense ) { 305 if ( array_key_exists( $expense['_wcbrr_category'], $categories ) ) { 306 $keywords[] = $expense['_wcbrr_category']; // Use the category key, because the category value is localized 307 } 308 309 if ( ! empty( $expense['_wcbrr_vendor_name'] ) ) { 310 $keywords[] = $expense['_wcbrr_vendor_name']; 311 } 312 313 if ( ! empty( $expense['_wcbrr_amount'] ) ) { 314 $keywords[] = $expense['_wcbrr_amount']; 315 } 316 } 317 } 318 319 return $keywords; 271 320 } 272 321 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/reimbursement-requests-list-table.php
r3294 r3299 52 52 $limit = 30; 53 53 $offset = $limit * ( $paged - 1 ); 54 55 $this->items = $wpdb->get_results( $wpdb->prepare( " 54 $search = ''; 55 56 if ( ! empty( $_REQUEST['s'] ) ) { 57 $search = $wpdb->prepare( 58 "AND `keywords` LIKE '%%%s%%'", 59 $wpdb->esc_like( wp_unslash( $_REQUEST['s'] ) ) 60 ); 61 } 62 63 $query = " 56 64 SELECT * 57 65 FROM $table_name 58 WHERE status = %s 66 WHERE 67 status = %s 68 {{search}} 59 69 ORDER BY date_requested ASC 60 70 LIMIT %d 61 OFFSET %d", 62 $status, 63 $limit, 64 $offset 65 ) ); 71 OFFSET %d 72 "; 73 74 $query = $wpdb->prepare( $query, $status, $limit, $offset ); 75 $query = str_replace( '{{search}}', $search, $query ); 76 77 $this->items = $wpdb->get_results( $query ); 66 78 67 79 // A second query is faster than using SQL_CALC_FOUND_ROWS during the first query -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/views/reimbursement-requests/page-reimbursement-requests.php
r2393 r3299 26 26 </h3> 27 27 28 <?php $list_table->display(); ?> 28 <div id="wcp-list-table"> 29 <form id="posts-filter" action="" method="get"> 30 <input type="hidden" name="page" value="reimbursement-requests-dashboard" /> 31 <input type="hidden" name="section" value="<?php echo esc_attr( get_current_section() ); ?>" /> 32 33 <?php $list_table->search_box( __( 'Search Reimbursements', 'wordcamporg' ), 'wcp' ); ?> 34 <?php $list_table->display(); ?> 35 </form> 36 </div> 29 37 </div>
Note: See TracChangeset
for help on using the changeset viewer.