%= javascript_include_tag("customer-modal", plugin: :redmine_qbo_calendar) %> <%= labelled_form_for @appointment do |f| %> <%= error_messages_for @appointment %> <%# No-new-work weeks: warned before saving (the day picked on the calendar), then after a save stopped over one. Users with "Override no-new-work weeks" can tick "Schedule anyway". %> <% if @no_work_weeks.present? %>
<% elsif @appointment.no_work_week_conflict? %>
<%= l(:text_no_work_week_cannot_override) %>
<% end %> <% end %><%= f.collection_select :user_id, User.active.sorted, :id, :name, { include_blank: true }, { label: false } %>
<%= f.text_field :subject, style: "width: 95%;", placeholder: l(:text_call_out_subject_placeholder) %>
<%= f.datetime_local_field :date %>
<%= f.number_field :duration, step: 1, size: 6, label: :label_duration %>
<% else %><%= f.text_field :subject, required: true, style: "width: 95%;" %>
<%= f.text_field :customer, label: :label_customer, class: "customer-name", autocomplete: "off", data: { autocomplete_url: "/customers/autocomplete" } %> <%= f.hidden_field :customer_id, id: "customer_id" %> <%# Creates the customer in a dialog without leaving the appointment (customer-modal.js), for users who may add customers %> <% if User.current.allowed_to?(:add_customers, nil, global: true) %> <%= link_to sprite_icon('add', l(:label_new_customer)), '#', id: 'inline-create-customer-btn', class: 'icon icon-add', title: l(:label_new_customer) %> <% end %>
<%= f.label :vehicle_id, l(:label_vehicle) %> <%= f.collection_select :vehicle_id, @appointment.customer&.vehicles || [], :id, :name, { include_blank: true }, { label: false, id: "appointment_vehicle_id" } %>
<%= f.label :estimate_id, l(:label_estimate) %> <%= f.collection_select :estimate_id, @appointment.customer&.estimates || [], :id, :name, { include_blank: true }, { label: false, id: "appointment_estimate_id" } %>
<%= f.label :user_id, l(:field_user) %> <%= f.collection_select :user_id, User.active.sorted, :id, :name, { include_blank: true }, { label: false } %>
<%= f.datetime_local_field :date %>
<%= f.number_field :estimated_hours, step: 1, size: 6 %>
<%# Picking an estimate fills in its labor hours; ticked, the hours may be lowered below them %><%= f.number_field :duration, step: 1, size: 6, label: :label_duration %>
<%# The statuses set up in the plugin settings, plus a removed one this appointment still has %> <% status_options = CustomerAppointment.status_options %> <% status_options += [[@appointment.status_record.name, @appointment.status]] if @appointment.status.present? && !@appointment.status_record.known? %><%= f.select :status, status_options, label: :field_status %>
<% end %><%= f.text_area :description, rows: 8, class: 'wiki-edit', style: 'width: 95%;', id: 'customer_appointment_description' %> <%= wikitoolbar_for 'customer_appointment_description' %>