2016-03-10 10:49:08 +00:00
|
|
|
module Admin::TechnologyTransfersHelper
|
|
|
|
def page_for_technology_transfer(course_object)
|
|
|
|
page = nil
|
|
|
|
pages = Page.where(:module=>"technology_transfer")
|
|
|
|
|
|
|
|
page = pages.first if page.nil?
|
|
|
|
request.protocol+(request.host_with_port+page.url+'/'+course_object.to_param).gsub('//','/') rescue "/"
|
|
|
|
end
|
2016-06-06 11:39:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_data_for_excel(year_start,year_end)
|
|
|
|
data = []
|
|
|
|
roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key)
|
|
|
|
roles.each do |role|
|
|
|
|
d = {}
|
|
|
|
d["name"] = role.title
|
|
|
|
mps = role.member_profile_ids
|
|
|
|
# d1 = DateTime.new(year_start,1,1,0,0)
|
|
|
|
# d2 = DateTime.new(year_end,12,31,23,59)
|
|
|
|
d["data"] = TechnologyTransfer.where(:year.gte => year_start, :year.lte => year_end, :member_profile_id.in => mps) rescue []
|
|
|
|
data << d
|
|
|
|
end
|
|
|
|
return data
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_chart_data(year_start,year_end,role,type)
|
|
|
|
case type
|
|
|
|
when "category"
|
|
|
|
jls = TechnologyTransferCategory.all
|
|
|
|
end
|
|
|
|
|
|
|
|
finaldata = []
|
|
|
|
role = Role.find(role) rescue nil
|
|
|
|
mps = []
|
|
|
|
if !role.nil?
|
|
|
|
mps = role.member_profile_ids
|
|
|
|
end
|
|
|
|
jls.each do |jl|
|
|
|
|
data = {}
|
|
|
|
data["name"] = jl.title
|
|
|
|
data["data"] = {}
|
|
|
|
(year_start..year_end).each do |year|
|
|
|
|
# d1 = DateTime.new(year,1,1,0,0)
|
|
|
|
# d2 = DateTime.new(year,12,31,23,59)
|
|
|
|
t = jl.technology_transfers.where(:year => year, :member_profile_id.in => mps).count rescue 0
|
|
|
|
data["data"][year.to_s] = t
|
|
|
|
end
|
|
|
|
finaldata << data
|
|
|
|
end
|
|
|
|
data = {"name" => "N/A", "data" => {}}
|
|
|
|
(year_start..year_end).each do |year|
|
|
|
|
# d1 = DateTime.new(year,1,1,0,0)
|
|
|
|
# d2 = DateTime.new(year,12,31,23,59)
|
|
|
|
case type
|
|
|
|
when "category"
|
|
|
|
t = TechnologyTransfer.where(:year => year, :member_profile_id.in => mps, :technology_transfer_category_id => nil).count rescue 0
|
|
|
|
end
|
|
|
|
|
|
|
|
data["data"][year.to_s] = t
|
|
|
|
end
|
|
|
|
finaldata << data
|
|
|
|
finaldata
|
|
|
|
end
|
2016-03-10 10:49:08 +00:00
|
|
|
end
|