diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb
index 950de23..8953f78 100644
--- a/app/views/common/_calendar.html.erb
+++ b/app/views/common/_calendar.html.erb
@@ -120,6 +120,16 @@
diff --git a/app/views/customer_appointments/_tooltip.html.erb b/app/views/customer_appointments/_tooltip.html.erb
index 2f8307a..548b14a 100644
--- a/app/views/customer_appointments/_tooltip.html.erb
+++ b/app/views/customer_appointments/_tooltip.html.erb
@@ -19,7 +19,13 @@
<% if appointment.customer %>
| <%= l(:label_customer) %> |
- <%= link_to appointment.customer %> |
+
+ <%= link_to appointment.customer %>
+ <%= link_to history_customer_appointments_path(customer_id: appointment.customer_id),
+ title: l(:label_appointment_history), class: 'appointment-history-icon' do %>
+
+ <% end %>
+ |
<% end %>
diff --git a/assets/stylesheets/customer_appointments.css b/assets/stylesheets/customer_appointments.css
index ee280e6..ecbc41a 100644
--- a/assets/stylesheets/customer_appointments.css
+++ b/assets/stylesheets/customer_appointments.css
@@ -609,3 +609,16 @@ table.cal td.today {
table.appointment-history td.subject {
text-align: left;
}
+
+/* Upcoming appointments on the customer page */
+.customer-appointments-simple .contextual {
+ margin-top: 0;
+}
+.customer-appointments-simple .appointment-history-link {
+ margin-top: 6px;
+ text-align: right;
+}
+.appointment-history-icon {
+ margin-left: 6px;
+ text-decoration: none;
+}
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8bb4ba8..7ea280a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -37,6 +37,11 @@ en:
label_appointment_new: "New Appointment"
label_appointments: Appointments
label_appointment_history: Appointment History
+ label_upcoming_customer_appointments: Upcoming Appointments
+ label_no_upcoming_appointments: "No upcoming appointments"
+ label_view_past_appointments:
+ one: "View 1 past appointment"
+ other: "View all %{count} past appointments"
label_appointment_history_for: "Appointment History: %{name}"
label_all_statuses: "All statuses"
label_date_from: From
diff --git a/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb b/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb
index 7a7f9d4..730a0f0 100644
--- a/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb
+++ b/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb
@@ -20,12 +20,19 @@ module RedmineQboCalendar
log "show_customer_view_right called"
customer = context[:customer]
- appointments = customer.customer_appointments.where('date >= ?', Date.today).order(date: :asc)
+ return unless customer
+ return unless User.current.allowed_to?(:view_customer_appointments, nil, global: true)
- return if appointments.empty?
+ cutoff = Time.zone.now.beginning_of_day
+ appointments = customer.customer_appointments.where('date >= ?', cutoff).order(date: :asc)
+ past_count = customer.customer_appointments.where('date < ?', cutoff).count
- context[:controller].send(:render_to_string, {
- partial: 'customer_appointments/list_simple', locals: { appointments: appointments }
+ # Nothing upcoming and no history: keep the customer page clean
+ return if appointments.empty? && past_count.zero?
+
+ context[:controller].send(:render_to_string, {
+ partial: 'customer_appointments/list_simple',
+ locals: { appointments: appointments, customer: customer, past_count: past_count }
})
end
@@ -37,4 +44,4 @@ module RedmineQboCalendar
end
end
end
-end
\ No newline at end of file
+end
\ No newline at end of file