I have tried to find this in google and in here but seems i cant find a decent answer here the problem what i want i want is i need to get the sum of the total hrs for each day from monday to sunday displaying like this please check this image
and my model is like this
class Staff < ActiveRecord::Base
has_many :task_logs
end
class Client < ActiveRecord::Base
has_many :task_logs
end
class TaskLog < ActiveRecord::Base
belongs_to :staff
belongs_to :client
end
and my controller
@hrs_staff_by_client = TaskLog.joins(:staff).joins(:client).joins(:user).select("staffs.full_name AS full_names").select("staffs.position AS positions").select("clients.full_name AS client_names").select("users.email AS emails").select("clients.*, SUM(task_logs.total_hrs) AS today").group("staffs.id, users.id, clients.id")
Aucun commentaire:
Enregistrer un commentaire