diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index c26719056..3e57f4945 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -5,9 +5,19 @@ class StatisticsController < ApplicationController before_filter :get_date, :only => [:index, :new, :edit] def index - @statistics = Statistic.all - + if params[:sub_category_id].present? + @statistics = Statistic.where(:sub_category_id => params[:sub_category_id]) + else + @statistics = Statistic.all + end + @statistics_count = @statistics.count + @limit = 10 + @is_remote = true + @statistics_pages = Paginator.new @statistics_count, @limit, params['page'] || 1 + @offset ||= @statistics_pages.offset + @statistics = paginateHelper @statistics, @limit respond_to do |format| + format.js format.html # index.html.erb format.json { render json: @statistics } end diff --git a/app/models/statistic.rb b/app/models/statistic.rb index 136944c09..ed51f21ed 100644 --- a/app/models/statistic.rb +++ b/app/models/statistic.rb @@ -5,4 +5,12 @@ class Statistic < ActiveRecord::Base def creator User.find self.user_id end + + def main_category + MainCategory.find self.main_category_id + end + + def sub_category + SubCategory.where(:id => sub_category_id).first + end end diff --git a/app/views/statistics/_statistics_list.html.erb b/app/views/statistics/_statistics_list.html.erb new file mode 100644 index 000000000..5de8a1026 --- /dev/null +++ b/app/views/statistics/_statistics_list.html.erb @@ -0,0 +1,34 @@ +<% @statistics.each do |statistic| %> +
<%= statistic.description.try(:html_safe) %>
+<%= statistic.description %>
-Name | -Description | -User | -Status | -- | - | - |
---|---|---|---|---|---|---|
<%= statistic.name %> | -<%= statistic.description %> | -<%= statistic.user_id %> | -<%= statistic.status %> | -<%= link_to 'Show', statistic %> | -<%= link_to 'Edit', edit_statistic_path(statistic) %> | -<%= link_to 'Destroy', statistic, method: :delete, data: { confirm: 'Are you sure?' } %> | -