mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 13:50:36 -05:00
- 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
70 lines
2.8 KiB
ERB
70 lines
2.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">
|
|
<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>
|
|
|
|
<p><%= f.select :status, CustomerAppointment::STATUSES, label: :field_status %></p>
|
|
|
|
<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> |