mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-02-13 09:34:00 -05:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1199af0886 | |||
| 5a2832b751 | |||
| 6fc2db5d73 | |||
| 634fd96e82 | |||
| ce624f178f | |||
| 808b84a346 | |||
| e4d2df889d | |||
| 715c412668 | |||
| e0a23bac20 | |||
| fa72b1c837 |
@@ -21,7 +21,7 @@ Adds vehicles that are owned by customers that can be attached to issues.
|
||||
```bash
|
||||
cd path/to/redmine/plugins
|
||||
git clone git@github.com:rickbarrette/redmine_qbo_vehicles.git
|
||||
cd redmine_qbo
|
||||
cd redmine_qbo_vehicles
|
||||
git checkout <tag>
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ Adds vehicles that are owned by customers that can be attached to issues.
|
||||
|
||||
## Usage
|
||||
|
||||
Simply add vehicles to customers via Customer view
|
||||
Simply add vehicles to customers via Customer Profile
|
||||
|
||||
Once a customer is attached to the customer, they can be attached to an issue.
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class VehiclesController < ApplicationController
|
||||
def index
|
||||
if params[:customer_id]
|
||||
begin
|
||||
@vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(:page => params[:page])
|
||||
@vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(page: params[:page])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
@@ -31,7 +31,7 @@ class VehiclesController < ApplicationController
|
||||
|
||||
# search for a vehicle by vin
|
||||
if params[:search]
|
||||
@vehicles = Vehicle.search(params[:search]).paginate(:page => params[:page])
|
||||
@vehicles = Vehicle.search(params[:search]).paginate(page: params[:page])
|
||||
if only_one_non_zero?(@vehicles)
|
||||
redirect_to @vehicles.first
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<h4><%=t(:field_vehicles)%>:</h4>
|
||||
<%= render :partial => 'vehicles/list', :locals => { :vehicles => customer.vehicles.paginate(:page => params[:page]) } %>
|
||||
<%= render partial: 'vehicles/list', locals: { vehicles: customer.vehicles.paginate(page: params[:page]) } %>
|
||||
<div style="float: right;">
|
||||
<%= button_to t(:button_new_vehice), new_customer_vehicle_path(customer), method: :get %>
|
||||
</div>
|
||||
@@ -6,43 +6,43 @@
|
||||
<div class="clearfix">
|
||||
<%=t(:field_customer)%>:
|
||||
<div class="input">
|
||||
<%= f.autocomplete_field :customer, autocomplete_customer_name_customers_path, :value => @customer.name, :update_elements => {:id => '#customer_id', :value => '#issue_customer'}, :required => true %>
|
||||
<%= f.hidden_field :customer_id, :id => "customer_id", :value => @customer.id %>
|
||||
<%= f.autocomplete_field :customer, autocomplete_customer_name_customers_path, value: @customer.name, update_elements: {id: '#customer_id', value: '#issue_customer'}, required: true %>
|
||||
<%= f.hidden_field :customer_id, id: "customer_id", value: @customer.id %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<%=t(:label_year)%>:
|
||||
<div class="input">
|
||||
<%= f.number_field :year, :autocomplete => "off" %>
|
||||
<%= f.number_field :year, autocomplete: "off" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<%=t(:label_make)%>:
|
||||
<div class="input">
|
||||
<%= f.text_field :make, :autocomplete => "off" %>
|
||||
<%= f.text_field :make, autocomplete: "off" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<%=t(:label_model)%>:
|
||||
<div class="input">
|
||||
<%= f.text_field :model, :autocomplete => "off" %>
|
||||
<%= f.text_field :model, autocomplete: "off" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<%=t(:field_vin)%>:
|
||||
<div class="input">
|
||||
<%= f.text_field :vin , :autofocus => true %>
|
||||
<%= f.text_field :vin , autofocus: true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<%=t(:field_notes)%>:
|
||||
<div class="input">
|
||||
<%= f.text_area :notes, :cols => 60, :rows => 10, :no_label => true %>
|
||||
<%= f.text_area :notes, cols: 60, rows: 10, no_label: true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= form_tag(vehicles_path, :method => "get", id: "search-form") do %>
|
||||
<%= text_field_tag :search, params[:search], placeholder: t(:label_search_vin), :autocomplete => "off" %>
|
||||
<%= form_tag(vehicles_path, method: "get", id: "search-form") do %>
|
||||
<%= text_field_tag :search, params[:search], placeholder: t(:label_search_vin), autocomplete: "off" %>
|
||||
<%= submit_tag t(:label_search) %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<h1><%=t(:label_edit_customer_vehicle)%></h1>
|
||||
<br/>
|
||||
<%= render :partial => 'vehicles/form' %>
|
||||
<%= render partial: 'vehicles/form' %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<h2><%=t(:label_cusomer_vehicles)%> <span style="float:right"> <%= render :partial => 'vehicles/search' %> </span> </h2>
|
||||
<h2><%=t(:label_cusomer_vehicles)%> <span style="float:right"> <%= render partial: 'vehicles/search' %> </span> </h2>
|
||||
<br/>
|
||||
|
||||
<%= render :partial => 'vehicles/list', locals: {vehicles: @vehicles} %>
|
||||
<%= render partial: 'vehicles/list', locals: {vehicles: @vehicles} %>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<h2><%=t(:label_new_vehicle)%></h2>
|
||||
<br/>
|
||||
<%= render :partial => 'vehicles/form' %>
|
||||
<%= render partial: 'vehicles/form' %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<h2><%=t(:field_vehicle)%> #<%=@vehicle.id%></h2>
|
||||
|
||||
<%= render :partial => 'vehicles/details', locals: {vehicle: @vehicle} %>
|
||||
<%= render partial: 'vehicles/details', locals: {vehicle: @vehicle} %>
|
||||
|
||||
<h3><%=@issues.open.count%> <%=t(:label_open_issues)%></h3>
|
||||
|
||||
<%= render :partial => 'issues/list_simple', locals: {issues: @issues.open} %>
|
||||
<%= render partial: 'issues/list_simple', locals: {issues: @issues.open} %>
|
||||
|
||||
<h3><%=@closed_issues.count%> <%=t(:label_closed_issues)%></h3>
|
||||
|
||||
<%= render :partial => 'issues/list_simple', locals: {issues: (@closed_issues)} %>
|
||||
<%= render partial: 'issues/list_simple', locals: {issues: (@closed_issues)} %>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# Nest Vehicles under customers
|
||||
resources :customers do
|
||||
resources :vehicles
|
||||
get :autocomplete_customer_name, :on => :collection
|
||||
get :autocomplete_customer_name, on: :collection
|
||||
end
|
||||
|
||||
#allow for just vehicles too
|
||||
|
||||
8
init.rb
8
init.rb
@@ -14,10 +14,10 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
||||
name 'Redmine QBO Vehicles plugin'
|
||||
author 'Rick Barrette'
|
||||
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
||||
version '2026.1.1'
|
||||
version '2026.1.4'
|
||||
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
||||
author_url 'https://barrettefabrication.com'
|
||||
requires_redmine :version_or_higher => '6.1.0'
|
||||
requires_redmine version_or_higher: '6.1.0'
|
||||
|
||||
# Ensure redmine_qbo is installed
|
||||
begin
|
||||
@@ -30,10 +30,10 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
||||
Issue.safe_attributes 'vehicle_id'
|
||||
|
||||
# Permissions for security
|
||||
permission :view_vehicles, :vehicles => :new, :public => false
|
||||
permission :view_vehicles, vehicles: :new, public: false
|
||||
|
||||
# Register top menu items
|
||||
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
|
||||
menu :top_menu, :vehicles, { controller: :vehicles, action: :index }, caption: 'Vehicles', if: Proc.new { User.current.logged? }
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ module Vehicles
|
||||
|
||||
include IssuesHelper
|
||||
|
||||
# Display vehicle information on the customer show view (right side)
|
||||
def show_customer_view_right(context={})
|
||||
|
||||
# Pass all prebuilt form components to our partial
|
||||
context[:controller].send(:render_to_string, {
|
||||
:partial => 'customers/show_hook', locals: { customer: context[:customer] }
|
||||
partial: 'customers/show_hook', locals: { customer: context[:customer] }
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
@@ -19,7 +19,6 @@ module Vehicles
|
||||
def process_invoice_custom_fields(context={})
|
||||
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields"
|
||||
issue = context[:issue]
|
||||
invoice = context[:invoice]
|
||||
|
||||
# update the invoive custom fields with infomation from the issue if available
|
||||
context[:invoice].custom_fields.each do |cf|
|
||||
|
||||
@@ -15,36 +15,19 @@ module Vehicles
|
||||
|
||||
include IssuesHelper
|
||||
|
||||
# Edit Issue Form
|
||||
# Here we build the required form components before passing them to a partial view formatting.
|
||||
def view_issues_form_details_bottom(context={})
|
||||
f = context[:form]
|
||||
issue = context[:issue]
|
||||
|
||||
# Check to see if the issue already belongs to a customer
|
||||
selected_vehicle = issue.vehicle.id unless issue.vehicle.nil?
|
||||
|
||||
# Load customer's vehicles
|
||||
if issue.customer
|
||||
if issue.customer.vehicles
|
||||
vehicles = issue.customer.vehicles.pluck(:name, :id)
|
||||
else
|
||||
vehicles = [nil].compact
|
||||
end
|
||||
else
|
||||
vehicles = [nil].compact
|
||||
end
|
||||
|
||||
# Generate the drop down list of vehicles
|
||||
vehicle = f.select :vehicle_id, vehicles, :selected => selected_vehicle, include_blank: true
|
||||
|
||||
# Pass all prebuilt form components to our partial
|
||||
# Load the customer's vehicles for selection in the issue form.
|
||||
context[:controller].send(:render_to_string, {
|
||||
:partial => 'issues/form_hook_vehicles',
|
||||
partial: 'issues/form_hook_vehicles',
|
||||
locals: {
|
||||
vehicle: vehicle
|
||||
vehicle: context[:form].select( :vehicle_id,
|
||||
context[:issue].customer ? context[:issue].customer.vehicles.pluck(:name, :id) : [],
|
||||
selected: context[:issue].vehicle ? context[:issue].vehicle.id : nil,
|
||||
include_blank: true )
|
||||
}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,28 +13,15 @@ module Vehicles
|
||||
|
||||
class IssuesShowHookListener < Redmine::Hook::ViewListener
|
||||
|
||||
# View Issue
|
||||
# Display the quickbooks contact in the issue
|
||||
# Display vehicle information on the issue view page.
|
||||
def show_issue_view_right(context={})
|
||||
issue = context[:issue]
|
||||
|
||||
begin
|
||||
v = issue.vehicle
|
||||
vehicle = link_to v.to_s, vehicle_path( v.id )
|
||||
vin = v.vin
|
||||
notes = v.notes
|
||||
rescue
|
||||
#do nothing
|
||||
end
|
||||
|
||||
split_vin = vin.scan(/.{1,9}/) if vin
|
||||
|
||||
context[:controller].send(:render_to_string, {
|
||||
:partial => 'issues/show_issue_view_right',
|
||||
partial: 'issues/show_issue_view_right',
|
||||
locals: {
|
||||
vehicle: vehicle,
|
||||
split_vin: split_vin,
|
||||
notes: notes
|
||||
vehicle: link_to(context[:issue].vehicle),
|
||||
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
|
||||
|
||||
@@ -16,18 +16,12 @@ module Vehicles
|
||||
|
||||
include IssuesHelper
|
||||
|
||||
# Edit Issue Form
|
||||
# Here we build the required form components before passing them to a partial view formatting.
|
||||
# Add vehicle information to the left column of the issue PDF
|
||||
def pdf_left(context={})
|
||||
issue = context[:issue]
|
||||
output = []
|
||||
v = issue.vehicle
|
||||
vehicle = v ? v.to_s : nil
|
||||
vin = v ? v.vin : nil
|
||||
notes = v ? v.notes : nil
|
||||
output << [l(:field_vehicles), vehicle]
|
||||
output << [l(:field_vin), vin ? vin.gsub(/(.{9})/, '\1 ') : nil]
|
||||
output << [l(:field_notes), notes]
|
||||
output << [l(:field_vehicles), context[:issue].vehicle ? context[:issue].vehicle.to_s : nil]
|
||||
output << [l(:field_vin), context[:issue].vehicle ? context[:issue].vehicle.vin.gsub(/(.{9})/, '\1 ') : nil]
|
||||
output << [l(:field_notes), context[:issue].vehicle ? context[:issue].vehicle.notes : nil]
|
||||
return output
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user