<?xml version="1.0" encoding="UTF-8"?>
<Report>
	<!-- $Id$ -->
	<Title><var var="WT_I18N::translate('Source')" /></Title>
	<Description><var var="WT_I18N::translate('A report of facts which are supported by a given source.')" /></Description>
	<Input name="sid" lookup="SOUR" default="" type="text"><var var="WT_I18N::translate('Find Source ID')" /></Input>
	<Input name="stype" type="select" default="facts" options="facts=>WT_I18N::translate('facts')|records=>WT_I18N::translate('records')"><var var="WT_I18N::translate('Source type')" /></Input>
	<Input name="sortby" type="select" default="BIRT:DATE" options="NAME=>WT_I18N::translate('sort by name')|BIRT:DATE=>WT_I18N::translate('sort by date of birth')"><var var="WT_I18N::translate('Sort order')" /></Input>
	<Input name="pageSize" type="select" default="A4" options="letter=>WT_I18N::translate_c('paper size','Letter')|A3=>WT_I18N::translate_c('paper size', 'A3')|A4=>WT_I18N::translate_c('paper size','A4')|legal=>WT_I18N::translate_c('paper size','Legal')"><var var="WT_I18N::translate('Page size')" /></Input>
	<Input name="fonts" type="select" default="dejavusans" options="arialunicid0=>WT_I18N::translate_c('font name', 'Arial')|dejavusans=>WT_I18N::translate_c('font name', 'DejaVu')|helvetica=>WT_I18N::translate_c('font name', 'Helvetica')"><var var="WT_I18N::translate('Font')"/></Input>

	<!-- Header -->
	<Style name="header" font="$fonts" size="18" style="b" />
	<!-- Source Title -->
	<Style name="header2" font="$fonts" size="14" style="b" />
	<!-- Name of the List Type. INDI or FAM -->
	<Style name="listtype" font="$fonts" size="12" style="b" />
	<!-- Page numbers text -->
	<Style name="pagenum" font="$fonts" size="8" />
	<!-- Generated by style - required style name by the generator -->
	<Style name="genby" font="$fonts" size="8" />
	<!-- Date Text - CSS Style name -->
	<Style name="date" font="$fonts" size="8"/>
	<!-- Column list labels - CSS Style name -->
	<Style name="list_label" font="$fonts" size="9" style="b"/>
	<!-- List values - CSS Style name -->
	<Style name="list_value" font="$fonts" size="8"/>

	<SetVar name="nameindi" value="200" />
	<SetVar name="datebirth" value="120" />
	<SetVar name="namefam" value="$nameindi + $datebirth" />
	<SetVar name="fact" value="100" />
	<SetVar name="dateevent" value="110" />
	<SetVar name="vspace" value="5" />
	<SetVar name="printedsource" value="0" />
	<SetVar name="moresourcespaceindi" value="$nameindi + $datebirth" />
	<SetVar name="ignore" value="CHAN,CHIL,FAMC,FAMS,HUSB,OBJE,RESN,SEX,SOUR,TITL,WIFE,_UID,_WT_OBJE_SORT"/>

	<Doc pageSize="$pageSize" orientation="landscape">
		<Header>
			<Cell align="center" newline="1" style="header"><var var="WT_I18N::translate('Source')" /></Cell>
			<Cell align="rightrtl" newline="1" style="pagenum"><var var="WT_I18N::translate('Page')" /> <PageNum /> <var var="WT_I18N::translate('of')" /> <TotalPages /></Cell>
			<!-- Source Title -->
			<Gedcom id="$sid">
				<Cell align="center" newline="1" style="header2"><GedcomValue tag="TITL" /></Cell>
			</Gedcom>
		</Header>

		<Body>
		<if condition="$stype=='facts'">
			<!-- List type -->
			<Cell align="center" newline="1" style="listtype"><var var="WT_I18N::translate('Individuals')" /></Cell>
			<TextBox height="$vspace" newline="1" padding="0"/>

			<!-- Individual Name -->
			<SetVar name="fill" value="" />
			<if condition="$sortby=='NAME'">
				<SetVar name="fill" value="#AAAAAA" />
			</if>
			<Cell bgcolor="$fill" border="1" style="list_label" width="$nameindi"><var var="WT_I18N::translate('Name')" /></Cell>
			<!-- Birth date -->
			<SetVar name="fill" value="" />
			<if condition="$sortby=='BIRT:DATE'">
				<SetVar name="fill" value="#AAAAAA" />
			</if>
			<Cell bgcolor="$fill" border="1" style="list_label" width="$datebirth"><var var="WT_Gedcom_Tag::getLabel('BIRT:DATE')" /></Cell>
			<!-- Name of the fact that contains the source -->
			<Cell border="1" style="list_label" width="$fact"><var var="WT_I18N::translate('Event')" /></Cell>
			<!-- Date of the fact -->
			<Cell border="1" style="list_label" width="$dateevent"><var var="WT_Gedcom_Tag::getLabel('DATE')" /></Cell>
			<!-- Detailed source text -->
			<Cell border="1" newline="1" style="list_label"><var var="WT_Gedcom_Tag::getLabel('SOUR:PAGE')" /></Cell>
			<TextBox height="$vspace" newline="1" padding="0"/>

			<!-- Individual List -->
			<List list="individual" filter1=":SOUR CONTAINS @$sid@" sortby="$sortby">
				<SetVar name="moresource" value="0" />
				<SetVar name="printsource" value="0" />
				<!-- Printed List counter -->
				<SetVar name="printedsource" value="$printedsource + 1" />

				<!-- Individual Name -->
				<Cell style="list_value" width="$nameindi"><GetPersonName id="" /></Cell>
				<!-- Birth date -->
				<Cell style="list_value" width="$datebirth"><GedcomValue tag="BIRT:DATE" /></Cell>
				<Facts ignore="$ignore">
					<SetVar name="printfact" value="0" />
					<RepeatTag tag="@fact:SOUR">
						<Gedcom id="@SOUR">
							<if condition="@ID==$sid">
								<SetVar name="printfact" value="1" />
							</if>
						</Gedcom>
					</RepeatTag>

					<if condition="$printfact==1">
						<SetVar name="printsource" value="0" />
						<!-- Indent the fact line if more then one fact has source -->
						<if condition="$moresource==1">
							<Cell style="list_value" width="$moresourcespaceindi"> </Cell>
						</if>

						<!-- Name of the fact that contains the source -->
						<Cell style="list_value" width="$fact"><var var="@fact" /></Cell>
						<!-- Date of the fact -->
						<Cell style="list_value" width="$dateevent"><GedcomValue tag="@fact:DATE"/></Cell>
						<!-- Detailed source text -->
						<Cell style="list_value" newline="1">
							<SetVar name="repeatedSource" value="0" />
							<RepeatTag tag="@fact:SOUR">
								<Gedcom id="@SOUR">
									<if condition="@ID==$sid">
										<SetVar name="printsource" value="1" />
									</if>
								</Gedcom>
								<if condition="$printsource==1">
									<if condition="$repeatedSource==1">; </if>
									<if condition="@SOUR:PAGE!='' or @SOUR:DATA:TEXT!=''">
										<SetVar name="repeatedSource" value="1" />
									</if>
									<GedcomValue tag="SOUR:PAGE"/>
									<if condition="@SOUR:DATA:TEXT!=''">
										<if condition="@SOUR:PAGE!=''">
											<br />
										</if>
										<GedcomValue tag="SOUR:DATA:TEXT" />
									</if>
									<SetVar name="printsource" value="0" />
								</if>
							</RepeatTag>
						</Cell>
						<SetVar name="moresource" value="1" />
					</if>
					<SetVar name="printfact" value="0" />
				</Facts>
			</List>

			<!-- Print the list counter -->
			<if condition="$printedsource==0">
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total individuals')"/>: 0</Cell>
			</if>
			<if condition="$printedsource > 0">
				<TextBox height="$vspace" newline="1" padding="0"/>
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total individuals')"/>: <var var="printedsource" /></Cell>
			</if>

			<NewPage />
			<!-- Family List -->
			<TextBox height="$vspace" newline="1" padding="0"/>
			<Cell align="center" newline="1" style="listtype"><var var="WT_I18N::translate('Families')" /></Cell>
			<TextBox height="$vspace" newline="1" padding="0"/>
			<!-- Family Name -->
			<Cell border="1" style="list_label" width="$namefam"><var var="WT_I18N::translate('Name')" /></Cell>
			<!-- Name of the fact that contains the source -->
			<Cell border="1" style="list_label" width="$fact"><var var="WT_I18N::translate('Event')" /></Cell>
			<!-- Date of the fact -->
			<Cell bgcolor="#AAAAAA" border="1" style="list_label" width="$dateevent"><var var="WT_Gedcom_Tag::getLabel('DATE')" /></Cell>
			<!-- Detailed source text -->
			<Cell border="1" newline="1" style="list_label"><var var="WT_Gedcom_Tag::getLabel('SOUR:PAGE')" /></Cell>

			<!-- Family List -->
			<TextBox height="$vspace" newline="1" padding="0"/>
			<SetVar name="printedsource" value="0" />
			<List list="family" filter1=":SOUR CONTAINS @$sid@" sortby="MARR:DATE">
				<SetVar name="moresource" value="0" />
				<SetVar name="printsource" value="0" />
				<!-- Printed List counter -->
				<SetVar name="printedsource" value="$printedsource + 1" />

				<!-- Family Name -->
				<Cell style="list_value" width="$namefam"><GetPersonName id="" /></Cell>
				<Facts ignore="$ignore">
					<SetVar name="printfact" value="0" />
					<RepeatTag tag="@fact:SOUR">
						<Gedcom id="@SOUR">
							<if condition="@ID==$sid">
								<SetVar name="printfact" value="1" />
							</if>
						</Gedcom>
					</RepeatTag>

					<if condition="$printfact==1">
						<SetVar name="printsource" value="0" />
						<!-- Indent the fact line if more then one fact has source -->
						<if condition="$moresource==1">
							<Cell style="list_value" width="$namefam"> </Cell>
						</if>

						<!-- Name of the fact that contains the source -->
						<Cell style="list_value" width="$fact">
							<if condition="@fact=='MARR'">
								<!-- Print different type of marriages -->
								<if condition="@MARR:TYPE==''">
									<var var="@fact" />
								</if>
								<if condition="@MARR:TYPE=='Religious'">
									<var var="WT_I18N::translate('Religious marriage')" />
								</if>
								<if condition="@MARR:TYPE=='Civil'">
									<var var="WT_I18N::translate('Civil marriage')" />
								</if>
								<if condition="@MARR:TYPE=='Partners'">
									<var var="WT_I18N::translate('Registered partnership')" />
								</if>
							</if>
							<if condition="@fact!='MARR'">
								<var var="@fact" />
							</if>
						</Cell>

						<!-- Date of the fact -->
						<Cell style="list_value" width="$dateevent"><GedcomValue tag="@fact:DATE"/></Cell>
						<!-- Detailed source text -->
						<Cell style="list_value" newline="1">
							<SetVar name="repeatedSource" value="0" />
							<RepeatTag tag="@fact:SOUR">
								<Gedcom id="@SOUR">
									<if condition="@ID==$sid">
										<SetVar name="printsource" value="1" />
									</if>
								</Gedcom>
								<if condition="$printsource==1">
									<if condition="$repeatedSource==1">; </if>
									<if condition="@SOUR:PAGE!='' or @SOUR:DATA:TEXT!=''">
										<SetVar name="repeatedSource" value="1" />
									</if>
									<GedcomValue tag="SOUR:PAGE"/>
									<if condition="@SOUR:DATA:TEXT!=''">
										<if condition="@SOUR:PAGE!=''">
											<br />
										</if>
										<GedcomValue tag="SOUR:DATA:TEXT" />
									</if>
									<SetVar name="printsource" value="0" />
								</if>
							</RepeatTag>
						</Cell>
						<SetVar name="moresource" value="1" />
					</if>
					<SetVar name="printfact" value="0" />
				</Facts>
			</List>

			<!-- Print the list counter -->
			<if condition="$printedsource==0">
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total families')"/>: 0</Cell>
			</if>
			<if condition="$printedsource > 0">
				<TextBox height="$vspace" newline="1" padding="0"/>
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total families')"/>: <var var="printedsource" /></Cell>
			</if>
			<TextBox height="$vspace" newline="1" padding="0"/>
		</if>
		<if condition="$stype=='records'">
			<!-- List type -->
			<Cell align="center" newline="1" style="listtype"><var var="WT_I18N::translate('Individuals')" /></Cell>
			<TextBox height="$vspace" newline="1" padding="0"/>

			<!-- Individual Name -->
			<SetVar name="fill" value="" />
			<if condition="$sortby=='NAME'">
				<SetVar name="fill" value="#AAAAAA" />
			</if>
			<Cell bgcolor="$fill" border="1" style="list_label" width="$nameindi"><var var="WT_I18N::translate('Name')" /></Cell>
			<!-- Birth date -->
			<SetVar name="fill" value="" />
			<if condition="$sortby=='BIRT:DATE'">
				<SetVar name="fill" value="#AAAAAA" />
			</if>
			<Cell bgcolor="$fill" border="1" style="list_label" width="$fact"><var var="WT_Gedcom_Tag::getLabel('BIRT:DATE')" /></Cell>
			<Cell border="1" style="list_label" width="$dateevent"><var var="WT_Gedcom_Tag::getLabel('BIRT:PLAC')" /></Cell>
			<Cell border="1" style="list_label" width="$fact"><var var="WT_Gedcom_Tag::getLabel('DEAT:DATE')" /></Cell>
			<Cell border="1" style="list_label" width="$dateevent"><var var="WT_Gedcom_Tag::getLabel('DEAT:PLAC')" /></Cell>
			<!-- Detailed source text -->
			<Cell border="1" newline="1" style="list_label"><var var="WT_Gedcom_Tag::getLabel('SOUR:PAGE')" /></Cell>
			<TextBox height="$vspace" newline="1" padding="0"/>

			<!-- Individual List -->
			<List list="individual" filter1="SOUR CONTAINS @$sid@" sortby="$sortby">
				<!-- Printed List counter -->
				<SetVar name="printedsource" value="$printedsource + 1" />
				<!-- Individual Name -->
				<Cell style="list_value" width="$nameindi"><GetPersonName id="" /></Cell>
				<!-- Birth date -->
				<Cell style="list_value" width="$dateevent"><GedcomValue tag="BIRT:DATE" /></Cell>
				<!-- Birth place -->
				<Cell style="list_value" width="$fact"><GedcomValue tag="BIRT:PLAC" /></Cell>
				<!-- Death date -->
				<Cell style="list_value" width="$dateevent"><GedcomValue tag="DEAT:DATE" /></Cell>
				<!-- Death place -->
				<Cell style="list_value" width="$fact"><GedcomValue tag="DEAT:PLAC" /></Cell>
				<!-- Detailed source text -->
				<Cell style="list_value" newline="1">
					<GedcomValue tag="SOUR:PAGE"/>
					<if condition="@SOUR:DATA:TEXT!=''">
						<br /><GedcomValue tag="SOUR:DATA:TEXT"/>
					</if>
				</Cell>	
			</List>

			<!-- Print the list counter -->
			<if condition="$printedsource==0">
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total individuals')"/>: 0</Cell>
			</if>
			<if condition="$printedsource > 0">
				<TextBox height="$vspace" newline="1" padding="0"/>
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total individuals')"/>: <var var="printedsource" /></Cell>
			</if>
			<NewPage />
			<!-- Family List -->
			<TextBox height="$vspace" newline="1" padding="0"/>
			<Cell align="center" newline="1" style="listtype"><var var="WT_I18N::translate('Families')" /></Cell>
			<TextBox height="$vspace" newline="1" padding="0"/>
			<!-- Family Name -->
			<Cell border="1" style="list_label" width="$namefam"><var var="WT_I18N::translate('Name')" /></Cell>
			<!-- Name of the fact that contains the source -->
			<Cell bgcolor="#AAAAAA" border="1" style="list_label" width="$dateevent"><var var="WT_Gedcom_Tag::getLabel('MARR:DATE')" /></Cell>
			<!-- Date of the fact -->
			<Cell border="1" style="list_label" width="$fact"><var var="WT_Gedcom_Tag::getLabel('MARR:PLAC')" /></Cell>
			<!-- Detailed source text -->
			<Cell border="1" newline="1" style="list_label"><var var="WT_Gedcom_Tag::getLabel('SOUR:PAGE')" /></Cell>

			<!-- Family List -->
			<TextBox height="$vspace" newline="1" padding="0"/>
			<SetVar name="printedsource" value="0" />
			<List list="family" filter1="SOUR CONTAINS @$sid@" sortby="MARR:DATE">
				<SetVar name="printsource" value="0" />
				<!-- Printed List counter -->
				<SetVar name="printedsource" value="$printedsource + 1" />

				<!-- Family Name -->
				<Cell style="list_value" width="$namefam"><GetPersonName id="" /></Cell>
				<!-- Date of the fact -->
				<Cell style="list_value" width="$dateevent"><GedcomValue tag="MARR:DATE"/></Cell>
				<!-- Place of the fact -->
				<Cell style="list_value" width="$fact"><GedcomValue tag="MARR:PLAC"/></Cell>
				<!-- Detailed source text -->
				<Cell style="list_value" newline="1">
					<GedcomValue tag="SOUR:PAGE"/>
					<if condition="@SOUR:DATA:TEXT!=''">
						<br /><GedcomValue tag="SOUR:DATA:TEXT"/>
					</if>
				</Cell>
			</List>

			<!-- Print the list counter -->
			<if condition="$printedsource==0">
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total families')"/>: 0</Cell>
			</if>
			<if condition="$printedsource > 0">
				<TextBox height="$vspace" newline="1" padding="0"/>
				<Cell align="rightrtl" newline="1" style="list_label"><var var="WT_I18N::translate('Total families')"/>: <var var="printedsource" /></Cell>
			</if>
			<TextBox height="$vspace" newline="1" padding="0"/>
		</if>
		</Body>

		<Footer>
			<Cell align="rightrtl" newline="1" style="date"><Now/></Cell>
		</Footer>

	</Doc>
</Report>
