<?xml version="1.0" encoding="UTF-8"?>
<PGVReport access="PRIV_NONE" icon="source">
	<PGVRTitle><PGVRvar var="pgv_lang[fact_sources_report]" /></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="pgv_lang[find_sourceid]" /></PGVRInput>
	<PGVRInput name="sortby" type="select" default="BIRT:DATE" options="NAME,BIRT:DATE"><PGVRvar var="pgv_lang[sort_by]" /></PGVRInput>
	<PGVRInput name="pageSize" type="select" default="A4" options="letter,A3,A4,legal"><PGVRvar var="pgv_lang[page_size]" /></PGVRInput>
	<PGVRInput name="fonts" type="select" default="dejavusans" options="arialunicid0,dejavusans,helvetica"><PGVRvar var="pgv_lang[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,_PGV_OBJS"/>

	<PGVRDoc pageSize="$pageSize" orientation="landscape">
		<PGVRHeader>
			<PGVRCell align="center" newline="1" style="header"><PGVRvar var="pgv_lang[source_list]" /></PGVRCell>
			<PGVRCell align="rightrtl" newline="1" style="pagenum"><PGVRvar var="pgv_lang[page]" /> <PGVRPageNum /> <PGVRvar var="pgv_lang[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="pgv_lang[individual_list]" /></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="pgv_lang[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="factarray[BIRT:DATE]" /></PGVRCell>
			<!-- Name of the fact that contains the source -->
			<PGVRCell border="1" style="list_label" width="$fact"><PGVRvar var="factarray[EVEN]" /></PGVRCell>
			<!-- Date of the fact -->
			<PGVRCell border="1" style="list_label" width="$dateevent"><PGVRvar var="factarray[DATE]" /></PGVRCell>
			<!-- Detailed source text -->
			<PGVRCell border="1" newline="1" style="list_label"><PGVRvar var="factarray[SOUR]" /></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="factarray[@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="pgv_lang[total_indis]"/>: 0</PGVRCell>
			</PGVRif>
			<PGVRif condition="$printedsource > 0">
				<PGVRTextBox height="$vspace" newline="1" padding="0"/>
				<PGVRCell align="rightrtl" newline="1" style="list_label"><PGVRvar var="pgv_lang[total_indis]"/>: <PGVRvar var="printedsource" /></PGVRCell>
			</PGVRif>

			<!-- Family List -->
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>
			<PGVRCell align="center" newline="1" style="listtype"><PGVRvar var="pgv_lang[family_list]" /></PGVRCell>
			<PGVRTextBox height="$vspace" newline="1" padding="0"/>
			<!-- Family Name -->
			<PGVRCell border="1" style="list_label" width="$namefam"><PGVRvar var="pgv_lang[name]" /></PGVRCell>
			<!-- Name of the fact that contains the source -->
			<PGVRCell border="1" style="list_label" width="$fact"><PGVRvar var="factarray[EVEN]" /></PGVRCell>
			<!-- Date of the fact -->
			<PGVRCell bgcolor="#AAAAAA" border="1" style="list_label" width="$dateevent"><PGVRvar var="factarray[DATE]" /></PGVRCell>
			<!-- Detailed source text -->
			<PGVRCell border="1" newline="1" style="list_label"><PGVRvar var="factarray[SOUR]" /></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="factarray[@fact]"/>
								</PGVRif>
								<PGVRif condition="@MARR:TYPE=='Religious'">
									<PGVRvar var="factarray[MARR_RELIGIOUS]" />
								</PGVRif>
								<PGVRif condition="@MARR:TYPE=='Civil'">
									<PGVRvar var="factarray[MARR_CIVIL]" />
								</PGVRif>
								<PGVRif condition="@MARR:TYPE=='Partners'">
									<PGVRvar var="factarray[MARR_PARTNERS]" />
								</PGVRif>
							</PGVRif>
							<PGVRif condition="@fact!='MARR'">
								<PGVRvar var="factarray[@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="pgv_lang[total_fams]"/>: 0</PGVRCell>
			</PGVRif>
			<PGVRif condition="$printedsource > 0">
				<PGVRTextBox height="$vspace" newline="1" padding="0"/>
				<PGVRCell align="rightrtl" newline="1" style="list_label"><PGVRvar var="pgv_lang[total_fams]"/>: <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>
