This commit is contained in:
Harry Bomrah 2017-08-18 16:15:21 +08:00
parent e33dee9a45
commit ebb90e12b7
2 changed files with 25 additions and 13 deletions

View File

@ -7,8 +7,9 @@ class MemberCounselorsController < CUserController
params = OrbitHelper.params
pcity = nil
page = Page.where(:page_id => params[:page_id]).first
schoolmembers = HpsMember.where(:user_type => 0).pluck(:id)
cities = HpsCity.all.collect do |city|
total = city.hps_files.count
total = city.hps_files.where(:hps_member_id.in => schoolmembers).count
pcity = city if idx == 0
idx = idx + 1
{
@ -43,7 +44,17 @@ class MemberCounselorsController < CUserController
school = HpsSchool.where(:uid => params[:uid]).first
members = HpsMember.where(:hps_school_id => school.id.to_s)
page = Page.where(:page_id => params[:page_id]).first
schoolmembers = HpsMember.where(:user_type => 0).pluck(:id)
files = []
cities = HpsCity.all.collect do |city|
total = city.hps_files.where(:hps_member_id.in => schoolmembers).count
{
"name" => city.name,
"total" => total,
"url" => "/" + I18n.locale.to_s + page.url + "?city_id=#{city.id.to_s}"
}
end
members.each do |member|
member.hps_files.desc(:created_at).each do |file|
files << {
@ -56,6 +67,7 @@ class MemberCounselorsController < CUserController
end
{
"files" => files,
"cities" => cities,
"data" => {
"back-url" => "/" + I18n.locale.to_s + page.url
}

View File

@ -43,11 +43,11 @@ class HpsMember
def get_user_type
case self.user_type
when 0
I18n.t("member_counselor.type1")
I18n.t("member_counselor.type1") #school
when 1
I18n.t("member_counselor.type2")
I18n.t("member_counselor.type2") #govt
when 2
I18n.t("member_counselor.type3")
I18n.t("member_counselor.type3") #counselor
end
end
end