<!DOCTYPE html>
<html lang="en">
{{fscript
	globals setCompaniesForDisplay: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 'Companies'}}</h2>
	{{foreach company companiesForDisplay do}}
	<table>
	<tr>
	<td>
		{{fscript
			
			((company fromRelationships count > 0) | (company toRelationships count > 0))ifFalse:
			[globals setShowRelationships:''.].
			
			((company extra1 == nil) & (company extra2 == nil) & (company extra3 == nil) & (company extra4 == nil) & (company extra5 == nil)
			 & (company extra6 == nil) & (company extra7 == nil) & (company extra8 == nil) & (company extra9 == nil) & (company extra10 == nil)
			 & (company extra11 == nil) & (company extra12 == nil) & (company extraDate1 == nil) & (company extraDate2 == nil)
			 & (company extraDate3 == nil) & (company extraDate4 == nil))ifTrue:
			[globals setShowExtraFields:''.].

		}}
		<h3>{{company.name}}</h3>
		
		{{if company.category}}<span id="labelHeader">{{localize 'Category'}}:</span> {{company.category.name}}<br>{{endif}}
		{{if company.industryType.name}}<span id="labelHeader">{{localize 'Industry'}}:</span> {{company.industryType.name}}<br>{{endif}}
		{{if company.regionType}}<span id="labelHeader">{{localize 'Region'}}:</span> {{company.regionType.name}}<br>{{endif}}
		{{if company.organizationType}}<span id="labelHeader">{{localize 'Type'}}:</span> {{company.organizationType.name}}<br>{{endif}}
		{{if company.keywordsString}}<span id="labelHeader">{{localize 'Keywords'}}:</span> {{company.keywordsString}}<br>{{endif}}
		<br>
		{{if company.defaultPhone}}<span id="labelHeader">{{company.defaultPhone.label.name}}:</span> {{company.defaultPhone.phoneNumber}}<br>{{endif}}
		{{if company.defaultEmailAddress}}<span id="labelHeader">{{company.defaultEmailAddress.label.name}}:</span> {{company.defaultEmailAddress.url}}<br>{{endif}}
		{{if company.priorityEnumWrapper.stringValue}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{company.priorityEnumWrapper.stringValue}}<br>{{endif}}
		{{if company.tickerSymbol}}<span id="labelHeader">{{localize 'Ticker'}}:</span> {{company.tickerSymbol}}<br>{{endif}}
		{{if company.sicCode}}<span id="labelHeader">{{localize 'SIC Code'}}:</span> {{company.sicCode}}<br>{{endif}}
		{{if company.numberOfEmployees}}<span id="labelHeader">{{localize 'Number of Employees'}}:</span> {{company.numberOfEmployees}}<br>{{endif}}
		{{if company.tagline}}<span id="labelHeader">{{localize 'Tagline'}}:</span> {{company.tagline}}<br><br>{{endif}}

		
		{{if company.plainTextDetails}}<span id="labelHeader">{{localize 'Details'}}:</span> {{company.plainTextDetails}}<br><br>{{endif}}

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

		{{if company.nextPendingTask}}
		<div id="groupHeader">{{localize 'NEXT TASK'}}</div>
		<br>
		<b>{{company.nextPendingTask.title}}</b><br>
		{{if company.nextPendingTask.dueDate}}<span id="labelHeader">{{localize 'Due'}}:</span> {{company.nextPendingTask.dueDate.mcShortDate}}<br>{{endif}}
		{{if company.nextPendingTask.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{company.nextPendingTask.startDate.mcLongDate}}<br>{{endif}}
		{{if company.nextPendingTask.completeDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{company.nextPendingTask.completeDate.mcLongDate}}<br>{{endif}}
		{{if company.nextPendingTask.priorityString}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{company.nextPendingTask.priorityString}}<br>{{endif}}
		{{endif}}
		<br>
		
		{{if company.timeblocks.@count}}
		<div id="groupHeader">{{localize 'APPOINTMENTS'}}</div><br>
			{{foreach appointment company.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>
			<span id="labelHeader">{{localize 'Details'}}:</span> {{appointment.details}}<br><br>
			{{endforeach do}}
			<br><br>
		{{endif}}
		
		{{if company.tasks.@count}}
		<div id="groupHeader">{{localize 'TASKS'}}</div><br>
			{{foreach task company.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}}<br>{{endif}}
			{{if task.completeDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{task.completeDate.mcLongDate}}<br>{{endif}}
			{{if task.priorityString}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{task.priorityString}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if company.contactRoles.@count}}
		<div id="groupHeader">{{localize 'People'}}</div><br>
			{{foreach role company.contactRoles do}} 
			<b>{{role.contact.derivedFullname}}</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.contact.defaultPhone}}<span id="labelHeader">{{localize 'Default Phone'}}:</span> {{role.contact.defaultPhone.phoneNumber}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if showRelationships}}
		<div id="groupHeader">{{localize 'RELATIONSHIPS'}}</div>
			<br>
			{{foreach relationship company.fromRelationships do}} 
			{{relationship.sourceOrganization.name}} {{relationship.relationshipType.name}} {{relationship.destinationOrganization.name}}<br>
			{{endforeach do}}
			{{foreach relationship contact.toRelationships do}} 
			{{relationship.sourceOrganization.name}} {{relationship.relationshipType.name}} {{relationship.destinationOrganization.name}}<br>
			{{endforeach do}}
			<br>
		{{endif}}
		
		{{if company.projectRoles.@count}}
		<div id="groupHeader">{{localize 'PROJECTS'}}</div><br>
			{{foreach role company.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>
			<span id="labelHeader">{{localize 'Due Date'}}:</span> {{role.project.dueDate.mcLongDate}}<br>
			<span id="labelHeader">{{localize 'Start Date'}}:</span> {{role.project.startDate.mcLongDate}}<br><br>
			<span id="labelHeader">{{localize 'Complete Date'}}:</span> {{role.project.completeDate.mcLongDate}}<br><br>
			{{endforeach do}}
		{{endif}}
		
		{{if company.opportunityRoles.@count}}
		<div id="groupHeader">{{localize 'OPPORTUNITIES'}}</div><br>
			{{foreach role company.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 company.groups.@count}}
		<div id="groupHeader">{{localize 'GROUPS'}}</div><br>
			{{foreach group company.groups do}} 
			<b>{{group.name}}</b><br>
			{{if group.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{group.startDate.mcLongDate}}<br>{{endif}}
			{{if group.endDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{group.endDate.mcLongDate}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if company.customRecordSets.@count}}
			<div id="groupHeader">{{localize 'FORMS'}}</div><br>
			{{foreach recordSet company.customRecordSets do}}
			<b>{{recordSet.customRecordSetDefinition.name}}</b><br>
				{{foreach record recordSet.customRecords do}}
	 			<span id="labelHeader">{{record.customRecordDefinition.name}}</span></br>
				{{record.displayString}}<br>
				{{endforeach do}}<br>
 			{{endforeach do}}
			<br>
		{{endif}}
		
		{{if showExtraFields}}
		<div id="groupHeader">{{localize 'EXTRA FIELDS'}}</div><br>
			{{if company.extra1}}<span id="labelHeader">{{company.extraFieldsNames.extra1}}:</span> {{company.extra1}}<br>{{endif}}
			{{if company.extra2}}<span id="labelHeader">{{company.extraFieldsNames.extra2}}:</span> {{company.extra2}}<br>{{endif}}
			{{if company.extra3}}<span id="labelHeader">{{company.extraFieldsNames.extra3}}:</span> {{company.extra3}}<br>{{endif}}
			{{if company.extra4}}<span id="labelHeader">{{company.extraFieldsNames.extra4}}:</span> {{company.extra4}}<br>{{endif}}
			{{if company.extra5}}<span id="labelHeader">{{company.extraFieldsNames.extra5}}:</span> {{company.extra5}}<br>{{endif}}
			{{if company.extra6}}<span id="labelHeader">{{company.extraFieldsNames.extra6}}:</span> {{company.extra6}}<br>{{endif}}
			{{if company.extra7}}<span id="labelHeader">{{company.extraFieldsNames.extra7}}:</span> {{company.extra7}}<br>{{endif}}
			{{if company.extra8}}<span id="labelHeader">{{company.extraFieldsNames.extra8}}:</span> {{company.extra8}}<br>{{endif}}
			{{if company.extra9}}<span id="labelHeader">{{company.extraFieldsNames.extra9}}:</span> {{company.extra9}}<br>{{endif}}
			{{if company.extra10}}<span id="labelHeader">{{company.extraFieldsNames.extra10}}:</span> {{company.extra10}}<br>{{endif}}
			{{if company.extra11}}<span id="labelHeader">{{company.extraFieldsNames.extra11}}:</span> {{company.extra11}}<br>{{endif}}
			{{if company.extra12}}<span id="labelHeader">{{company.extraFieldsNames.extra12}}:</span> {{company.extra12}}<br>{{endif}}
		
			{{if company.extraDate1}}<span id="labelHeader">{{company.extraFieldsNames.extraDate1}}:</span> {{company.extraDate1.mcLongDateTime}}<br>{{endif}}
			{{if company.extraDate2}}<span id="labelHeader">{{company.extraFieldsNames.extraDate2}}:</span> {{company.extraDate2.mcLongDateTime}}<br>{{endif}}
			{{if company.extraDate3}}<span id="labelHeader">{{company.extraFieldsNames.extraDate3}}:</span> {{company.extraDate3.mcLongDateTime}}<br>{{endif}}
			{{if company.extraDate4}}<span id="labelHeader">{{company.extraFieldsNames.extraDate4}}:</span> {{company.extraDate4.mcLongDateTime}}<br>{{endif}}
		<br>
		{{endif}}

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

		{{if company.electronicAddresses.@count}}
		<div id="groupHeader">{{localize 'ELECTRONIC ADDRESSES'}}</div><br>
			{{foreach electronicAddress company.electronicAddresses do}}
			<span id="labelHeader">{{electronicAddress.label.name}}:</span> {{electronicAddress.url}}<br>
			<br>
			{{endforeach do}}
		{{endif}}
		
		{{if company.notes.@count}}
		<div id="groupHeader">{{localize 'NOTES'}}</div><br>
			{{foreach note company.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 company.emails.@count}}
		<div id="groupHeader">{{localize 'EMAILS'}}</div><br>
			{{foreach email company.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>