bsw@558: local member = param.get("member", "table") bsw@558: local for_member = param.get("for_member", atom.boolean) bsw@558: local filter_unit = param.get_all_cgi()["filter_unit"] or "personal" bsw@558: bsw@558: bsw@558: execute.view{ bsw@558: module = "index", view = "_notifications" bsw@558: } bsw@558: bsw@558: bsw@558: ui.container{ attr = { class = "ui_filter_head" }, content = function() bsw@558: bsw@558: ui.link{ bsw@558: attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil }, bsw@558: text = _"My units and areas", bsw@558: module = "index", view = "index", params = { filter_unit = "personal" } bsw@558: } bsw@558: bsw@558: slot.put(" ") bsw@558: bsw@558: ui.link{ bsw@558: attr = { class = filter_unit == "global" and "active" or nil }, bsw@558: text = _"All units", bsw@558: module = "index", view = "index", params = { filter_unit = "global" } bsw@558: } bsw@558: end } bsw@558: bsw@558: slot.put("
") bsw@558: bsw@558: bsw@558: if filter_unit == "global" then bsw@558: execute.view{ module = "unit", view = "_list" } bsw@558: return bsw@558: end bsw@558: bsw@558: local units = Unit:new_selector():exec() bsw@558: bsw@558: for i, unit in ipairs(units) do bsw@558: local trustee_member = Member:new_selector() bsw@558: :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id }) bsw@558: :optional_object_mode() bsw@558: :exec() bsw@558: bsw@558: local areas_selector = Area:new_selector() bsw@558: :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id }) bsw@558: :add_where{ "area.unit_id = ?", unit.id } bsw@558: :add_where{ "area.active" } bsw@558: :add_order_by("area.member_weight DESC") bsw@558: bsw@558: local area_count = areas_selector:count() bsw@558: bsw@558: ui.container{ attr = { class = "member_area_list" }, content = function() bsw@558: ui.container{ attr = { class = "xunit_head" }, content = function() bsw@558: ui.link{ bsw@558: text = unit.name, bsw@558: module = "unit", view = "show", id = unit.id bsw@558: } bsw@558: bsw@558: if trustee_member then bsw@558: local text = _("Unit delegated to '#{name}'", { name = trustee_member.name }) bsw@558: ui.image{ bsw@558: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@558: static = "delegation_arrow_24_horizontal.png" bsw@558: } bsw@558: execute.view{ bsw@558: module = "member_image", bsw@558: view = "_show", bsw@558: params = { bsw@558: member = trustee_member, bsw@558: image_type = "avatar", bsw@558: show_dummy = true, bsw@558: class = "micro_avatar", bsw@558: popup_text = text bsw@558: } bsw@558: } bsw@558: end bsw@558: end } bsw@558: bsw@558: if area_count > 0 then bsw@558: execute.view{ bsw@558: module = "area", view = "_list", bsw@558: params = { areas_selector = areas_selector, hide_membership = true } bsw@558: } bsw@558: elseif member:has_voting_right_for_unit_id(unit.id) then bsw@558: if for_member then bsw@558: ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." } bsw@558: else bsw@558: ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." } bsw@558: end bsw@558: end bsw@558: local max_area_count = Area:new_selector() bsw@558: :add_where{ "area.unit_id = ?", unit.id } bsw@558: :add_where{ "area.active" } bsw@558: :count() bsw@558: local more_area_count = max_area_count - area_count bsw@558: local delegated_count = Area:new_selector() bsw@558: :add_where{ "area.unit_id = ?", unit.id } bsw@558: :add_where{ "area.active" } bsw@558: :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } ) bsw@558: :add_where{ "membership.member_id ISNULL" } bsw@558: :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } ) bsw@558: :count() bsw@558: if more_area_count > 0 then bsw@558: slot.put("
") bsw@558: ui.container{ attr = { class = "more_areas" }, content = function() bsw@558: ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id } bsw@558: end } bsw@558: end bsw@558: end } bsw@558: bsw@558: end bsw@558: bsw@558: