<!DOCTYPE html>
<html lang="en">
{{fscript
	globals setContactsForDisplay:selectedObjects.	
}}
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="{{framework}}/default.css" type="text/css" charset="utf-8">
	<link rel="stylesheet" href="{{framework}}/screen.css" type="text/css" charset="utf-8" media="screen">
	<link rel="stylesheet" href="{{framework}}/print.css" type="text/css" charset="utf-8" media="print">
	<link rel="stylesheet" href="{{resources}}/custom.css" type="text/css" charset="utf-8">
	
</head>
<body>
	<h2>{{localize 'Contacts'}}</h2>
	{{foreach contact contactsForDisplay do}}
	<table>
	<tr>
	<td>
		{{fscript
			
			((contact fromRelationships count > 0) | (contact toRelationships count > 0))ifFalse:
			[globals setShowRelationships:''.].
			
			((contact extra1 == nil) & (contact extra2 == nil) & (contact extra3 == nil) & (contact extra4 == nil) & (contact extra5 == nil)
			 & (contact extra6 == nil) & (contact extra7 == nil) & (contact extra8 == nil) & (contact extra9 == nil) & (contact extra10 == nil)
			 & (contact extra11 == nil) & (contact extra12 == nil) & (contact extraDate1 == nil) & (contact extraDate2 == nil)
			 & (contact extraDate3 == nil) & (contact extraDate4 == nil))ifTrue:
			[globals setShowExtraFields:''.].

		}}
		<h3>{{contact.firstname}} {{contact.lastname}}</h3>
		
		{{if contact.defaultPhone}}<span id="labelHeader">{{contact.defaultPhone.label.name}}:</span> {{contact.defaultPhone.phoneNumber}}<br>{{endif}}
		{{if contact.defaultEmailAddress}}<span id="labelHeader">{{contact.defaultEmailAddress.label.name}}:</span> {{contact.defaultEmailAddress.url}}<br>{{endif}}
		{{if contact.category}}<span id="labelHeader">{{localize 'Category'}}:</span> {{contact.category.name}}<br>{{endif}}
		{{if contact.keywordsString}}<span id="labelHeader">{{localize 'Keywords'}}:</span> {{contact.keywordsString}}<br><br>{{endif}}
		
		{{if contact.relationshipToMe}}<span id="labelHeader">{{localize 'Relation To Me'}}:</span> {{contact.relationshipToMe}}<br>{{endif}}
		
		{{if contact.alias}}<span id="labelHeader">{{localize 'Alias'}}:</span> {{contact.alias}}<br>{{endif}}
		{{if contact.nickname}}<span id="labelHeader">{{localize 'Nickname'}}:</span> {{contact.nickname}}<br>{{endif}}
		{{if contact.birthdayString}}<span id="labelHeader">{{localize 'Birthday'}}:</span> {{contact.birthdayString}}<br>{{endif}}
		{{if contact.anniversaryString}}<span id="labelHeader">{{localize 'Anniversary'}}:</span> {{contact.anniversaryString}}<br>{{endif}}
		{{if contact.hobbies}}<span id="labelHeader">{{localize 'Hobbies'}}:</span> {{contact.hobbies}}<br>{{endif}}
		{{if contact.priorityEnumWrapper.stringValue}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{contact.priorityEnumWrapper.stringValue}}<br>{{endif}}
		{{if contact.tagline}}<span id="labelHeader">{{localize 'Tagline'}}:</span> {{contact.tagline}}<br>{{endif}}
		{{if contact.details}}<span id="labelHeader">{{localize 'Details'}}:</span> {{contact.details.plainTextRepresentation}}<br>{{endif}}

		<br><br>
		{{if contact.geoAddresses.@count}}
			<div id="groupHeader">{{localize 'ADDRESSES'}}</div><br>
			{{foreach address contact.geoAddresses do}} 
			<span id="labelHeader">{{address.label.name}}</span><br>
			{{address.street}} <br>
			{{address.city}} {{address.state}} {{address.postalCode}}<br>
			{{address.country}}<br><br>
			{{endforeach do}}
		{{endif}}

		{{if showRelationships}}
		<div id="groupHeader">{{localize 'RELATIONSHIPS'}}</div>
			<br>
			{{foreach relationship contact.fromRelationships do}} 
			{{relationship.sourceContact.name}} {{relationship.relationshipType.name}} {{relationship.destinationContact.name}}<br>
			{{endforeach do}}
			{{foreach relationship contact.toRelationships do}} 
			{{relationship.sourceContact.name}} {{relationship.relationshipType.name}} {{relationship.destinationContact.name}}<br>
			{{endforeach do}}
			<br>
		{{endif}}

		{{if contact.nextPendingTask}}
		<div id="groupHeader">{{localize 'NEXT TASK'}}</div>
		<br>
		<b>{{contact.nextPendingTask.title}}</b><br>
		{{if contact.nextPendingTask.dueDate}}<span id="labelHeader">{{localize 'Due'}}:</span> {{contact.nextPendingTask.dueDate.mcShortDate}}<br>{{endif}}
		{{if contact.nextPendingTask.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{contact.nextPendingTask.startDate.mcLongDate}}<br>{{endif}}
		{{if contact.nextPendingTask.completeDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{contact.nextPendingTask.completeDate.mcLongDate}}<br>{{endif}}
		{{if contact.nextPendingTask.priorityString}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{contact.nextPendingTask.priorityString}}<br>{{endif}}
		{{endif}}
		<br>
		
		{{if contact.organizationRoles.@count}}
		<div id="groupHeader">{{localize 'COMPANIES'}}</div><br>
			{{foreach role contact.organizationRoles do}} 
			<b>{{role.organization.name}}</b><br>
			{{if role.roleType.name}}<span id="labelHeader">{{localize 'Role Type'}}:</span> {{role.roleType.name}}<br>{{endif}}
			{{if role.department}}<span id="labelHeader">{{localize 'Department'}}:</span> {{role.department}}<br>{{endif}}
			{{if role.name}}<span id="labelHeader">{{localize 'Title'}}:</span> {{role.name}}<br>{{endif}}
			{{if role.organization.defaultPhone}}<span id="labelHeader">{{localize 'Default Phone'}}:</span> {{role.organization.defaultPhone.phoneNumber}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if contact.timeblocks.@count}}
		<div id="groupHeader">{{localize 'APPOINTMENTS'}}</div><br>
			{{foreach appointment contact.timeblocks do}} 
			<b>{{appointment.subject}}</b><br>
			<span id="labelHeader">{{localize 'Status'}}:</span> {{appointment.statusString}}<br>
			<span id="labelHeader">{{localize 'Time'}}:</span> {{appointment.startDate.mcLongDate}} at {{appointment.startDate.mcShortTime}} - {{appointment.endDate.mcShortTime}}<br>
			{{if appointment.details}}<span id="labelHeader">{{localize 'Details'}}:</span> {{appointment.details}}<br>
			{{endif}}
			<br>
			{{endforeach do}}
			<br><br>
		{{endif}}
		
		{{if contact.tasks.@count}}
		<div id="groupHeader">{{localize 'TASKS'}}</div><br>
			{{foreach task contact.tasks do}} 
			<b>{{task.title}}</b><br>
			{{if task.dueDate}}<span id="labelHeader">{{localize 'Due'}}:</span> {{task.dueDate.mcLongDate}}<br>{{endif}}
			{{if task.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{task.startDate.mcLongDate}}{{endif}}
			{{if task.completeDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{task.completeDate.mcLongDate}}{{endif}}
			{{if task.priorityString}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{task.priorityString}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if contact.projectRoles.@count}}
		<div id="groupHeader">{{localize 'PROJECTS'}}</div><br>
			{{foreach role contact.projectRoles do}} 
			<b>{{role.project.name}}</b><br>
			<span id="labelHeader">{{localize 'Role Type'}}:</span> {{role.roleType.name}}<br>
			<span id="labelHeader">{{localize 'Status'}}:</span> {{role.project.statusString}}<br>
			{{if role.project.dueDate}}<span id="labelHeader">{{localize 'Due Date'}}:</span> {{role.project.dueDate.mcLongDate}}<br>{{endif}}
			{{if role.project.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{role.project.startDate.mcLongDate}}<br>{{endif}}
			{{if role.project.completeDate}}<span id="labelHeader">{{localize 'Complete Date'}}:</span> {{role.project.completeDate.mcLongDate}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if contact.opportunityRoles.@count}}
		<div id="groupHeader">{{localize 'OPPORTUNITIES'}}</div><br>
			{{foreach role contact.opportunityRoles do}} 
			<b>{{role.opportunity.name}}</b><br>
			<span id="labelHeader">{{localize 'Role Type'}}:</span> {{role.roleType.name}}<br>
			<span id="labelHeader">{{localize 'Status'}}:</span> {{role.opportunity.opportunityStateString}}<br>
			{{if role.opportunity.dueDate}}<span id="labelHeader">{{localize 'Forecasted Date'}}:</span> {{role.opportunity.dueDate.mcLongDate}}<br>{{endif}}
			{{if role.opportunity.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{role.opportunity.startDate.mcLongDate}}<br>{{endif}}
			{{if role.opportunity.completeDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{role.opportunity.completeDate.mcLongDate}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if contact.correspondences.@count}}
		<div id="groupHeader">{{localize 'LETTERS'}}</div><br>
			{{foreach correspondence contact.correspondences do}} 
			<span id="labelHeader">{{localize 'Subject'}}:</span> {{correspondence.subject}}     
			<span id="labelHeader">{{localize 'Create Date'}}:</span>{{correspondence.createDate.mcLongDateTime}}<br>
			<br>
			{{endforeach do}}
			<br>
		{{endif}}
		
		{{if contact.groups.@count}}
		<div id="groupHeader">{{localize 'GROUPS'}}</div><br>
			{{foreach group contact.groups do}} 
			<b>{{group.name}}</b><br>

			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if contact.customRecordSets.@count}}
			<div id="groupHeader">{{localize 'FORMS'}}</div><br>
			{{foreach recordSet contact.customRecordSets do}}
			<b>{{recordSet.customRecordSetDefinition.name}}</b><br>
				{{foreach record recordSet.customRecords do}}
	 			{{if record.displayString}}<span id="labelHeader">{{record.customRecordDefinition.name}}</span></br>
				{{record.displayString}}<br>{{endif}}
				{{endforeach do}}<br>
 			{{endforeach do}}
			<br>
		{{endif}}
		
		{{if showExtraFields}}
		<div id="groupHeader">{{localize 'EXTRA FIELDS'}}</div><br>
			{{if contact.extra1}}<span id="labelHeader">{{contact.extraFieldsNames.extra1}}:</span> {{contact.extra1}}<br>{{endif}}
			{{if contact.extra2}}<span id="labelHeader">{{contact.extraFieldsNames.extra2}}:</span> {{contact.extra2}}<br>{{endif}}
			{{if contact.extra3}}<span id="labelHeader">{{contact.extraFieldsNames.extra3}}:</span> {{contact.extra3}}<br>{{endif}}
			{{if contact.extra4}}<span id="labelHeader">{{contact.extraFieldsNames.extra4}}:</span> {{contact.extra4}}<br>{{endif}}
			{{if contact.extra5}}<span id="labelHeader">{{contact.extraFieldsNames.extra5}}:</span> {{contact.extra5}}<br>{{endif}}
			{{if contact.extra6}}<span id="labelHeader">{{contact.extraFieldsNames.extra6}}:</span> {{contact.extra6}}<br>{{endif}}
			{{if contact.extra7}}<span id="labelHeader">{{contact.extraFieldsNames.extra7}}:</span> {{contact.extra7}}<br>{{endif}}
			{{if contact.extra8}}<span id="labelHeader">{{contact.extraFieldsNames.extra8}}:</span> {{contact.extra8}}<br>{{endif}}
			{{if contact.extra9}}<span id="labelHeader">{{contact.extraFieldsNames.extra9}}:</span> {{contact.extra9}}<br>{{endif}}
			{{if contact.extra10}}<span id="labelHeader">{{contact.extraFieldsNames.extra10}}:</span> {{contact.extra10}}<br>{{endif}}
			{{if contact.extra11}}<span id="labelHeader">{{contact.extraFieldsNames.extra11}}:</span> {{contact.extra11}}<br>{{endif}}
			{{if contact.extra12}}<span id="labelHeader">{{contact.extraFieldsNames.extra12}}:</span> {{contact.extra12}}<br>{{endif}}
		
		{{if contact.extraDate1}}<span id="labelHeader">{{contact.extraFieldsNames.extraDate1}}:</span> {{contact.extraDate1.mcLongDateTime}}<br>{{endif}}
		{{if contact.extraDate2}}<span id="labelHeader">{{contact.extraFieldsNames.extraDate2}}:</span> {{contact.extraDate2.mcLongDateTime}}<br>{{endif}}
		{{if contact.extraDate3}}<span id="labelHeader">{{contact.extraFieldsNames.extraDate3}}:</span> {{contact.extraDate3.mcLongDateTime}}<br>{{endif}}
		{{if contact.extraDate4}}<span id="labelHeader">{{contact.extraFieldsNames.extraDate4}}:</span> {{contact.extraDate4.mcLongDateTime}}<br>{{endif}}
		<br>
		{{endif}}

		{{if contact.phones.@count}}
		<div id="groupHeader">{{localize 'ALL PHONES'}}</div><br>
			{{foreach phone contact.phones do}}
			<span id="labelHeader">{{phone.label.name}}:</span> {{phone.phoneNumber}}<br>
			{{endforeach do}}
			<br>
		{{endif}}

		{{if contact.electronicAddresses.@count}}
		<div id="groupHeader">{{localize 'ELECTRONIC ADDRESSES'}}</div><br>
			{{foreach electronicAddress contact.electronicAddresses do}}
			<span id="labelHeader">{{electronicAddress.label.name}}:</span> {{electronicAddress.url}}<br>
			{{endforeach do}}
		{{endif}}
		<br>
		
		{{if contact.notes.@count}}
		<div id="groupHeader">{{localize 'NOTES'}}</div><br>
			{{foreach note contact.notesSortedByCreateDateDescending do}}
			<span id="labelHeader">{{localize 'Title'}}:</span> {{note.title}}<br>
			<span id="labelHeader">{{localize 'Create Date'}}:</span> {{note.createDate.mcLongDateTime}}<br>
			<span id="labelHeader">{{localize 'Content'}}:</span> {{note.attachmentFreeTextRepresentation}}<br>
			<br><br>
			{{endforeach do}}
		{{endif}}
		
		{{if contact.emails.@count}}
		<div id="groupHeader">{{localize 'EMAILS'}}</div><br>
			{{foreach email contact.emails do}}
			<span id="labelHeader">{{localize 'Subject'}}:</span> {{email.subject}}<br>
			<span id="labelHeader">{{localize 'Sender'}}:</span> {{email.fromString}}<br>
			<span id="labelHeader">{{localize 'Create Date'}}:</span> {{email.createDate.mcLongDateTime}}<br>
			<span id="labelHeader">{{localize 'Content'}}:</span> {{email.largeData.plainTextRepresentation}}<br>
			<br><br>
			{{endforeach do}}
		{{endif}}
		<br>
	<td>
	<tr>
	</table>
	<br><br><br>
	{{endforeach do}}
	<br>
	<div id="reportfooter">
	{{localize 'Generated by %@ on %@', objectContext.user.contact.cachedName, date}}.		
	</div>

</body>
</html>