module Flyboy module ApplicationHelper def goal_color(goal) return "onalert" if Flyboy::Task.where('goal_id = ? AND done = ? AND term < ?', goal.id, false, Date.today).count > 0 return "onwarning" if Flyboy::Task.where('goal_id = ? AND done = ? AND term > ? AND reminder < ?', goal.id , false, Date.today, Date.today).count > 0 return "finished" if goal.closed? return "ontime" end def task_color(task) return "finished" if task.done return "ontime" if task.reminder > Date.today return "onalert" if task.term < Date.today return "onwarning" end end end