mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 21:50:37 -05:00
- Issues' estimated hours are spread over their working days from start to due date, instead of counted in full on both the start and due dates - Tooltips in the two rightmost columns open leftward again (the rule targeted the old table layout) - Today scrolls when today is on the page (the check read calendar values that don't exist) - "Day N of M" on calendar cards and My Page skips holidays; My Page uses the user's date - Each appointment's working days are worked out once per page (CustomerAppointment#working_days), and shared by placement, hours, day numbers and the end date - The calendar toggles are kept in the session, so changing month loads the page once - Clicking inside an open tooltip keeps it open; estimates load with the appointments - Hours in a working day is a plugin setting (default 8) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.8 KiB
ERB
71 lines
2.8 KiB
ERB
<h3><%= l(:label_upcoming_appointments, default: 'My Upcoming Appointments') %></h3>
|
|
|
|
<%
|
|
today = User.current.today
|
|
holidays = Holiday.all.to_a
|
|
|
|
# Safely filter appointments by logged-in user across possible user column names
|
|
appointments_scope = CustomerAppointment.includes(:customer, :vehicle)
|
|
if CustomerAppointment.column_names.include?('user_id')
|
|
appointments_scope = appointments_scope.where(user_id: User.current.id)
|
|
elsif CustomerAppointment.column_names.include?('assigned_to_id')
|
|
appointments_scope = appointments_scope.where(assigned_to_id: User.current.id)
|
|
elsif CustomerAppointment.column_names.include?('author_id')
|
|
appointments_scope = appointments_scope.where(author_id: User.current.id)
|
|
end
|
|
|
|
# Look back up to 60 days to capture multi-day appointments starting in the past
|
|
raw_appointments = appointments_scope.where('date >= ?', today - 60.days)
|
|
|
|
# One row per working day (weekends and holidays skipped, as on the calendar), from today on
|
|
expanded_appointments = raw_appointments.flat_map do |appointment|
|
|
days = appointment.working_days(holidays: holidays)
|
|
days.each_with_index.filter_map do |date, index|
|
|
{ appointment: appointment, date: date, day_number: index + 1, total_days: days.size } if date >= today
|
|
end
|
|
end
|
|
|
|
# Sort upcoming occurrences chronologically and take top 10
|
|
expanded_appointments = expanded_appointments.sort_by { |item| [item[:date], item[:appointment].date] }.first(10)
|
|
%>
|
|
|
|
<% if expanded_appointments.any? %>
|
|
<table class="list appointments">
|
|
<thead>
|
|
<tr>
|
|
<th><%= l(:label_title) %></th>
|
|
<th><%= l(:label_customer) %></th>
|
|
<th><%= l(:label_vehicle) %></th>
|
|
<th><%= l(:label_date) %></th>
|
|
<th class="status"><%= l(:label_status) %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% expanded_appointments.each do |item| %>
|
|
<% appt = item[:appointment] %>
|
|
<tr class="<%= cycle('odd', 'even') %> appointment-row">
|
|
<td class="subject">
|
|
<%= link_to appt.subject, customer_appointment_path(appt) %>
|
|
<% if item[:total_days] > 1 %>
|
|
<small class="muted">(Day <%= item[:day_number] %> of <%= item[:total_days] %>)</small>
|
|
<% end %>
|
|
</td>
|
|
<td class="customer">
|
|
<%= link_to appt.customer unless appt.customer.nil? %>
|
|
</td>
|
|
<td class="vehicle">
|
|
<%= link_to appt.vehicle unless appt.vehicle.nil? %>
|
|
</td>
|
|
<td class="start-date">
|
|
<%= format_date(item[:date]) %>
|
|
</td>
|
|
<td class="status">
|
|
<%= appointment_status_badge(appt, css: 'badge status-badge') %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
|
<% end %> |