<#-- @ftlvariable name="pedigrees" type="java.util.Collection<cz.vrk.pi.crm.api.cmku.dog.DogPedigreeTemplateData>" -->
<data>
	<printVersion>${printVersion?string("ANO", "NE")}</printVersion>
    <#if pedigrees??>
        <#list pedigrees as pedigree>
			<pedigree>
				<pedigreeType>${pedigree.pedigreeType}</pedigreeType>
                <#if pedigree.breedName??>
                    <#assign breedName = pedigree.breedName?split("/")>
                </#if>
				<breedName><#if breedName??>${breedName[0]!""}</#if></breedName>
				<breedNameEn><#if breedName??>${breedName[1]!""}</#if></breedNameEn>
				<name>${pedigree.name}</name>
				<breedingStationName>${pedigree.breedingStationName}</breedingStationName>
				<breederName>${(pedigree.breederName)!""}</breederName>
				<breederStreet>${(pedigree.breederStreet)!""}</breederStreet>
				<breederCity>${(pedigree.breederCity)!""}</breederCity>
				<breederZip>${(pedigree.breederZip)!""}</breederZip>
				<sex>${pedigree.sexShort}</sex>
				<fullNumber>${pedigree.fullNumber}</fullNumber>
				<foreignRegistrationNumber>${pedigree.foreignRegistrationNumber}</foreignRegistrationNumber>
				<tatooNumber>${pedigree.tatooNumber}</tatooNumber>
				<chipNumber>${(pedigree.chipNumber)!""}</chipNumber>
				<birthday>${((pedigree.birthday)?string("dd.MM.yyyy"))!""}</birthday>
				<colorName>${(pedigree.colorName)!""}</colorName>
				<furName>${(pedigree.furName)!""}</furName>
				<pedigreePrintedByUsername>${(pedigree.pedigreePrintedByUsername)!""}</pedigreePrintedByUsername>
				<pedigreePrintDate>${((pedigree.pedigreePrintDate)?string("dd.MM.yyyy"))!""}</pedigreePrintDate>

				<#list 1..5 as x>
                    <#assign hasOwner = false>
                    <#if pedigree.owners?has_content>
                        <#if pedigree.owners[x - 1]??>
                            <#assign owner = pedigree.owners[x - 1]>
                            <#assign hasOwner = true>
                        </#if>
                    </#if>
					<owner>
						<name><#if hasOwner>${owner.name!""}</#if></name>
						<address><#if hasOwner>${owner.address!""}</#if></address>
						<fromDate><#if hasOwner>${((owner.fromDate)?string("dd.MM.yyyy"))!""}</#if></fromDate>
						<toDate><#if hasOwner>${((owner.toDate)?string("dd.MM.yyyy"))!""}</#if></toDate>
					</owner>
				</#list>

				<familyTree>
                    <#if pedigree.familyTree??>
                        <@constructTree pedigree.familyTree.father!{} pedigree.familyTree.mother!{} 1 />
                    </#if>
				</familyTree>
			</pedigree>
        </#list>
    </#if>
</data>

<#macro constructTree father mother depth>
    <#local newDepth = depth + 1 />
    <#if father?has_content>
		<father>
            <#if depth = 2 || depth = 3>
				<name>
                    ${father.fullName}
				</name>
                <#if depth = 3>
					<lineOne></lineOne>
                </#if>
            <#else>
				<name>
                    ${father.name}
				</name>
				<breedingStationName><#if father.breedingStationName??>${father.breedingStationName}</#if></breedingStationName>
				<colorName>${(father.colorName)!""}</colorName>
				<height><#if father.height??>${father.height} cm</#if></height>
            </#if>

			<fullNumber>
                <#if father.foreignNumber?has_content>
                    ${father.foreignNumber} <#if father.registrationNumber?has_content>(${father.registrationNumber})</#if>
                <#else>
                    ${father.registrationNumber!""}
                </#if>
			</fullNumber>

            <@constructTree father.father!{} father.mother!{} newDepth />
		</father>
    </#if>
    <#if mother?has_content>
		<mother>
            <#if depth = 3 || depth = 4>
				<name>
                    ${mother.fullName}
				</name>
                <#if depth = 3>
					<lineOne></lineOne>
                </#if>
            <#else>
				<name>
                    ${mother.name}
				</name>
				<breedingStationName><#if mother.breedingStationName??>${mother.breedingStationName}</#if></breedingStationName>
				<colorName>${(mother.colorName)!""}</colorName>
				<height><#if mother.height??>${mother.height} cm</#if></height>
            </#if>

			<fullNumber>
                <#if mother.foreignNumber?has_content>
                    ${mother.foreignNumber} <#if mother.registrationNumber?has_content>(${mother.registrationNumber})</#if>
                <#else>
                    ${mother.registrationNumber!""}
                </#if>
			</fullNumber>

            <@constructTree mother.father!{} mother.mother!{} newDepth />
		</mother>
    </#if>
</#macro>