mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
More Progress!
This commit is contained in:
@@ -28,26 +28,30 @@ class VehiclesController < ApplicationController
|
|||||||
|
|
||||||
# create a new vehicle
|
# create a new vehicle
|
||||||
def create
|
def create
|
||||||
Vehicle.new(params).save
|
@vehicle = Vehicle.new(params)
|
||||||
|
@vehicle.save!
|
||||||
|
redirect_to @vehicle
|
||||||
end
|
end
|
||||||
|
|
||||||
# display a specific vehicle
|
# display a specific vehicle
|
||||||
def show
|
def show
|
||||||
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
# return an HTML form for editing a vehicle
|
# return an HTML form for editing a vehicle
|
||||||
def edit
|
def edit
|
||||||
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
|
@selected_customer = @vehicle.qbo_customer.name if @vehicle.qbo_customer
|
||||||
end
|
end
|
||||||
|
|
||||||
# update a specific vehicle
|
# update a specific vehicle
|
||||||
def update
|
def update
|
||||||
v = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
if v != nil
|
if @vehicle.update_attributes(params)
|
||||||
#TODO something
|
flash[:success] = "Vehicle updated"
|
||||||
|
redirect_to @vehicle
|
||||||
else
|
else
|
||||||
flash.now[:error] = "No Vehicle Found"
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ class QboCustomer < ActiveRecord::Base
|
|||||||
attr_accessible :name
|
attr_accessible :name
|
||||||
validates_presence_of :id, :name
|
validates_presence_of :id, :name
|
||||||
|
|
||||||
def to_s; name end
|
self.primary_key = "id"
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
def get_base
|
def get_base
|
||||||
Qbo.get_base(:customer)
|
Qbo.get_base(:customer)
|
||||||
|
|||||||
48
app/views/vehicles/_form.html.erb
Normal file
48
app/views/vehicles/_form.html.erb
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="span6 columns">
|
||||||
|
<fieldset>
|
||||||
|
|
||||||
|
<%= form_for @vehicle do |f| %>
|
||||||
|
<div class="clearfix">
|
||||||
|
Customer:
|
||||||
|
<div class="input">
|
||||||
|
<%= f.select :qbo_customer_id, QboCustomer.all.pluck(:name, :id).sort, include_blank: true, :selected => @selected_customer, :required => true%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
Year:
|
||||||
|
<div class="input">
|
||||||
|
<%= f.text_field :year, :required => true %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
Make:
|
||||||
|
<div class="input">
|
||||||
|
<%= f.text_field :make, :required => true %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
Model:
|
||||||
|
<div class="input">
|
||||||
|
<%= f.text_field :model, :required => true %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
Notes:
|
||||||
|
<div class="input">
|
||||||
|
<%= f.text_area :notes, :rows => 6%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<%= f.submit %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
3
app/views/vehicles/edit.html.erb
Normal file
3
app/views/vehicles/edit.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<h1>Edit Customer Vehicle</h1>
|
||||||
|
<br/>
|
||||||
|
<%= render :partial => 'vehicles/form' %>
|
||||||
@@ -1,22 +1,10 @@
|
|||||||
<!--
|
|
||||||
#The MIT License (MIT)
|
|
||||||
#
|
|
||||||
#Copyright (c) 2016 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<h1>Customer Vehicles</h1>
|
<h1>Customer Vehicles</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<% Vehicle.all.each do |vehicle| %>
|
<% Vehicle.all.each do |vehicle| %>
|
||||||
<br/>
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
<%= vehicle.qbo_customer.name if vehicle.qbo_customer %> <%= vehicle.to_s %> <%= button_to "Edit", vehicle, method: :edit %> <%= button_to "Delete", vehicle, method: :delete, data: {confirm: "You sure?"} %>
|
<%= vehicle.qbo_customer.name if vehicle.qbo_customer %> <%= vehicle.to_s %> <%= button_to "Edit", edit_vehicle_path(vehicle), method: :get%> <%= button_to "Delete", vehicle, method: :delete, data: {confirm: "You sure?"} %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
<h1>Customer Vehicles</h1>
|
<h1>New Customer Vehicle</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<%= form_for @vehicle do |f| %>
|
<%= render :partial => 'vehicles/form' %>
|
||||||
Customer: <%= f.select :qbo_customer_id, QboCustomer.all.pluck(:name, :id).sort, include_blank: true, :required => true%><br />
|
|
||||||
Year: <%= f.text_field :year, :required => true %><br />
|
|
||||||
Make: <%= f.text_field :make, :required => true %><br />
|
|
||||||
Model: <%= f.text_area :model, :required => true %><br />
|
|
||||||
Notes: <%= f.text_area :notes, :rows => 3%><br />
|
|
||||||
<%= f.submit %>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
9
app/views/vehicles/show.html.erb
Normal file
9
app/views/vehicles/show.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<h1>Customer Vehicle</h1>
|
||||||
|
<br/>
|
||||||
|
<%= @vehicle.qbo_customer.name if @vehicle.qbo_customer %>
|
||||||
|
<br/>
|
||||||
|
<%= @vehicle.to_s %>
|
||||||
|
<br/>
|
||||||
|
<%= button_to "Edit", edit_vehicle_path(@vehicle), method: :get%>
|
||||||
|
<br/>
|
||||||
|
<%= button_to "Delete", @vehicle, method: :delete, data: {confirm: "You sure?"} %>
|
||||||
3
init.rb
3
init.rb
@@ -42,6 +42,7 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
#Quickbooks.sandbox_mode = true
|
#Quickbooks.sandbox_mode = true
|
||||||
|
|
||||||
# Register QBO top menu item
|
# Register QBO top menu item
|
||||||
menu :top_menu, :qbo, { :controller => 'qbo', :action => 'index' }, :caption => 'Quickbooks', :if => Proc.new { User.current.admin? }
|
menu :top_menu, :qbo, { :controller => :qbo, :action => :index }, :caption => 'Quickbooks', :if => Proc.new { User.current.admin? }
|
||||||
|
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
|
|||||||
# Edit Issue Form
|
# Edit Issue Form
|
||||||
# Show a dropdown for quickbooks contacts
|
# Show a dropdown for quickbooks contacts
|
||||||
def view_issues_form_details_bottom(context={})
|
def view_issues_form_details_bottom(context={})
|
||||||
# Update the customer and item database
|
|
||||||
QboCustomer.update_all
|
|
||||||
#QboItem.update_all
|
|
||||||
QboInvoice.update_all
|
|
||||||
#QboEstimate.update_all
|
|
||||||
|
|
||||||
# Check to see if there is a quickbooks user attached to the issue
|
# Check to see if there is a quickbooks user attached to the issue
|
||||||
selected_customer = context[:issue].qbo_customer ? context[:issue].qbo_customer.id : nil
|
selected_customer = context[:issue].qbo_customer ? context[:issue].qbo_customer.id : nil
|
||||||
|
|||||||
Reference in New Issue
Block a user