Second part of admin-namespace-reorder. Also renamed OrderGroup into Ordergroup. More view-sharing between groups is neccessary.

This commit is contained in:
Benjamin Meichsner 2009-01-14 12:46:01 +01:00
parent 2d5dc03b90
commit fadc951208
83 changed files with 410 additions and 518 deletions

View file

@ -0,0 +1,69 @@
class Admin::OrdergroupsController < ApplicationController
before_filter :authenticate_admin
def index
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
@per_page = params[:per_page].to_i
else
@per_page = 20
end
# if the search field is used
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
@total = Ordergroup.count(:conditions => conditions )
@ordergroups = Ordergroup.paginate(:conditions => conditions, :page => params[:page],
:per_page => @per_page, :order => 'name')
respond_to do |format|
format.html # index.html.erb
format.js { render :partial => "ordergroups" }
end
end
def show
@ordergroup = Ordergroup.find(params[:id])
end
def new
@ordergroup = Ordergroup.new
end
def edit
@ordergroup = Ordergroup.find(params[:id])
end
def create
@ordergroup = Ordergroup.new(params[:Ordergroup])
if @ordergroup.save
flash[:notice] = 'Ordergroup was successfully created.'
redirect_to([:admin, @ordergroup])
else
render :action => "new"
end
end
def update
@ordergroup = Ordergroup.find(params[:id])
if @ordergroup.update_attributes(params[:Ordergroup])
flash[:notice] = 'Ordergroup was successfully updated.'
redirect_to([:admin, @ordergroup])
else
render :action => "edit"
end
end
def destroy
@ordergroup = Ordergroup.find(params[:id])
@ordergroup.destroy
redirect_to(admin_Ordergroups_url)
end
def memberships
@group = Ordergroup.find(params[:id])
end
end

View file

@ -1,5 +1,6 @@
class Admin::UsersController < ApplicationController class Admin::UsersController < ApplicationController
before_filter :authenticate_admin before_filter :authenticate_admin
filter_parameter_logging :password, :password_confirmation # do not log passwort parameters
def index def index
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100) if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)

View file

@ -1,4 +1,5 @@
class Admin::WorkgroupsController < ApplicationController class Admin::WorkgroupsController < ApplicationController
before_filter :authenticate_admin
def index def index
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100) if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
@ -10,6 +11,7 @@ class Admin::WorkgroupsController < ApplicationController
# if the search field is used # if the search field is used
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil? conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
@total = Ordergroup.count(:conditions => conditions )
@workgroups = Workgroup.paginate(:conditions => conditions, :page => params[:page], @workgroups = Workgroup.paginate(:conditions => conditions, :page => params[:page],
:per_page => @per_page, :order => 'name') :per_page => @per_page, :order => 'name')

View file

@ -2,234 +2,11 @@ class AdminController < ApplicationController
before_filter :authenticate_admin before_filter :authenticate_admin
filter_parameter_logging :password, :password_confirmation # do not log passwort parameters filter_parameter_logging :password, :password_confirmation # do not log passwort parameters
verify :method => :post, :only => [ :destroyUser, :createUser, :updateUser, :destroyGroup, :createGroup, :updateGroup], :redirect_to => { :action => :index }
# Messages
MESG_NO_ADMIN_ANYMORE = "Du bist nun kein Admin mehr"
def index def index
@user = self.current_user @user = self.current_user
@groups = Group.find(:all, :limit => 5, :order => 'created_on DESC') @groups = Group.find(:all, :limit => 10, :order => 'created_on DESC')
@users = User.find(:all, :limit => 5, :order => 'created_on DESC') @users = User.find(:all, :limit => 10, :order => 'created_on DESC')
end
# ************************** group actions **************************
def listGroups
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
@per_page = params[:per_page].to_i
else
@per_page = 20
end
# if the search field is used
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
@total = Group.count(:conditions => conditions)
@groups = Group.paginate(:conditions => conditions, :page => params[:page], :per_page => @per_page, :order => 'type DESC, name')
respond_to do |format|
format.html # index.html.erb
format.js do
render :update do |page|
page.replace_html 'table', :partial => "listGroups"
end
end
end
end
def showGroup
@group = Group.find(params[:id])
end
def newGroup
@group = Group.new
render :action => 'newGroup'
end
def newOrderGroup
@group = OrderGroup.new
render :action => 'newGroup'
end
def createGroup
@group = Group.new(params[:group])
if @group.save
flash[:notice] = 'Neue Gruppe wurde angelegt.'
redirect_to :action => 'members', :id => @group.id
else
flash[:error] = 'Gruppe konnte nicht angelegt werden.'
render :action => 'newGroup'
end
end
def createOrderGroup
@group = OrderGroup.new(params[:group])
@group.account_balance = 0
@group.account_updated = Time.now
if @group.save
flash[:notice] = 'Neue Bestellgruppe wurde angelegt.'
redirect_to :action => 'members', :id => @group.id
else
flash[:error] = 'Gruppe konnte nicht angelegt werden.'
render :action => 'newGroup'
end
end
def editGroup
@group = Group.find(params[:id])
render :template => 'groups/edit'
end
def updateGroup
@group = Group.find(params[:id])
if @group.update_attributes(params[:group])
flash[:notice] = 'Group was successfully updated.'
redirect_to :action => 'showGroup', :id => @group
else
render :template => 'groups/edit'
end
end
def destroyGroup
begin
group = Group.find(params[:id])
group.destroy
redirect_to :action => 'listGroups'
rescue => error
flash[:error] = error.to_s
redirect_to :action => "showGroup", :id => group
end
end
# ************************** Membership methods ******************************
# loads the membership-page
def members
@group = Group.find(params[:id])
end
# adds a new member to the group
def addMember
@group = Group.find(params[:id])
user = User.find(params[:user])
Membership.create(:group => @group, :user => user)
redirect_to :action => 'memberships_reload', :id => @group
end
# the membership will find an end....
def dropMember
begin
group = Group.find(params[:group])
Membership.find(params[:membership]).destroy
if User.find(@current_user.id).role_admin?
redirect_to :action => 'memberships_reload', :id => group
else
# If the user drops himself from admin group
flash[:notice] = MESG_NO_ADMIN_ANYMORE
render(:update) {|page| page.redirect_to :controller => "index"}
end
rescue => error
flash[:error] = error.to_s
redirect_to :action => 'memberships_reload', :id => group
end
end
# the two boxes 'members' and 'non members' will be reload through ajax
def memberships_reload
@group = Group.find(params[:id])
render :update do |page|
page.replace_html 'members', :partial => 'groups/members', :object => @group
page.replace_html 'non_members', :partial => 'groups/non_members', :object => @group
end
end
# ****************************** User methdos ******************************
def listUsers
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
@per_page = params[:per_page].to_i
else
@per_page = 20
end
# if the search field is used
conditions = "first_name LIKE '%#{params[:query]}%' OR last_name LIKE '%#{params[:query]}%'" unless params[:query].nil?
@total = User.count(:conditions => conditions)
@users = User.paginate :page => params[:page], :conditions => conditions, :per_page => @per_page, :order => 'nick'
respond_to do |format|
format.html # listUsers.haml
format.js do
render :update do |page|
page.replace_html 'table', :partial => "listUsers"
end
end
end
end
def showUser
@user = User.find(params[:id])
end
def newUser
@user = User.new
if request.xml_http_request?
render :update do |page|
page.replace_html 'userForm', :partial => "newUser"
page['newUser'].show
end
end
end
def createUser
@user = User.new(params[:user])
@user.set_password({:required => true}, params[:user][:password], params[:user][:password_confirmation])
if @user.errors.empty? && @user.save
for setting in User::setting_keys.keys
@user.settings[setting] = (params[:user][:settings] && params[:user][:settings][setting] == '1' ? '1' : nil)
end
flash[:notice] = MSG_USER_CREATED
redirect_to :action => 'listUsers'
else
render :action => 'newUser'
end
end
def editUser
@user = User.find(params[:id])
if request.xml_http_request?
render :update do |page|
page.replace_html 'userForm', :partial => "newUser"
page['newUser'].show
end
end
end
def updateUser
@user = User.find(params[:id])
@user.set_password({:required => false}, params[:user][:password], params[:user][:password_confirmation])
@user.attributes = params[:user]
for setting in User::setting_keys.keys
@user.settings[setting] = (params[:user][:settings] && params[:user][:settings][setting] == '1' ? '1' : nil)
end
if @user.errors.empty? && @user.save
flash[:notice] = MSG_USER_UPDATED
redirect_to :action => 'showUser', :id => @user
else
render :action => 'editUser'
end
end
def destroyUser
user = User.find(params[:id])
if user.nick == @current_user.nick
# deny destroying logged-in-user
flash[:error] = ERR_NO_SELF_DELETE
else
user.destroy
flash[:notice] = MSG_USER_DELETED
end
redirect_to :action => 'listUsers'
end end
end end

View file

@ -98,11 +98,11 @@ class Finance::BalancingController < ApplicationController
end end
# Creates a new GroupOrderArticleResult # Creates a new GroupOrderArticleResult
# If the the chosen OrderGroup hasn't ordered yet, a GroupOrderResult will created # If the the chosen Ordergroup hasn't ordered yet, a GroupOrderResult will created
def createGroupResult def createGroupResult
@result = GroupOrderArticleResult.new(params[:group_order_article_result]) @result = GroupOrderArticleResult.new(params[:group_order_article_result])
order = @result.order_article_result.order order = @result.order_article_result.order
orderGroup = OrderGroup.find(params[:group_order_article_result][:group_order_result_id]) orderGroup = Ordergroup.find(params[:group_order_article_result][:group_order_result_id])
# creates a new GroupOrderResult if necessary # creates a new GroupOrderResult if necessary
unless @result.group_order_result = GroupOrderResult.find(:first, unless @result.group_order_result = GroupOrderResult.find(:first,
:conditions => ["group_order_results.group_name = ? AND group_order_results.order_id = ?", orderGroup.name, order.id ]) :conditions => ["group_order_results.group_name = ? AND group_order_results.order_id = ?", orderGroup.name, order.id ])
@ -208,12 +208,12 @@ class Finance::BalancingController < ApplicationController
end end
end end
# before the order will booked, a view lists all OrderGroups and its order_prices # before the order will booked, a view lists all Ordergroups and its order_prices
def confirm def confirm
@order = Order.find(params[:id]) @order = Order.find(params[:id])
end end
# Balances the Order, Update of the OrderGroup.account_balances # Balances the Order, Update of the Ordergroup.account_balances
def close def close
@order = Order.find(params[:id]) @order = Order.find(params[:id])
begin begin

