Fixes to search paging/links.
Fix to bug calculating cogs owed causing orphaned table inventory_cogs_owed entries and possible errors in cogs sold calculations.