Files
redmine_qbo_calendar/app/views/customer_appointments/show.html.erb
T
Claude fc503fca68 Estimate hours rule, linked issues, issue creation via redmine_qbo_billing
- An appointment's hours can't be less than its estimate's labor hours
  (checked when the estimate or hours change, so the quick status buttons
  still work on older appointments). Picking an estimate on the form, or
  arriving from an estimate page, raises the hours to match.
- The appointment page lists the issues linked to its estimate.
- Creating issues from an estimate moved to redmine_qbo_billing (now
  required): Create Issues from Estimate opens its page with this
  appointment's dates, technician, vehicle and project (via
  qbo_billing_issue_defaults). The builder, preview page, settings and rake
  task are removed here; the old settings stay registered so billing can
  read them until its own are saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-30 23:11:33 -04:00

145 lines
6.0 KiB
ERB

<div class="contextual">
<%= link_to issues_calendar_path do %>
<i class="fa-regular fa-calendar-days"></i> <%= l(:button_calendar) %>
<% end %>
<% if @appointment.customer %>
<%= link_to history_customer_appointments_path(customer_id: @appointment.customer_id) do %>
<i class="fa-solid fa-clock-rotate-left"></i> <%= l(:label_appointment_history) %>
<% end %>
<% end %>
<% if 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 %>
<i class="fa-solid fa-plus"></i> <%= l(:label_new_issue) %>
<% end %>
<% end %>
<%# Issues from the estimate are made by redmine_qbo_billing, 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 %>
<i class="fa-solid fa-list-check"></i> <%= 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 %>
<i class="fa-solid fa-pen-to-square"></i> <%= 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 %>
<i class="fa-solid fa-trash"></i> <%= l(:button_delete) %>
<% end %>
<% end %>
</div>
<h2>
<% if @appointment.date %>
<div class="calendar-badge">
<div class="month"><%= @appointment.date.strftime('%b').upcase %></div>
<div class="day"><%= @appointment.date.day %></div>
</div>
<% end %>
<span class="appointment-title"><%= @appointment.subject %></span>
<span class="appointment-dates">
<% 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 %>
</span>
</h2>
<% if User.current.allowed_to?(:edit_customer_appointments, nil, global: true) %>
<%# Quick Status Action Buttons %>
<%
statuses = CustomerAppointment::STATUSES
current_status = @appointment.status.to_s.parameterize.underscore
%>
<div class="appointment-quick-actions">
<span class="quick-action-label"><%= l(:label_change_status, default: 'Change Status:') %></span>
<% statuses.reject { |s| s == current_status }.each do |status_key| %>
<%= link_to status_key.humanize,
customer_appointment_path(@appointment, customer_appointment: { status: status_key }),
method: :patch,
class: "quick-status-btn status-#{status_key.parameterize}" %>
<% end %>
</div>
<% end %>
<div class="issue details">
<div class="attributes">
<div class="splitcontent">
<div class="splitcontentleft">
<div class="attribute">
<div class="label"><%= l(:label_customer, default: 'Customer') %>:</div>
<div class="value"><%= link_to_if @appointment.customer, @appointment.customer&.name, @appointment.customer %></div>
</div>
<div class="attribute">
<div class="label"><%= l(:label_vehicle, default: 'Vehicle') %>:</div>
<div class="value"><%= link_to_if @appointment.vehicle, @appointment.vehicle&.name, @appointment.vehicle %></div>
</div>
<div class="attribute">
<div class="label"><%= l(:label_primary_phone, default: 'Primary phone') %>:</div>
<div class="value"><%= @appointment.customer&.primary_phone %></div>
</div>
<div class="attribute">
<div class="label"><%= l(:label_estimate) %>:</div>
<% if @appointment.estimate %>
<div class="value"><%= link_to @appointment.estimate, @appointment.estimate, target: "_blank" %></div>
<% end %>
</div>
</div>
<div class="splitcontentright">
<div class="attribute">
<div class="label"><%= l(:field_status) %>:</div>
<div class="value">
<span class="status-badge status-<%= @appointment.status.to_s.parameterize %>">
<%= @appointment.status.to_s.humanize %>
</span>
</div>
</div>
<div class="attribute">
<div class="label"><%= l(:label_time, default: 'Time') %>:</div>
<div class="value">
<%= @appointment.date ? @appointment.date.strftime('%I:%M %p') : '-' %>
</div>
</div>
<div class="attribute">
<div class="label"><%= l(:field_user) %>:</div>
<div class="value"><%= link_to_user(@appointment.user) %></div>
</div>
<div class="attribute">
<div class="label"><%= l(:label_duration, default: 'Duration') %>:</div>
<div class="value"><%= @appointment.duration %> <%= l(:label_days) %></div>
</div>
<div class="attribute">
<div class="label"><%= l(:field_estimated_hours) %>:</div>
<div class="value"><%= @appointment.estimated_hours %> <%= l(:label_hours) %></div>
</div>
</div>
</div>
</div>
<% if @appointment.description.present? %>
<hr />
<div class="description">
<p><strong><%= l(:field_description) %></strong></p>
<div class="wiki">
<%= textilizable(@appointment, :description) %>
</div>
</div>
<% end %>
</div>
<% if @appointment.estimate %>
<h3><%= l(:label_estimate_issues, estimate: @appointment.estimate.doc_number) %></h3>
<%= render partial: 'issues/list_simple', locals: { issues: @estimate_issues } %>
<% end %>
<%= call_hook :show_customer_appointment, { appointment: @appointment } %>