View file

@ -22,8 +22,8 @@ class Finance::TransactionsController < ApplicationController
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil? conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
@total = OrderGroup.count(:conditions => conditions) @total = Ordergroup.count(:conditions => conditions)
@groups = OrderGroup.paginate :conditions => conditions, :page => params[:page], :per_page => @per_page, :order => sort @groups = Ordergroup.paginate :conditions => conditions, :page => params[:page], :per_page => @per_page, :order => sort
respond_to do |format| respond_to do |format|
format.html format.html
@ -36,7 +36,7 @@ class Finance::TransactionsController < ApplicationController
end end
def list def list
@group = OrderGroup.find(params[:id]) @group = Ordergroup.find(params[:id])
if params['sort'] if params['sort']
sort = case params['sort'] sort = case params['sort']
@ -69,12 +69,12 @@ class Finance::TransactionsController < ApplicationController
end end
def new def new
@group = OrderGroup.find(params[:id]) @group = Ordergroup.find(params[:id])
@financial_transaction = @group.financial_transactions.build @financial_transaction = @group.financial_transactions.build
end end
def create def create
@group = OrderGroup.find(params[:financial_transaction][:order_group_id]) @group = Ordergroup.find(params[:financial_transaction][:ordergroup_id])
amount = params[:financial_transaction][:amount] amount = params[:financial_transaction][:amount]
note = params[:financial_transaction][:note] note = params[:financial_transaction][:note]
begin begin
@ -97,7 +97,7 @@ class Finance::TransactionsController < ApplicationController
params[:financial_transactions].each do |trans| params[:financial_transactions].each do |trans|
# ignore empty amount fields ... # ignore empty amount fields ...
unless trans[:amount].blank? unless trans[:amount].blank?
OrderGroup.find(trans[:order_group_id]).addFinancialTransaction trans[:amount], note, @current_user Ordergroup.find(trans[:ordergroup_id]).addFinancialTransaction trans[:amount], note, @current_user
end end
end end
flash[:notice] = 'Saved all transactions successfully' flash[:notice] = 'Saved all transactions successfully'

View file

@ -112,11 +112,11 @@ class IndexController < ApplicationController
end end
# update the Group # update the Group
# only access to description for OrderGroups # only access to description for Ordergroups
def updateGroup def updateGroup
@group = Group.find(params[:id]) @group = Group.find(params[:id])
authenticate_membership(@group) authenticate_membership(@group)
if @group.is_a?(OrderGroup) if @group.is_a?(Ordergroup)
@group.update_attribute(:description, params[:group][:description]) @group.update_attribute(:description, params[:group][:description])
else else
@group.update_attributes(params[:group]) @group.update_attributes(params[:group])
@ -149,8 +149,8 @@ class IndexController < ApplicationController
group = Group.find(params[:group]) group = Group.find(params[:group])
authenticate_membership(group) authenticate_membership(group)
membership = Membership.find(params[:membership]) membership = Membership.find(params[:membership])
if group.is_a?(OrderGroup) && group.memberships.size == 1 if group.is_a?(Ordergroup) && group.memberships.size == 1
# Deny dropping member if the group is an OrderGroup and there is only one member left. # Deny dropping member if the group is an Ordergroup and there is only one member left.
flash[:error] = ERR_LAST_MEMBER flash[:error] = ERR_LAST_MEMBER
else else
membership.destroy membership.destroy
@ -196,7 +196,7 @@ class IndexController < ApplicationController
# sort by ordergroups # sort by ordergroups
if params[:sort_by_ordergroups] if params[:sort_by_ordergroups]
@users = [] @users = []
OrderGroup.find(:all, :order => "name").each do |group| Ordergroup.find(:all, :order => "name").each do |group|
group.users.each do |user| group.users.each do |user|
@users << user @users << user
end end
@ -229,7 +229,7 @@ class IndexController < ApplicationController
# gives an overview for the workgroups and its members # gives an overview for the workgroups and its members
def workgroups def workgroups
@groups = Group.find :all, :conditions => "type != 'OrderGroup'", :order => "name" @groups = Group.find :all, :conditions => "type != 'Ordergroup'", :order => "name"
end end
# Invites a new user to join foodsoft in this group. # Invites a new user to join foodsoft in this group.

View file

@ -1,8 +1,8 @@
# Controller for all ordering-actions that are performed by a user who is member of an OrderGroup. # Controller for all ordering-actions that are performed by a user who is member of an Ordergroup.
# Management actions that require the "orders" role are handled by the OrdersController. # Management actions that require the "orders" role are handled by the OrdersController.
class OrderingController < ApplicationController class OrderingController < ApplicationController
# Security # Security
before_filter :ensureOrderGroupMember before_filter :ensureOrdergroupMember
verify :method => :post, :only => [:saveOrder], :redirect_to => { :action => :index } verify :method => :post, :only => [:saveOrder], :redirect_to => { :action => :index }
# Messages # Messages
@ -33,7 +33,7 @@ class OrderingController < ApplicationController
if !@order.current? if !@order.current?
flash[:notice] = ERROR_ALREADY_FINISHED flash[:notice] = ERROR_ALREADY_FINISHED
redirect_to :action => 'index' redirect_to :action => 'index'
elsif !(@order_group = @current_user.find_ordergroup) elsif !(@ordergroup = @current_user.find_ordergroup)
flash[:notice] = ERROR_NO_ORDERGROUP flash[:notice] = ERROR_NO_ORDERGROUP
redirect_to :controller => 'index' redirect_to :controller => 'index'
else else
@ -43,7 +43,7 @@ class OrderingController < ApplicationController
@articles_by_category = @order.get_articles @articles_by_category = @order.get_articles
# save results of earlier orders in array # save results of earlier orders in array
ordered_articles = Array.new ordered_articles = Array.new
@group_order = @order.group_orders.find(:first, :conditions => "order_group_id = #{@order_group.id}", :include => :group_order_articles) @group_order = @order.group_orders.find(:first, :conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
if @group_order if @group_order
# Group has already ordered, so get the results... # Group has already ordered, so get the results...
for article in @group_order.group_order_articles for article in @group_order.group_order_articles
@ -54,10 +54,10 @@ class OrderingController < ApplicationController
'tolerance_result' => result[:tolerance]} 'tolerance_result' => result[:tolerance]}
end end
@version = @group_order.lock_version @version = @group_order.lock_version
@availableFunds = @order_group.getAvailableFunds(@group_order) @availableFunds = @ordergroup.getAvailableFunds(@group_order)
else else
@version = 0 @version = 0
@availableFunds = @order_group.getAvailableFunds @availableFunds = @ordergroup.getAvailableFunds
end end
# load prices .... # load prices ....
@ -90,7 +90,7 @@ class OrderingController < ApplicationController
if (!order.current?) if (!order.current?)
flash[:error] = ERROR_ALREADY_FINISHED flash[:error] = ERROR_ALREADY_FINISHED
redirect_to :action => 'index' redirect_to :action => 'index'
elsif !(order_group = @current_user.find_ordergroup) elsif !(ordergroup = @current_user.find_ordergroup)
flash[:error] = ERROR_NO_ORDERGROUP flash[:error] = ERROR_NO_ORDERGROUP
redirect_to :controller => 'index' redirect_to :controller => 'index'
elsif (params[:total_balance].to_i < 0) elsif (params[:total_balance].to_i < 0)
@ -100,12 +100,12 @@ class OrderingController < ApplicationController
begin begin
Order.transaction do Order.transaction do
# Create group order if necessary... # Create group order if necessary...
if (groupOrder = order.group_orders.find(:first, :conditions => "order_group_id = #{order_group.id}", :include => [:group_order_articles])) if (groupOrder = order.group_orders.find(:first, :conditions => "ordergroup_id = #{ordergroup.id}", :include => [:group_order_articles]))
if (params[:version].to_i != groupOrder.lock_version) # check for conflicts well ahead if (params[:version].to_i != groupOrder.lock_version) # check for conflicts well ahead
raise ActiveRecord::StaleObjectError raise ActiveRecord::StaleObjectError
end end
else else
groupOrder = GroupOrder.new(:order_group => order_group, :order => order, :updated_by => @current_user, :price => 0) groupOrder = GroupOrder.new(:ordergroup => ordergroup, :order => order, :updated_by => @current_user, :price => 0)
groupOrder.save! groupOrder.save!
end end
# Create/update GroupOrderArticles... # Create/update GroupOrderArticles...
@ -142,7 +142,7 @@ class OrderingController < ApplicationController
end end
end end
# Shows the Result for the OrderGroup the current user belongs to # Shows the Result for the Ordergroup the current user belongs to
# this method decides between finished and unfinished orders # this method decides between finished and unfinished orders
def my_order_result def my_order_result
@order= Order.find(params[:id]) @order= Order.find(params[:id])
@ -153,7 +153,7 @@ class OrderingController < ApplicationController
@order_value= @groupOrderResult.price if @groupOrderResult @order_value= @groupOrderResult.price if @groupOrderResult
@comments= @order.comments @comments= @order.comments
else else
@group_order = @order.group_orders.find_by_order_group_id(@current_user.find_ordergroup.id) @group_order = @order.group_orders.find_by_ordergroup_id(@current_user.find_ordergroup.id)
@order_value= @group_order.price if @group_order @order_value= @group_order.price if @group_order
end end
end end
@ -211,9 +211,9 @@ class OrderingController < ApplicationController
private private
# Returns true if @current_user is member of an OrderGroup. # Returns true if @current_user is member of an Ordergroup.
# Used as a :before_filter by OrderingController. # Used as a :before_filter by OrderingController.
def ensureOrderGroupMember def ensureOrdergroupMember
!@current_user.find_ordergroup.nil? !@current_user.find_ordergroup.nil?
end end

View file

