<% non_working_days = Setting.non_working_week_days || [] app_datetime = (appointment.respond_to?(:date) && appointment.date.present?) ? appointment.date : appointment.start_date start_date = app_datetime.to_date target_date = day.to_date duration = [appointment.duration.to_i, 1].max day_number = 0 if target_date >= start_date date_cursor = start_date working_count = 0 while date_cursor <= target_date unless non_working_days.include?(date_cursor.cwday.to_s) working_count += 1 end if date_cursor == target_date day_number = working_count break end date_cursor += 1 end end %> <%= tag.div class: ['appointment-block', 'tooltip', appointment.status.to_s.parameterize] do %>
<%# Row 1: Avatar | Title %>
<% if appointment.user %> <%= avatar(appointment.user, size: 25, class: "appointment-avatar") %> <% end %> <%= link_to(appointment.subject, customer_appointment_path(appointment), class: "appointment-link") %>

<%# Row 2: Time | Day Count | Hours %>
<%= appointment.date.strftime('%I:%M %p') if appointment.date.present? %> <% if duration > 1 && day_number.positive? && day_number <= duration %> (Day <%= day_number %> of <%= duration %>) <% end %> <%= number_with_precision(appointment.estimated_hours.to_f, precision: 1) %>h
<%# Row 3: Details %> <% if appointment.customer %>
<%= appointment.customer.name %> <% if appointment.vehicle %>
<%= appointment.vehicle.name %> <% end %>
<% end %>
<%= render partial: "customer_appointments/tooltip", locals: { appointment: appointment, day: day } %> <% end %>