Refactor reports to generate on demand.

Extract the report logic out of the user interface into a separate
library.
Change the UI to respond to requiring a date range for a report.