<?xml version="1.0" encoding="UTF-8"?>
<PGVReport>
	<PGVRTitle><PGVRvar var="i18n::translate('Fact Sources')" /></PGVRTitle>
	<PGVRDescription>Prints a list of individuals and families with a specific source for facts</PGVRDescription>

	<PGVRInput name="sid" lookup="SOUR" default="" type="text"><PGVRvar var="i18n::translate('Find Source ID')" /></PGVRInput>
	<PGVRInput name="sortby" type="select" default="BIRT:DATE" options="NAME,BIRT:DATE"><PGVRvar var="i18n::translate('Sort by')" /></PGVRInput>
	<PGVRInput name="pageSize" type="select" default="A4" options="letter,A3,A4,legal"><PGVRvar var="i18n::translate('Page size')" /></PGVRInput>
	<PGVRInput name="fonts" type="select" default="dejavusans" options="arialunicid0,dejavusans,helvetica"><PGVRvar var="i18n::translate('Font')"/></PGVRInput>

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

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

	<PGVRDoc pageSize="$pageSize" orientation="landscape">
		<PGVRHeader>
			<PGVRCell align="center" newline="1" style="header"><PGVRvar var="i18n::translate('Sources')" /></PGVRCell>
			<PGVRCell align="rightrtl" newline="1" style="pagenum"><PGVRvar var="i18n::translate('Page')" /> <PGVRPageNum /> <PGVRvar var="i18n::translate('of')" /> <PGVRTotalPages /></PGVRCell>
			<!-- Source Title -->
			<PGVRGedcom id="$sid">
				<PGVRCell align="center" newline="1" style="header2"><PGVRGedcomValue tag="TITL" /> (<PGVRvar var="sid"/>)</PGVRCell>
			</PGVRGedcom>
		</PGVRHeader>

		<PGVRBody>
			<!-- List type -->
			<PGVRCell align="center" newline="1" style="listtype"><PGVRvar var="i18n::translate('Individuals')" /></PGVRCell>
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>

			<!-- Individual Name -->
			<PGVRSetVar name="fill" value="" />
			<PGVRif condition="$sortby=='NAME'">
				<PGVRSetVar name="fill" value="#AAAAAA" />
			</PGVRif>
			<PGVRCell bgcolor="$fill" border="1" style="list_label" width="$nameindi"><PGVRvar var="i18n::translate('Name')" /></PGVRCell>
			<!-- Birth date -->
			<PGVRSetVar name="fill" value="" />
			<PGVRif condition="$sortby=='BIRT:DATE'">
				<PGVRSetVar name="fill" value="#AAAAAA" />
			</PGVRif>
			<PGVRCell bgcolor="$fill" border="1" style="list_label" width="$datebirth"><PGVRvar var="i18n::translate('Birth Date')" /></PGVRCell>
			<!-- Name of the fact that contains the source -->
			<PGVRCell border="1" style="list_label" width="$fact"><PGVRvar var="i18n::translate('Event')" /></PGVRCell>
			<!-- Date of the fact -->
			<PGVRCell border="1" style="list_label" width="$dateevent"><PGVRvar var="i18n::translate('Date')" /></PGVRCell>
			<!-- Detailed source text -->
			<PGVRCell border="1" newline="1" style="list_label"><PGVRvar var="i18n::translate('Source')" /></PGVRCell>
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>

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

				<!-- Individual Name -->
				<PGVRCell style="list_value" width="$nameindi"><PGVRGetPersonName id="" /> - (<PGVRGedcomValue tag="@id" />)</PGVRCell>
				<!-- Birth date -->
				<PGVRCell style="list_value" width="$datebirth"><PGVRGedcomValue tag="BIRT:DATE" /></PGVRCell>
				<PGVRFacts ignore="$ignore">
					<PGVRSetVar name="printfact" value="0" />
					<PGVRRepeatTag tag="@fact:SOUR">
						<PGVRGedcom id="@SOUR">
							<PGVRif condition="@ID==$sid">
								<PGVRSetVar name="printfact" value="1" />
							</PGVRif>
						</PGVRGedcom>
					</PGVRRepeatTag>

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

						<!-- Name of the fact that contains the source -->
						<PGVRCell style="list_value" width="$fact"><PGVRvar var="i18n::translate('@fact')"/></PGVRCell>
						<!-- Date of the fact -->
						<PGVRCell style="list_value" width="$dateevent"><PGVRGedcomValue tag="@fact:DATE"/></PGVRCell>
						<!-- Detailed source text -->
						<PGVRCell style="list_value" newline="1">
							<PGVRRepeatTag tag="@fact:SOUR">
								<PGVRGedcom id="@SOUR">
									<PGVRif condition="@ID==$sid">
										<PGVRSetVar name="printsource" value="1" />
									</PGVRif>
								</PGVRGedcom>
								<PGVRif condition="$printsource==1">
									<PGVRGedcomValue tag="SOUR:PAGE"/>
									<PGVRif condition="@SOUR:DATA:TEXT!=''">
										<br /><PGVRGedcomValue tag="SOUR:DATA:TEXT"/>
									</PGVRif>
									<PGVRSetVar name="printsource" value="0" />
								</PGVRif>
							</PGVRRepeatTag>
						</PGVRCell>
						<PGVRSetVar name="moresource" value="1" />
					</PGVRif>
					<PGVRSetVar name="printfact" value="0" />
				</PGVRFacts>
			</PGVRList>

			<!-- Print the list counter -->
			<PGVRif condition="$printedsource==0">
				<PGVRCell align="rightrtl" newline="1" style="list_label"><PGVRvar var="i18n::translate('Total individuals')"/>: 0</PGVRCell>
			</PGVRif>
			<PGVRif condition="$printedsource > 0">
				<PGVRTextBox height="$vspace" newline="1" padding="0"/>
				<PGVRCell align="rightrtl" newline="1" style="list_label"><PGVRvar var="i18n::translate('Total individuals')"/>: <PGVRvar var="printedsource" /></PGVRCell>
			</PGVRif>

			<!-- Family List -->
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>
			<PGVRCell align="center" newline="1" style="listtype"><PGVRvar var="i18n::translate('Families')" /></PGVRCell>
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>
			<!-- Family Name -->
			<PGVRCell border="1" style="list_label" width="$namefam"><PGVRvar var="i18n::translate('Name')" /></PGVRCell>
			<!-- Name of the fact that contains the source -->
			<PGVRCell border="1" style="list_label" width="$fact"><PGVRvar var="i18n::translate('Event')" /></PGVRCell>
			<!-- Date of the fact -->
			<PGVRCell bgcolor="#AAAAAA" border="1" style="list_label" width="$dateevent"><PGVRvar var="i18n::translate('Date')" /></PGVRCell>
			<!-- Detailed source text -->
			<PGVRCell border="1" newline="1" style="list_label"><PGVRvar var="i18n::translate('Source')" /></PGVRCell>

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

				<!-- Family Name -->
				<PGVRCell style="list_value" width="$namefam"><PGVRGetPersonName id="" /> - (<PGVRGedcomValue tag="@id" />)</PGVRCell>
				<PGVRFacts ignore="$ignore">
					<PGVRSetVar name="printfact" value="0" />
					<PGVRRepeatTag tag="@fact:SOUR">
						<PGVRGedcom id="@SOUR">
							<PGVRif condition="@ID==$sid">
								<PGVRSetVar name="printfact" value="1" />
							</PGVRif>
						</PGVRGedcom>
					</PGVRRepeatTag>

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

						<!-- Name of the fact that contains the source -->
						<PGVRCell style="list_value" width="$fact">
							<PGVRif condition="@fact=='MARR'">
								<!-- Print different type of marriages -->
								<PGVRif condition="@MARR:TYPE==''">
									<PGVRvar var="i18n::translate('@fact')"/>
								</PGVRif>
								<PGVRif condition="@MARR:TYPE=='Religious'">
									<PGVRvar var="i18n::translate('Religious Marriage')" />
								</PGVRif>
								<PGVRif condition="@MARR:TYPE=='Civil'">
									<PGVRvar var="i18n::translate('Civil Marriage')" />
								</PGVRif>
								<PGVRif condition="@MARR:TYPE=='Partners'">
									<PGVRvar var="i18n::translate('Registered Partnership')" />
								</PGVRif>
							</PGVRif>
							<PGVRif condition="@fact!='MARR'">
								<PGVRvar var="i18n::translate('@fact')"/>
							</PGVRif>
						</PGVRCell>

						<!-- Date of the fact -->
						<PGVRCell style="list_value" width="$dateevent"><PGVRGedcomValue tag="@fact:DATE"/></PGVRCell>
						<!-- Detailed source text -->
						<PGVRCell style="list_value" newline="1">
							<PGVRRepeatTag tag="@fact:SOUR">
								<PGVRGedcom id="@SOUR">
									<PGVRif condition="@ID==$sid">
										<PGVRSetVar name="printsource" value="1" />
									</PGVRif>
								</PGVRGedcom>
								<PGVRif condition="$printsource==1">
									<PGVRGedcomValue tag="SOUR:PAGE"/>
									<PGVRif condition="@SOUR:DATA:TEXT!=''">
										<br /><PGVRGedcomValue tag="SOUR:DATA:TEXT"/>
									</PGVRif>
									<PGVRSetVar name="printsource" value="0" />
								</PGVRif>
							</PGVRRepeatTag>
						</PGVRCell>
						<PGVRSetVar name="moresource" value="1" />
					</PGVRif>
					<PGVRSetVar name="printfact" value="0" />
				</PGVRFacts>
			</PGVRList>

			<!-- Print the list counter -->
			<PGVRif condition="$printedsource==0">
				<PGVRCell align="rightrtl" newline="1" style="list_label"><PGVRvar var="i18n::translate('Total families')"/>: 0</PGVRCell>
			</PGVRif>
			<PGVRif condition="$printedsource > 0">
				<PGVRTextBox height="$vspace" newline="1" padding="0"/>
				<PGVRCell align="rightrtl" newline="1" style="list_label"><PGVRvar var="i18n::translate('Total families')"/>: <PGVRvar var="printedsource" /></PGVRCell>
			</PGVRif>
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>
		</PGVRBody>

		<PGVRFooter>
			<PGVRCell align="rightrtl" newline="1" style="date"><PGVRNow/></PGVRCell>
		</PGVRFooter>

	</PGVRDoc>
</PGVReport>
