<?xml version="1.0" encoding="UTF-8"?>
<Report>
<!-- $Id$ -->
	<Title><var var="i18n::translate('Ahnentafel Report')" /></Title>
	<Description>Prints an Ahnentafel report for the selected individual</Description>
	<Input name="pid" lookup="INDI" type="text"><var var="i18n::translate('Enter Individual ID')" /></Input>
	<Input name="maxgen" type="select" options="3=>3|4=>4|5=>5|6=>6|7=>7|8=>8|9=>9|*=>*"><var var="i18n::translate('Generations')" /></Input>
	<Input name="sources" type="checkbox" default="1"><var var="i18n::translate('Show sources?')" /></Input>
	<Input name="notes" type="checkbox" default="1"><var var="i18n::translate('Show notes?')" /></Input>
	<Input name="pageSize" type="select" default="A4" options="letter=>i18n::translate_c('paper size','Letter')|A3=>i18n::translate_c('paper size', 'A3')|A4=>i18n::translate_c('paper size','A4')|legal=>i18n::translate_c('paper size','Legal')"><var var="i18n::translate('Page size')" /></Input>
	<Input name="fonts" type="select" default="dejavusans" options="arialunicid0=>i18n::translate_c('font name', 'Arial')|dejavusans=>i18n::translate_c('font name', 'DejaVu')|helvetica=>i18n::translate_c('font name', 'Helvetica')"><var var="i18n::translate('Font')"/></Input>
	
	<!-- Header -->
	<Style name="header" font="$fonts" size="14" style="b" />
	<!-- Page numbers text -->
	<Style name="pagenum" font="$fonts" size="8"/>
	<!-- Standard text -->
	<Style name="text" font="$fonts" size="10"/>
	<!-- Links to sources - required style name by the generator -->
	<Style name="footnotenum" font="$fonts" size="7"/>
	<!-- Source text - FootnoteTexts - required style name by the generator -->
	<Style name="footnote" font="$fonts" size="8"/>
	<!-- Generated by style - required style name by the generator -->
	<Style name="genby" font="$fonts" size="8" />
	<!-- Date Text-->
	<Style name="date" font="$fonts" size="8"/>
	<!-- Note Text -->
	<Style name="note" font="$fonts" size="9"/>
	<!-- Individual name -->
	<Style name="name" font="$fonts" size="10" style="b" />
	<Style name="subheader" font="$fonts" size="12" style="b" />

	<SetVar name="num" value="1" />
	<SetVar name="generation" value="0" />
	<SetVar name="empty_name" value="f" />
	<SetVar name="empty_start_value" value="0" />
	<!-- New Page for Sources controller if SOUR exist -->
	<SetVar name="source_exist" value="0" />

	<Doc pageSize="$pageSize">
		<Header>
			<Cell align="center" height="30" newline="1" style="header"><var var="i18n::translate('Ahnentafel Report for ')" /><GetPersonName id="$pid" /></Cell>
			<Cell align="rightrtl" newline="1" style="pagenum"><var var="i18n::translate('Page')" /> <PageNum /> <var var="i18n::translate('of')" /> <TotalPages /></Cell>
		</Header>

		<Body>
			<Relatives id="$pid" group="direct-ancestors" sortby="none" maxgen="$maxgen" showempty="true">
				<SetVar name="gender" value="m" />
				<if condition="@SEX=='F'">
					<SetVar name="gender" value="f" />
				</if>
				<if condition="$generation!=@generation">
					<if condition="$empty_name=='t'" >
						<TextBox width="50" height="20">
							<SetVar name="empty_end_value" value="$num-1" />
							<Text style="text"><var var="empty_start_value" />-<var var="empty_end_value" />.</Text>
						</TextBox>
						<TextBox width="475" height="12" newline="1" >
							<Text style="text"><br /></Text>
						</TextBox>
						<TextBox width="25" height="20" newline="1">
							<Text style="text"><br /></Text>
						</TextBox>
						<SetVar name="empty_start_value" value="$num" />
					</if>
					<Cell align="center" height="30" newline="1" style="subheader"><var var="i18n::translate('Generation ')" /><Generation /></Cell>
					<SetVar name="generation" value="@generation" />
				</if>
				<SetVar name="indiname" value="@NAME" />
				<if condition="$indiname==''">
					<if condition="$empty_name=='f'">
						<SetVar name="empty_name" value="t" />
						<SetVar name="empty_start_value" value="$num" />
					</if>
				</if>
				<if condition="$indiname!=''">
					<if condition="$empty_name=='t'" >
						<TextBox width="50" height="20">
							<SetVar name="empty_end_value" value="$num-1" />
							<Text style="text"><var var="empty_start_value" />-<var var="empty_end_value" />.</Text>
						</TextBox>
						<TextBox width="475" height="12" newline="1">
							<Text style="text"><br /></Text>
						</TextBox>
						<TextBox width="25" height="20" newline="1">
							<Text style="text"><br /></Text>
						</TextBox>
						<SetVar name="empty_name" value="f" />
					</if>
					
					<!-- Generation counter -->
					<TextBox width="25" height="30">
						<Text style="text"><var var="num" />.</Text>
					</TextBox>
					
					<!-- 	Sentence 1
							Individual, name... -->
					<TextBox height="12" newline="1">
						<Text style="name"><GetPersonName id="" /> </Text>
						<if condition="$sources==1">
							<!-- Level 1 Sourcees -->
							<RepeatTag tag="SOUR">
								<Footnote>
									<Gedcom id="@SOUR">
										<GedcomValue tag="TITL" />
									</Gedcom>
									<if condition="@PAGE!=''">: </if>
									<GedcomValue tag="SOUR:PAGE"/> <GedcomValue tag="SOUR:DATA:TEXT"/>
								</Footnote>
								<SetVar name="source_exist" value="1"/>
							</RepeatTag>
						</if>
						<!-- Individual, birth... -->
						<Gedcom id="BIRT">
							<Text style="text">
								<if condition="$gender=='m'">
									<var var="i18n::translate_c('MALE', 'was born')" />
								</if>
								<if condition="$gender=='f'">
									<var var="i18n::translate_c('FEMALE', 'was born')" />
								</if>
							</Text>
							<if condition="$sources==1">
								<RepeatTag tag="BIRT:SOUR">
									<Footnote>
										<Gedcom id="@SOUR">
											<GedcomValue tag="TITL" />
										</Gedcom>
										<if condition="@PAGE!=''">: </if>
										<GedcomValue tag="PAGE" level="3"/> <GedcomValue tag="DATA:TEXT" level="3"/>
									</Footnote>
									<SetVar name="source_exist" value="1"/>
								</RepeatTag>
							</if>
							<if condition="@DATE!=''">
								<Text style="text"><var var=" " /> <GedcomValue tag="DATE" level="2" /></Text>
							</if>
							<if condition="@PLAC!=''">
								<Text style="text"><var var="i18n::translate(' in ')" /> <GedcomValue tag="PLAC" level="2" /></Text>
							</if>
							<if condition="(@desc=='Y') or (@DATE=='' and @PLAC=='')">
								<Text style="text"><var var="i18n::translate(' but the details are unknown')" /></Text>
							</if>
							<Text style="text">.</Text>
						</Gedcom>

						<!-- 	Sentence 2
								Individual, christened... -->
						<Gedcom id="CHR">
							<Text style="text"> 
								<if condition="$gender=='m'">
									<var var="i18n::translate('He was christened')" />
								</if>
								<if condition="$gender=='f'">
									<var var="i18n::translate('She was christened')" />
								</if>
							</Text>
							<if condition="$sources==1">
								<RepeatTag tag="CHR:SOUR">
									<Footnote>
										<Gedcom id="@SOUR">
											<GedcomValue tag="TITL" />
										</Gedcom>
										<if condition="@PAGE!=''">: </if>
										<GedcomValue tag="PAGE" level="3"/> <GedcomValue tag="DATA:TEXT" level="3"/>
									</Footnote>
									<SetVar name="source_exist" value="1"/>
								</RepeatTag>
							</if>
							<if condition="@DATE!=''">
								<Text style="text"><var var=" " /> <GedcomValue tag="DATE" level="2" /></Text>
							</if>
							<if condition="@PLAC!=''">
								<Text style="text"><var var="i18n::translate(' in ')" /> <GedcomValue tag="PLAC" level="2" /></Text>
							</if>
							<if condition="(@desc=='Y') or (@DATE=='' and @PLAC=='')">
								<Text style="text"><var var="i18n::translate(' but the details are unknown')" /></Text>
							</if>
							<Text style="text">.</Text>
						</Gedcom>
						<SetVar name="cpid" value="@ID" />
						<if condition="$cpid!=$spid">
							<Gedcom id="@FAMS">
								<if condition="$cpid==@HUSB">
									<SetVar name="spid" value="@WIFE" />
								</if>
								<if condition="$cpid==@WIFE">
									<SetVar name="spid" value="@HUSB" />
								</if>
								<Gedcom id="MARR">
									<if condition="$spid!='' and @DATE!='' and @PLAC!=''">
										<Text style="text"><br />
											<if condition="$gender=='m'">
												<var var="i18n::translate('He married')" />
											</if>
											<if condition="$gender=='f'">
												<var var="i18n::translate('She married')" />
											</if>
										</Text>
										<if condition="$sources==1">
											<RepeatTag tag="MARR:SOUR">
												<Footnote>
													<Gedcom id="@SOUR">
														<GedcomValue tag="TITL" />
													</Gedcom>
														<if condition="@PAGE!=''">: </if>
													<GedcomValue tag="PAGE" level="3"/> <GedcomValue tag="DATA:TEXT" level="3"/>
												</Footnote>
												<SetVar name="source_exist" value="1"/>
											</RepeatTag>
										</if>
										<if condition="$spid!=''">
											<Text style="text"> <GetPersonName id="$spid" /></Text>
										</if>
										<Text style="text"> <var var=" " /></Text>								
										<if condition="@DATE!=''">
											<Text style="text"><var var=" " /> <GedcomValue tag="DATE" level="2" /><if condition="@PLAC==''"> </if></Text>
										</if>
										<if condition="@PLAC!=''">
											<Text style="text"><var var="i18n::translate(' in ')" /> <GedcomValue tag="PLAC" level="2" /></Text>
										</if>
										<if condition="((@desc=='Y') or (@DATE=='' and @PLAC=='')) and ($spid=='')">
											<Text style="text"><var var="i18n::translate(' but the details are unknown')" /></Text>
										</if>
										<Text style="text">.</Text>
									</if>
								</Gedcom>
							</Gedcom>
						</if>
						<Gedcom id="DEAT">
							<Text style="text"><br />
								<if condition="$gender=='m'">
									<var var="i18n::translate('He died')" />
								</if>
								<if condition="$gender=='f'">
									<var var="i18n::translate('She died')" />
								</if>
							</Text>
							<if condition="$sources==1">
								<RepeatTag tag="DEAT:SOUR">
									<Footnote>
										<Gedcom id="@SOUR">
											<GedcomValue tag="TITL" />
										</Gedcom>
										<if condition="@PAGE!=''">: </if>
										<GedcomValue tag="PAGE" level="3"/> <GedcomValue tag="DATA:TEXT" level="3"/>
									</Footnote>
									<SetVar name="source_exist" value="1"/>
								</RepeatTag>
							</if>
							<if condition="@DATE!=''">
								<Text style="text"><var var=" " /> <GedcomValue tag="DATE" level="2" /></Text>
							</if>
							<if condition="@PLAC!=''">
								<Text style="text"><var var="i18n::translate(' in ')" /> <GedcomValue tag="PLAC" level="2" /></Text>
							</if>
							<if condition="(@desc=='Y') or (@DATE=='' and @PLAC=='')">
								<Text style="text"><var var="i18n::translate(' but the details are unknown')" /></Text>
							</if>
							<Text style="text">.  </Text>
						</Gedcom>
						<Gedcom id="BURI">
							<Text style="text">
								<if condition="$gender=='m'">
									<var var="i18n::translate('He was buried')" />
								</if>
								<if condition="$gender=='f'">
									<var var="i18n::translate('She was buried')" />
								</if>
							</Text>
							<if condition="$sources==1">
								<RepeatTag tag="BURI:SOUR">
									<Footnote>
										<Gedcom id="@SOUR">
											<GedcomValue tag="TITL" />
										</Gedcom>
										<if condition="@PAGE!=''">: </if>
										<GedcomValue tag="PAGE" level="3"/> <GedcomValue tag="DATA:TEXT" level="3"/>
									</Footnote>
									<SetVar name="source_exist" value="1"/>
								</RepeatTag>
							</if>
							<if condition="@DATE!=''">
								<Text style="text"><var var=" " /> <GedcomValue tag="DATE" level="2" /></Text>
							</if>
							<if condition="@PLAC!=''">
								<Text style="text"><var var="i18n::translate(' in ')" /> <GedcomValue tag="PLAC" level="2" /></Text>
							</if>
							<if condition="(@desc=='Y') or (@DATE=='' and @PLAC=='')">
								<Text style="text"><var var="i18n::translate(' but the details are unknown')" /></Text>
							</if>
							<Text style="text">.</Text>
						</Gedcom>
					</TextBox>
					<if condition="$notes==1">
						<RepeatTag tag="NOTE">
							<TextBox height="3" newline="1" padding="0"/>
							<Cell height="12" left="30" newline="1" style="note"><GedcomValue tag="NOTE"/></Cell>
						</RepeatTag>
					</if>
					<TextBox height="10" newline="1" padding="0"/>
				</if>
				<SetVar name="num" value="$num+1" />
			</Relatives>
			<!-- if the sources were on, print the source citations as footnotes -->
			<if condition="($sources==1) and ($source_exist==1)">
				<NewPage/>
				<TextBox width="$width" height="20" newline="1">
					<Text style="subheader"><var var="i18n::translate('Sources')" /><br /><br /></Text>
					<FootnoteTexts />
				</TextBox>
			</if>
		</Body>
		<Footer>
			<Cell align="rightrtl" style="date"><Now /></Cell>
		</Footer>
	</Doc>
</Report>
