diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 74cf1d9..a66da2c 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -59,29 +59,58 @@ <% week.each do |day| %> + <% + # Non-appointment events (Issues, Versions, etc.) + standard_events = calendar.events_on(day).reject { |e| e.is_a?(CustomerAppointment) } + + # Appointments matching duration on this working day + matching_appointments = all_appointments.select { |app| appointment_occurs_on.call(app, day) } + + day_events = standard_events + matching_appointments + + # Sum estimated hours for Issues and CustomerAppointments + total_hours = day_events.sum do |event| + if event.is_a?(Issue) + event.estimated_hours.to_f + elsif event.is_a?(CustomerAppointment) + if event.respond_to?(:estimated_hours) && event.estimated_hours.present? + event.estimated_hours.to_f + else + event.duration.to_f + end + else + 0.0 + end + end + %> +
- <%= day.day %> - (<%= abbr_day_name(day.cwday) %>) - - <% if day >= User.current.today %> - <%= link_to sprite_icon('add'), - new_customer_appointment_path(start_date: day), - class: 'icon-only icon-add', - title: l(:label_appointment_new, default: 'New Appointment') %> - <% end %> +
+ + <% if total_hours > 0 %> + + <%= total_hours.round(1) %>h + + <% end %> + + + + <% if day >= User.current.today %> + <%= link_to sprite_icon('add'), + new_customer_appointment_path(start_date: day), + class: 'icon-only icon-add', + title: l(:label_appointment_new, default: 'New Appointment') %> + <% end %> + + + + (<%= abbr_day_name(day.cwday) %>) + <%= day.day %> +
- <% - # Non-appointment events (Issues, Versions, etc.) - standard_events = calendar.events_on(day).reject { |e| e.is_a?(CustomerAppointment) } - - # Appointments matching duration on this working day - matching_appointments = all_appointments.select { |app| appointment_occurs_on.call(app, day) } - %> - - <% (standard_events + matching_appointments).each do |event| %> + <% day_events.each do |event| %> <% if event.is_a?(Issue) %>