Clean up and speed up full report code

Removed entire block of code that looped database results into an array
which then created the report, opting to just do everything within the
initial while loop. Added a temp table to hold activity results for the
year in focus to reduce overhead. Tidied up the main query.

TODO: Rewrite main query to include the second query within the first
to really speed things up.