2 Commits

Author SHA1 Message Date
a709fecd0c 2026.2.5 2026-02-21 08:34:33 -05:00
6db87dd551 search for a vehicle by vin, make, model, or year, plus sql sanitization 2026-02-21 08:33:59 -05:00
4 changed files with 7 additions and 6 deletions

View File

@@ -50,9 +50,10 @@ class Vehicle < ActiveRecord::Base
write_attribute(:vin, val) write_attribute(:vin, val)
end end
# search for a vin # search for a vehicle by vin, make, model, or year
def self.search(search) def self.search(query)
where("vin LIKE ?", "%#{search}%") q = sanitize_sql_like(query)
where("vin LIKE ? OR make LIKE ? OR model LIKE ? OR year LIKE ?", "%#{q}%", "%#{q}%", "%#{q}%", "%#{q}%")
end end
# decodes a vin and updates self # decodes a vin and updates self

View File

@@ -1,4 +1,4 @@
<%= form_tag(vehicles_path, method: "get", id: "search-form") do %> <%= form_tag(vehicles_path, method: "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: t(:label_search_vin), autocomplete: "off" %> <%= text_field_tag :search, params[:search], placeholder: t(:label_search), autocomplete: "off" %>
<%= submit_tag t(:label_search) %> <%= submit_tag t(:label_search) %>
<% end %> <% end %>

View File

@@ -28,7 +28,7 @@ en:
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_vin: "Search Vehicles by VIN" label_search: "Search Vehicles"
label_year: "Year" label_year: "Year"
no_customer: "Customer no longer exists" no_customer: "Customer no longer exists"
notice_vehicle_created: "Vehicle was successfully created." notice_vehicle_created: "Vehicle was successfully created."

View File

@@ -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.2.4' version '2026.2.5'
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'