@ -3,7 +3,7 @@ class TasksController < ApplicationController
def index def index
@non_group_tasks = Task.find :all, :conditions => "group_id IS NULL AND done = 0", :order => "due_date ASC" @non_group_tasks = Task.find :all, :conditions => "group_id IS NULL AND done = 0", :order => "due_date ASC"
@groups = Group.find :all, :conditions => "type != 'OrderGroup'" @groups = Group.find :all, :conditions => "type != 'Ordergroup'"
end end
def myTasks def myTasks
@ -109,7 +109,7 @@ class TasksController < ApplicationController
# shows workgroup (normal group) to edit weekly_tasks_template # shows workgroup (normal group) to edit weekly_tasks_template
def workgroup def workgroup
@group = Group.find(params[:id]) @group = Group.find(params[:id])
if @group.is_a? OrderGroup if @group.is_a? Ordergroup
flash[:error] = "Keine Arbeitsgruppe gefunden" flash[:error] = "Keine Arbeitsgruppe gefunden"
redirect_to :action => "index" redirect_to :action => "index"
end end

View file

@ -1,2 +0,0 @@
module Admin::MembershipsHelper
end

View file

@ -1,2 +0,0 @@
module Admin::UsersHelper
end

View file

@ -1,2 +0,0 @@
module AdminHelper
end

View file

@ -15,17 +15,27 @@ module ApplicationHelper
# Creates ajax-controlled-links for pagination # Creates ajax-controlled-links for pagination
# see also the plugin "will_paginate" # see also the plugin "will_paginate"
def pagination_links_remote(collection, per_page = @per_page, params = {}) def pagination_links_remote(collection, options = {})
per_page = options[:per_page] || @per_page
params = options[:params] || {}
update = options[:update] || nil
# Translations # Translations
previous_label = '&laquo; ' + _('Previous') previous_label = '&laquo; ' + _('Previous')
next_label = _('Next') + ' &raquo;' next_label = _('Next') + ' &raquo;'
# Merge other url-options for will_paginate # Merge other url-options for will_paginate
params = params.merge({:per_page => per_page}) params = params.merge({:per_page => per_page})
will_paginate collection, {:params => params, :remote => true, :previous_label => previous_label, :next_label => next_label} will_paginate collection, { :params => params, :remote => true, :update => update,
:previous_label => previous_label, :next_label => next_label, }
end end
# Link-collection for per_page-options when using the pagination-plugin # Link-collection for per_page-options when using the pagination-plugin
def items_per_page(per_page_options = [20, 50, 100], current = @per_page, action = controller.action_name) def items_per_page(options = {})
per_page_options = options[:per_page_options] || [20, 50, 100]
current = options[:current] || @per_page
action = options[:action] || controller.action_name
update = options[:update] || nil
links = [] links = []
per_page_options.each do |per_page| per_page_options.each do |per_page|
unless per_page == current unless per_page == current
@ -34,7 +44,7 @@ module ApplicationHelper
{ :url => { :action => action, :params => {:per_page => per_page}}, { :url => { :action => action, :params => {:per_page => per_page}},
:before => "Element.show('loader')", :before => "Element.show('loader')",
:success => "Element.hide('loader')", :success => "Element.hide('loader')",
:method => :get } ) :method => :get, :update => update } )
else else
links << per_page links << per_page
end end

View file

@ -1,2 +0,0 @@
module Finance::OrdersHelper
end

View file

@ -1,2 +0,0 @@
module Finance::TransactionsHelper
end

View file

@ -1,2 +0,0 @@
module FinanceHelper
end

View file

@ -1,2 +0,0 @@
module GroupsHelper
end

View file

@ -1,2 +0,0 @@
module IndexHelper
end

View file

@ -1,2 +0,0 @@
module LoginHelper
end

View file

@ -1,2 +0,0 @@
module MessagesHelper
end

View file

@ -1,2 +0,0 @@
module OrderingHelper
end

View file

@ -1,2 +0,0 @@
module SuppliersHelper
end

View file

@ -1,2 +0,0 @@
module UsersHelper
end

View file

@ -1,23 +1,23 @@
# == Schema Information # == Schema Information
# Schema version: 20090102171850 # Schema version: 20090114101610
# #
# Table name: financial_transactions # Table name: financial_transactions
# #
# id :integer(4) not null, primary key # id :integer(4) not null, primary key
# order_group_id :integer(4) default(0), not null # ordergroup_id :integer(4) default(0), not null
# amount :decimal(8, 2) default(0.0), not null # amount :decimal(8, 2) default(0.0), not null
# note :text default(""), not null # note :text default(""), not null
# user_id :integer(4) default(0), not null # user_id :integer(4) default(0), not null
# created_on :datetime not null # created_on :datetime not null
# #
# financial transactions are the foodcoop internal financial transactions # financial transactions are the foodcoop internal financial transactions
# only order_groups have an account balance and are happy to transfer money # only ordergroups have an account balance and are happy to transfer money
class FinancialTransaction < ActiveRecord::Base class FinancialTransaction < ActiveRecord::Base
belongs_to :order_group belongs_to :ordergroup
belongs_to :user belongs_to :user
validates_presence_of :note, :user_id, :order_group_id validates_presence_of :note, :user_id, :ordergroup_id
validates_numericality_of :amount validates_numericality_of :amount
# Custom attribute setter that accepts decimal numbers using localized decimal separator. # Custom attribute setter that accepts decimal numbers using localized decimal separator.

View file

@ -41,11 +41,11 @@ class Group < ActiveRecord::Base
memberships.find_by_user_id(user.id) memberships.find_by_user_id(user.id)
end end
# Returns all NONmembers and a checks for possible multiple OrderGroup-Memberships # Returns all NONmembers and a checks for possible multiple Ordergroup-Memberships
def non_members def non_members
nonMembers = Array.new nonMembers = Array.new
for user in User.find(:all, :order => "nick") for user in User.find(:all, :order => "nick")
unless self.users.include?(user) || ( self.is_a?(OrderGroup) && user.find_ordergroup ) unless self.users.include?(user) || ( self.is_a?(Ordergroup) && user.find_ordergroup )
nonMembers << user nonMembers << user
end end
end end
@ -57,16 +57,16 @@ class Group < ActiveRecord::Base
raise ERR_LAST_ADMIN_GROUP_DELETE if self.role_admin == true && Group.find_all_by_role_admin(true).size == 1 raise ERR_LAST_ADMIN_GROUP_DELETE if self.role_admin == true && Group.find_all_by_role_admin(true).size == 1
end end
# get all groups, which are NOT OrderGroups # get all groups, which are NOT Ordergroups
def self.workgroups def self.workgroups
Workgroup.all Workgroup.all
end end
protected protected
# validates uniqueness of the Group.name. Checks groups and order_groups # validates uniqueness of the Group.name. Checks groups and ordergroups
def validate def validate
errors.add(:name, "ist schon vergeben") if (group = Group.find_by_name(name) || group = OrderGroup.find_by_name(name)) && self != group errors.add(:name, "ist schon vergeben") if (group = Group.find_by_name(name) || group = Ordergroup.find_by_name(name)) && self != group
end end
# add validation check on update # add validation check on update

View file

@ -1,10 +1,10 @@
# == Schema Information # == Schema Information
# Schema version: 20090102171850 # Schema version: 20090114101610
# #
# Table name: group_orders # Table name: group_orders
# #
# id :integer(4) not null, primary key # id :integer(4) not null, primary key
# order_group_id :integer(4) default(0), not null # ordergroup_id :integer(4) default(0), not null
# order_id :integer(4) default(0), not null # order_id :integer(4) default(0), not null
# price :decimal(8, 2) default(0.0), not null # price :decimal(8, 2) default(0.0), not null
# lock_version :integer(4) default(0), not null # lock_version :integer(4) default(0), not null
@ -12,21 +12,21 @@
# updated_by_user_id :integer(4) default(0), not null # updated_by_user_id :integer(4) default(0), not null
# #
# A GroupOrder represents an Order placed by an OrderGroup. # A GroupOrder represents an Order placed by an Ordergroup.
class GroupOrder < ActiveRecord::Base class GroupOrder < ActiveRecord::Base
belongs_to :order belongs_to :order
belongs_to :order_group belongs_to :ordergroup
has_many :group_order_articles, :dependent => :destroy has_many :group_order_articles, :dependent => :destroy
has_many :order_articles, :through => :group_order_articles has_many :order_articles, :through => :group_order_articles
has_many :group_order_article_results has_many :group_order_article_results
belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id" belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id"
validates_presence_of :order_id validates_presence_of :order_id
validates_presence_of :order_group_id validates_presence_of :ordergroup_id
validates_presence_of :updated_by validates_presence_of :updated_by
validates_numericality_of :price validates_numericality_of :price
validates_uniqueness_of :order_group_id, :scope => :order_id # order groups can only order once per order validates_uniqueness_of :ordergroup_id, :scope => :order_id # order groups can only order once per order
# Updates the "price" attribute. # Updates the "price" attribute.
# This will be the maximum value of a current order # This will be the maximum value of a current order

View file

@ -12,7 +12,7 @@
# #
# A GroupOrderArticle stores the sum of how many items of an OrderArticle are ordered as part of a GroupOrder. # A GroupOrderArticle stores the sum of how many items of an OrderArticle are ordered as part of a GroupOrder.
# The chronologically order of the OrderGroup - activity are stored in GroupOrderArticleQuantity # The chronologically order of the Ordergroup - activity are stored in GroupOrderArticleQuantity
# #
class GroupOrderArticle < ActiveRecord::Base class GroupOrderArticle < ActiveRecord::Base
@ -94,7 +94,7 @@ class GroupOrderArticle < ActiveRecord::Base
end end
end end
# Determines how many items of this article the OrderGroup receives. # Determines how many items of this article the Ordergroup receives.
# Returns a hash with three keys: :quantity / :tolerance / :total # Returns a hash with three keys: :quantity / :tolerance / :total
# #
# See description of the ordering algorithm in the general application documentation for details. # See description of the ordering algorithm in the general application documentation for details.

View file

@ -9,13 +9,13 @@
# price :decimal(8, 2) default(0.0), not null # price :decimal(8, 2) default(0.0), not null
# #
# OrderGroups, which participate on a specific order will have a line # Ordergroups, which participate on a specific order will have a line
class GroupOrderResult < ActiveRecord::Base class GroupOrderResult < ActiveRecord::Base
belongs_to :order belongs_to :order
has_many :group_order_article_results, :dependent => :destroy has_many :group_order_article_results, :dependent => :destroy
# Calculates the Order-Price for the OrderGroup and updates the price-attribute # Calculates the Order-Price for the Ordergroup and updates the price-attribute
def updatePrice def updatePrice
total = 0 total = 0
group_order_article_results.each do |result| group_order_article_results.each do |result|

