Update Model

Change purchase model to invoice model
Use db global variable (fix db connection problem)
Add API controller

Add File API controller
Add Invoice API controller
Fix DB connection problem
Add more API routes (File, Invoice)