Fix SQL errors when searching sales log page

The SQL to generate the sales total for the filtered list, and the months for the filter drop-down use the WHERE conditions from the generated query, however they don't use the relevant JOINS leading them to try and restrict the query on fields which don't exist. This adds the joins to the query, which means that searching the sales log no longer WSODs. Sales totals, and month filters appear to be correct on my test site. 

Fixes #510