diff --git a/app/controllers/member_counselors_controller.rb b/app/controllers/member_counselors_controller.rb index 9cfce38..8470120 100644 --- a/app/controllers/member_counselors_controller.rb +++ b/app/controllers/member_counselors_controller.rb @@ -4,10 +4,24 @@ class MemberCounselorsController < CUserController def index idx = 0 + params = OrbitHelper.params + pcity = nil + page = Page.where(:page_id => params[:page_id]).first cities = HpsCity.all.collect do |city| - total = 0 + total = city.hps_files.count + pcity = city if idx == 0 idx = idx + 1 - schools = city.hps_schools.collect do |school| + { + "name" => city.name, + "total" => total, + "url" => "/" + I18n.locale.to_s + page.url + "?city_id=#{city.id.to_s}" + } + end + if params[:city_id].present? + pcity = HpsCity.find(params[:city_id]) + end + total = 0 + schools = pcity.hps_schools.collect do |school| members = HpsMember.where(:hps_school_id => school.id.to_s).pluck(:id) count = HpsFile.where(:hps_member_id.in => members).count total = count + total @@ -17,15 +31,9 @@ class MemberCounselorsController < CUserController "count" => count } end - { - "name" => city.name, - "total" => total, - "id" => "tab#{idx}", - "schools" => schools - } - end { "cities" => cities, + "schools" => schools, "extras" => {} } end @@ -104,6 +112,8 @@ class MemberCounselorsController < CUserController def file_upload hpsfile = HpsFile.new(hps_file_params) hpsfile.hps_member = current_counselor_user + city = HpsCity.find(current_counselor_user.hps_city_id) + hpsfile.hps_city = city hpsfile.save redirect_to member_dash_path(current_counselor_user.account) end diff --git a/app/views/member_counselors/_form.html.erb b/app/views/member_counselors/_form.html.erb index ebb763b..1afe1cc 100644 --- a/app/views/member_counselors/_form.html.erb +++ b/app/views/member_counselors/_form.html.erb @@ -49,7 +49,10 @@   - <%= f.submit "Submit", :class => "btn btn-primary" %>Back + + <%= f.submit "Submit", :class => "btn btn-primary" %> + Back +