View file

@ -95,7 +95,7 @@ class Message < ActiveRecord::Base
# Example: # Example:
# Message.from_template( # Message.from_template(
# 'order_finished', # 'order_finished',
# {:user => user, :group => order_group, :order => self, :results => results, :total => group_order.price}, # {:user => user, :group => ordergroup, :order => self, :results => results, :total => group_order.price},
# {:recipient_id => user.id, :recipients => recipients, :subject => "Bestellung beendet: #{self.name}"} # {:recipient_id => user.id, :recipients => recipients, :subject => "Bestellung beendet: #{self.name}"}
# ).save! # ).save!
def self.from_template(template, vars, attributes) def self.from_template(template, vars, attributes)

View file

@ -24,7 +24,7 @@ class Order < ActiveRecord::Base
has_many :order_articles, :dependent => :destroy has_many :order_articles, :dependent => :destroy
has_many :articles, :through => :order_articles has_many :articles, :through => :order_articles
has_many :group_orders, :dependent => :destroy has_many :group_orders, :dependent => :destroy
has_many :order_groups, :through => :group_orders has_many :ordergroups, :through => :group_orders
has_many :order_article_results, :dependent => :destroy has_many :order_article_results, :dependent => :destroy
has_many :group_order_results, :dependent => :destroy has_many :group_order_results, :dependent => :destroy
belongs_to :supplier belongs_to :supplier
@ -96,10 +96,10 @@ class Order < ActiveRecord::Base
find :all, :conditions => ['booked = ?', true], :order => 'ends desc', :include => :supplier find :all, :conditions => ['booked = ?', true], :order => 'ends desc', :include => :supplier
end end
# search GroupOrder of given OrderGroup # search GroupOrder of given Ordergroup
def group_order(ordergroup) def group_order(ordergroup)
unless finished unless finished
return group_orders.detect {|o| o.order_group_id == ordergroup.id} return group_orders.detect {|o| o.ordergroup_id == ordergroup.id}
else else
return group_order_results.detect {|o| o.group_name == ordergroup.name} return group_order_results.detect {|o| o.group_name == ordergroup.name}
end end
@ -180,7 +180,7 @@ class Order < ActiveRecord::Base
#saves ordergroups, which take part in this order #saves ordergroups, which take part in this order
self.group_orders.each do |go| self.group_orders.each do |go|
group_order_result = GroupOrderResult.create!(:order => self, group_order_result = GroupOrderResult.create!(:order => self,
:group_name => go.order_group.name, :group_name => go.ordergroup.name,
:price => go.price) :price => go.price)
end end
# saves every article of the order # saves every article of the order
@ -203,7 +203,7 @@ class Order < ActiveRecord::Base
oa.group_order_articles.each do |goa| oa.group_order_articles.each do |goa|
result = goa.orderResult result = goa.orderResult
# find appropriate GroupOrderResult # find appropriate GroupOrderResult
group_order_result = GroupOrderResult.find(:first, :conditions => ['order_id = ? AND group_name = ?', self.id, goa.group_order.order_group.name]) group_order_result = GroupOrderResult.find(:first, :conditions => ['order_id = ? AND group_name = ?', self.id, goa.group_order.ordergroup.name])
group_order_article_result = GroupOrderArticleResult.new(:order_article_result => article_result, group_order_article_result = GroupOrderArticleResult.new(:order_article_result => article_result,
:group_order_result => group_order_result, :group_order_result => group_order_result,
:quantity => result[:total], :quantity => result[:total],
@ -274,15 +274,15 @@ class Order < ActiveRecord::Base
end end
end end
# Sets "booked"-attribute to true and updates all OrderGroup_account_balances # Sets "booked"-attribute to true and updates all Ordergroup_account_balances
def balance(user) def balance(user)
raise "Bestellung wurde schon abgerechnet" if self.booked raise "Bestellung wurde schon abgerechnet" if self.booked
transaction_note = "Bestellung: #{name}, von #{starts.strftime('%d.%m.%Y')} bis #{ends.strftime('%d.%m.%Y')}" transaction_note = "Bestellung: #{name}, von #{starts.strftime('%d.%m.%Y')} bis #{ends.strftime('%d.%m.%Y')}"
transaction do transaction do
# update OrderGroups # update Ordergroups
group_order_results.each do |result| group_order_results.each do |result|
price = result.price * -1 # decrease! account balance price = result.price * -1 # decrease! account balance
OrderGroup.find_by_name(result.group_name).addFinancialTransaction(price, transaction_note, user) Ordergroup.find_by_name(result.group_name).addFinancialTransaction(price, transaction_note, user)
end end
self.booked = true self.booked = true
self.updated_by = user self.updated_by = user
@ -319,9 +319,9 @@ class Order < ActiveRecord::Base
def notifyOrderFinished def notifyOrderFinished
# Loop through GroupOrderResults for this order: # Loop through GroupOrderResults for this order:
for group_order in self.group_order_results for group_order in self.group_order_results
order_group = OrderGroup.find_by_name(group_order.group_name) ordergroup = Ordergroup.find_by_name(group_order.group_name)
# Determine group users that want a notification message: # Determine group users that want a notification message:
users = order_group.users.reject{|u| u.settings["notify.orderFinished"] != '1'} users = ordergroup.users.reject{|u| u.settings["notify.orderFinished"] != '1'}
unless (users.empty?) unless (users.empty?)
# Assemble the order message text: # Assemble the order message text:
results = group_order.group_order_article_results.find(:all, :include => [:order_article_result]) results = group_order.group_order_article_results.find(:all, :include => [:order_article_result])
@ -330,7 +330,7 @@ class Order < ActiveRecord::Base
for user in users for user in users
Message.from_template( Message.from_template(
'order_finished', 'order_finished',
{:user => user, :group => order_group, :order => self, :results => results, :total => group_order.price}, {:user => user, :group => ordergroup, :order => self, :results => results, :total => group_order.price},
{:recipient_id => user.id, :recipients => recipients, :subject => "Bestellung beendet: #{self.name}"} {:recipient_id => user.id, :recipients => recipients, :subject => "Bestellung beendet: #{self.name}"}
).save! ).save!
end end

View file

@ -23,13 +23,13 @@
# task_required_users :integer(4) default(1) # task_required_users :integer(4) default(1)
# #
# OrderGroups can order, they are "children" of the class Group # Ordergroups can order, they are "children" of the class Group
# #
# OrderGroup have the following attributes, in addition to Group # Ordergroup have the following attributes, in addition to Group
# * account_balance (decimal) # * account_balance (decimal)
# * account_updated (datetime) # * account_updated (datetime)
# * actual_size (int) : how many persons are ordering through the OrderGroup # * actual_size (int) : how many persons are ordering through the Ordergroup
class OrderGroup < Group class Ordergroup < Group
has_many :financial_transactions, :dependent => :destroy has_many :financial_transactions, :dependent => :destroy
has_many :group_orders, :dependent => :destroy has_many :group_orders, :dependent => :destroy
has_many :orders, :through => :group_orders has_many :orders, :through => :group_orders
@ -44,9 +44,9 @@ class OrderGroup < Group
# messages # messages
ERR_NAME_IS_USED_IN_ARCHIVE = "Der Name ist von einer ehemaligen Gruppe verwendet worden." ERR_NAME_IS_USED_IN_ARCHIVE = "Der Name ist von einer ehemaligen Gruppe verwendet worden."
# if the order_group.name is changed, group_order_result.name has to be adapted # if the ordergroup.name is changed, group_order_result.name has to be adapted
def before_update def before_update
ordergroup = OrderGroup.find(self.id) ordergroup = Ordergroup.find(self.id)
unless (ordergroup.name == self.name) || ordergroup.group_order_results.empty? unless (ordergroup.name == self.name) || ordergroup.group_order_results.empty?
# rename all finished orders # rename all finished orders
for result in ordergroup.group_order_results for result in ordergroup.group_order_results
@ -59,7 +59,7 @@ class OrderGroup < Group
# * excludeGroupOrder (GroupOrder): exclude this GroupOrder from the calculation # * excludeGroupOrder (GroupOrder): exclude this GroupOrder from the calculation
def getAvailableFunds(excludeGroupOrder = nil) def getAvailableFunds(excludeGroupOrder = nil)
funds = account_balance funds = account_balance
for order in GroupOrder.find_all_by_order_group_id(self.id) for order in GroupOrder.find_all_by_ordergroup_id(self.id)
unless order == excludeGroupOrder unless order == excludeGroupOrder
funds -= order.price funds -= order.price
end end
@ -70,11 +70,11 @@ class OrderGroup < Group
return funds return funds
end end
# Creates a new FinancialTransaction for this OrderGroup and updates the account_balance accordingly. # Creates a new FinancialTransaction for this Ordergroup and updates the account_balance accordingly.
# Throws an exception if it fails. # Throws an exception if it fails.
def addFinancialTransaction(amount, note, user) def addFinancialTransaction(amount, note, user)
transaction do transaction do
trans = FinancialTransaction.new(:order_group => self, :amount => amount, :note => note, :user => user) trans = FinancialTransaction.new(:ordergroup => self, :amount => amount, :note => note, :user => user)
trans.save! trans.save!
self.account_balance += trans.amount self.account_balance += trans.amount
self.account_updated = trans.created_on self.account_updated = trans.created_on
@ -137,7 +137,7 @@ class OrderGroup < Group
errors.add(:name, ERR_NAME_IS_USED_IN_ARCHIVE) unless GroupOrderResult.find_all_by_group_name(self.name).empty? errors.add(:name, ERR_NAME_IS_USED_IN_ARCHIVE) unless GroupOrderResult.find_all_by_group_name(self.name).empty?
end end
def validate_on_update def validate_on_update
ordergroup = OrderGroup.find(self.id) ordergroup = Ordergroup.find(self.id)
errors.add(:name, ERR_NAME_IS_USED_IN_ARCHIVE) unless ordergroup.name == self.name || GroupOrderResult.find_all_by_group_name(self.name).empty? errors.add(:name, ERR_NAME_IS_USED_IN_ARCHIVE) unless ordergroup.name == self.name || GroupOrderResult.find_all_by_group_name(self.name).empty?
end end

View file

@ -23,7 +23,7 @@ require 'digest/sha1'
class User < ActiveRecord::Base class User < ActiveRecord::Base
has_many :memberships, :dependent => :destroy has_many :memberships, :dependent => :destroy
has_many :groups, :through => :memberships has_many :groups, :through => :memberships
has_many :order_groups, :through => :memberships, :source => :group has_many :ordergroups, :through => :memberships, :source => :group
has_many :assignments, :dependent => :destroy has_many :assignments, :dependent => :destroy
has_many :tasks, :through => :assignments has_many :tasks, :through => :assignments
@ -146,10 +146,10 @@ class User < ActiveRecord::Base
groups.detect {|group| group.role_orders?} groups.detect {|group| group.role_orders?}
end end
# Returns the user's OrderGroup or nil if none found. # Returns the user's Ordergroup or nil if none found.
def find_ordergroup def find_ordergroup
order_groups.first ordergroups.first
#groups.find(:first, :conditions => "type = 'OrderGroup'") #groups.find(:first, :conditions => "type = 'Ordergroup'")
end end
# Find all tasks, for which the current user should be responsible # Find all tasks, for which the current user should be responsible
@ -195,7 +195,7 @@ class User < ActiveRecord::Base
return true if group.users.detect {|user| user == self} return true if group.users.detect {|user| user == self}
end end
#Returns an array with the users groups (but without the OrderGroups -> because tpye=>"") #Returns an array with the users groups (but without the Ordergroups -> because tpye=>"")
def member_of_groups() def member_of_groups()
self.groups.find(:all, :conditions => {:type => ""}) self.groups.find(:all, :conditions => {:type => ""})
end end

View file

@ -1,27 +0,0 @@
%p
%table{:style => "width:100%"}
%tr
%td
= pagination_links_remote @groups
%td{:style => "text-align:right"}
- if @total > 20
= items_per_page
%table.list
%thead
%tr
%th Name
%th Typ
%th Mitglieder
%th
%tbody
- for group in @groups
%tr{:class => cycle('even','odd', :name => 'groups')}
%td= link_to group.name, :action => 'showGroup', :id => group
%td= group.is_a?(OrderGroup) ? 'Bestellgruppe' : 'Gruppe'
%td= group.users.size
%td
= link_to image_tag('b_users.png', :size => '16x16', :border => "0", :alt => 'Mitlglieder bearbeiten'), :action => 'members', :id => group
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Gruppe bearbeiten'), :action => 'editGroup', :id => group)
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Gruppe löschen'), {:action => 'destroyGroup', :id => group}, |
:confirm => 'Willst du ' + group.name + ' wirklich löschen?', |
:method => "post") |

View file

@ -37,14 +37,14 @@
<% for group in @groups %> <% for group in @groups %>
<tr class="<%= cycle('even','odd', :name => 'groups') %>"> <tr class="<%= cycle('even','odd', :name => 'groups') %>">
<td><%= link_to group.name, :action => 'showGroup', :id => group %></td> <td><%= link_to group.name, :action => 'showGroup', :id => group %></td>
<td><%= group.is_a?(OrderGroup) ? 'Bestellgruppe' : 'Gruppe' %></td> <td><%= group.is_a?(Ordergroup) ? 'Bestellgruppe' : 'Gruppe' %></td>
<td><%= group.users.size %></td> <td><%= group.users.size %></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>
<br /> <br />
<%= link_to 'Alle Gruppen', :action => 'listGroups' %> | <%= link_to 'Alle Gruppen', :action => 'listGroups' %> |
<%= link_to "Neue Bestellgruppe", :action => "newOrderGroup" %> | <%= link_to "Neue Bestellgruppe", :action => "newOrdergroup" %> |
<%= link_to "Neue Gruppe", :action => "newGroup" %> <%= link_to "Neue Gruppe", :action => "newGroup" %>
</div> </div>
</div> </div>

View file

@ -1,2 +0,0 @@
<%= render :partial => 'groups/edit_members' %>
<p style="clear:both"><%= link_to 'Gruppenübersicht', :action => 'listGroups' %></p>

View file

@ -1,8 +0,0 @@
<h1>Neue <%= @group.is_a?(OrderGroup) ? 'Bestellgruppe' : 'Gruppe' %></h1>
<div class="edit_form" style="width:50em">
<% form_tag(:action => (@group.is_a?(OrderGroup) ? 'createOrderGroup' : 'createGroup')) do %>
<%= render :partial => 'groups/form' %>
<br style="clear:both" />
<%= submit_tag "Speichern" %> | <%= link_to "Abbrechen", :action => "listGroups" %>
<% end %>
</div>

View file

@ -0,0 +1,45 @@
- form_for [:admin, @ordergroup] do |@form|
= @form.error_messages
%div{:style => "float:left;width:55%;"}
%p
= @form.label :name
%br/
= @form.text_field :name, :size => 20
%p
= @form.label :description
%br/
= @form.text_field :description, :size => 40
%p
= @form.label :actual_size, "Aktuelle Gruppengröße"
%br/
= @form.text_field :actual_size, :size => 3
%div{:style => "float:right;width:40%"}
%h3 Gruppe hat Zugriff auf
%table
%tr
%td
= @form.label :role_admin, "Administration"
%td= @form.check_box :role_admin
%tr
%td
= @form.label :role_finance, "Finanzen"
%td= @form.check_box :role_finance
%tr
%td
= @form.label :role_suppliers, "Lieferantenverwaltung"
%td= @form.check_box :role_suppliers
%tr
%td
= @form.label :role_article_meta, "Artikelverwaltung"
%td= @form.check_box :role_article_meta
%tr
%td
= @form.label :role_orders, "Bestellungsverwaltung"
%td= @form.check_box :role_orders
%br{ :style => "clear:both" }
= submit_tag "Speichern"
|
= link_to "Abbrechen", admin_ordergroups_path

View file

@ -0,0 +1,24 @@
%p
%table{:style => "width:100%"}
%tr
%td
= pagination_links_remote @ordergroups, { :update => "ordergroups" }
%td{:style => "text-align:right"}
- if @total > 20
= items_per_page :update => "ordergroups"
%table.list
%thead
%tr
%th Name
%th Mitglieder
%th
%tbody
- for ordergroup in @ordergroups
%tr{:class => cycle('even','odd', :name => 'groups')}
%td= link_to ordergroup.name, [:admin, ordergroup]
%td= ordergroup.users.size
%td
= link_to image_tag('b_users.png', :size => '16x16', :border => "0", :alt => 'Mitlglieder bearbeiten'), memberships_admin_ordergroup_path(ordergroup)
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Gruppe bearbeiten'), edit_admin_ordergroup_path(ordergroup))
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Gruppe löschen'), [:admin, ordergroup], |
:confirm => 'Willst du ' + ordergroup.name + ' wirklich löschen?', :method => :delete) |

