<data>
	<organization>
		<name>${organizationData.name}</name>
		<address>${organizationData.mainContact.address}</address>
		<web>www.retriever-klub.cz</web>
	</organization>
    <#if participantsData?has_content>
        <#list participantsData as participant>
            <@printParticipant participant />
        </#list>
    <#else>
        <@printEmptyParticipant />
    </#if>
</data>

<#macro printParticipant participant>
    <#local contacts = participantContacts?api.get(participant.id)>
    <#local infos = participantInfos?api.get(participant.id)>
    <#local assets = participantAssets?api.get(participant.id)>
    <#if assets?has_content>
        <#if ParticipantFunctions.getAssetByFunction(assets, 'Fena')??>
            <#local fena = ParticipantFunctions.getAssetByFunction(assets, 'Fena')>
        </#if>
        <#if ParticipantFunctions.getAssetByFunction(assets, 'Pes 1')??>
            <#local pes1 = ParticipantFunctions.getAssetByFunction(assets, 'Pes 1')>
        </#if>
        <#if ParticipantFunctions.getAssetByFunction(assets, 'Pes 2')??>
            <#local pes2 = ParticipantFunctions.getAssetByFunction(assets, 'Pes 2')>
        </#if>
    </#if>
	<#local publishDate = ParticipantFunctions.getInfoValue(infos, 'Datum vydání KL')>
	<#local limitationDate = ParticipantFunctions.getInfoValue(infos, 'Omezení KL')>
	<participant>
		<formNumber>${ParticipantFunctions.getInfoValue(infos, 'Č. KL')}</formNumber>
		<validity>${RKCZFunctions.printValidityRange(publishDate, limitationDate)}</validity>
		<breed><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Plemeno')}</#if></breed>
		<matting>${ParticipantFunctions.getInfoValue(infos, 'Datum krytí')}</matting>
		<insemination>${ParticipantFunctions.getInfoValue(infos, 'Inseminace')}</insemination>
		<semenType>${ParticipantFunctions.getInfoValue(infos, 'Typ semene')}</semenType>

		<female>
			<name><#if fena??>${fena.name?html!""}</#if></name>
			<birthday><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Datum narození')}</#if></birthday>
			<numberRKCZ><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Č. uchovnění')}</#if></numberRKCZ>
			<number><#if fena??>${fena.number!""}</#if></number>
			<hd><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'HD')}</#if></hd>
			<ed><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'ED')}</#if></ed>
			<ocd><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'OCD')}</#if></ocd>
			<dentition><#if fena??>${ParticipantFunctions.getAssetAttributeValue(fena.renderedAttributes, 'Chrup')}</#if></dentition>
			<genTestRequired>${ParticipantFunctions.getInfoValue(infos, 'GenTesty feny - povinné')}</genTestRequired>
            <genTestRecommended>${ParticipantFunctions.getInfoValue(infos, 'GenTesty feny - nepovinné')}</genTestRecommended>
            <genTestOther>${ParticipantFunctions.getInfoValue(infos, 'Další údaje feny')}</genTestOther>
            <#if fena??>
                <#local femaleMembers = assetMembers?api.get(fena.id)![]>

                <#if ParticipantFunctions.getAssetMemberByType(femaleMembers, 'Majitel')??>
                    <#local femaleMemberByType = ParticipantFunctions.getAssetMemberByType(femaleMembers, 'Majitel')>
                    <#if femaleMemberByType?has_content>
                        <#local femaleOwnerContact = ParticipantFunctions.getContactByType(femaleMemberByType.contacts, 'Kontaktní adresa')>
                    </#if>
                </#if>
            </#if>
			<owner>
				<name><#if femaleMemberByType??>${femaleMemberByType.name!""}</#if></name>
				<address><#if femaleOwnerContact??>${femaleOwnerContact.address}</#if></address>
				<email><#if femaleOwnerContact??>${femaleOwnerContact.emails}</#if></email>
				<mobile><#if femaleOwnerContact??>${femaleOwnerContact.mobiles}</#if></mobile>
			</owner>
		</female>
		<male1>
			<name><#if pes1??>${pes1.name?html!""}</#if></name>
			<birthday><#if pes1??>${ParticipantFunctions.getAssetAttributeValue(pes1.renderedAttributes, 'Datum narození')}</#if></birthday>
			<number><#if pes1??>${pes1.number!""}</#if></number>
			<hd><#if pes1??>${ParticipantFunctions.getAssetAttributeValue(pes1.renderedAttributes, 'HD')}</#if></hd>
			<ed><#if pes1??>${ParticipantFunctions.getAssetAttributeValue(pes1.renderedAttributes, 'ED')}</#if></ed>
			<ocd><#if pes1??>${ParticipantFunctions.getAssetAttributeValue(pes1.renderedAttributes, 'OCD')}</#if></ocd>
			<dentition><#if pes1??>${ParticipantFunctions.getAssetAttributeValue(pes1.renderedAttributes, 'Chrup')}</#if></dentition>
			<genTestRequired>${ParticipantFunctions.getInfoValue(infos, 'GenTesty KP1 - povinné')}</genTestRequired>
            <genTestRecommended>${ParticipantFunctions.getInfoValue(infos, 'GenTesty KP1 - nepovinné')}</genTestRecommended>
            <genTestOther>${ParticipantFunctions.getInfoValue(infos, 'Další údaje KP1')}</genTestOther>
			<recommended>${ParticipantFunctions.getInfoValue(infos, 'Povoleno krytí P1')?replace('✖ ', '')?replace('✔ ', '')}</recommended>
            <#if pes1??>
                <#local male1Members = assetMembers?api.get(pes1.id)![]>
                <#if ParticipantFunctions.getAssetMemberByType(male1Members, 'Majitel')??>
                    <#local male1MemberByType = ParticipantFunctions.getAssetMemberByType(male1Members, 'Majitel')>
                    <#if male1MemberByType?has_content>
                        <#local male1OwnerContact = ParticipantFunctions.getContactByType(male1MemberByType.contacts, 'Kontaktní adresa')>
                    </#if>
                </#if>
            </#if>
			<owner>
				<name><#if male1MemberByType??>${male1MemberByType.name!""}</#if></name>
				<address><#if male1OwnerContact??>${male1OwnerContact.address}</#if></address>
				<email><#if male1OwnerContact??>${male1OwnerContact.emails}</#if></email>
				<mobile><#if male1OwnerContact??>${male1OwnerContact.mobiles}</#if></mobile>
			</owner>
		</male1>
		<male2>
			<name><#if pes2??>${pes2.name?html!""}</#if></name>
			<birthday><#if pes2??>${ParticipantFunctions.getAssetAttributeValue(pes2.renderedAttributes, 'Datum narození')}</#if></birthday>
			<number><#if pes2??>${pes2.number!""}</#if></number>
			<hd><#if pes2??>${ParticipantFunctions.getAssetAttributeValue(pes2.renderedAttributes, 'HD')}</#if></hd>
			<ed><#if pes2??>${ParticipantFunctions.getAssetAttributeValue(pes2.renderedAttributes, 'ED')}</#if></ed>
			<ocd><#if pes2??>${ParticipantFunctions.getAssetAttributeValue(pes2.renderedAttributes, 'OCD')}</#if></ocd>
			<dentition><#if pes2??>${ParticipantFunctions.getAssetAttributeValue(pes2.renderedAttributes, 'Chrup')}</#if></dentition>
			<genTestRequired>${ParticipantFunctions.getInfoValue(infos, 'GenTesty KP2 - povinné')}</genTestRequired>
            <genTestRecommended>${ParticipantFunctions.getInfoValue(infos, 'GenTesty KP2 - nepovinné')}</genTestRecommended>
            <genTestOther>${ParticipantFunctions.getInfoValue(infos, 'Další údaje KP2')}</genTestOther>
			<recommended>${ParticipantFunctions.getInfoValue(infos, 'Povoleno krytí P2')?replace('✖ ', '')?replace('✔ ', '')}</recommended>
            <#if pes2??>
                <#local male2Members = assetMembers?api.get(pes2.id)![]>
                <#if ParticipantFunctions.getAssetMemberByType(male2Members, 'Majitel')??>
                    <#local male2MemberByType = ParticipantFunctions.getAssetMemberByType(male2Members, 'Majitel')>
                    <#if male2MemberByType?has_content>
                        <#local male2OwnerContact = ParticipantFunctions.getContactByType(male2MemberByType.contacts, 'Kontaktní adresa')>
                    </#if>
                </#if>
            </#if>
			<owner>
				<name><#if male2MemberByType??>${male2MemberByType.name!""}</#if></name>
				<address><#if male2OwnerContact??>${male2OwnerContact.address}</#if></address>
				<email><#if male2OwnerContact??>${male2OwnerContact.emails}</#if></email>
				<mobile><#if male2OwnerContact??>${male2OwnerContact.mobiles}</#if></mobile>
			</owner>
		</male2>
		<created>${publishDate!""}</created>
		<createdBy>${ParticipantFunctions.getInfoValue(infos, 'Poradce chovu')?html}</createdBy>
	</participant>
</#macro>

<#macro printEmptyParticipant>
	<participant>
		<formNumber />
		<validity />
		<breed />
		<matting />
		<insemination />
		<semenType />
		<female>
			<name />
			<birthday />
			<numberRKCZ />
			<number />
			<hd />
			<ed />
			<ocd />
			<dentition />
			<genTestRequired />
			<genTestRecommended />
			<genTestOther />
			<owner>
				<name />
				<address />
				<email />
				<mobile />
			</owner>
		</female>
		<male1>
			<name />
			<birthday />
			<number />
			<recommended />
			<hd />
			<ed />
			<ocd />
			<dentition />
			<genTestRequired />
			<genTestRecommended />
			<genTestOther />
			<owner>
				<name />
				<address />
				<email />
				<mobile />
			</owner>
		</male1>
		<male2>
			<name />
			<birthday />
			<number />
			<recommended />
			<hd />
			<ed />
			<ocd />
			<dentition/>
			<genTestRequired />
			<genTestRecommended />
			<genTestOther />
			<owner>
				<name />
				<address />
				<email />
				<mobile />
			</owner>
		</male2>
		<created />
		<createdBy />
	</participant>
</#macro>

