-- Style for football tables
local pp = {}  
function pp.header(t,Args,p_sub,pos_label,group_col,VTE_text,full_table,results_header_txt)
-- Load relevant modules
local yesno = require('Module:Yesno')  
-- Create table header
-- Pre stuff
local team_width = Args['teamwidth'] or '190'
local sort_text = yesno(Args['sortable_table'] or 'no') and ' sortable' or ''
local show_played = not yesno(Args['hide_played'] or 'no')
local rounds_won = yesno(Args['show_rw'] or Args['rounds_won'] or 'no')
table.insert(t,'{|\n') -- Open table
-- Table title
if Args['title'] or Args['table_header'] then
table.insert(t,'|+ ' .. (Args['title'] or Args['table_header']) .. '\n')
end
-- Custom header options
local played_head_text = Args['pld_header'] or '<abbr title="விளையாடிய ஆட்டங்கள்">வி</abbr>'
local draw_head_text = Args['draw_header']
or (yesno(Args['use_tie'] or 'no') and '<abbr title="முறிநிலை">மு.நி</abbr>') or '<abbr title="வெற்றி-தோல்வி இல்லை">ச</abbr>'
local group_head_text = Args['group_header'] or '<abbr title="குழு">குழு</abbr>'
local team_head_text = Args['team_header'] or 'அணி'
local away_goals_head_text = Args['away_goals_header'] or '<abbr title="வெளி கோல்கள்">வெ.கோ</abbr>'
local bonus_head_text = Args['bonus_header'] or '<abbr title="மேலதிக புள்ளிகள்">மே.பு</abbr>'
local rw_head_text = Args['rw_header'] or '<abbr title="வென்ற சுற்றுகள்">வெ.சு</abbr>'
local loss_first = Args['loss_before_draw'] or Args['loss_before_tie'] or false
-- What to rank the teams by
local ranking_style = string.lower(Args['ranking_style'] or 'pts')
local show_points, show_wperc, show_perc, show_ppg = false, false, false, false
if ranking_style=='w' or ranking_style=='win' or ranking_style=='wins' or ranking_style=='' then
-- Based on wins
elseif ranking_style=='wperc' or ranking_style=='win percentage' or ranking_style=='wpct' then
show_wperc = true
elseif ranking_style=='perc' or ranking_style=='percentage' or ranking_style=='%' then
-- Based on percentage
show_perc = true
elseif ranking_style=='ppg' or ranking_style=='points per game' or ranking_style=='ptspergame' then
-- Based on points per game
show_ppg = true
elseif ranking_style=='percpts' or ranking_style=='%pts' then
-- Based on percentage and points
show_perc = true
show_points = true
elseif ranking_style=='ppgpts' then
-- Based on ppg and points
show_ppg = true
show_points = true
else
-- Based on points
show_points = true
end
local pts_perc_first = yesno((show_points and Args['pts_first']) or (show_perc and Args['perc_first']) or 'no')
local show_away_goals = yesno(Args['show_away_goals'] or 'no')
local show_bonus_points = yesno(Args['show_bonus_points'] or 'no')
local show_win = yesno(Args['show_win'] or 'yes')
local show_draw = yesno(Args['show_draw'] or 'yes')
local show_loss = yesno(Args['show_loss'] or 'yes')
-- Use points instead of goals for/against
local for_against_style = Args['for_against_style'] or 'goals'
local fa_letter, fa_word_sing, fa_word_plur
local hide_for_against = false
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if for_against_style=='g' or for_against_style=='goal' or for_against_style=='goals' then
fa_letter = 'கோ'
fa_word_sing = 'கோல்'
fa_word_plur = 'கோல்கள்'
elseif for_against_style=='f' or for_against_style=='' or for_against_style=='frames' then
fa_letter = 'F'
fa_word_sing = 'Frame'
fa_word_plur = 'Frames'
elseif for_against_style=='m' or for_against_style=='match' or for_against_style=='matches' then
fa_letter = 'ஆ'
fa_word_sing = 'ஆட்டம்'
fa_word_plur = 'ஆட்டங்கள்'
elseif for_against_style=='game' or for_against_style=='games' then
fa_letter = 'ஆ'
fa_word_sing = 'ஆட்டம்'
fa_word_plur = 'ஆட்டங்கள்'
elseif for_against_style=='p' or for_against_style=='point' or for_against_style=='points' then
fa_letter = 'பு'
fa_word_sing = 'புள்ளி'
fa_word_plur = 'புள்ளிகள்'
elseif for_against_style=='s' or for_against_style=='set' or for_against_style=='sets' then
fa_letter = 'S'
fa_word_sing = 'Set'
fa_word_plur = 'Sets'
elseif for_against_style=='r' or for_against_style=='run' or for_against_style=='runs' then
fa_letter = 'ஓ'
fa_word_sing = 'ஓட்டம்'
fa_word_plur = 'ஓட்டங்கள்'
elseif for_against_style=='' then
hide_for_against = true
else
fa_letter = 'கோ'
fa_word_sing = 'கோல்'
fa_word_plur = 'கோல்கள்'
end
-- Whether to use goal ratio (goal average) instead
local do_ratio = yesno(Args['use_goal_ratio'] or 'no')
local do_average = yesno(Args['use_goal_average'] or 'no')  
-- Whether to use goal percentage instead
local do_percentage = yesno(Args['use_goal_percentage'] or Args['use_point_percentage'] or 'no')  
local do_point_for_avg = yesno(Args['use_goals_per_match'] or Args['use_points_per_match'] or 'no')  
-- Whether to suppress the GR/GA/G% column entirely
local do_difference = yesno(Args['use_goal_diff'] or 'yes')  
-- Use games behind header
local show_GB = yesno(Args['show_GB'] or 'no')  
-- Initialize
local tt = {}
tt.count = 0 -- Up by one after every call
tt.tab_text = t -- Actual text
-- Actual headers
if pos_label ~= nil then
tt = p_sub.colhead(tt,28,pos_label) -- Position col
end
-- Add group header
if full_table and group_col then
tt = p_sub.colhead(tt,28,group_head_text) -- Group col
end
tt = p_sub.colhead(tt,team_width,team_head_text..VTE_text) -- Team col
if pts_perc_first then
if show_points then
tt = p_sub.colhead(tt,28,'<abbr title="புள்ளிகள்">புள்ளி</abbr>') -- Points col
end
if show_perc then
tt = p_sub.colhead(tt,36,'<abbr title="வெற்றி விழுக்காடு">வெ.வி</abbr>') -- Win percentage col
end
if show_ppg then
tt = p_sub.colhead(tt,36,'<abbr title="ஆட்டம் ஒன்றின் புள்ளிகள்">ஆ.ஒ.பு</abbr>') -- Points per game col
end
end
if show_played then
tt = p_sub.colhead(tt,28,played_head_text) -- Matches played col
end
if full_table then
if show_win then
tt = p_sub.colhead(tt,28,'<abbr title="வெற்றி">வெ</abbr>') -- Win col
end
if loss_first then
if show_loss then
tt = p_sub.colhead(tt,28,'<abbr title="தோல்வி">தோ</abbr>') -- Loss col
end
if show_draw then
tt = p_sub.colhead(tt,28,draw_head_text) -- Draw col
end
else
if show_draw then
tt = p_sub.colhead(tt,28,draw_head_text) -- Draw col
end
if show_loss then
tt = p_sub.colhead(tt,28,'<abbr title="தோல்வி">தோ</abbr>') -- Loss col
end
end
if rounds_won then
tt = p_sub.colhead(tt,28,rw_head_text) -- Rounds won
end
if not hide_for_against then
if not yesno(Args['hide_for_against_columns'] or 'no') then
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_plur..' நேர்">'..fa_letter..'நே</abbr>') -- For col
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_plur..' எதிர்">'..fa_letter..'எ</abbr>') -- Against col
end
if do_ratio or do_average then
local ratio_word = do_ratio and ' ratio' or ' average'
local ratio_letter = do_ratio and 'R' or 'Av'
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_sing..ratio_word..'">'..fa_letter..ratio_letter..'</abbr>') -- Ratio col
elseif do_percentage then
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_sing..' விழுக்காடு">PP</abbr>') -- Percentage col
elseif do_point_for_avg then
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_plur..' ஆட்டம் ஒன்றிற்கு">'..fa_letter..'புஆ</abbr>') -- Points per match
elseif do_difference then
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_sing..' வேறுபாடு">'..fa_letter..'வே</abbr>') -- Difference col
end
end
end
if show_away_goals then
tt = p_sub.colhead(tt,28,away_goals_head_text) -- Away goals col
end
if show_bonus_points then
tt = p_sub.colhead(tt,28,bonus_head_text) -- Bonus points col
end
if not pts_perc_first then
if show_points then
tt = p_sub.colhead(tt,28,'<abbr title="புள்ளிகள்">பு</abbr>') -- Points col
end
if show_perc then
tt = p_sub.colhead(tt,36,'<abbr title="வெற்றி விழுக்காடு">வெ.வி</abbr>') -- Win percentage col
elseif show_wperc then
tt = p_sub.colhead(tt,36,'<abbr title="வெற்றி விழுக்காடு">வெ.வி</abbr>') -- Win percentage col
end
if show_ppg then
tt = p_sub.colhead(tt,36,'<abbr title="புள்ளிகள்/ஆட்டம்">பு/ஆ</abbr>') -- Points per game col
end
end
if full_table then
if show_GB then -- Games behind header