Files
redmine_qbo_calendar/app/views/customer_appointments/_calendar_event.html.erb
T
rickyandClaude Opus 5.5 31356ac3fb Appointment statuses in the plugin settings; call-outs as their own entry
Statuses (name, colour, counts toward hours, order) are set up on the plugin's settings page
instead of being hard-coded. Appointments keep a fixed key, so renaming is safe; removing a status
in use asks which status to move its appointments to (done on save by a SettingsController hook).
Colours come from the settings everywhere statuses show, which also fixes Cancelled never being
coloured (cancelled/canceled mismatch).

Call-outs (an employee off work) are their own kind of entry (event_type 'call_out') with an
employee, date, days and notes, added from a button on each calendar day. They sit at the top of
the day in red stripes and never count toward hours. Migration 004 converts Call_Out appointments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 20:22:52 -05:00

85 lines
2.6 KiB
ERB

<%
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
%>
<%
status = appointment.status_record
css = ['appointment-block', 'tooltip', (appointment.call_out? ? 'call-out' : status.key.parameterize), ('no-hours' if status && !status.counts_hours?)]
%>
<%= tag.div class: css.compact, style: status&.style do %>
<div class="appointment-bar"></div>
<div class="appointment-card">
<%# Row 1: Avatar | Title %>
<div class="appointment-header">
<% if appointment.user %>
<%= avatar(appointment.user, size: 25, class: "appointment-avatar") %>
<% end %>
<span class="appointment-title">
<%= link_to(appointment.subject, customer_appointment_path(appointment), class: "appointment-link") %>
</span>
</div>
<hr class="appointment-divider" />
<%# Row 2: Time | Day Count | Hours %>
<div class="appointment-meta">
<span class="appointment-time">
<%= appointment.date.strftime('%I:%M %p') if appointment.date.present? %>
</span>
<% if duration > 1 && day_number.positive? && day_number <= duration %>
<span class="appointment-days">(Day <%= day_number %> of <%= duration %>)</span>
<% end %>
<%# Call-outs don't use hours %>
<% if appointment.call_out? %>
<span class="appointment-call-out-label" title="<%= l(:label_call_out) %>"><i class="fa-solid fa-user-slash"></i></span>
<% else %>
<span class="appointment-hours">
<%= number_with_precision(appointment.estimated_hours.to_f, precision: 1) %>h
</span>
<% end %>
</div>
<%# Row 3: Details %>
<% if appointment.customer %>
<hr class="appointment-divider" />
<div class="appointment-detail">
<%= appointment.customer.name %>
<% if appointment.vehicle %>
<br/> <%= appointment.vehicle.name %>
<% end %>
</div>
<% end %>
</div>
<span class="tip">
<%= render partial: "customer_appointments/tooltip", locals: { appointment: appointment, day: day } %>
</span>
<% end %>