View file

@ -0,0 +1,4 @@
- title "Bestellgruppe bearbeiten"
.edit_form{:style => "width:50em"}
= render :partial => 'form'

View file

@ -1,14 +1,17 @@
%h1=_ 'Groups' - title "Bestellgruppen"
%p %p
%i %i
Hier kannst du Hier kannst du
= link_to 'neue Gruppen', :action => 'newGroup' = link_to 'neue Bestellgruppen', new_admin_ordergroup_path
und
= link_to 'neue Bestellgruppen', :action => 'newOrderGroup'
anlegen, Gruppen bearbeiten und löschen. anlegen, Gruppen bearbeiten und löschen.
%p %p
Beachte dabei den <em>Unterschied zwischen Gruppe und Bestellgruppe</em>: Beachte dabei den <em>Unterschied zwischen Gruppe und Bestellgruppe</em>:
Eine <em>Bestellgruppe</em> hat ein Konto und kann Essen bestellen, eine <em>Gruppe</em> ist eine Arbeitsgruppe wie z.B. die "Sortiergruppe". Eine Bestellgruppe hat ein Konto und kann Essen bestellen. In einer
%em= link_to 'Arbeisgruppe', admin_workgroups_path
(z.b. 'Soritiergruppe')
koordinieren sich die Mitglieder mittels Aufgaben und Nachrichten.
Nutzer_innen können immer nur einer Bestellgruppe, aber beliebig vielen anderen Gruppen angehören. Nutzer_innen können immer nur einer Bestellgruppe, aber beliebig vielen anderen Gruppen angehören.
.left_column{:style => "width:100%"} .left_column{:style => "width:100%"}
.box_title .box_title
@ -16,17 +19,16 @@
.column_content .column_content
#group_filter #group_filter
%form{:name=>"sform", :action=>"", :style=>"display:inline;"} %form{:name=>"sform", :action=>"", :style=>"display:inline;"}
%label{:for => 'article_name'} Suche in Name : %label{:for => 'ordergroup_name'} Suche in Name :
= text_field_tag("query", params['query'], :size => 10 ) = text_field_tag("query", params['query'], :size => 10 )
= observe_field 'query', :frequency => 2, | = observe_field 'query', :frequency => 2, |
:before => "Element.show('loader')", | :before => "Element.show('loader')", |
:success => "Element.hide('loader')", | :success => "Element.hide('loader')", |
:url => {:action => 'listGroups'}, | :update => "ordergroups", |
:with => 'query' | :url => admin_ordergroups_path, |
#table :with => 'query', |
= render :partial => "listGroups" :method => :get |
- if @current_user.role_admin? #ordergroups
= link_to 'Neue Gruppe', :action => 'newGroup' = render :partial => "ordergroups"
| = link_to 'Neue Arbeits', new_admin_ordergroup_path
= link_to 'Neue Bestellgruppe', :action => 'newOrderGroup'

View file

@ -0,0 +1,3 @@
= render :partial => 'admin/memberships/edit_members'
%p{ :style => "clear:both" }
= link_to 'Gruppenübersicht', admin_ordergroups_path

View file

@ -0,0 +1,4 @@
- title "Bestellgruppe anlegen"
.edit_form{:style => "width:50em"}
= render :partial => 'form'

View file

