<%= link_to issues_calendar_path do %> <%= l(:button_calendar) %> <% end %> <% if @appointment.customer %> <%= link_to history_customer_appointments_path(customer_id: @appointment.customer_id) do %> <%= l(:label_appointment_history) %> <% end %> <% end %> <% if !@appointment.call_out? && User.current.allowed_to?(:add_customer_appointments, nil, global: true) %> <%= link_to new_issue_path(issue: { customer_id: @appointment.customer_id, vehicle_id: @appointment.vehicle_id, estimate_id: @appointment.estimate_id }), target: :_blank do %> <%= l(:label_new_issue) %> <% end %> <% end %> <%# Issues from the estimate are made by redmine_qbo, with this appointment's dates, technician and vehicle %> <% if @appointment.estimate && User.current.allowed_to?(:create_estimate_issues, nil, global: true) %> <%= link_to issues_preview_qbo_estimate_path(@appointment.estimate_id, appointment_id: @appointment.id) do %> <%= l(:button_create_issues_from_estimate) %> <% end %> <% end %> <% if User.current.allowed_to?(:edit_customer_appointments, nil, global: true) %> <%= link_to edit_customer_appointment_path(@appointment) do %> <%= l(:button_edit) %> <% end %> <% end %> <% if User.current.allowed_to?(:delete_customer_appointments, nil, global: true) %> <%= link_to customer_appointment_path(@appointment), method: :delete, data: { confirm: l(:text_are_you_sure) } do %> <%= l(:button_delete) %> <% end %> <% end %>

<% if @appointment.date %>
<%= @appointment.date.strftime('%b').upcase %>
<%= @appointment.date.day %>
<% end %> <%= @appointment.subject %> <% if @appointment.date %> (<%= format_date(@appointment.date) %> <%= l(:label_at, default: 'at') %> <%= @appointment.date.strftime('%I:%M %p') %> <% if @appointment.respond_to?(:due_date) && @appointment.due_date.present? && @appointment.duration.to_i > 1 %> - <%= format_date(@appointment.due_date) %> <% end %>) <% end %>

<%# Quick status buttons; call-outs have no status %> <% if !@appointment.call_out? && User.current.allowed_to?(:edit_customer_appointments, nil, global: true) %>
<%= l(:label_change_status, default: 'Change Status:') %> <% CustomerAppointment.statuses.reject { |s| s.key == @appointment.status_record.key }.each do |status| %> <%= link_to status.name, customer_appointment_path(@appointment, customer_appointment: { status: status.key }), method: :patch, class: 'quick-status-btn', style: status.style %> <% end %>
<% end %>
<% if @appointment.call_out? %> <%# A call-out is about the employee who's off, not a customer %>
<%= l(:label_employee) %>:
<%= link_to_user(@appointment.user) %>
<% else %>
<%= l(:label_customer, default: 'Customer') %>:
<%= link_to_if @appointment.customer, @appointment.customer&.name, @appointment.customer %>
<%= l(:label_vehicle, default: 'Vehicle') %>:
<%= link_to_if @appointment.vehicle, @appointment.vehicle&.name, @appointment.vehicle %>
<%= l(:label_primary_phone, default: 'Primary phone') %>:
<%= @appointment.customer&.primary_phone %>
<%= l(:label_estimate) %>:
<% if @appointment.estimate %>
<%= link_to @appointment.estimate, @appointment.estimate, target: "_blank" %>
<% end %>
<% end %>
<%= l(:field_status) %>:
<%= appointment_status_badge(@appointment) %>
<%= l(:label_time, default: 'Time') %>:
<%= @appointment.date ? @appointment.date.strftime('%I:%M %p') : '-' %>
<% unless @appointment.call_out? %>
<%= l(:field_user) %>:
<%= link_to_user(@appointment.user) %>
<% end %>
<%= l(:label_duration, default: 'Duration') %>:
<%= @appointment.duration %> <%= l(:label_days) %>
<% unless @appointment.call_out? %>
<%= l(:field_estimated_hours) %>:
<%= @appointment.estimated_hours %> <%= l(:label_hours) %> <% if @appointment.partial_estimate? && @appointment.estimate %>(<%= l(:label_partial_estimate) %>)<% end %>
<% end %>
<% if @appointment.description.present? %>

<%= l(:field_description) %>

<%= textilizable(@appointment, :description) %>
<% end %>
<% if @appointment.estimate %>

<%= l(:label_estimate_issues, estimate: @appointment.estimate.doc_number) %>

<%= render partial: 'issues/list_simple', locals: { issues: @estimate_issues } %> <% end %> <%= call_hook :show_customer_appointment, { appointment: @appointment } %>