Added buttons to in/decrease group order article results.
This commit is contained in:
parent
8fbce954e3
commit
6da9190b03
3 changed files with 26 additions and 1 deletions
|
@ -196,6 +196,28 @@ class Finance::BalancingController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_group_order_article_result
|
||||||
|
goa = GroupOrderArticle.find(params[:id])
|
||||||
|
|
||||||
|
if params[:modifier] == '-'
|
||||||
|
goa.update_attributes({:result => goa.result - 1})
|
||||||
|
elsif params[:modifier] == '+'
|
||||||
|
goa.update_attributes({:result => goa.result + 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
render :update do |page|
|
||||||
|
goa.group_order.update_price! # Update the price attribute of new GroupOrder
|
||||||
|
goa.order_article.update_results! if goa.order_article.article.is_a?(StockArticle) # Update units_to_order of order_article
|
||||||
|
|
||||||
|
page["order_article_#{goa.order_article.id}"].replace_html :partial => 'order_article', :locals => {:order_article => goa.order_article}
|
||||||
|
page["group_order_articles_#{goa.order_article.id}"].replace_html :partial => 'group_order_articles',
|
||||||
|
:locals => {:order_article => goa.order_article}
|
||||||
|
page["summary"].replace_html :partial => 'summary', :locals => {:order => goa.order_article.order}
|
||||||
|
page["order_profit"].visual_effect :highlight, :duration => 2
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def destroy_group_order_article
|
def destroy_group_order_article
|
||||||
goa = GroupOrderArticle.find(params[:id])
|
goa = GroupOrderArticle.find(params[:id])
|
||||||
goa.destroy
|
goa.destroy
|
||||||
|
|
|
@ -24,6 +24,7 @@ class GroupOrderArticle < ActiveRecord::Base
|
||||||
|
|
||||||
validates_presence_of :group_order_id, :order_article_id
|
validates_presence_of :group_order_id, :order_article_id
|
||||||
validates_inclusion_of :quantity, :in => 0..99
|
validates_inclusion_of :quantity, :in => 0..99
|
||||||
|
validates_inclusion_of :result, :in => 0..99, :allow_nil => true
|
||||||
validates_inclusion_of :tolerance, :in => 0..99
|
validates_inclusion_of :tolerance, :in => 0..99
|
||||||
validates_uniqueness_of :order_article_id, :scope => :group_order_id # just once an article per group order
|
validates_uniqueness_of :order_article_id, :scope => :group_order_id # just once an article per group order
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@
|
||||||
%td
|
%td
|
||||||
%td{:style=>"width:50%"}
|
%td{:style=>"width:50%"}
|
||||||
= group_order_article.group_order.ordergroup.name
|
= group_order_article.group_order.ordergroup.name
|
||||||
%td{:id => "group_order_article_#{group_order_article.id}_quantity"}
|
%td{:id => "group_order_article_#{group_order_article.id}_quantity", :style => "white-space:nowrap"}
|
||||||
= group_order_article.result
|
= group_order_article.result
|
||||||
|
= button_to_remote( "+", :url => {:action => "update_group_order_article_result", :id => group_order_article, :modifier => '+'}, :html => {:style => "float:left"}, :success => "Element.hide('loader');", :before => "Element.show('loader');")
|
||||||
|
= button_to_remote( "-", :url => {:action => "update_group_order_article_result", :id => group_order_article, :modifier => '-'}, :success => "Element.hide('loader');", :before => "Element.show('loader');")
|
||||||
%td.currency
|
%td.currency
|
||||||
= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result, :unit => "")
|
= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result, :unit => "")
|
||||||
%td.actions{:style=>"width:1em"}
|
%td.actions{:style=>"width:1em"}
|
||||||
|
|
Loading…
Reference in a new issue