@ -0,0 +1,42 @@
- title "Arbeitsgruppe #{@ordergroup.name}"
.left_column{:style => "width:45em"}
.box_title
%h2 Übersicht
.column_content
%p
%b Beschreibung:
=h @ordergroup.description
%p
%b Gruppe hat Zugriff auf:
- roles = Array.new
- roles << 'Administration' if @ordergroup.role_admin?
- roles << 'Finanzen' if @ordergroup.role_finance?
- roles << 'Lieferanten' if @ordergroup.role_suppliers?
- roles << 'Artikel' if @ordergroup.role_article_meta?
- roles << 'Bestellungsverwaltung' if @ordergroup.role_orders?
=h roles.join(', ')
%p
- if @ordergroup.weekly_task
%b wöchentlicher Job:
=h @ordergroup.task_name
am
= weekday(@ordergroup.weekday)
- else
kein wöchentlicher Job definiert
= link_to 'Gruppe bearbeiten', edit_admin_ordergroup_path(@ordergroup)
|
= link_to 'Löschen', [:admin, @ordergroup], :confirm => 'Bist Du sicher?', :method => :delete
|
= link_to 'Nachricht senden', :controller => 'messages', :action => 'group', :id => @ordergroup
.box_title
%h2 Mitglieder
.column_content
- if @ordergroup.memberships.empty?
%i Diese Gruppe hat derzeit keine Mitglieder
- else
%ul{:style => "list-style-type:decimal;"}
- for membership in @ordergroup.memberships
%li= link_to membership.user.nick, [:admin, membership.user]
%p= link_to 'Mitglieder bearbeiten', memberships_admin_ordergroup_path(@ordergroup)
%p{:style => "clear:both"}= link_to "Gruppenübersicht", admin_ordergroups_path

View file

@ -1,54 +0,0 @@
%h1
= @group.is_a?(OrderGroup) ? "Bestellgruppe:" : "Gruppe:"
=h @group.name
.left_column{:style => "width:45em"}
.box_title
%h2 Übersicht
.column_content
%p
%b Beschreibung:
=h @group.description
- if @group.is_a?(OrderGroup)
%p
%b Gruppengröße:
= @group.actual_size
%p
%b Kontostand:
= @group.account_balance
%p
%b Kontostand aktualisiert:
= @group.account_updated
%p
%b Gruppe hat Zugriff auf:
- roles = Array.new
- roles << 'Administration' if @group.role_admin?
- roles << 'Finanzen' if @group.role_finance?
- roles << 'Lieferanten' if @group.role_suppliers?
- roles << 'Artikel' if @group.role_article_meta?
- roles << 'Bestellungsverwaltung' if @group.role_orders?
=h roles.join(', ')
%p
- if @group.weekly_task
%b wöchentlicher Job:
=h @group.task_name
am
= weekday(@group.weekday)
- else
kein wöchentlicher Job definiert
= link_to 'Gruppe bearbeiten', :action => 'editGroup', :id => @group
|
= link_to 'Löschen', { :action => 'destroyGroup', :id => @group }, :confirm => 'Bist Du sicher?', :method => "post"
|
= link_to 'Nachricht senden', :controller => 'messages', :action => 'group', :id => @group
.box_title
%h2 Mitglieder
.column_content
- if @group.memberships.empty?
%i Diese Gruppe hat derzeit keine Mitglieder
- else
%ul{:style => "list-style-type:decimal;"}
- for membership in @group.memberships
%li= link_to membership.user.nick, :action => 'showUser', :id => membership.user
%p= link_to 'Mitglieder bearbeiten', :action => 'members', :id => @group
%p{:style => "clear:both"}= link_to "Gruppenübersicht", :action => "listGroups"

View file

@ -2,10 +2,10 @@
%table{:style => "width:100%"} %table{:style => "width:100%"}
%tr %tr
%td %td
= pagination_links_remote @workgroups = pagination_links_remote @workgroups, { :update => "workgroups" }
%td{:style => "text-align:right"} %td{:style => "text-align:right"}
- if @workgroups.size > 20 - if @total.size > 20
= items_per_page = items_per_page :update => "workgroups"
%table.list %table.list
%thead %thead
%tr %tr

View file

@ -1,4 +1,5 @@
%p= pagination_links_remote @articles, 10, {:import_query => params[:import_query], :lists => params[:lists], :regional => params[:regional]} %p= pagination_links_remote @articles, :per_page => 10, |
:params => {:import_query => params[:import_query], :lists => params[:lists], :regional => params[:regional]} |
%table.list %table.list
%thead %thead
%tr %tr

View file

@ -6,10 +6,10 @@
%table{:style => "width:100%"} %table{:style => "width:100%"}
%tr %tr
%td %td
= pagination_links_remote @articles, @per_page, {:sort => params[:sort]} = pagination_links_remote @articles, :params => {:sort => params[:sort]}
%td{:style => "text-align:right"} %td{:style => "text-align:right"}
- if @total > 30 - if @total > 30
= items_per_page([30, 100, 500]) = items_per_page :per_page_options => [30, 100, 500]
%table#articles_table.list.articles %table#articles_table.list.articles
%thead %thead
@ -49,7 +49,7 @@
= hidden_field_tag 'supplier', @supplier.id = hidden_field_tag 'supplier', @supplier.id
%p %p
= pagination_links_remote @articles, @per_page, {:sort => params[:sort]} = pagination_links_remote @articles, :params => {:sort => params[:sort]}
:plain :plain
<script type="text/javascript"> <script type="text/javascript">

View file

@ -6,7 +6,7 @@
= error_messages_for 'result' = error_messages_for 'result'
%p %p
Gruppe: Gruppe:
= @form.select "group_order_result_id", OrderGroup.find(:all, :order => "name").collect {|og| [og.name, og.id] } = @form.select "group_order_result_id", Ordergroup.find(:all, :order => "name").collect {|og| [og.name, og.id] }
%p %p
Menge: Menge:
= @form.text_field "quantity", :size => 5 = @form.text_field "quantity", :size => 5

View file

@ -35,7 +35,7 @@
- @financial_transactions.each do |ft| - @financial_transactions.each do |ft|
%tr{:class => cycle("even","odd", :name => "financial_transaction")} %tr{:class => cycle("even","odd", :name => "financial_transaction")}
%td= format_date(ft.created_on) %td= format_date(ft.created_on)
%td= ft.order_group.name %td= ft.ordergroup.name
%td{:style => "width:50%"}=h ft.note %td{:style => "width:50%"}=h ft.note
%td{:style => "color:#{ft.amount < 0 ? 'red' : 'black'}", :class => "currency"}= number_to_currency(ft.amount) %td{:style => "color:#{ft.amount < 0 ? 'red' : 'black'}", :class => "currency"}= number_to_currency(ft.amount)

View file

@ -7,7 +7,7 @@
<p>Anzahl gefundener Transaktionen: <b><%= @total %></b></p> <p>Anzahl gefundener Transaktionen: <b><%= @total %></b></p>
<p> <p>
<%= pagination_links_remote @financial_transactions, @per_page, {:sort => params[:sort], :query => params['query']}%> <%= pagination_links_remote @financial_transactions, :params => {:sort => params[:sort], :query => params['query']}%>
</p> </p>

View file

@ -1,6 +1,6 @@
%tr.transaction %tr.transaction
%td %td
%select{:name => 'financial_transactions[][order_group_id]'} %select{:name => 'financial_transactions[][ordergroup_id]'}
= options_for_select OrderGroup.find(:all, :order => 'name').collect { |g| [ g.name, g.id ] } = options_for_select Ordergroup.find(:all, :order => 'name').collect { |g| [ g.name, g.id ] }
%td= text_field_tag 'financial_transactions[][amount]' %td= text_field_tag 'financial_transactions[][amount]'
%td= link_to_function image_tag("b_drop.png", :size => "16x16", :alt => _("Remove"), :border => "0"), "$(this).up('.transaction').remove()", {:title => _("Remove ordergroup")} %td= link_to_function image_tag("b_drop.png", :size => "16x16", :alt => _("Remove"), :border => "0"), "$(this).up('.transaction').remove()", {:title => _("Remove ordergroup")}

View file

@ -5,7 +5,7 @@
%table{:style => "width:100%"} %table{:style => "width:100%"}
%tr %tr
%td %td
= pagination_links_remote @groups, @per_page, {:sort => params[:sort]} = pagination_links_remote @groups, :params => {:sort => params[:sort]}
%td{:style => "text-align:right"} %td{:style => "text-align:right"}
- if @total > 20 - if @total > 20
= items_per_page = items_per_page

View file

@ -22,4 +22,4 @@
= render :partial => "ordergroups" = render :partial => "ordergroups"
%br/ %br/
- if @current_user.role_admin? - if @current_user.role_admin?
= link_to _("New ordergroup"), :controller => 'admin', :action => 'newOrderGroup' = link_to _("New ordergroup"), :controller => 'admin', :action => 'newOrdergroup'

View file

@ -3,7 +3,7 @@
.edit_form{ :style => "width:30em" } .edit_form{ :style => "width:30em" }
- form_for(@financial_transaction, :url => { :action => 'create' }) do |f| - form_for(@financial_transaction, :url => { :action => 'create' }) do |f|
= f.error_messages = f.error_messages
= f.hidden_field :order_group_id = f.hidden_field :ordergroup_id
%p %p
Group: Group:
%b=h @group.name %b=h @group.name

View file

@ -5,15 +5,15 @@
%b= _("Note") + ":" %b= _("Note") + ":"
= text_field_tag "note" = text_field_tag "note"
%p %p
%table#OrderGroups{:style => "width:20em"} %table#Ordergroups{:style => "width:20em"}
%tr %tr
%th=_ "Ordergroup" %th=_ "Ordergroup"
%th=_ "Amount" %th=_ "Amount"
= render :partial => 'order_group', :collection => [1, 2, 3] = render :partial => 'ordergroup', :collection => [1, 2, 3]
%p %p
= link_to_function _("Add another ordergroup") do |page| = link_to_function _("Add another ordergroup") do |page|
- page.insert_html :bottom, :OrderGroups, :partial => 'order_group' - page.insert_html :bottom, :Ordergroups, :partial => 'ordergroup'
%p %p
= submit_tag _("Save") = submit_tag _("Save")
| |

View file

