local application = {}

application.setdb = function(db)
  application.db = db
end

application.new = function(t)
  local application_record = {}
  application_record.type = 'application'
  application_record.username = t.username
  application_record.salutation = t.salutation
  application_record.firstname = t.firstname
  application_record.lastname = t.lastname
  application_record.position = t.position
  application_record.store = t.store
  application_record.address = t.address
  application_record.practice_type = t.practice_type
  application_record.phone_office = t.phone_office
  application_record.phone_cell = t.phone_cell
  application_record.email = t.email
  application_record.submitted_at = os.time()
  application_record.status = 'open'
  
  application.db:insertrecord(application_record)
  
  return application_record
end

return application