mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 13:50:36 -05:00
Statuses (name, colour, counts toward hours, order) are set up on the plugin's settings page instead of being hard-coded. Appointments keep a fixed key, so renaming is safe; removing a status in use asks which status to move its appointments to (done on save by a SettingsController hook). Colours come from the settings everywhere statuses show, which also fixes Cancelled never being coloured (cancelled/canceled mismatch). Call-outs (an employee off work) are their own kind of entry (event_type 'call_out') with an employee, date, days and notes, added from a button on each calendar day. They sit at the top of the day in red stripes and never count toward hours. Migration 004 converts Call_Out appointments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
3.8 KiB
ERB
89 lines
3.8 KiB
ERB
<%= javascript_include_tag("customer-modal", plugin: :redmine_qbo_calendar) %>
|
|
|
|
<%= labelled_form_for @appointment do |f| %>
|
|
<%= error_messages_for @appointment %>
|
|
|
|
<div class="box tabular">
|
|
<%= f.hidden_field :event_type %>
|
|
<% if @appointment.call_out? %>
|
|
<%# An employee off work: no customer, vehicle, estimate, hours or status %>
|
|
<p>
|
|
<label for="customer_appointment_user_id"><%= l(:label_employee) %> <span class="required">*</span></label>
|
|
<%= f.collection_select :user_id, User.active.sorted, :id, :name, { include_blank: true }, { label: false } %>
|
|
</p>
|
|
|
|
<p>
|
|
<%= f.text_field :subject, style: "width: 95%;", placeholder: l(:text_call_out_subject_placeholder) %>
|
|
</p>
|
|
|
|
<p><%= f.datetime_local_field :date %></p>
|
|
<p><%= f.number_field :duration, step: 1, size: 6, label: :label_duration %></p>
|
|
<% else %>
|
|
<p><%= f.text_field :subject, required: true, style: "width: 95%;" %></p>
|
|
|
|
<p>
|
|
<%= 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" %>
|
|
<!-- Add Quick Create Button -->
|
|
<a href="#" id="inline-create-customer-btn" class="icon-only icon-add" title="<%=l(:label_new_customer)%>"></a>
|
|
</p>
|
|
|
|
<p>
|
|
<%= 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" } %>
|
|
</p>
|
|
|
|
<p>
|
|
<%= 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" } %>
|
|
</p>
|
|
|
|
<p>
|
|
<%= f.label :user_id, l(:field_user) %>
|
|
<%= f.collection_select :user_id, User.active.sorted, :id, :name, { include_blank: true }, { label: false } %>
|
|
</p>
|
|
|
|
<p><%= f.datetime_local_field :date %></p>
|
|
|
|
<p><%= f.number_field :estimated_hours, step: 1, size: 6 %></p>
|
|
<p><%= f.number_field :duration, step: 1, size: 6, label: :label_duration %></p>
|
|
|
|
<%# 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? %>
|
|
<p><%= f.select :status, status_options, label: :field_status %></p>
|
|
<% end %>
|
|
|
|
<p>
|
|
<%= f.text_area :description,
|
|
rows: 8,
|
|
class: 'wiki-edit',
|
|
style: 'width: 95%;',
|
|
id: 'customer_appointment_description' %>
|
|
<%= wikitoolbar_for 'customer_appointment_description' %>
|
|
</p>
|
|
</div>
|
|
|
|
<%= submit_tag l(:button_save) %>
|
|
<% end %>
|
|
|
|
<%# When an estimate is picked, the hours are raised to at least its labor hours %>
|
|
<%= javascript_tag do %>
|
|
$(function () {
|
|
var $estimate = $('#appointment_estimate_id');
|
|
var $hours = $('#customer_appointment_estimated_hours');
|
|
if (!$estimate.length || !$hours.length) return;
|
|
$estimate.on('change', function () {
|
|
if (!this.value) return;
|
|
$.getJSON('<%= j estimate_hours_customer_appointments_path %>', { estimate_id: this.value }).done(function (data) {
|
|
var hours = parseInt(data.hours, 10) || 0;
|
|
if (hours > (parseInt($hours.val(), 10) || 0)) $hours.val(hours);
|
|
});
|
|
});
|
|
});
|
|
<% end %>
|
|
|
|
<!-- Modal Container for Inline Customer Creation -->
|
|
<div id="new-customer-dialog" style="display:none;" title="<%= t(:label_new_customer, default: 'New Customer') %>">
|
|
<!-- The form will be dynamically loaded via JS or rendered here -->
|
|
</div> |