mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-10-03 20:40:43 -04:00
76 lines
2.2 KiB
ERB
76 lines
2.2 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
|
|
%>
|
|
|
|
<%= tag.div class: ['appointment-block', 'tooltip', appointment.status.to_s.parameterize] 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: 14, 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 %>
|
|
<small class="muted">(Day <%= day_number %> of <%= duration %>)</small>
|
|
<% end %>
|
|
|
|
<span class="appointment-hours">
|
|
<%= number_with_precision(appointment.estimated_hours.to_f, precision: 1) %>h
|
|
</span>
|
|
</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 %> |