diff --git a/app/controllers/foodcoop/ordergroups_controller.rb b/app/controllers/foodcoop/ordergroups_controller.rb new file mode 100644 index 00000000..19ccae3f --- /dev/null +++ b/app/controllers/foodcoop/ordergroups_controller.rb @@ -0,0 +1,29 @@ +class Foodcoop::OrdergroupsController < ApplicationController + + 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 (params[:only_active].to_i == 1) + if (! params[:query].blank?) + conditions = ["orders.starts >= ? AND name LIKE ?", Time.now.months_ago(3), "%#{params[:query]}%"] + else + conditions = ["orders.starts >= ?", Time.now.months_ago(3)] + end + else + # if somebody uses the search field: + conditions = ["name LIKE ?", "%#{params[:query]}%"] unless params[:query].blank? + end + + @total = Ordergroup.count(:conditions => conditions, :include => "orders") + @ordergroups = Ordergroup.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "name", :include => "orders") + + respond_to do |format| + format.html # index.html.erb + format.js { render :partial => "ordergroups" } + end + end +end diff --git a/app/controllers/foodcoop_controller.rb b/app/controllers/foodcoop_controller.rb index 18097da4..0c22d44d 100644 --- a/app/controllers/foodcoop_controller.rb +++ b/app/controllers/foodcoop_controller.rb @@ -44,34 +44,6 @@ class FoodcoopController < ApplicationController @groups = Workgroup.find :all, :order => "name" end - def ordergroups - #@order_groups = Ordergroup.find :all, :order => "name" - 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 (params[:only_active].to_i == 1) - if (! params[:query].blank?) - conditions = ["orders.starts >= ? AND name LIKE ?", Time.now.months_ago(3), "%#{params[:query]}%"] - else - conditions = ["orders.starts >= ?", Time.now.months_ago(3)] - end - else - # if somebody uses the search field: - conditions = ["name LIKE ?", "%#{params[:query]}%"] unless params[:query].blank? - end - - @total = Ordergroup.count(:conditions => conditions, :include => "orders") - @ordergroups = Ordergroup.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "name", :include => "orders") - - respond_to do |format| - format.html # index.html.erb - format.js { render :partial => "ordergroups" } - end - end - def group end diff --git a/app/views/foodcoop/_ordergroups.html.haml b/app/views/foodcoop/ordergroups/_ordergroups.html.haml similarity index 100% rename from app/views/foodcoop/_ordergroups.html.haml rename to app/views/foodcoop/ordergroups/_ordergroups.html.haml diff --git a/app/views/foodcoop/ordergroups.html.haml b/app/views/foodcoop/ordergroups/index.html.haml similarity index 100% rename from app/views/foodcoop/ordergroups.html.haml rename to app/views/foodcoop/ordergroups/index.html.haml diff --git a/app/views/layouts/_main_tabnav.html.erb b/app/views/layouts/_main_tabnav.html.erb index 4799caaf..c6822a2c 100644 --- a/app/views/layouts/_main_tabnav.html.erb +++ b/app/views/layouts/_main_tabnav.html.erb @@ -8,7 +8,7 @@ { :name => "Mein Profil", :url => "/home/profile"} ] }, - { :name => "Foodcoop", :url => "/tasks", :active => ["foodcoop", "tasks", "messages"], + { :name => "Foodcoop", :url => "/tasks", :active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups"], :subnav => [ { :name => "Mitglieder", :url => "/foodcoop/members"}, { :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"}, diff --git a/app/views/ordergroups/edit.html.erb b/app/views/ordergroups/edit.html.erb new file mode 100644 index 00000000..a7fd7911 --- /dev/null +++ b/app/views/ordergroups/edit.html.erb @@ -0,0 +1,88 @@ +<% title "Edit Ordergroup" %> + +<% form_for @ordergroup do |f| %> + <%= f.error_messages %> +
+ <%= f.label :type %>
+ <%= f.text_field :type %>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+ <%= f.label :description %>
+ <%= f.text_field :description %>
+
+ <%= f.label :account_balance %>
+ <%= f.text_field :account_balance %>
+
+ <%= f.label :account_updated %>
+ <%= f.datetime_select :account_updated %>
+
+ <%= f.label :created_on %>
+ <%= f.datetime_select :created_on %>
+
+ <%= f.label :role_admin %>
+ <%= f.check_box :role_admin %>
+
+ <%= f.label :role_suppliers %>
+ <%= f.check_box :role_suppliers %>
+
+ <%= f.label :role_article_meta %>
+ <%= f.check_box :role_article_meta %>
+
+ <%= f.label :role_finance %>
+ <%= f.check_box :role_finance %>
+
+ <%= f.label :role_orders %>
+ <%= f.check_box :role_orders %>
+
+ <%= f.label :weekly_task %>
+ <%= f.check_box :weekly_task %>
+
+ <%= f.label :weekday %>
+ <%= f.text_field :weekday %>
+
+ <%= f.label :task_name %>
+ <%= f.text_field :task_name %>
+
+ <%= f.label :task_description %>
+ <%= f.text_field :task_description %>
+
+ <%= f.label :task_required_users %>
+ <%= f.text_field :task_required_users %>
+
+ <%= f.label :deleted_at %>
+ <%= f.datetime_select :deleted_at %>
+
+ <%= f.label :contact_person %>
+ <%= f.text_field :contact_person %>
+
+ <%= f.label :contact_phone %>
+ <%= f.text_field :contact_phone %>
+
+ <%= f.label :contact_address %>
+ <%= f.text_field :contact_address %>
+
<%= f.submit "Submit" %>
+<% end %> + + diff --git a/app/views/ordergroups/index.html.erb b/app/views/ordergroups/index.html.erb new file mode 100644 index 00000000..fca03433 --- /dev/null +++ b/app/views/ordergroups/index.html.erb @@ -0,0 +1,52 @@ +<% title "Ordergroups" %> + +Type | +Name | +Description | +Account Balance | +Account Updated | +Created On | +Role Admin | +Role Suppliers | +Role Article Meta | +Role Finance | +Role Orders | +Weekly Task | +Weekday | +Task Name | +Task Description | +Task Required Users | +Deleted At | +Contact Person | +Contact Phone | +Contact Address | +|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%=h ordergroup.type %> | +<%=h ordergroup.name %> | +<%=h ordergroup.description %> | +<%=h ordergroup.account_balance %> | +<%=h ordergroup.account_updated %> | +<%=h ordergroup.created_on %> | +<%=h ordergroup.role_admin %> | +<%=h ordergroup.role_suppliers %> | +<%=h ordergroup.role_article_meta %> | +<%=h ordergroup.role_finance %> | +<%=h ordergroup.role_orders %> | +<%=h ordergroup.weekly_task %> | +<%=h ordergroup.weekday %> | +<%=h ordergroup.task_name %> | +<%=h ordergroup.task_description %> | +<%=h ordergroup.task_required_users %> | +<%=h ordergroup.deleted_at %> | +<%=h ordergroup.contact_person %> | +<%=h ordergroup.contact_phone %> | +<%=h ordergroup.contact_address %> | +<%= link_to "Edit", edit_ordergroup_path(ordergroup) %> | +