@ -2,7 +2,7 @@
<!--[form:group]--> <!--[form:group]-->
%div{:style => "float:left;width:55%;"} %div{:style => "float:left;width:55%;"}
- if controller.controller_name == "admin" || !@group.is_a?(OrderGroup) - if controller.controller_name == "admin" || !@group.is_a?(Ordergroup)
%p %p
%label{:for => "group_name"} Names %label{:for => "group_name"} Names
%br/ %br/
@ -11,7 +11,7 @@
%label{:for => "group_description"} Beschreibung %label{:for => "group_description"} Beschreibung
%br/ %br/
= text_field 'group', 'description', :size => 40 = text_field 'group', 'description', :size => 40
- if @group.is_a?(OrderGroup) && controller.controller_name == "admin" - if @group.is_a?(Ordergroup) && controller.controller_name == "admin"
%p %p
%label{:for => "group_actual_size"} Aktuelle Gruppengröße %label{:for => "group_actual_size"} Aktuelle Gruppengröße
%br/ %br/
@ -40,7 +40,7 @@
%td %td
%label{:for => "group_role_orders"} Bestellungsverwaltung %label{:for => "group_role_orders"} Bestellungsverwaltung
%td= check_box 'group', 'role_orders' %td= check_box 'group', 'role_orders'
-unless @group.is_a?(OrderGroup) -unless @group.is_a?(Ordergroup)
%div{:style => "clear:both"} %div{:style => "clear:both"}
%h3 %h3
Wöchentliche Jobs definieren? Wöchentliche Jobs definieren?

View file

@ -1,4 +1,4 @@
- for group in Group.find :all, :conditions => "type != 'OrderGroup'" - for group in Group.find :all, :conditions => "type != 'Ordergroup'"
%h4= link_to_function group.name, "Element.toggle('group_#{group.id}')" %h4= link_to_function group.name, "Element.toggle('group_#{group.id}')"
%ul{:style => "display:none"}[group] %ul{:style => "display:none"}[group]
- for user in group.users.find :all, :order => "nick" - for user in group.users.find :all, :order => "nick"

View file

@ -21,8 +21,8 @@
- for user in @users - for user in @users
%tr{:class => cycle('even','odd', :name => 'users')} %tr{:class => cycle('even','odd', :name => 'users')}
- groups = user.groups - groups = user.groups
- ordergroup = groups.detect { |group| group.is_a?(OrderGroup) } - ordergroup = groups.detect { |group| group.is_a?(Ordergroup) }
- workgroups = groups.select { |group| !group.is_a?(OrderGroup) }.collect(&:name) - workgroups = groups.select { |group| !group.is_a?(Ordergroup) }.collect(&:name)
%td= link_to user.nick, {:controller => "messages", :action => "user", :id => user}, :title => _('Send user an email') %td= link_to user.nick, {:controller => "messages", :action => "user", :id => user}, :title => _('Send user an email')
%td=h user.first_name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1' %td=h user.first_name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
%td=h user.last_name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1' %td=h user.last_name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'

View file

@ -8,13 +8,13 @@
%li= link_to _("Write message"), :controller => "messages", :action => "new" %li= link_to _("Write message"), :controller => "messages", :action => "new"
// Orders // Orders
- hasOrderGroup = !@current_user.find_ordergroup.nil? - hasOrdergroup = !@current_user.find_ordergroup.nil?
- hasOrdersRole = @current_user.role_orders? - hasOrdersRole = @current_user.role_orders?
- if hasOrderGroup || hasOrdersRole - if hasOrdergroup || hasOrdersRole
%li %li
= _("Orders") = _("Orders")
%ul %ul
- if hasOrderGroup - if hasOrdergroup
%li= link_to _('Order summary'), :controller => "ordering" %li= link_to _('Order summary'), :controller => "ordering"
- if hasOrdersRole - if hasOrdersRole
%li= link_to _('Finish order'), :controller => 'orders' %li= link_to _('Finish order'), :controller => 'orders'
@ -39,5 +39,5 @@
%li %li
= _('Administration') = _('Administration')
%ul %ul
%li= link_to _("New ordergroup"), :controller => "admin", :action => "newOrderGroup" %li= link_to _("New ordergroup"), :controller => "admin", :action => "newOrdergroup"
%li= link_to _("New user"), :controller => "admin", :action => "newUser" %li= link_to _("New user"), :controller => "admin", :action => "newUser"

View file

@ -38,7 +38,7 @@
// Current orders // Current orders
= render :partial => 'ordering/currentOrders' = render :partial => 'ordering/currentOrders'
// OrderGroup overview // Ordergroup overview
.box_title .box_title
%h2=_ "My ordergroup" %h2=_ "My ordergroup"
.column_content .column_content

View file

@ -1,6 +1,6 @@
<%= render :partial => 'groups/edit_members' %> <%= render :partial => 'groups/edit_members' %>
<p style="clear:both"> <p style="clear:both">
<% if @group.is_a?(OrderGroup) -%> <% if @group.is_a?(Ordergroup) -%>
<%= link_to "Zurück", :action => "myOrdergroup" %> <%= link_to "Zurück", :action => "myOrdergroup" %>
<% else -%> <% else -%>
<%= link_to 'Zurück', :action => 'showGroup', :id => @group %> <%= link_to 'Zurück', :action => 'showGroup', :id => @group %>

View file

@ -21,7 +21,7 @@ You can also see in which workgroups you are.
<% for membership in Membership.find_all_by_user_id(@user.id) %> <% for membership in Membership.find_all_by_user_id(@user.id) %>
<p> <p>
<%= link_to(membership.group.name, :action => 'showGroup', :id => membership.group) %> <%= link_to(membership.group.name, :action => 'showGroup', :id => membership.group) %>
<% if membership.group.type != 'OrderGroup' %> <% if membership.group.type != 'Ordergroup' %>
(<%= link_to _("Cancel membership"), { :action => 'cancel_membership', :id => membership }, :confirm => _("Are you sure to cancel this membership?"), :method => :post %>) (<%= link_to _("Cancel membership"), { :action => 'cancel_membership', :id => membership }, :confirm => _("Are you sure to cancel this membership?"), :method => :post %>)
<% end %> <% end %>
</p> </p>

View file

@ -1,8 +1,8 @@
%h1 %h1
=h @group.is_a?(OrderGroup) ? "Bestellgruppe:" : "Gruppe:" =h @group.is_a?(Ordergroup) ? "Bestellgruppe:" : "Gruppe:"
=h @group.name =h @group.name
= render :partial => "showGroup" = render :partial => "showGroup"
- unless @group.is_a?(OrderGroup) - unless @group.is_a?(Ordergroup)
%p{:style => "clear:both"} %p{:style => "clear:both"}
= link_to "alle Arbeitsgruppen", :action => "workgroups" = link_to "alle Arbeitsgruppen", :action => "workgroups"

View file

@ -7,7 +7,7 @@
{ :name => "Workgroups", :url => "/index/workgroups"}, { :name => "Workgroups", :url => "/index/workgroups"},
{ :name => "Tasks", :url => "/tasks"}, { :name => "Tasks", :url => "/tasks"},
{ :name => "Messages", :url => "/messages/inbox"}, { :name => "Messages", :url => "/messages/inbox"},
{ :name => "My Ordergroup", :url => my_order_group_path}, { :name => "My Ordergroup", :url => my_ordergroup_path},
{ :name => "My Ordergroup", :url => my_profile_path} { :name => "My Ordergroup", :url => my_profile_path}
] ]
}, },
@ -36,11 +36,12 @@
] ]
}, },
{ :name => "Administration", :url => "/admin", { :name => "Administration", :url => "/admin",
:active => ["admin", "admin/users", "admin/workgroups"], :active => ["admin", "admin/users", "admin/ordergroups", "admin/workgroups"],
:access? => (u.role_admin?), :access? => (u.role_admin?),
:subnav => [ :subnav => [
{ :name => "Users", :url => "/admin/users" }, { :name => "Users", :url => admin_users_path },
{ :name => "Workgroups", :url => "/admin/workgroups" } { :name => "Ordergroups", :url => admin_ordergroups_path },
{ :name => "Workgroups", :url => admin_workgroups_path }
] ]
} }
] ]

View file

@ -1,5 +1,5 @@
- if controller.action_name == 'myOrders' - if controller.action_name == 'myOrders'
= pagination_links_remote @bookedOrders, 10, {:show_all => params[:show_all]} = pagination_links_remote @bookedOrders, :per_page => 10, :params => {:show_all => params[:show_all]}
%table.list %table.list
%thead %thead
%tr %tr
@ -16,7 +16,7 @@
%td= format_time(order.order.ends) %td= format_time(order.order.ends)
%td{:class => "currency"}= number_to_currency(order.price) %td{:class => "currency"}= number_to_currency(order.price)
- else - else
// check if the OrderGroup has ordered // check if the Ordergroup has ordered
- if groupOrder = order.group_order(@orderGroup) - if groupOrder = order.group_order(@orderGroup)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')} %tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.name, :action => 'my_order_result', :id => order %td= link_to order.name, :action => 'my_order_result', :id => order

View file

@ -17,7 +17,7 @@
%td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order %td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order
%td=h order.supplier.name %td=h order.supplier.name
%td=h format_time(order.ends) unless order.ends.nil? %td=h format_time(order.ends) unless order.ends.nil?
- if (groupOrder = order.group_orders.find(:first, :conditions => ["order_group_id = ?", @orderGroup.id])) - if (groupOrder = order.group_orders.find(:first, :conditions => ["ordergroup_id = ?", @orderGroup.id]))
- total += groupOrder.price - total += groupOrder.price
%td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})" %td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})"
%td= number_to_currency(groupOrder.price) %td= number_to_currency(groupOrder.price)

View file

@ -14,7 +14,7 @@
%td= format_time(order.order.ends) %td= format_time(order.order.ends)
%td{:class => "currency"}= number_to_currency(order.price) %td{:class => "currency"}= number_to_currency(order.price)
- else - else
// check if the OrderGroup has ordered // check if the Ordergroup has ordered
- if groupOrder = order.group_order(@orderGroup) - if groupOrder = order.group_order(@orderGroup)
%tr{:class=> cycle('even', 'odd', :name => 'finishedOrders')} %tr{:class=> cycle('even', 'odd', :name => 'finishedOrders')}
%td= link_to order.name, :action => 'my_order_result', :id => order %td= link_to order.name, :action => 'my_order_result', :id => order

View file

@ -1,6 +1,6 @@
%h1= _('Order Overview') %h1= _('Order Overview')
// OrderGroups Account Balance // Ordergroups Account Balance
.left_column{:style => "width:26%"} .left_column{:style => "width:26%"}
.box_title .box_title
%h2=h @orderGroup.name %h2=h @orderGroup.name

View file

