Business history log

FROM CASE 79
A central event log used to track major changes to business objects and major events of significance in AyaNova
Consumed by various widgets for record history purposes
Default feature, no need to turn on or off
Items are only removed from log when source object is deleted (and replaced with a deleted entry and textual description of deleted item)
Has to handle a scenario where there is no data for an object because in future we will likely have a purge feature or maybe a feature to turn it off and needs to accept that scenario
?FUTURE: Has some sort of checksum or verification so we can tell it wasn't fucked with (too hard to implement, would be something like a blockchain?)
?FUTURE: Needs a cleaner job that periodically looks for non-existant objects that are logged
?FUTURE: keeps logs for 45 days initially keeps forever or until object is deleted


ROUTES
------
Fetch a constructed, localized log for the following:
    - Supply user ID, optional time range, get back a log of everything the user did in order for all time or just the specified time range
    - Supply object type, object id, optional time range, get back a log of history for that object for all time or time range specified

Fetch the above but in raw form as data as well??

EVENT_TYPES
-----------
A master enum of all event types in RAVEN.
Co-used by this log feature, but also used by notification system
Also used by localized text feature to fetch text about event for display in log and notification etc
May be used for other things in future.
Common event types that apply to any object and then specific event types that apply to particular types of objects but all in the same master enum

EventType
ALL OBJECTS
1 = created
2 = retrieved (keep just in case, but perhaps not to be used unless high level of logging required?)
3 = modified
4 = deleted

SPECIFIC OBJECT EXAMPLE
Workorder:
4=Closed
5=Servicecompleted
6=all parts set to used in Service
7 = accepted from csr
etc


EVENT LOG DB SCHEMA
------------------------------------
AYaTYPE (object type int), 
AYID (object id),
AYEVENT (event of interest type int defined in central master enum of all events), 
TIMESTAMP (unix epoch), 
USERID,
TEXTRA (text field to identify stuff that can't be retrieved from source object, i.e. deleted record name) 


DELETION
--------
Initially, the only way an entry is removed from the log is via deletion of the source object
When a source object is deleted, the entire history for that object is removed from the log and a new entry is created showing the deletion and textual representation of the object
    - The record has the object type so no need to redundently store that, just the name: "1234" for workorder 1234 or "ABC Accounting" for the client name etc


PURGING (FUTURE)
----------------
Items that might be most purgeable in any future purge scenario:
- Retrieved events
- File attachment download events
- fetch logfile


TODO:
1) Implement this log and routes to interact with it
2) Implement a cleaner job to remove events for nonexistant objects that aren't deleted