mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-08-19 05:30:42 -04:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05bbcb43db | ||
|
|
9cc2af9cec | ||
|
|
9d101fef38 | ||
|
|
fe81cb6ff8 | ||
|
|
a9d0eafa40 | ||
|
|
7158a8b02c | ||
|
|
bdfad0d020 | ||
|
|
16e3d79ea8 | ||
|
|
6da0972476 | ||
|
|
35542ba1b9 | ||
|
|
cc94401a1f | ||
|
|
6012434de2 |
@@ -33,6 +33,23 @@ class Vehicle < ApplicationRecord
|
|||||||
issues.includes(:invoices).flat_map(&:invoices).uniq.compact
|
issues.includes(:invoices).flat_map(&:invoices).uniq.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_service
|
||||||
|
return issues
|
||||||
|
.joins(:custom_values)
|
||||||
|
.where(custom_values: { custom_field_id: CustomField.find_by(name: "Mileage")&.id })
|
||||||
|
.where.not(custom_values: { value: ['', nil] })
|
||||||
|
.order(created_on: :desc)
|
||||||
|
.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def last_service_date
|
||||||
|
return last_service.created_on&.to_date
|
||||||
|
end
|
||||||
|
|
||||||
|
def last_service_mileage
|
||||||
|
return last_service&.custom_values&.find_by(custom_field_id: CustomField.find_by(name: "Mileage")&.id)&.value.presence
|
||||||
|
end
|
||||||
|
|
||||||
def make=(val)
|
def make=(val)
|
||||||
super(val.to_s.strip)
|
super(val.to_s.strip)
|
||||||
end
|
end
|
||||||
@@ -41,6 +58,11 @@ class Vehicle < ApplicationRecord
|
|||||||
super(val.to_s.strip)
|
super(val.to_s.strip)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
val = self[:name]
|
||||||
|
val.present? ? val : to_s
|
||||||
|
end
|
||||||
|
|
||||||
# Redmine compatibility shim
|
# Redmine compatibility shim
|
||||||
def project
|
def project
|
||||||
nil
|
nil
|
||||||
@@ -63,7 +85,9 @@ class Vehicle < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
return self[:name] if self[:name].present?
|
||||||
return vin if year.blank? || make.blank? || model.blank?
|
return vin if year.blank? || make.blank? || model.blank?
|
||||||
|
|
||||||
suffix = vin.to_s[9..] || vin
|
suffix = vin.to_s[9..] || vin
|
||||||
"#{year} #{make} #{model} - #{suffix}"
|
"#{year} #{make} #{model} - #{suffix}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<% if appointment.customer.present? %>
|
||||||
|
<% unless appointment.vehicle.present? &&%>
|
||||||
|
<p>
|
||||||
|
<%= link_to new_vehicle_path(customer_id: appointment.customer_id), class: 'icon icon-add' do %>
|
||||||
|
<%= l(:label_add_vehicle) %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
@@ -8,10 +8,13 @@
|
|||||||
<div class="value" id="vin">
|
<div class="value" id="vin">
|
||||||
<div id="copyLink" onclick="handleCopy(event)"><%= split_vin[0] if split_vin %><b><%= split_vin[1] if split_vin %></b></div>
|
<div id="copyLink" onclick="handleCopy(event)"><%= split_vin[0] if split_vin %><b><%= split_vin[1] if split_vin %></b></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="vehicle_notes attribute">
|
<div class="vehicle_notes attribute">
|
||||||
<div class="label"><%= t(:field_notes) %>:</div>
|
<div class="label"><%= t(:field_notes) %>:</div>
|
||||||
<pre class="value" id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit; "><%=notes%></pre>
|
<% if vehicle.present? %>
|
||||||
|
<div class="value wiki">
|
||||||
|
<%= textilizable(@issue.vehicle, :notes) %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t(:field_customer) %></th>
|
<th><%= t(:field_customer) %></th>
|
||||||
<td><%= vehicle.customer ? link_to(vehicle.customer.name, customer_path(vehicle.customer)) : t(:no_customer) %></td>
|
<td><%= vehicle.customer ? link_to(vehicle.customer.name, customer_path(vehicle.customer)) : t(:no_customer) %></td>
|
||||||
@@ -23,31 +22,36 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
<th><%= t(:label_trim) %></th>
|
<th><%= t(:label_trim) %></th>
|
||||||
<td><%= vehicle.doors %> <%= t(:label_door) if vehicle.doors? %> <%= vehicle.trim %></td>
|
<td><%= vehicle.doors %> <%= t(:label_door) if vehicle.doors? %> <%= vehicle.trim %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentright">
|
||||||
|
|
||||||
<h4><%= t(:field_notes) %>:</h4>
|
<h4><%= t(:field_notes) %>:</h4>
|
||||||
<pre id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit; ">
|
<div class="vehicle_notes attribute">
|
||||||
<td><%= vehicle.notes %></td>
|
<div class="label"><%= t(:field_notes) %>:</div>
|
||||||
</pre>
|
<% if vehicle.notes.present? %>
|
||||||
</tr>
|
<div class="value wiki">
|
||||||
|
<%= textilizable(vehicle, :notes) %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<% mileage = vehicle.last_service_mileage %>
|
||||||
const preElement = document.getElementById('note-display');
|
|
||||||
// This takes the text, trims the edges, and puts it back
|
|
||||||
preElement.textContent = preElement.textContent.trim();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
<% if mileage %>
|
||||||
</div>
|
<p>
|
||||||
</div>
|
<b><%= t(:label_last_service) %></b> <%= vehicle.last_service_date %>
|
||||||
|
at <%= mileage %> <%= t(:label_miles) %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
<%= button_to t(:label_edit), edit_vehicle_path(vehicle), method: :get %>
|
<%= button_to t(:label_edit), edit_vehicle_path(vehicle), method: :get %>
|
||||||
|
|||||||
@@ -42,7 +42,14 @@
|
|||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<%=t(:field_notes)%>:
|
<%=t(:field_notes)%>:
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= f.text_area :notes, cols: 60, rows: 10, no_label: true %>
|
<p>
|
||||||
|
<%= f.text_area :notes,
|
||||||
|
rows: 8,
|
||||||
|
class: 'wiki-edit',
|
||||||
|
style: 'width: 95%;',
|
||||||
|
id: 'customer_appointment_description' %>
|
||||||
|
<%= wikitoolbar_for 'customer_appointment_description' %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,22 @@
|
|||||||
<% if show_customer %>
|
<% if show_customer %>
|
||||||
<%= vehicle.customer %>
|
<%= vehicle.customer %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
||||||
|
<%
|
||||||
|
mileage = vehicle.last_service_mileage
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if mileage %>
|
||||||
|
<br/>
|
||||||
|
<b><%= t(:label_last_service) %></b> <%= vehicle.last_service_date %>
|
||||||
|
at <%= mileage %> <%= t(:label_miles) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,19 @@ en:
|
|||||||
field_vehicle: "Vehicle"
|
field_vehicle: "Vehicle"
|
||||||
field_vehicles: "Vehicles"
|
field_vehicles: "Vehicles"
|
||||||
field_vin: "VIN"
|
field_vin: "VIN"
|
||||||
|
label_add_vehicle: "Add Vehicle"
|
||||||
label_customer_vehicles: "Customer Vehicles"
|
label_customer_vehicles: "Customer Vehicles"
|
||||||
label_edit: "Edit"
|
label_edit: "Edit"
|
||||||
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
||||||
|
label_last_service: "Last Serviced:"
|
||||||
label_make: "Make"
|
label_make: "Make"
|
||||||
|
label_miles: "miles"
|
||||||
label_model: "Model"
|
label_model: "Model"
|
||||||
label_new_vehicle: "New Customer Vehicle"
|
label_new_vehicle: "New Customer Vehicle"
|
||||||
label_no_vehicles: "There are no vehicles containing the term(s)"
|
label_no_vehicles: "There are no vehicles containing the term(s)"
|
||||||
label_search_vehicles: "Search Vehicles"
|
label_search_vehicles: "Search Vehicles"
|
||||||
|
label_unknown: "Unknown"
|
||||||
|
label_vehicle: "Vehicle"
|
||||||
label_year: "Year"
|
label_year: "Year"
|
||||||
no_customer: "Customer no longer exists"
|
no_customer: "Customer no longer exists"
|
||||||
notice_decoding_vin: "Decoding VIN… this page will update automatically."
|
notice_decoding_vin: "Decoding VIN… this page will update automatically."
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
|||||||
name 'Redmine QBO Vehicles plugin'
|
name 'Redmine QBO Vehicles plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
||||||
version '2026.3.4'
|
version '2026.8.1'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine version_or_higher: '6.1.0'
|
requires_redmine version_or_higher: '6.1.0'
|
||||||
|
|||||||
@@ -18,5 +18,6 @@ module RedmineQboVehicles
|
|||||||
Vehicles::Hooks::IssuesShowHookListener
|
Vehicles::Hooks::IssuesShowHookListener
|
||||||
Vehicles::Hooks::PdfHookListener
|
Vehicles::Hooks::PdfHookListener
|
||||||
Vehicles::Hooks::ViewHookListener
|
Vehicles::Hooks::ViewHookListener
|
||||||
|
Vehicles::Hooks::CustomerAppointmentShowHookListener
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2016 - 2026 rick barrette
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
module Vehicles
|
||||||
|
module Hooks
|
||||||
|
|
||||||
|
class CustomerAppointmentShowHookListener < Redmine::Hook::ViewListener
|
||||||
|
|
||||||
|
include IssuesHelper
|
||||||
|
|
||||||
|
# Display vehicle information on the customer show view (right side)
|
||||||
|
def show_customer_appointment(context={})
|
||||||
|
|
||||||
|
context[:controller].send(:render_to_string, {
|
||||||
|
partial: 'customer_appointments/show_hook', locals: { appointment: context[:appointment] }
|
||||||
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -18,13 +18,17 @@ module Vehicles
|
|||||||
def view_issues_form_details_bottom(context={})
|
def view_issues_form_details_bottom(context={})
|
||||||
|
|
||||||
# Load the customer's vehicles for selection in the issue form.
|
# Load the customer's vehicles for selection in the issue form.
|
||||||
|
vehicles = context[:issue].customer&.vehicles || []
|
||||||
|
|
||||||
context[:controller].send(:render_to_string, {
|
context[:controller].send(:render_to_string, {
|
||||||
partial: 'issues/form_hook_vehicles',
|
partial: 'issues/form_hook_vehicles',
|
||||||
locals: {
|
locals: {
|
||||||
vehicle: context[:form].select( :vehicle_id,
|
vehicle: context[:form].select(
|
||||||
context[:issue].customer ? context[:issue].customer.vehicles.pluck(:name, :id) : [],
|
:vehicle_id,
|
||||||
selected: context[:issue].vehicle ? context[:issue].vehicle.id : nil,
|
vehicles.map { |v| [v.name, v.id] },
|
||||||
include_blank: true )
|
selected: context[:issue].vehicle&.id,
|
||||||
|
include_blank: true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ module Vehicles
|
|||||||
partial: 'issues/show_issue_view_right',
|
partial: 'issues/show_issue_view_right',
|
||||||
locals: {
|
locals: {
|
||||||
vehicle: context[:issue].vehicle ? link_to(context[:issue].vehicle) : nil,
|
vehicle: context[:issue].vehicle ? link_to(context[:issue].vehicle) : nil,
|
||||||
split_vin: context[:issue].vehicle ? context[:issue].vehicle.vin.to_s.scan(/.{1,9}/) : nil,
|
split_vin: context[:issue].vehicle ? context[:issue].vehicle.vin.to_s.scan(/.{1,9}/) : nil
|
||||||
notes: context[:issue].vehicle ? context[:issue].vehicle.notes : nil
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user