@ -147,7 +147,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="6"></td> <td colspan="6"></td>
<td colspan="3" class="currency"><%=_ "New account balance"%>: <strong><span id="new_balance"><%= @order_group.account_balance - total %></span> <%= L18n.number.currency.format.unit %></strong></td> <td colspan="3" class="currency"><%=_ "New account balance"%>: <strong><span id="new_balance"><%= @ordergroup.account_balance - total %></span> <%= L18n.number.currency.format.unit %></strong></td>
</tr> </tr>
<tr> <tr>
<td style="text-align:left;"><%= link_to_top %></td> <td style="text-align:left;"><%= link_to_top %></td>
@ -157,7 +157,7 @@
</tfoot> </tfoot>
</table> </table>
</div> </div>
<input type="hidden" id="total_balance" name="total_balance" value="<%= @order_group.account_balance - total %>"/> <input type="hidden" id="total_balance" name="total_balance" value="<%= @ordergroup.account_balance - total %>"/>
<input type="hidden" name="version" value="<%= @version %>"/> <input type="hidden" name="version" value="<%= @version %>"/>
<% end %> <% end %>
</div> </div>

View file

@ -1,4 +1,4 @@
= pagination_links_remote @orders, @per_page, {:sort => params[:sort]} = pagination_links_remote @orders, :params => {:sort => params[:sort]}
%table.list{:style => "width: 100%"} %table.list{:style => "width: 100%"}
%thead %thead
%tr %tr

View file

@ -56,7 +56,7 @@ while (page_number * max_articles_per_page < total_num_articles) do # Start pag
group_result = [truncate(group_order_result.group_name, 20)] group_result = [truncate(group_order_result.group_name, 20)]
for article in current_articles for article in current_articles
# get the OrderGroupResult for this article # get the OrdergroupResult for this article
result = GroupOrderArticleResult.find(:first, result = GroupOrderArticleResult.find(:first,
:conditions => ['order_article_result_id = ? AND group_order_result_id = ?', article.id, group_order_result.id]) :conditions => ['order_article_result_id = ? AND group_order_result_id = ?', article.id, group_order_result.id])
group_result << ((result.nil? || result == 0) ? "" : result.quantity.to_i) group_result << ((result.nil? || result == 0) ? "" : result.quantity.to_i)

View file

@ -34,7 +34,7 @@
= _("Groups ordered") + ":" = _("Groups ordered") + ":"
%b= @group_orders.size %b= @group_orders.size
- unless @finished - unless @finished
= "[#{@group_orders.collect{|g| g.order_group.name}.join(', ')}]" unless @group_orders.empty? = "[#{@group_orders.collect{|g| g.ordergroup.name}.join(', ')}]" unless @group_orders.empty?
- else - else
= "[#{@group_orders.collect{|g| g.group_name}.join(', ')}]" unless @group_orders.empty? = "[#{@group_orders.collect{|g| g.group_name}.join(', ')}]" unless @group_orders.empty?
%p %p

View file

@ -29,7 +29,7 @@
%label{:for => "task_group"} %label{:for => "task_group"}
%b=_ 'Group' %b=_ 'Group'
%br/ %br/
= select(:task, :group_id, Group.find(:all, :conditions => "type != 'OrderGroup'", :order => 'name').collect {|g| [ g.name, g.id ] }, { :include_blank => true }) = select(:task, :group_id, Group.find(:all, :conditions => "type != 'Ordergroup'", :order => 'name').collect {|g| [ g.name, g.id ] }, { :include_blank => true })
%p %p
%label{:for => "task_due_date"} %label{:for => "task_due_date"}
%b=_ 'Due date' %b=_ 'Due date'

View file

@ -15,5 +15,5 @@
%li %li
=_ 'Group tasks' =_ 'Group tasks'
%ul %ul
- for group in Group.find :all, :conditions => "type != 'OrderGroup'" - for group in Group.find :all, :conditions => "type != 'Ordergroup'"
%li= link_to group.name, :action => "workgroup", :id => group %li= link_to group.name, :action => "workgroup", :id => group

View file

@ -3,8 +3,8 @@ ActionController::Routing::Routes.draw do |map|
map.namespace :admin do |admin| map.namespace :admin do |admin|
admin.resources :users admin.resources :users
admin.resources :workgroups, :member => { :memberships => :get } admin.resources :workgroups, :member => { :memberships => :get }
admin.resources :ordergroups, :member => { :memberships => :get }
admin.connect 'memberships/:action/:id', :controller => 'memberships' admin.connect 'memberships/:action/:id', :controller => 'memberships'
admin.add_member 'add_member', :controller => 'memberships', :action => 'add_member'
end end
map.namespace :finance do |finance| map.namespace :finance do |finance|
@ -18,7 +18,7 @@ ActionController::Routing::Routes.draw do |map|
:collection => { :shared_suppliers => :get } :collection => { :shared_suppliers => :get }
map.my_profile 'my_profile', :controller => 'index', :action => 'myProfile' map.my_profile 'my_profile', :controller => 'index', :action => 'myProfile'
map.my_order_group 'my_order_group', :controller => 'index', :action => 'myOrdergroup' map.my_ordergroup 'my_ordergroup', :controller => 'index', :action => 'myOrdergroup'
map.root :controller => 'index' map.root :controller => 'index'

View file

@ -0,0 +1,15 @@
class RenameOrdergroups < ActiveRecord::Migration
def self.up
rename_column :financial_transactions, :order_group_id, :ordergroup_id
rename_column :group_orders, :order_group_id, :ordergroup_id
remove_index :group_orders, :name => "index_group_orders_on_order_group_id_and_order_id"
add_index :group_orders, [:ordergroup_id, :order_id], :unique => true
Group.find(:all, :conditions => { :type => "OrderGroup" }).each do |ordergroup|
ordergroup.update_attribute(:type, "Ordergroup")
end
end
def self.down
end
end

View file

@ -9,7 +9,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20090113111624) do ActiveRecord::Schema.define(:version => 20090114101610) do
create_table "article_categories", :force => true do |t| create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false t.string "name", :default => "", :null => false
@ -78,11 +78,11 @@ ActiveRecord::Schema.define(:version => 20090113111624) do
end end
create_table "financial_transactions", :force => true do |t| create_table "financial_transactions", :force => true do |t|
t.integer "order_group_id", :default => 0, :null => false t.integer "ordergroup_id", :default => 0, :null => false
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.text "note", :null => false t.text "note", :null => false
t.integer "user_id", :default => 0, :null => false t.integer "user_id", :default => 0, :null => false
t.datetime "created_on", :null => false t.datetime "created_on", :null => false
end end
create_table "group_order_article_quantities", :force => true do |t| create_table "group_order_article_quantities", :force => true do |t|
@ -121,7 +121,7 @@ ActiveRecord::Schema.define(:version => 20090113111624) do
add_index "group_order_results", ["group_name", "order_id"], :name => "index_group_order_results_on_group_name_and_order_id", :unique => true add_index "group_order_results", ["group_name", "order_id"], :name => "index_group_order_results_on_group_name_and_order_id", :unique => true
create_table "group_orders", :force => true do |t| create_table "group_orders", :force => true do |t|
t.integer "order_group_id", :default => 0, :null => false t.integer "ordergroup_id", :default => 0, :null => false
t.integer "order_id", :default => 0, :null => false t.integer "order_id", :default => 0, :null => false
t.decimal "price", :precision => 8, :scale => 2, :default => 0.0, :null => false t.decimal "price", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.integer "lock_version", :default => 0, :null => false t.integer "lock_version", :default => 0, :null => false
@ -129,7 +129,7 @@ ActiveRecord::Schema.define(:version => 20090113111624) do
t.integer "updated_by_user_id", :default => 0, :null => false t.integer "updated_by_user_id", :default => 0, :null => false
end end
add_index "group_orders", ["order_group_id", "order_id"], :name => "index_group_orders_on_order_group_id_and_order_id", :unique => true add_index "group_orders", ["ordergroup_id", "order_id"], :name => "index_group_orders_on_ordergroup_id_and_order_id", :unique => true
create_table "groups", :force => true do |t| create_table "groups", :force => true do |t|
t.string "type", :default => "", :null => false t.string "type", :default => "", :null => false

View file

@ -1,5 +1,5 @@
# == Schema Information # == Schema Information
# Schema version: 20090113111624 # Schema version: 20090114101610
# #
# Table name: articles # Table name: articles
# #

View file

@ -1,14 +1,14 @@
# == Schema Information # == Schema Information
# Schema version: 20090102171850 # Schema version: 20090114101610
# #
# Table name: financial_transactions # Table name: financial_transactions
# #
# id :integer(4) not null, primary key # id :integer(4) not null, primary key
# order_group_id :integer(4) default(0), not null # ordergroup_id :integer(4) default(0), not null
# amount :decimal(8, 2) default(0.0), not null # amount :decimal(8, 2) default(0.0), not null
# note :text default(""), not null # note :text default(""), not null
# user_id :integer(4) default(0), not null # user_id :integer(4) default(0), not null
# created_on :datetime not null # created_on :datetime not null
# #
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

View file

@ -27,11 +27,11 @@
first: first:
id: 1 id: 1
name: Order Group 1 name: Order Group 1
type: OrderGroup type: Ordergroup
another: another:
id: 2 id: 2
name: Order Group 2 name: Order Group 2
type: OrderGroup type: Ordergroup
admins: admins:
id: 3 id: 3
name: Administrators name: Administrators

View file

@ -1,5 +1,5 @@
# == Schema Information # == Schema Information
# Schema version: 20090113111624 # Schema version: 20090114101610
# #
# Table name: suppliers # Table name: suppliers
# #

View file

@ -0,0 +1,8 @@
require 'test_helper'
class Admin::OrdergroupsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View file

@ -34,7 +34,8 @@ module WillPaginate
:page_links => true, :page_links => true,
:container => true, :container => true,
# bennis hack for ajax-support # bennis hack for ajax-support
:remote => false :remote => false,
:update => nil,
} }
mattr_reader :pagination_options mattr_reader :pagination_options
@ -303,7 +304,7 @@ module WillPaginate
if @options[:remote] == true if @options[:remote] == true
@template.link_to_remote text, :url => url_for(page), :html => attributes, @template.link_to_remote text, :url => url_for(page), :html => attributes,
:before => "Element.show('loader')", :success => "Element.hide('loader')", :before => "Element.show('loader')", :success => "Element.hide('loader')",
:method => :get :method => :get, :update => @options[:update]
else else
@template.link_to text, url_for(page), attributes @template.link_to text, url_for(page), attributes
end end