• Resolved awijasa

    (@awijasa)


    Hello,

    Accounting > Sales > Payment > Customer Search is ignoring the search term.

    Steps to reproduce:
    1. Login to /wp-admin
    2. Click Accounting > Customers
    3. Create two Customers
    4. Click Accounting > Sales
    5. Click the Payment button at the top
    6. Click the Customer Search box
    7. No matter the search term you put in, it always list all Customers

    I have a test site for you https://wperp.cloud77.com. If you want to use it, please let me know your email address.

    Workaround:

    Add this code to /erp/includes/functions-people.php, right after $sql['where'] = [''];

    
    if( !empty( $s ) ) {
    
    	$search_term = '%' . $wpdb->esc_like( $s ) . '%';
    
    	$sql['where'][] = $wpdb->prepare(
    		"AND ( " .
    			"LOWER( people.first_name ) LIKE %s OR " .
    			"LOWER( people.last_name ) LIKE %s OR " .
    			"LOWER( people.company ) LIKE %s OR " .
    			"LOWER( people.email ) LIKE %s OR " .
    			"LOWER( people.phone ) LIKE %s OR " .
    			"LOWER( people.mobile ) LIKE %s OR " .
    			"LOWER( people.other ) LIKE %s OR " .
    			"LOWER( people.website ) LIKE %s OR " .
    			"LOWER( people.fax ) LIKE %s OR " .
    			"LOWER( people.notes ) LIKE %s OR " .
    			"LOWER( people.street_1 ) LIKE %s OR " .
    			"LOWER( people.street_2 ) LIKE %s OR " .
    			"LOWER( people.city ) LIKE %s OR " .
    			"LOWER( people.state ) LIKE %s OR " .
    			"LOWER( people.postal_code ) LIKE %s OR " .
    			"LOWER( people.country ) LIKE %s" .
    		")",
    		array(
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term
    		)
    	);
    }
    

    Thanks,

    @awijasa

    • This topic was modified 7 years, 5 months ago by awijasa.
    • This topic was modified 7 years, 5 months ago by awijasa.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter awijasa

    (@awijasa)

    Actually, the code should be:

    
    if( !empty( $s ) ) {
    
    	$search_term = '%' . $wpdb->esc_like( str_replace( "\'", "'", $s ) ) . '%';
    
    	$sql['where'][] = $wpdb->prepare(
    		"AND ( " .
    			"LOWER( people.first_name ) LIKE %s OR " .
    			"LOWER( people.last_name ) LIKE %s OR " .
    			"LOWER( people.company ) LIKE %s OR " .
    			"LOWER( people.email ) LIKE %s OR " .
    			"LOWER( people.phone ) LIKE %s OR " .
    			"LOWER( people.mobile ) LIKE %s OR " .
    			"LOWER( people.other ) LIKE %s OR " .
    			"LOWER( people.website ) LIKE %s OR " .
    			"LOWER( people.fax ) LIKE %s OR " .
    			"LOWER( people.notes ) LIKE %s OR " .
    			"LOWER( people.street_1 ) LIKE %s OR " .
    			"LOWER( people.street_2 ) LIKE %s OR " .
    			"LOWER( people.city ) LIKE %s OR " .
    			"LOWER( people.state ) LIKE %s OR " .
    			"LOWER( people.postal_code ) LIKE %s OR " .
    			"LOWER( people.country ) LIKE %s" .
    		")",
    		array(
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term
    		)
    	);
    }
    
    Thread Starter awijasa

    (@awijasa)

    Here is a version with stripslashes:

    
    if( !empty( $s ) ) {
    
    	$search_term = '%' . $wpdb->esc_like( stripslashes( $s ) ) . '%';
    
    	$sql['where'][] = $wpdb->prepare(
    		"AND ( " .
    			"LOWER( people.first_name ) LIKE %s OR " .
    			"LOWER( people.last_name ) LIKE %s OR " .
    			"LOWER( people.company ) LIKE %s OR " .
    			"LOWER( people.email ) LIKE %s OR " .
    			"LOWER( people.phone ) LIKE %s OR " .
    			"LOWER( people.mobile ) LIKE %s OR " .
    			"LOWER( people.other ) LIKE %s OR " .
    			"LOWER( people.website ) LIKE %s OR " .
    			"LOWER( people.fax ) LIKE %s OR " .
    			"LOWER( people.notes ) LIKE %s OR " .
    			"LOWER( people.street_1 ) LIKE %s OR " .
    			"LOWER( people.street_2 ) LIKE %s OR " .
    			"LOWER( people.city ) LIKE %s OR " .
    			"LOWER( people.state ) LIKE %s OR " .
    			"LOWER( people.postal_code ) LIKE %s OR " .
    			"LOWER( people.country ) LIKE %s" .
    		")",
    		array(
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term,
    			$search_term
    		)
    	);
    }
    

    @awijasa,

    This search option has been updated!
    Thanks a lot for your contribution. This is really appreciable.

    Cheers!

    Thread Starter awijasa

    (@awijasa)

    Awesome! Will the resolution be applied to WP ERP 1.2.7?

    Thanks,

    @awijasa

    @awijasa,

    Yes! Hopefully, it will be implemented in the next version.

    Thanks ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Accounting > Sales > Payment > Customer Search is ignoring the search term’ is closed to new replies.