Permanently protected module

Module:Reports

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]

Usage

Render organizations information

{{#invoke:Reports|render_org_infos_table}}

This loops through the organizational information Lua table and render onto WAD Portal Org Info.

Render affiliate reports

{{#invoke:Reports|render_arp_table}}

This loops through the affiliate reports Lua table and redner onto WAD Portal Reports.

Render affiliate sandbox reports

{{#invoke:Reports|render_arp_sandbox_table}}

This loops through the affiliate sandbox reports Lua table and render onto WAD Portal Sandbox Reports.

Render derecognized affiliates

{{#invoke:Reports|render_derecognized_affiliates}}

This loops through the derecognized affiliates Lua table and renders onto WAD Portal derecognized affiliates.

Translation

The strings for this module are contained in Template:i18n/Reports.

-- Lua script to render user facing information on [[m:WADP]] & its sub-pages.

local p = {}

-- Constants: Note that, these constants are not used during if()
--  conditions, they're only used duing assignment of a value to
--  a variable.
DERECONIZED_STATUS = 'dereconized'
DERECONISED_STATUS = 'dereconised'
NOT_REQUIRED = "''Not Required''"
TICK = 'Tick'
CROSS = 'Cross'
NEW_AFFILIATE_NOR_TEXT = "<span style='color: blue'>''New affiliate''</span>"
NON_COMPLIANT_NOR_TEXT = "<span style='color: red'>''Noncompliant''</span>"
COMPLIANT_NOR_TEXT = "''Compliant''"
NOT_APPLICABLE_TEXT = 'Not applicable'


-- [DB Storage]: Lua tables for Org Infos and Reports data.
org_infos = require( 'Module:Organizational_Informations' )
activities_reports = require( 'Module:Activities_Reports' )
financial_reports = require( 'Module:Financial_Reports' )
grant_reports = require( 'Module:Grant_Reports' ) -- To be used in Phase II.

-- [DB Storage]: Lua tables for Sandbox Reports data **only** (for tests).
sandbox_activities_reports = require( 'Module:Activities_Reports/Sandbox' )
sandbox_financial_reports = require( 'Module:Financial_Reports/Sandbox' )

-- [Util]: Months number to name map (e.g. 1 -> January, 12 -> December).
months = {
	'January', 'February', 'March', 'April', 'May', 'June',
	'July', 'August', 'September', 'October', 'November', 'December',
}

-- [Util]: Months number to short name map (e.g. 1 -> Jan, 12 -> Dec).
short_months = {
	'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
	'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec',
}

-- [Util]: Helper modules related to translations and text direction.
is_rtl = require( 'Module:Is rtl' )
lang = mw.getCurrentFrame():preprocess( '{{int:lang}}' )
ModuleMsg = require( 'Module:ModuleMsg' )
msg = ModuleMsg:get_msgs( 'Template:I18n/Reports', lang )

function get_translation( entry )
	-- Get WADP forms strings and their translations.
	--
	-- Usage:
	--   entry: table containing the entries to translate
	--
	-- Return table: translated entry (with English as fallback)
	
	if entry.unique_id == nil or lang == 'en' then
		-- This system assumes that a unique id is assigned.
		return entry
	end

	for k, v in pairs( entry ) do
		if msg[k] ~= nil then
			entry[k] = msg[k]
		end
	end

	return entry
end

function get_directionality()
	-- Should something be left-aligned or right-aligned?
	if is_rtl[lang] == true then
		return 'right'
	end
	return 'left'
end

function is_current_report( ts )
	-- Check if the report year matches the current year
	--
	-- Usage:
	--   ts: time stamp of the report
	--
	-- Return boolean: If report is current (true) or not (false)
	
	c_year = os.date( '%Y' );
	ts_year = mw.text.split( ts, '-' )[1]

	if ts_year == c_year then
		return true
	end
	
	return false
end

function iter( ar, fr, gr )
	-- Iterate over multiple Lua tables at the same time
	--
	-- Usage:
	--   ar: Activities reports Lua table
	--   fr: Financial reports Lua table
	--   gr: Grant report Lua table
	--
	-- Return table: Entries at index i of the tables
	
	local i = 0
	return function()
		i = i + 1
		return ar[i], fr[i], gr[i]
	end
end

function get_affiliate_latest_reports( org_info, activities_reports, financial_reports, grant_reports )
	-- Function to fetch the latest report for an affiliate available in
	-- different report tables. In the case of multiple reports submitted
	-- for the same day, month or year, this function will use the timestamp
	-- to get the latest report.
	--
	-- Usage:
	--   org_info: organizational information used for creating the relationship
	--   activities_reports: activities reports Lua table.
	--   financial_reports: financial reports Lua table.
	--   grant_reports: grant reports Lua table.
	--
	--
	-- Return table: entry for the latest activities_report, financial_report, grant report
	
	tmp_ar = { dos_stamp = '1800-01-01:T00:00:00Z' }
	tmp_fr = { dos_stamp = '1800-01-01T00:00:00Z' }
	tmp_gr = { dos_stamp = '1800-01-01T00:00:00Z' }
	
	for activities_report, financial_report, grant_report in iter( activities_reports, financial_reports, grant_reports ) do
		if activities_report ~= nil and org_info.group_name == activities_report.group_name then
			if activities_report.dos_stamp > tmp_ar.dos_stamp then
				tmp_ar = activities_report	
			end
		end

		if financial_report ~= nil and org_info.group_name == financial_report.group_name then
			if financial_report.dos_stamp > tmp_fr.dos_stamp then
				tmp_fr = financial_report	
			end
		end

		if grant_report ~= nil and org_info.group_name == grant_report.group_name then
			if grant_report.dos_stamp > tmp_gr.dos_stamp then
				tmp_gr = grant_report	
			end
		end
	end
	
	return tmp_ar, tmp_fr, tmp_gr
end

function build_arp_template( frame, org_info, activities_report, financial_report, grant_report )
	-- Build entries for the WADP Reports table template.
	--
	-- Usage:
	--   frame: The frame object
	--   org_info: Organization information
	--   activities_report: Activities report for that organization in the current year
	--   financial_report: Financial report for that organization in the current year
	--   grant_report: Grant report for that organization for the current year
	--
	-- Return string: wikitext
	
	org_info = get_translation( org_info )
	template_args = {}
	
	if org_info.affiliate_code ~= nil then
		template_args.affiliate_code = org_info.affiliate_code
	end
	if org_info.group_name ~= nil then
		template_args.affiliate_name = '[[' .. org_info.group_name .. ']]'
	end
	if org_info.org_type ~= nil then
		if org_info.org_type == 'User Group' then
			template_args.org_type = 'WUG'
		elseif org_info.org_type == 'Chapter' then
			template_args.org_type = 'Chap'
		elseif org_info.org_type == 'Thematic Organization' then
			template_args.org_type = 'ThOrg'
		elseif org_info.org_type == 'Allied or other organization' then
			template_args.org_type = 'AOrg'
		end
	end
	if org_info.legal_entity ~= nil and org_info.legal_entity == 'No' then
		template_args.financial_report = NOT_REQUIRED
	end
	
	if activities_report.report_link ~= nil then
		reporting_year = mw.text.split( activities_report.end_date, '/' )[3]
		sd_month_number = tonumber( mw.text.split( activities_report.start_date, '/' )[2] )
		ed_month_number = tonumber( mw.text.split( activities_report.end_date, '/' )[2] )

		-- Compute AAR identifiers
		end_year = tonumber( mw.text.split( activities_report.end_date, '/' )[3] )
		temp = end_year - 1 -- To be used to contruct the year identifier
		end_year_sub = mw.ustring.sub( tostring( end_year ), -2 )

		-- Compose the translatable link for activity reports
		if activities_report.report_link_en ~= nil then
			translatable_report_link = '<sup>[' ..
				activities_report.report_link_en .. ' [' .. activities_report.report_lang_code ..
			']]</sup>'
		elseif activities_report.report_lang_code ~= nil and activities_report.report_link_en == nil then
			translatable_report_link = '(' .. activities_report.report_lang_code .. ')'	
		else
			translatable_report_link = ' (en)'
		end

		if activities_report.report_type == 'Annual Activities Report' then
			template_args.activities_report = '[' ..
				activities_report.report_link .. ' ' .. temp .. '-'.. end_year_sub ..
			'] ' .. translatable_report_link
			template_args.fiscal_year = short_months[sd_month_number] .. ' - ' .. short_months[ed_month_number]
		elseif activities_report.report_type == 'Quarterly Activities Report' then
			template_args.activities_report = '[' .. 
				activities_report.report_link ..
				' ' .. short_months[sd_month_number] .. '-' .. short_months[ed_month_number] .. ' ' .. tostring(end_year) ..
			'] ' .. translatable_report_link
			-- template_args.fiscal_year = short_months[sd_month_number] .. ' - ' .. short_months[ed_month_number]
		elseif activities_report.report_type == 'Multi-year Activities Report' then
			end_year = mw.text.split(activities_report.end_date, "/")[3]
			start_year = mw.text.split(activities_report.start_date, "/")[3]
			template_args.activities_report = '[' ..
				activities_report.report_link .. ' ' .. start_year .. '-'.. end_year ..
			'] ' .. translatable_report_link
			template_args.fiscal_year = short_months[sd_month_number] .. ' - ' .. short_months[ed_month_number]
		else
			template_args.activities_report = '[' ..
				activities_report.report_link .. ' ' .. short_months[ed_month_number] .. '-' .. reporting_year ..
			'] ' .. translatable_report_link
			template_args.fiscal_year = 'Monthly reporting'
		end
		
		-- [feat] Add reporting month
		if org_info.org_type == 'User Group' then
			reporting_month = ed_month_number + 1
			if reporting_month > 12 then
				template_args.reporting_month = short_months[reporting_month - 12]
			else
				template_args.reporting_month = short_months[reporting_month]
			end
		elseif org_info.org_type == 'Chapter' or org_info.org_type == 'Thematic Organization' then
			reporting_month = ed_month_number + 4
			if reporting_month > 12 then
				template_args.reporting_month = short_months[reporting_month - 12]
			else
				template_args.reporting_month = short_months[reporting_month]
			end
		end
	end

	if financial_report.report_link ~= nil then
		-- Compose the translatable link for financial reports
		if financial_report.report_link_en ~= nil then
			translatable_report_link = '<sup>[' ..
				financial_report.report_link_en .. ' [' .. financial_report.report_lang_code..
			']]</sup>'
		elseif financial_report.report_lang_code ~= nil
			and financial_report.report_link_en == nil then
				translatable_report_link = '(' .. financial_report.report_lang_code .. ')'	
		else
			translatable_report_link = '(en)'
		end
		
		if financial_report.report_type == 'Annual Financial Report' then
			-- Compute AAR & FR identifiers
			end_year = tonumber( mw.text.split( financial_report.end_date, '/' )[3])
			temp = end_year - 1 -- To be used to contruct the year identifier
			end_year_sub = mw.ustring.sub( tostring( end_year ), -2 )
			template_args.financial_report = '[' ..
				financial_report.report_link .. ' ' .. temp .. '-'.. end_year_sub ..
			'] ' .. translatable_report_link
		elseif financial_report.report_type == 'Multi-year Financial Report' then
			end_year = mw.text.split( financial_report.end_date, '/' )[3]
			start_year = mw.text.split( financial_report.start_date, '/' )[3]
			template_args.financial_report = '[' ..
				financial_report.report_link .. ' ' .. start_year .. '-'.. end_year ..
			'] '  .. translatable_report_link
		end
	end
	
	-- TODO: Logic to be revisited in Phase II
	-- if grant_report.report_link ~= nil then
	--	template_args.grant_report = '[' .. grant_report.report_link .. ' ' .. grant_report.report_type .. ']'
	--	if is_current_report(grant_report.dos_stamp) then
	--		template_args.uptodate_reporting = frame:expandTemplate{title = 'Tick'}
	--	else
	--		template_args.uptodate_reporting = frame:expandTemplate{title = 'Cross'}
	--	end
	--end
	
	--if org_info.legal_entity ~= nil then
	--	if ( is_current_report(financial_report.dos_stamp) and is_current_report(activities_report.dos_stamp) ) then
	--		template_args.uptodate_reporting = frame:expandTemplate{title = 'Tick'}
	--	elseif org_info.legal_entity == 'No' then
	--		if is_current_report(activities_report.dos_stamp) then
	--			template_args.uptodate_reporting = frame:expandTemplate{title = 'Tick'}
	--		end
	--	else
	--		template_args.uptodate_reporting = frame:expandTemplate{title = 'Cross'}
	--	end
	--end
	
	--if org_info.notes_on_reporting == '' then
	--	template_args.notes_on_reporting = 'Awaiting M&E staff\'s remark...'
	--else
	--	template_args.notes_on_reporting = "'''''" .. org_info.notes_on_reporting .. "'''''"
	--end
	
	if org_info.org_type == 'Allied or other organization' then
		template_args.uptodate_reporting = NOT_REQUIRED
		template_args.notes_on_reporting = NOT_REQUIRED
	end
	
	-- M&E staff priority override
	if org_info.uptodate_reporting == 'Tick' then
		template_args.uptodate_reporting = frame:expandTemplate{ title = TICK }
		template_args.notes_on_reporting = COMPLIANT_NOR_TEXT
	elseif org_info.uptodate_reporting == 'Cross' and org_info.notes_on_reporting ~= '' then
		template_args.uptodate_reporting = frame:expandTemplate{ title = CROSS }
		template_args.notes_on_reporting = "''" .. org_info.notes_on_reporting .. "''"
	elseif org_info.uptodate_reporting == 'Cross' then
		template_args.uptodate_reporting = frame:expandTemplate{ title = CROSS }
		template_args.notes_on_reporting = NON_COMPLIANT_NOR_TEXT
	end

	affiliate_record = frame:expandTemplate{
		title = 'Reports record s1',
		args = template_args
	}

	return affiliate_record
end

function build_org_infos_template( frame, entry )
	-- Build entries for the organizational information template.
	--
	-- Usage:
	--   frame: The frame object
	--   entry: An org infos entry with relevant data
	--
	-- Return string: wikitext

	entry = get_translation(entry)
	social_media = ''
	
	template_args = { type = entry.org_type, }

	if entry.unique_id ~= nil then
		template_args.unique_id = entry.unique_id	
	end
	
	if entry.affiliate_code ~= nil then
		template_args.affiliate_code = entry.affiliate_code	
	end

	if entry.group_name ~= nil then
		template_args.name = '[[' .. entry.group_name .. ']]'
	end

	if entry.other ~= nil then
		template_args.blog_or_news = '[' .. entry.other	.. ' ' .. entry.affiliate_code .. "'s news or blog]"
	end

	if entry.agreement_date ~= nil then
		if entry.org_type == 'Allied or other organization' then
			template_args.agreement_date = NOT_APPLICABLE_TEXT
		else
			template_args.agreement_date = entry.agreement_date
		end
	end

	if entry.twitter ~= nil then
		social_media = social_media .. '[[File:Twitter_Logo.png|26px|link=' .. entry.twitter .. ']]'
	end

	if entry.facebook ~= nil then
		social_media = social_media .. '&nbsp;&nbsp;&nbsp;[[File:Facebook_icon_192.png |26px|link=' .. entry.facebook .. ']]'
	end

	template_args.social_media = social_media

	entrycontent = frame:expandTemplate{
		title = 'Reports record s2',
		args = template_args
	}

	return entrycontent
end

function build_derecog_template( frame, entry )
	-- Build entries for derecognized affiliates template.
	--
	-- Usage:
	--   frame: The frame object
	--   entry: An org infos entry with relevant data
	--
	-- Return string: wikitext
	
	entry = get_translation( entry )
	template_args = { type = entry.org_type, }

	if entry.affiliate_code ~= nil then
		template_args.affiliate_code = entry.affiliate_code	
	end

	if entry.group_name ~= nil then
		template_args.name = '[[' .. entry.group_name .. ']]'
	end

	for _, activities_report in ipairs( activities_reports ) do
		if ( entry.group_name == activities_report.group_name ) then
			-- Let's keep this logic if we intend to show other reports in the future
			latest_ar, latest_fr, latest_gr = get_affiliate_latest_reports(
				entry, activities_reports, financial_reports, grant_reports
			)
			year = mw.text.split( latest_ar.dos_stamp, '-' )[1]
			if ( latest_ar ~= nil ) then
				template_args.activities_report =  '[' .. latest_ar.report_link .. ' ' .. year .. ']'
			end
			break
		end
	end

	if entry.agreement_date ~= nil then
		template_args.agreement_date = entry.agreement_date
	end

	if entry.derecognition_date ~= nil then
		template_args.derecognition_date = entry.derecognition_date
	end

	entrycontent = frame:expandTemplate{
		title = 'Reports derecognized affiliates',
		args = template_args
	}

	return entrycontent
end

function p.render_arp_table( frame )
	-- Function to render the affiliates Report table
	-- using the 'Reports record s2' template.
	--
	-- Usage:
	--   frame: The frame object
	--
	-- Return string: wikitext
	
	reports = ''
	template_args = {}

	for _, org_info in ipairs( org_infos ) do
		-- TODO: Decide whether to hide the reports for derecognized groups as well.
		for activities_report, financial_report, grant_report in iter(
			activities_reports, financial_reports, grant_reports
		) do
			if activities_report == nil then
				activities_report = {}	
			end

			if financial_report == nil then
				financial_report = {}
			end

			if grant_report == nil then
				grant_report = {}
			end

			-- Special Cases: M&E Staff override for new affiliates: "Tick-N"
			-- and "Cross-N"
			if org_info.uptodate_reporting == 'Tick-N' then
				template_args.affiliate_code = org_info.affiliate_code
				template_args.affiliate_name = '[[' .. org_info.group_name .. ']]'
				if org_info.org_type ~= nil then
					if org_info.org_type == 'User Group' then
						template_args.org_type = 'WUG'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Chapter' then
						template_args.org_type = 'Chap'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Thematic Organization' then
						template_args.org_type = 'ThOrg'
						template_args.reporting_month = '-'
					end
				end
				if org_info.legal_entity ~= nil and org_info.legal_entity == 'No' then
					template_args.financial_report = NOT_REQUIRED
				end
				template_args.financial_report = '-'
				template_args.activities_report = '-'
				template_args.fiscal_year = '-'
				template_args.uptodate_reporting = frame:expandTemplate{ title = 'Tick' }
				template_args.notes_on_reporting = NEW_AFFILIATE_NOR_TEXT

				affiliate_record = frame:expandTemplate{
					title = 'Reports record s1',
					args = template_args
				}

				reports = reports .. "\n" .. affiliate_record
				break
			elseif org_info.uptodate_reporting == 'Cross-N' then
				template_args.affiliate_code = org_info.affiliate_code
				template_args.affiliate_name = '[[' .. org_info.group_name .. ']]'
				if org_info.org_type ~= nil then
					if org_info.org_type == 'User Group' then
						template_args.org_type = 'WUG'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Chapter' then
						template_args.org_type = 'Chap'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Thematic Organization' then
						template_args.org_type = 'ThOrg'
						template_args.reporting_month = '-'
					end
				end
				if org_info.legal_entity ~= nil and org_info.legal_entity == 'No' then
					template_args.financial_report = NOT_REQUIRED
				end
				template_args.financial_report = '-'
				template_args.activities_report = '-'
				template_args.fiscal_year = '-'
				template_args.uptodate_reporting = frame:expandTemplate{ title = CROSS }
				template_args.notes_on_reporting = NEW_AFFILIATE_NOR_TEXT

				affiliate_record = frame:expandTemplate{
					title = 'Reports record s1',
					args = template_args
				}

				reports = reports .. "\n" .. affiliate_record
				break
			-- End of special case
			elseif (
				org_info.group_name == grant_report.group_name
				or org_info.group_name == activities_report.group_name
				or org_info.group_name == financial_report.group_name
			) then
				latest_ar, latest_fr, latest_gr = get_affiliate_latest_reports(
					org_info, activities_reports, financial_reports, grant_reports
				)
				reports = reports .. "\n" .. build_arp_template( frame, org_info, latest_ar, latest_fr, latest_gr )
				break
			end
		end
	end

	return reports
end

-- Sandbox Reports code section
function p.render_arp_sandbox_table( frame )
	-- Function to render the SAR (Sandbox Affiliates Reports) table
	-- using the 'Reports record s2' template.
	--
	-- Usage:
	--   frame: The frame object
	--
	-- Return string: wikitext

	reports = ''
	template_args = {}

	for _, org_info in ipairs( org_infos ) do
		-- TODO: Decide whether to hide the reports for derecognized groups as well.
		for sandbox_activities_report,
			sandbox_financial_report,
			-- no-op for grant report
			grant_report in iter( sandbox_activities_reports, sandbox_financial_reports, grant_reports ) do

			if sandbox_activities_report == nil then
				sandbox_activities_report = {}	
			end

			if sandbox_financial_report == nil then
				sandbox_financial_report = {}
			end

			if grant_report == nil then
				grant_report = {}
			end

			-- Special Cases: M&E Staff override for new affiliates: "Tick-N"
			-- and "Cross-N"
			if org_info.uptodate_reporting == 'Tick-N' then
				if org_info.affiliate_code ~= nil then
					template_args.affiliate_code = org_info.affiliate_code
				end
				template_args.affiliate_name = '[[' .. org_info.group_name .. ']]'
				if org_info.org_type ~= nil then
					if org_info.org_type == 'User Group' then
						template_args.org_type = 'WUG'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Chapter' then
						template_args.org_type = 'Chap'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Thematic Organization' then
						template_args.org_type = 'ThOrg'
						template_args.reporting_month = '-'
					end
				end
				if org_info.legal_entity ~= nil and org_info.legal_entity == 'No' then
					template_args.financial_report = NOT_REQUIRED
				end
				template_args.financial_report = '-'
				template_args.activities_report = '-'
				template_args.fiscal_year = '-'
				template_args.uptodate_reporting = frame:expandTemplate{ title = TICK }
				template_args.notes_on_reporting = NEW_AFFILIATE_NOR_TEXT

				affiliate_record = frame:expandTemplate{
					title = 'Reports record s1',
					args = template_args
				}

				reports = reports .. "\n" .. affiliate_record
				break
			elseif org_info.uptodate_reporting == 'Cross-N' then
				if org_info.affiliate_code ~= nil then
					template_args.affiliate_code = org_info.affiliate_code
				end
				template_args.affiliate_name = '[[' .. org_info.group_name .. ']]'
				if org_info.org_type ~= nil then
					if org_info.org_type == 'User Group' then
						template_args.org_type = 'WUG'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Chapter' then
						template_args.org_type = 'Chap'
						template_args.reporting_month = '-'
					elseif org_info.org_type == 'Thematic Organization' then
						template_args.org_type = 'ThOrg'
						template_args.reporting_month = '-'
					end
				end
				if org_info.legal_entity ~= nil and org_info.legal_entity == 'No' then
					template_args.financial_report = NOT_REQUIRED
				end
				template_args.financial_report = '-'
				template_args.activities_report = '-'
				template_args.fiscal_year = '-'
				template_args.uptodate_reporting = frame:expandTemplate{ title = CROSS }
				template_args.notes_on_reporting = NEW_AFFILIATE_NOR_TEXT

				affiliate_record = frame:expandTemplate{
					title = 'Reports record s1',
					args = template_args
				}

				reports = reports .. "\n" .. affiliate_record
				break
			-- End of special case
			elseif (
				org_info.group_name == grant_report.group_name
				or org_info.group_name == sandbox_activities_report.group_name
				or org_info.group_name == sandbox_financial_report.group_name
			) then
				latest_sb_ar, latest_sb_fr, latest_gr = get_affiliate_latest_reports(
					org_info, sandbox_activities_reports, sandbox_financial_reports, grant_reports
				)
				reports = reports .. "\n" .. build_arp_template( frame, org_info, latest_sb_ar, latest_sb_fr, latest_gr )
				break
			end
		end
	end

	return reports
end

function p.render_org_infos_table( frame )
	-- Function for rendering or displaying organizational
	-- information table using the 'Reports record s2' template.
	-- 
	-- Usage:
	--   frame: The frame object
	--
	-- Return string: wikitext
	
	orgInfoTable = ''
	
	for _, org_info in ipairs( org_infos ) do
		if org_info.status == DERECONIZED_STATUS or org_info.status == DERECONISED_STATUS then
			-- Ignore!
		else
			orgInfoTable = orgInfoTable .. "\n" .. build_org_infos_template( frame, org_info )
		end
	end

	return orgInfoTable
end

function p.render_derecognized_affiliates( frame )
	-- Function for rendering or displaying derecognized affiliates.
	-- 
	-- Usage:
	--   frame: The frame object
	--
	-- Return string: wikitext

	derecogTable = ''
	aa_report = ''

	for _, org_info in ipairs( org_infos ) do
		if org_info.status == DERECONIZED_STATUS or org_info.status == DERECONISED_STATUS then
			derecogTable = derecogTable .. "\n" .. build_derecog_template( frame, org_info )
		end
	end

	return derecogTable
end

return p