Second part of admin-namespace-reorder. Also renamed OrderGroup into Ordergroup. More view-sharing between groups is neccessary.
This commit is contained in:
parent
2d5dc03b90
commit
fadc951208
83 changed files with 410 additions and 518 deletions
69
app/controllers/admin/ordergroups_controller.rb
Normal file
69
app/controllers/admin/ordergroups_controller.rb
Normal 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
|
|
@ -1,6 +1,7 @@
|
|||
class Admin::UsersController < ApplicationController
|
||||
before_filter :authenticate_admin
|
||||
|
||||
filter_parameter_logging :password, :password_confirmation # do not log passwort parameters
|
||||
|
||||
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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Admin::WorkgroupsController < ApplicationController
|
||||
before_filter :authenticate_admin
|
||||
|
||||
def index
|
||||
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
|
||||
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
|
||||
|
||||
@total = Ordergroup.count(:conditions => conditions )
|
||||
@workgroups = Workgroup.paginate(:conditions => conditions, :page => params[:page],
|
||||
:per_page => @per_page, :order => 'name')
|
||||
|
||||
|
|
|
@ -1,235 +1,12 @@
|
|||
class AdminController < ApplicationController
|
||||
before_filter :authenticate_admin
|
||||
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
|
||||
@user = self.current_user
|
||||
@groups = Group.find(:all, :limit => 5, :order => 'created_on DESC')
|
||||
@users = User.find(:all, :limit => 5, :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'
|
||||
@groups = Group.find(:all, :limit => 10, :order => 'created_on DESC')
|
||||
@users = User.find(:all, :limit => 10, :order => 'created_on DESC')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -98,11 +98,11 @@ class Finance::BalancingController < ApplicationController
|
|||
end
|
||||
|
||||
# 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
|
||||
@result = GroupOrderArticleResult.new(params[:group_order_article_result])
|
||||
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
|
||||
unless @result.group_order_result = GroupOrderResult.find(:first,
|
||||
: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
|
||||
|
||||
# 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
|
||||
@order = Order.find(params[:id])
|
||||
end
|
||||
|
||||
# Balances the Order, Update of the OrderGroup.account_balances
|
||||
# Balances the Order, Update of the Ordergroup.account_balances
|
||||
def close
|
||||
@order = Order.find(params[:id])
|
||||
begin
|
||||
|
|
|
@ -22,8 +22,8 @@ class Finance::TransactionsController < ApplicationController
|
|||
|
||||
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
|
||||
|
||||
@total = OrderGroup.count(:conditions => conditions)
|
||||
@groups = OrderGroup.paginate :conditions => conditions, :page => params[:page], :per_page => @per_page, :order => sort
|
||||
@total = Ordergroup.count(:conditions => conditions)
|
||||
@groups = Ordergroup.paginate :conditions => conditions, :page => params[:page], :per_page => @per_page, :order => sort
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
@ -36,7 +36,7 @@ class Finance::TransactionsController < ApplicationController
|
|||
end
|
||||
|
||||
def list
|
||||
@group = OrderGroup.find(params[:id])
|
||||
@group = Ordergroup.find(params[:id])
|
||||
|
||||
if params['sort']
|
||||
sort = case params['sort']
|
||||
|
@ -69,12 +69,12 @@ class Finance::TransactionsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@group = OrderGroup.find(params[:id])
|
||||
@group = Ordergroup.find(params[:id])
|
||||
@financial_transaction = @group.financial_transactions.build
|
||||
end
|
||||
|
||||
def create
|
||||
@group = OrderGroup.find(params[:financial_transaction][:order_group_id])
|
||||
@group = Ordergroup.find(params[:financial_transaction][:ordergroup_id])
|
||||
amount = params[:financial_transaction][:amount]
|
||||
note = params[:financial_transaction][:note]
|
||||
begin
|
||||
|
@ -97,7 +97,7 @@ class Finance::TransactionsController < ApplicationController
|
|||
params[:financial_transactions].each do |trans|
|
||||
# ignore empty amount fields ...
|
||||
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
|
||||
flash[:notice] = 'Saved all transactions successfully'
|
||||
|
|
|
@ -112,11 +112,11 @@ class IndexController < ApplicationController
|
|||
end
|
||||
|
||||
# update the Group
|
||||
# only access to description for OrderGroups
|
||||
# only access to description for Ordergroups
|
||||
def updateGroup
|
||||
@group = Group.find(params[:id])
|
||||
authenticate_membership(@group)
|
||||
if @group.is_a?(OrderGroup)
|
||||
if @group.is_a?(Ordergroup)
|
||||
@group.update_attribute(:description, params[:group][:description])
|
||||
else
|
||||
@group.update_attributes(params[:group])
|
||||
|
@ -149,8 +149,8 @@ class IndexController < ApplicationController
|
|||
group = Group.find(params[:group])
|
||||
authenticate_membership(group)
|
||||
membership = Membership.find(params[:membership])
|
||||
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.
|
||||
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.
|
||||
flash[:error] = ERR_LAST_MEMBER
|
||||
else
|
||||
membership.destroy
|
||||
|
@ -196,7 +196,7 @@ class IndexController < ApplicationController
|
|||
# sort by ordergroups
|
||||
if params[:sort_by_ordergroups]
|
||||
@users = []
|
||||
OrderGroup.find(:all, :order => "name").each do |group|
|
||||
Ordergroup.find(:all, :order => "name").each do |group|
|
||||
group.users.each do |user|
|
||||
@users << user
|
||||
end
|
||||
|
@ -229,7 +229,7 @@ class IndexController < ApplicationController
|
|||
|
||||
# gives an overview for the workgroups and its members
|
||||
def workgroups
|
||||
@groups = Group.find :all, :conditions => "type != 'OrderGroup'", :order => "name"
|
||||
@groups = Group.find :all, :conditions => "type != 'Ordergroup'", :order => "name"
|
||||
end
|
||||
|
||||
# Invites a new user to join foodsoft in this group.
|
||||
|
|
|
@ -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.
|
||||
class OrderingController < ApplicationController
|
||||
# Security
|
||||
before_filter :ensureOrderGroupMember
|
||||
before_filter :ensureOrdergroupMember
|
||||
verify :method => :post, :only => [:saveOrder], :redirect_to => { :action => :index }
|
||||
|
||||
# Messages
|
||||
|
@ -33,7 +33,7 @@ class OrderingController < ApplicationController
|
|||
if !@order.current?
|
||||
flash[:notice] = ERROR_ALREADY_FINISHED
|
||||
redirect_to :action => 'index'
|
||||
elsif !(@order_group = @current_user.find_ordergroup)
|
||||
elsif !(@ordergroup = @current_user.find_ordergroup)
|
||||
flash[:notice] = ERROR_NO_ORDERGROUP
|
||||
redirect_to :controller => 'index'
|
||||
else
|
||||
|
@ -43,7 +43,7 @@ class OrderingController < ApplicationController
|
|||
@articles_by_category = @order.get_articles
|
||||
# save results of earlier orders in array
|
||||
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
|
||||
# Group has already ordered, so get the results...
|
||||
for article in @group_order.group_order_articles
|
||||
|
@ -54,10 +54,10 @@ class OrderingController < ApplicationController
|
|||
'tolerance_result' => result[:tolerance]}
|
||||
end
|
||||
@version = @group_order.lock_version
|
||||
@availableFunds = @order_group.getAvailableFunds(@group_order)
|
||||
@availableFunds = @ordergroup.getAvailableFunds(@group_order)
|
||||
else
|
||||
@version = 0
|
||||
@availableFunds = @order_group.getAvailableFunds
|
||||
@availableFunds = @ordergroup.getAvailableFunds
|
||||
end
|
||||
|
||||
# load prices ....
|
||||
|
@ -90,7 +90,7 @@ class OrderingController < ApplicationController
|
|||
if (!order.current?)
|
||||
flash[:error] = ERROR_ALREADY_FINISHED
|
||||
redirect_to :action => 'index'
|
||||
elsif !(order_group = @current_user.find_ordergroup)
|
||||
elsif !(ordergroup = @current_user.find_ordergroup)
|
||||
flash[:error] = ERROR_NO_ORDERGROUP
|
||||
redirect_to :controller => 'index'
|
||||
elsif (params[:total_balance].to_i < 0)
|
||||
|
@ -100,12 +100,12 @@ class OrderingController < ApplicationController
|
|||
begin
|
||||
Order.transaction do
|
||||
# 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
|
||||
raise ActiveRecord::StaleObjectError
|
||||
end
|
||||
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!
|
||||
end
|
||||
# Create/update GroupOrderArticles...
|
||||
|
@ -142,7 +142,7 @@ class OrderingController < ApplicationController
|
|||
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
|
||||
def my_order_result
|
||||
@order= Order.find(params[:id])
|
||||
|
@ -153,7 +153,7 @@ class OrderingController < ApplicationController
|
|||
@order_value= @groupOrderResult.price if @groupOrderResult
|
||||
@comments= @order.comments
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -211,9 +211,9 @@ class OrderingController < ApplicationController
|
|||
|
||||
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.
|
||||
def ensureOrderGroupMember
|
||||
def ensureOrdergroupMember
|
||||
!@current_user.find_ordergroup.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ class TasksController < ApplicationController
|
|||
|
||||
def index
|
||||
@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
|
||||
|
||||
def myTasks
|
||||
|
@ -109,7 +109,7 @@ class TasksController < ApplicationController
|
|||
# shows workgroup (normal group) to edit weekly_tasks_template
|
||||
def workgroup
|
||||
@group = Group.find(params[:id])
|
||||
if @group.is_a? OrderGroup
|
||||
if @group.is_a? Ordergroup
|
||||
flash[:error] = "Keine Arbeitsgruppe gefunden"
|
||||
redirect_to :action => "index"
|
||||
end
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
module Admin::MembershipsHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module Admin::UsersHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module AdminHelper
|
||||
end
|
|
@ -15,17 +15,27 @@ module ApplicationHelper
|
|||
|
||||
# Creates ajax-controlled-links for pagination
|
||||
# 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
|
||||
previous_label = '« ' + _('Previous')
|
||||
next_label = _('Next') + ' »'
|
||||
# Merge other url-options for will_paginate
|
||||
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
|
||||
|
||||
# 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 = []
|
||||
per_page_options.each do |per_page|
|
||||
unless per_page == current
|
||||
|
@ -34,7 +44,7 @@ module ApplicationHelper
|
|||
{ :url => { :action => action, :params => {:per_page => per_page}},
|
||||
:before => "Element.show('loader')",
|
||||
:success => "Element.hide('loader')",
|
||||
:method => :get } )
|
||||
:method => :get, :update => update } )
|
||||
else
|
||||
links << per_page
|
||||
end
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
module Finance::OrdersHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module Finance::TransactionsHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module FinanceHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module GroupsHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module IndexHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module LoginHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module MessagesHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module OrderingHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module SuppliersHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module UsersHelper
|
||||
end
|
|
@ -1,23 +1,23 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
# Schema version: 20090114101610
|
||||
#
|
||||
# Table name: financial_transactions
|
||||
#
|
||||
# id :integer(4) not null, primary key
|
||||
# order_group_id :integer(4) default(0), not null
|
||||
# amount :decimal(8, 2) default(0.0), not null
|
||||
# note :text default(""), not null
|
||||
# user_id :integer(4) default(0), not null
|
||||
# created_on :datetime not null
|
||||
# id :integer(4) not null, primary key
|
||||
# ordergroup_id :integer(4) default(0), not null
|
||||
# amount :decimal(8, 2) default(0.0), not null
|
||||
# note :text default(""), not null
|
||||
# user_id :integer(4) default(0), not null
|
||||
# created_on :datetime not null
|
||||
#
|
||||
|
||||
# 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
|
||||
belongs_to :order_group
|
||||
belongs_to :ordergroup
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :note, :user_id, :order_group_id
|
||||
validates_presence_of :note, :user_id, :ordergroup_id
|
||||
validates_numericality_of :amount
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
|
|
|
@ -41,11 +41,11 @@ class Group < ActiveRecord::Base
|
|||
memberships.find_by_user_id(user.id)
|
||||
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
|
||||
nonMembers = Array.new
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
# get all groups, which are NOT OrderGroups
|
||||
# get all groups, which are NOT Ordergroups
|
||||
def self.workgroups
|
||||
Workgroup.all
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# validates uniqueness of the Group.name. Checks groups and order_groups
|
||||
# validates uniqueness of the Group.name. Checks groups and ordergroups
|
||||
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
|
||||
|
||||
# add validation check on update
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
# Schema version: 20090114101610
|
||||
#
|
||||
# Table name: group_orders
|
||||
#
|
||||
# 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
|
||||
# price :decimal(8, 2) default(0.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
|
||||
#
|
||||
|
||||
# A GroupOrder represents an Order placed by an OrderGroup.
|
||||
# A GroupOrder represents an Order placed by an Ordergroup.
|
||||
class GroupOrder < ActiveRecord::Base
|
||||
|
||||
belongs_to :order
|
||||
belongs_to :order_group
|
||||
belongs_to :ordergroup
|
||||
has_many :group_order_articles, :dependent => :destroy
|
||||
has_many :order_articles, :through => :group_order_articles
|
||||
has_many :group_order_article_results
|
||||
belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id"
|
||||
|
||||
validates_presence_of :order_id
|
||||
validates_presence_of :order_group_id
|
||||
validates_presence_of :ordergroup_id
|
||||
validates_presence_of :updated_by
|
||||
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.
|
||||
# This will be the maximum value of a current order
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -94,7 +94,7 @@ class GroupOrderArticle < ActiveRecord::Base
|
|||
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
|
||||
#
|
||||
# See description of the ordering algorithm in the general application documentation for details.
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
# 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
|
||||
|
||||
belongs_to :order
|
||||
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
|
||||
total = 0
|
||||
group_order_article_results.each do |result|
|
||||
|
|
|
@ -95,7 +95,7 @@ class Message < ActiveRecord::Base
|
|||
# Example:
|
||||
# Message.from_template(
|
||||
# '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}"}
|
||||
# ).save!
|
||||
def self.from_template(template, vars, attributes)
|
||||
|
|
|
@ -24,7 +24,7 @@ class Order < ActiveRecord::Base
|
|||
has_many :order_articles, :dependent => :destroy
|
||||
has_many :articles, :through => :order_articles
|
||||
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 :group_order_results, :dependent => :destroy
|
||||
belongs_to :supplier
|
||||
|
@ -96,10 +96,10 @@ class Order < ActiveRecord::Base
|
|||
find :all, :conditions => ['booked = ?', true], :order => 'ends desc', :include => :supplier
|
||||
end
|
||||
|
||||
# search GroupOrder of given OrderGroup
|
||||
# search GroupOrder of given Ordergroup
|
||||
def group_order(ordergroup)
|
||||
unless finished
|
||||
return group_orders.detect {|o| o.order_group_id == ordergroup.id}
|
||||
return group_orders.detect {|o| o.ordergroup_id == ordergroup.id}
|
||||
else
|
||||
return group_order_results.detect {|o| o.group_name == ordergroup.name}
|
||||
end
|
||||
|
@ -180,7 +180,7 @@ class Order < ActiveRecord::Base
|
|||
#saves ordergroups, which take part in this order
|
||||
self.group_orders.each do |go|
|
||||
group_order_result = GroupOrderResult.create!(:order => self,
|
||||
:group_name => go.order_group.name,
|
||||
:group_name => go.ordergroup.name,
|
||||
:price => go.price)
|
||||
end
|
||||
# saves every article of the order
|
||||
|
@ -203,7 +203,7 @@ class Order < ActiveRecord::Base
|
|||
oa.group_order_articles.each do |goa|
|
||||
result = goa.orderResult
|
||||
# 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_result => group_order_result,
|
||||
:quantity => result[:total],
|
||||
|
@ -274,15 +274,15 @@ class Order < ActiveRecord::Base
|
|||
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)
|
||||
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 do
|
||||
# update OrderGroups
|
||||
# update Ordergroups
|
||||
group_order_results.each do |result|
|
||||
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
|
||||
self.booked = true
|
||||
self.updated_by = user
|
||||
|
@ -319,9 +319,9 @@ class Order < ActiveRecord::Base
|
|||
def notifyOrderFinished
|
||||
# Loop through GroupOrderResults for this order:
|
||||
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:
|
||||
users = order_group.users.reject{|u| u.settings["notify.orderFinished"] != '1'}
|
||||
users = ordergroup.users.reject{|u| u.settings["notify.orderFinished"] != '1'}
|
||||
unless (users.empty?)
|
||||
# Assemble the order message text:
|
||||
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
|
||||
Message.from_template(
|
||||
'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}"}
|
||||
).save!
|
||||
end
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
# 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_updated (datetime)
|
||||
# * actual_size (int) : how many persons are ordering through the OrderGroup
|
||||
class OrderGroup < Group
|
||||
# * actual_size (int) : how many persons are ordering through the Ordergroup
|
||||
class Ordergroup < Group
|
||||
has_many :financial_transactions, :dependent => :destroy
|
||||
has_many :group_orders, :dependent => :destroy
|
||||
has_many :orders, :through => :group_orders
|
||||
|
@ -44,9 +44,9 @@ class OrderGroup < Group
|
|||
# messages
|
||||
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
|
||||
ordergroup = OrderGroup.find(self.id)
|
||||
ordergroup = Ordergroup.find(self.id)
|
||||
unless (ordergroup.name == self.name) || ordergroup.group_order_results.empty?
|
||||
# rename all finished orders
|
||||
for result in ordergroup.group_order_results
|
||||
|
@ -59,7 +59,7 @@ class OrderGroup < Group
|
|||
# * excludeGroupOrder (GroupOrder): exclude this GroupOrder from the calculation
|
||||
def getAvailableFunds(excludeGroupOrder = nil)
|
||||
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
|
||||
funds -= order.price
|
||||
end
|
||||
|
@ -70,11 +70,11 @@ class OrderGroup < Group
|
|||
return funds
|
||||
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.
|
||||
def addFinancialTransaction(amount, note, user)
|
||||
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!
|
||||
self.account_balance += trans.amount
|
||||
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?
|
||||
end
|
||||
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?
|
||||
end
|
||||
|
|
@ -23,7 +23,7 @@ require 'digest/sha1'
|
|||
class User < ActiveRecord::Base
|
||||
has_many :memberships, :dependent => :destroy
|
||||
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 :tasks, :through => :assignments
|
||||
|
||||
|
@ -146,10 +146,10 @@ class User < ActiveRecord::Base
|
|||
groups.detect {|group| group.role_orders?}
|
||||
end
|
||||
|
||||
# Returns the user's OrderGroup or nil if none found.
|
||||
# Returns the user's Ordergroup or nil if none found.
|
||||
def find_ordergroup
|
||||
order_groups.first
|
||||
#groups.find(:first, :conditions => "type = 'OrderGroup'")
|
||||
ordergroups.first
|
||||
#groups.find(:first, :conditions => "type = 'Ordergroup'")
|
||||
end
|
||||
|
||||
# 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}
|
||||
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()
|
||||
self.groups.find(:all, :conditions => {:type => ""})
|
||||
end
|
||||
|
|
|
@ -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") |
|
|
@ -37,14 +37,14 @@
|
|||
<% for group in @groups %>
|
||||
<tr class="<%= cycle('even','odd', :name => 'groups') %>">
|
||||
<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>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<br />
|
||||
<%= link_to 'Alle Gruppen', :action => 'listGroups' %> |
|
||||
<%= link_to "Neue Bestellgruppe", :action => "newOrderGroup" %> |
|
||||
<%= link_to "Neue Bestellgruppe", :action => "newOrdergroup" %> |
|
||||
<%= link_to "Neue Gruppe", :action => "newGroup" %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<%= render :partial => 'groups/edit_members' %>
|
||||
<p style="clear:both"><%= link_to 'Gruppenübersicht', :action => 'listGroups' %></p>
|
|
@ -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>
|
45
app/views/admin/ordergroups/_form.html.haml
Normal file
45
app/views/admin/ordergroups/_form.html.haml
Normal 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
|
24
app/views/admin/ordergroups/_ordergroups.html.haml
Normal file
24
app/views/admin/ordergroups/_ordergroups.html.haml
Normal 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) |
|
4
app/views/admin/ordergroups/edit.html.haml
Normal file
4
app/views/admin/ordergroups/edit.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- title "Bestellgruppe bearbeiten"
|
||||
|
||||
.edit_form{:style => "width:50em"}
|
||||
= render :partial => 'form'
|
|
@ -1,14 +1,17 @@
|
|||
%h1=_ 'Groups'
|
||||
- title "Bestellgruppen"
|
||||
|
||||
%p
|
||||
%i
|
||||
Hier kannst du
|
||||
= link_to 'neue Gruppen', :action => 'newGroup'
|
||||
und
|
||||
= link_to 'neue Bestellgruppen', :action => 'newOrderGroup'
|
||||
= link_to 'neue Bestellgruppen', new_admin_ordergroup_path
|
||||
anlegen, Gruppen bearbeiten und löschen.
|
||||
|
||||
%p
|
||||
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.
|
||||
.left_column{:style => "width:100%"}
|
||||
.box_title
|
||||
|
@ -16,17 +19,16 @@
|
|||
.column_content
|
||||
#group_filter
|
||||
%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 )
|
||||
|
||||
= observe_field 'query', :frequency => 2, |
|
||||
:before => "Element.show('loader')", |
|
||||
:success => "Element.hide('loader')", |
|
||||
:url => {:action => 'listGroups'}, |
|
||||
:with => 'query' |
|
||||
#table
|
||||
= render :partial => "listGroups"
|
||||
- if @current_user.role_admin?
|
||||
= link_to 'Neue Gruppe', :action => 'newGroup'
|
||||
|
|
||||
= link_to 'Neue Bestellgruppe', :action => 'newOrderGroup'
|
||||
:update => "ordergroups", |
|
||||
:url => admin_ordergroups_path, |
|
||||
:with => 'query', |
|
||||
:method => :get |
|
||||
#ordergroups
|
||||
= render :partial => "ordergroups"
|
||||
= link_to 'Neue Arbeits', new_admin_ordergroup_path
|
3
app/views/admin/ordergroups/memberships.html.haml
Normal file
3
app/views/admin/ordergroups/memberships.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
= render :partial => 'admin/memberships/edit_members'
|
||||
%p{ :style => "clear:both" }
|
||||
= link_to 'Gruppenübersicht', admin_ordergroups_path
|
4
app/views/admin/ordergroups/new.html.haml
Normal file
4
app/views/admin/ordergroups/new.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- title "Bestellgruppe anlegen"
|
||||
|
||||
.edit_form{:style => "width:50em"}
|
||||
= render :partial => 'form'
|
42
app/views/admin/ordergroups/show.html.haml
Normal file
42
app/views/admin/ordergroups/show.html.haml
Normal 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
|
|
@ -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"
|
|
@ -2,10 +2,10 @@
|
|||
%table{:style => "width:100%"}
|
||||
%tr
|
||||
%td
|
||||
= pagination_links_remote @workgroups
|
||||
= pagination_links_remote @workgroups, { :update => "workgroups" }
|
||||
%td{:style => "text-align:right"}
|
||||
- if @workgroups.size > 20
|
||||
= items_per_page
|
||||
- if @total.size > 20
|
||||
= items_per_page :update => "workgroups"
|
||||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
|
|
|
@ -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
|
||||
%thead
|
||||
%tr
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
%table{:style => "width:100%"}
|
||||
%tr
|
||||
%td
|
||||
= pagination_links_remote @articles, @per_page, {:sort => params[:sort]}
|
||||
= pagination_links_remote @articles, :params => {:sort => params[:sort]}
|
||||
%td{:style => "text-align:right"}
|
||||
- if @total > 30
|
||||
= items_per_page([30, 100, 500])
|
||||
= items_per_page :per_page_options => [30, 100, 500]
|
||||
|
||||
%table#articles_table.list.articles
|
||||
%thead
|
||||
|
@ -49,7 +49,7 @@
|
|||
|
||||
= hidden_field_tag 'supplier', @supplier.id
|
||||
%p
|
||||
= pagination_links_remote @articles, @per_page, {:sort => params[:sort]}
|
||||
= pagination_links_remote @articles, :params => {:sort => params[:sort]}
|
||||
|
||||
:plain
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
= error_messages_for 'result'
|
||||
%p
|
||||
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
|
||||
Menge:
|
||||
= @form.text_field "quantity", :size => 5
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
- @financial_transactions.each do |ft|
|
||||
%tr{:class => cycle("even","odd", :name => "financial_transaction")}
|
||||
%td= format_date(ft.created_on)
|
||||
%td= ft.order_group.name
|
||||
%td= ft.ordergroup.name
|
||||
%td{:style => "width:50%"}=h ft.note
|
||||
%td{:style => "color:#{ft.amount < 0 ? 'red' : 'black'}", :class => "currency"}= number_to_currency(ft.amount)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<p>Anzahl gefundener Transaktionen: <b><%= @total %></b></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>
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%tr.transaction
|
||||
%td
|
||||
%select{:name => 'financial_transactions[][order_group_id]'}
|
||||
= options_for_select OrderGroup.find(:all, :order => 'name').collect { |g| [ g.name, g.id ] }
|
||||
%select{:name => 'financial_transactions[][ordergroup_id]'}
|
||||
= options_for_select Ordergroup.find(:all, :order => 'name').collect { |g| [ g.name, g.id ] }
|
||||
%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")}
|
|
@ -5,7 +5,7 @@
|
|||
%table{:style => "width:100%"}
|
||||
%tr
|
||||
%td
|
||||
= pagination_links_remote @groups, @per_page, {:sort => params[:sort]}
|
||||
= pagination_links_remote @groups, :params => {:sort => params[:sort]}
|
||||
%td{:style => "text-align:right"}
|
||||
- if @total > 20
|
||||
= items_per_page
|
||||
|
|
|
@ -22,4 +22,4 @@
|
|||
= render :partial => "ordergroups"
|
||||
%br/
|
||||
- if @current_user.role_admin?
|
||||
= link_to _("New ordergroup"), :controller => 'admin', :action => 'newOrderGroup'
|
||||
= link_to _("New ordergroup"), :controller => 'admin', :action => 'newOrdergroup'
|
|
@ -3,7 +3,7 @@
|
|||
.edit_form{ :style => "width:30em" }
|
||||
- form_for(@financial_transaction, :url => { :action => 'create' }) do |f|
|
||||
= f.error_messages
|
||||
= f.hidden_field :order_group_id
|
||||
= f.hidden_field :ordergroup_id
|
||||
%p
|
||||
Group:
|
||||
%b=h @group.name
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
%b= _("Note") + ":"
|
||||
= text_field_tag "note"
|
||||
%p
|
||||
%table#OrderGroups{:style => "width:20em"}
|
||||
%table#Ordergroups{:style => "width:20em"}
|
||||
%tr
|
||||
%th=_ "Ordergroup"
|
||||
%th=_ "Amount"
|
||||
= render :partial => 'order_group', :collection => [1, 2, 3]
|
||||
= render :partial => 'ordergroup', :collection => [1, 2, 3]
|
||||
|
||||
%p
|
||||
= link_to_function _("Add another ordergroup") do |page|
|
||||
- page.insert_html :bottom, :OrderGroups, :partial => 'order_group'
|
||||
- page.insert_html :bottom, :Ordergroups, :partial => 'ordergroup'
|
||||
%p
|
||||
= submit_tag _("Save")
|
||||
|
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<!--[form:group]-->
|
||||
%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
|
||||
%label{:for => "group_name"} Names
|
||||
%br/
|
||||
|
@ -11,7 +11,7 @@
|
|||
%label{:for => "group_description"} Beschreibung
|
||||
%br/
|
||||
= 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
|
||||
%label{:for => "group_actual_size"} Aktuelle Gruppengröße
|
||||
%br/
|
||||
|
@ -40,7 +40,7 @@
|
|||
%td
|
||||
%label{:for => "group_role_orders"} Bestellungsverwaltung
|
||||
%td= check_box 'group', 'role_orders'
|
||||
-unless @group.is_a?(OrderGroup)
|
||||
-unless @group.is_a?(Ordergroup)
|
||||
%div{:style => "clear:both"}
|
||||
%h3
|
||||
Wöchentliche Jobs definieren?
|
||||
|
|
|
@ -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}')"
|
||||
%ul{:style => "display:none"}[group]
|
||||
- for user in group.users.find :all, :order => "nick"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
- for user in @users
|
||||
%tr{:class => cycle('even','odd', :name => 'users')}
|
||||
- groups = user.groups
|
||||
- ordergroup = groups.detect { |group| group.is_a?(OrderGroup) }
|
||||
- workgroups = groups.select { |group| !group.is_a?(OrderGroup) }.collect(&:name)
|
||||
- ordergroup = groups.detect { |group| group.is_a?(Ordergroup) }
|
||||
- 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=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'
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
%li= link_to _("Write message"), :controller => "messages", :action => "new"
|
||||
|
||||
// Orders
|
||||
- hasOrderGroup = !@current_user.find_ordergroup.nil?
|
||||
- hasOrdergroup = !@current_user.find_ordergroup.nil?
|
||||
- hasOrdersRole = @current_user.role_orders?
|
||||
- if hasOrderGroup || hasOrdersRole
|
||||
- if hasOrdergroup || hasOrdersRole
|
||||
%li
|
||||
= _("Orders")
|
||||
%ul
|
||||
- if hasOrderGroup
|
||||
- if hasOrdergroup
|
||||
%li= link_to _('Order summary'), :controller => "ordering"
|
||||
- if hasOrdersRole
|
||||
%li= link_to _('Finish order'), :controller => 'orders'
|
||||
|
@ -39,5 +39,5 @@
|
|||
%li
|
||||
= _('Administration')
|
||||
%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"
|
|
@ -38,7 +38,7 @@
|
|||
// Current orders
|
||||
= render :partial => 'ordering/currentOrders'
|
||||
|
||||
// OrderGroup overview
|
||||
// Ordergroup overview
|
||||
.box_title
|
||||
%h2=_ "My ordergroup"
|
||||
.column_content
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%= render :partial => 'groups/edit_members' %>
|
||||
<p style="clear:both">
|
||||
<% if @group.is_a?(OrderGroup) -%>
|
||||
<% if @group.is_a?(Ordergroup) -%>
|
||||
<%= link_to "Zurück", :action => "myOrdergroup" %>
|
||||
<% else -%>
|
||||
<%= link_to 'Zurück', :action => 'showGroup', :id => @group %>
|
||||
|
|
|
@ -21,7 +21,7 @@ You can also see in which workgroups you are.
|
|||
<% for membership in Membership.find_all_by_user_id(@user.id) %>
|
||||
<p>
|
||||
<%= 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 %>)
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
%h1
|
||||
=h @group.is_a?(OrderGroup) ? "Bestellgruppe:" : "Gruppe:"
|
||||
=h @group.is_a?(Ordergroup) ? "Bestellgruppe:" : "Gruppe:"
|
||||
=h @group.name
|
||||
= render :partial => "showGroup"
|
||||
|
||||
- unless @group.is_a?(OrderGroup)
|
||||
- unless @group.is_a?(Ordergroup)
|
||||
%p{:style => "clear:both"}
|
||||
= link_to "alle Arbeitsgruppen", :action => "workgroups"
|
|
@ -7,7 +7,7 @@
|
|||
{ :name => "Workgroups", :url => "/index/workgroups"},
|
||||
{ :name => "Tasks", :url => "/tasks"},
|
||||
{ :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}
|
||||
]
|
||||
},
|
||||
|
@ -36,11 +36,12 @@
|
|||
]
|
||||
},
|
||||
{ :name => "Administration", :url => "/admin",
|
||||
:active => ["admin", "admin/users", "admin/workgroups"],
|
||||
:active => ["admin", "admin/users", "admin/ordergroups", "admin/workgroups"],
|
||||
:access? => (u.role_admin?),
|
||||
:subnav => [
|
||||
{ :name => "Users", :url => "/admin/users" },
|
||||
{ :name => "Workgroups", :url => "/admin/workgroups" }
|
||||
{ :name => "Users", :url => admin_users_path },
|
||||
{ :name => "Ordergroups", :url => admin_ordergroups_path },
|
||||
{ :name => "Workgroups", :url => admin_workgroups_path }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- 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
|
||||
%thead
|
||||
%tr
|
||||
|
@ -16,7 +16,7 @@
|
|||
%td= format_time(order.order.ends)
|
||||
%td{:class => "currency"}= number_to_currency(order.price)
|
||||
- else
|
||||
// check if the OrderGroup has ordered
|
||||
// check if the Ordergroup has ordered
|
||||
- if groupOrder = order.group_order(@orderGroup)
|
||||
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
|
||||
%td= link_to order.name, :action => 'my_order_result', :id => order
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
%td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order
|
||||
%td=h order.supplier.name
|
||||
%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
|
||||
%td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})"
|
||||
%td= number_to_currency(groupOrder.price)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
%td= format_time(order.order.ends)
|
||||
%td{:class => "currency"}= number_to_currency(order.price)
|
||||
- else
|
||||
// check if the OrderGroup has ordered
|
||||
// check if the Ordergroup has ordered
|
||||
- if groupOrder = order.group_order(@orderGroup)
|
||||
%tr{:class=> cycle('even', 'odd', :name => 'finishedOrders')}
|
||||
%td= link_to order.name, :action => 'my_order_result', :id => order
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%h1= _('Order Overview')
|
||||
|
||||
// OrderGroups Account Balance
|
||||
// Ordergroups Account Balance
|
||||
.left_column{:style => "width:26%"}
|
||||
.box_title
|
||||
%h2=h @orderGroup.name
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
<td style="text-align:left;"><%= link_to_top %></td>
|
||||
|
@ -157,7 +157,7 @@
|
|||
</tfoot>
|
||||
</table>
|
||||
</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 %>"/>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -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%"}
|
||||
%thead
|
||||
%tr
|
||||
|
|
|
@ -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)]
|
||||
|
||||
for article in current_articles
|
||||
# get the OrderGroupResult for this article
|
||||
# get the OrdergroupResult for this article
|
||||
result = GroupOrderArticleResult.find(:first,
|
||||
: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)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
= _("Groups ordered") + ":"
|
||||
%b= @group_orders.size
|
||||
- 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
|
||||
= "[#{@group_orders.collect{|g| g.group_name}.join(', ')}]" unless @group_orders.empty?
|
||||
%p
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
%label{:for => "task_group"}
|
||||
%b=_ 'Group'
|
||||
%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
|
||||
%label{:for => "task_due_date"}
|
||||
%b=_ 'Due date'
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
%li
|
||||
=_ 'Group tasks'
|
||||
%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
|
|
@ -3,8 +3,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.namespace :admin do |admin|
|
||||
admin.resources :users
|
||||
admin.resources :workgroups, :member => { :memberships => :get }
|
||||
admin.resources :ordergroups, :member => { :memberships => :get }
|
||||
admin.connect 'memberships/:action/:id', :controller => 'memberships'
|
||||
admin.add_member 'add_member', :controller => 'memberships', :action => 'add_member'
|
||||
end
|
||||
|
||||
map.namespace :finance do |finance|
|
||||
|
@ -18,7 +18,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
:collection => { :shared_suppliers => :get }
|
||||
|
||||
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'
|
||||
|
||||
|
|
15
db/migrate/20090114101610_rename_ordergroups.rb
Normal file
15
db/migrate/20090114101610_rename_ordergroups.rb
Normal 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
|
16
db/schema.rb
16
db/schema.rb
|
@ -9,7 +9,7 @@
|
|||
#
|
||||
# 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|
|
||||
t.string "name", :default => "", :null => false
|
||||
|
@ -78,11 +78,11 @@ ActiveRecord::Schema.define(:version => 20090113111624) do
|
|||
end
|
||||
|
||||
create_table "financial_transactions", :force => true do |t|
|
||||
t.integer "order_group_id", :default => 0, :null => false
|
||||
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.text "note", :null => false
|
||||
t.integer "user_id", :default => 0, :null => false
|
||||
t.datetime "created_on", :null => false
|
||||
t.integer "ordergroup_id", :default => 0, :null => false
|
||||
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.text "note", :null => false
|
||||
t.integer "user_id", :default => 0, :null => false
|
||||
t.datetime "created_on", :null => false
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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.decimal "price", :precision => 8, :scale => 2, :default => 0.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
|
||||
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|
|
||||
t.string "type", :default => "", :null => false
|
||||
|
|
2
test/fixtures/articles.yml
vendored
2
test/fixtures/articles.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090113111624
|
||||
# Schema version: 20090114101610
|
||||
#
|
||||
# Table name: articles
|
||||
#
|
||||
|
|
14
test/fixtures/financial_transactions.yml
vendored
14
test/fixtures/financial_transactions.yml
vendored
|
@ -1,14 +1,14 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
# Schema version: 20090114101610
|
||||
#
|
||||
# Table name: financial_transactions
|
||||
#
|
||||
# id :integer(4) not null, primary key
|
||||
# order_group_id :integer(4) default(0), not null
|
||||
# amount :decimal(8, 2) default(0.0), not null
|
||||
# note :text default(""), not null
|
||||
# user_id :integer(4) default(0), not null
|
||||
# created_on :datetime not null
|
||||
# id :integer(4) not null, primary key
|
||||
# ordergroup_id :integer(4) default(0), not null
|
||||
# amount :decimal(8, 2) default(0.0), not null
|
||||
# note :text default(""), not null
|
||||
# user_id :integer(4) default(0), not null
|
||||
# created_on :datetime not null
|
||||
#
|
||||
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
|
4
test/fixtures/groups.yml
vendored
4
test/fixtures/groups.yml
vendored
|
@ -27,11 +27,11 @@
|
|||
first:
|
||||
id: 1
|
||||
name: Order Group 1
|
||||
type: OrderGroup
|
||||
type: Ordergroup
|
||||
another:
|
||||
id: 2
|
||||
name: Order Group 2
|
||||
type: OrderGroup
|
||||
type: Ordergroup
|
||||
admins:
|
||||
id: 3
|
||||
name: Administrators
|
||||
|
|
2
test/fixtures/suppliers.yml
vendored
2
test/fixtures/suppliers.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090113111624
|
||||
# Schema version: 20090114101610
|
||||
#
|
||||
# Table name: suppliers
|
||||
#
|
||||
|
|
8
test/functional/admin/ordergroups_controller_test.rb
Normal file
8
test/functional/admin/ordergroups_controller_test.rb
Normal 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
|
|
@ -34,7 +34,8 @@ module WillPaginate
|
|||
:page_links => true,
|
||||
:container => true,
|
||||
# bennis hack for ajax-support
|
||||
:remote => false
|
||||
:remote => false,
|
||||
:update => nil,
|
||||
}
|
||||
mattr_reader :pagination_options
|
||||
|
||||
|
@ -303,7 +304,7 @@ module WillPaginate
|
|||
if @options[:remote] == true
|
||||
@template.link_to_remote text, :url => url_for(page), :html => attributes,
|
||||
:before => "Element.show('loader')", :success => "Element.hide('loader')",
|
||||
:method => :get
|
||||
:method => :get, :update => @options[:update]
|
||||
else
|
||||
@template.link_to text, url_for(page), attributes
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue