<!DOCTYPE html>
<html lang="en">
{{fscript
	globals setOpportunitiesForDisplay: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 'Opportunities'}}</h2>
	{{foreach opportunity opportunitiesForDisplay do}}
	<table>
	<tr>
	<td>
		{{fscript
						
			((opportunity extra1 == nil) & (opportunity extra2 == nil) & (opportunity extra3 == nil) & (opportunity extra4 == nil) & (opportunity extra5 == nil)
			 & (opportunity extra6 == nil) & (opportunity extra7 == nil) & (opportunity extra8 == nil) & (opportunity extra9 == nil) & (opportunity extra10 == nil)
			 & (opportunity extra11 == nil) & (opportunity extra12 == nil) & (opportunity extraDate1 == nil) & (opportunity extraDate2 == nil)
			 & (opportunity extraDate3 == nil) & (opportunity extraDate4 == nil))ifTrue:
			[globals setShowExtraFields:''.].

		}}
		<h3>{{opportunity.name}}</h3>
		
		{{if opportunity.opportunityStateString}}<span id="labelHeader">{{localize 'State'}}:</span> {{opportunity.opportunityStateString}}<br>{{endif}}
		{{if opportunity.opportunityStateReason}}<span id="labelHeader">{{localize 'State Reason'}}:</span> {{opportunity.opportunityStateReason.name}}<br>{{endif}}
		{{if opportunity.opportunityType}}<span id="labelHeader">{{localize 'Type'}}:</span> {{opportunity.opportunityType.name}}<br>{{endif}}
		{{if opportunity.dueDate}}<span id="labelHeader">{{localize 'Forecasted Date'}}:</span> {{opportunity.dueDate.mcLongDateTime}}<br>{{endif}}
		{{if opportunity.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{opportunity.startDate.mcLongDateTime}}<br>{{endif}}
		{{if opportunity.completeDate}}<span id="labelHeader">{{localize 'Complete Date'}}:</span> {{opportunity.completeDate.mcLongDateTime}}<br>{{endif}}
		<br>
		{{if opportunity.probability}}<span id="labelHeader">{{localize 'Probability'}}:</span> {{opportunity.probability}}%<br>{{endif}}
		{{if opportunity.cachedTotalAmount}}<span id="labelHeader">{{localize 'Total'}}:</span> {{opportunity.cachedTotalAmount}}<br><br>{{endif}}
		
		{{if opportunity.category}}<span id="labelHeader">{{localize 'Category'}}:</span> {{opportunity.category.name}}<br>{{endif}}
		{{if opportunity.keywordsString}}<span id="labelHeader">{{localize 'Keywords'}}:</span> {{opportunity.keywordsString}}<br>{{endif}}
		<br>
		{{if opportunity.currentPipeline}}<span id="labelHeader">{{localize 'Current Pipeline'}}:</span> {{opportunity.currentPipeline.name}}<br>{{endif}}
		{{if opportunity.currentPipelineStage}}<span id="labelHeader">{{localize 'Current Pipeline Stage'}}:</span> {{opportunity.currentPipelineStage.name}}<br><br>{{endif}}
		
		{{if opportunity.details}}<span id="labelHeader">{{localize 'Details'}}:</span><br>
		{{opportunity.details}}<br><br>{{endif}}
		
		{{if opportunity.contactRoles.@count}}
		<div id="groupHeader">{{localize 'CONTACTS'}}</div><br>
			{{foreach role opportunity.contactRoles do}} 
			<b>{{role.contact.firstname}} {{role.contact.lastname}}</b><br>
			{{if role.roleType.name}}<span id="labelHeader">{{localize 'Role Type'}}:</span> {{role.roleType.name}}<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 opportunity.organizationRoles.@count}}
		<div id="groupHeader">{{localize 'COMPANIES'}}</div><br>
			{{foreach role opportunity.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.name}}<span id="labelHeader">{{localize 'Title'}}:</span> {{role.name}}<br>{{endif}}
			{{if role.contact.defaultPhone}}<span id="labelHeader">{{localize 'Default Phone'}}:</span> {{role.organization.defaultPhone.phoneNumber}}<br>{{endif}}
			<br>
			{{endforeach do}}
		{{endif}}

		{{if opportunity.nextPendingTask}}
		<div id="groupHeader">{{localize 'NEXT TASK'}}</div>
		<br>
		<b>{{opportunity.nextPendingTask.title}}</b><br>
		<span id="labelHeader">{{localize 'Status'}}:</span> {{opportunity.nextPendingTask.statusString}}<br>
		{{if opportunity.nextPendingTask.dueDate}}<span id="labelHeader">{{localize 'Due'}}:</span> {{opportunity.nextPendingTask.dueDate.mcShortDate}}<br>{{endif}}
		{{if opportunity.nextPendingTask.startDate}}<span id="labelHeader">{{localize 'Start Date'}}:</span> {{opportunity.nextPendingTask.startDate.mcLongDate}}<br>{{endif}}
		{{if opportunity.nextPendingTask.completeDate}}<span id="labelHeader">{{localize 'End Date'}}:</span> {{opportunity.nextPendingTask.completeDate.mcLongDate}}<br>{{endif}}
		{{if opportunity.nextPendingTask.priorityString}}<span id="labelHeader">{{localize 'Priority'}}:</span> {{opportunity.nextPendingTask.priorityString}}<br>{{endif}}
		<br>
		{{endif}}

		
		{{if opportunity.timeblocks.@count}}
		<div id="groupHeader">{{localize 'APPOINTMENTS'}}</div><br>
			{{foreach appointment opportunity.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 opportunity.tasks.@count}}
		<div id="groupHeader">{{localize 'TASKS'}}</div><br>
			{{foreach task opportunity.tasks do}} 
			<b>{{task.title}}</b><br>
			<span id="labelHeader">{{localize 'Status'}}:</span> {{task.statusString}}<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 opportunity.groups.@count}}
		<div id="groupHeader">{{localize 'GROUPS'}}</div><br>
			{{foreach group opportunity.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 opportunity.customRecordSets.@count}}
			<div id="groupHeader">{{localize 'FORMS'}}</div><br>
			{{foreach recordSet opportunity.customRecordSets do}}
			{{recordSet.customRecordSetDefinition.name}}<br>
				{{foreach record recordSet.customRecords do}}
	 			{{if record.displayString}}<span id="labelHeader">{{record.customRecordDefinition.name}}</span></br>
				{{record.displayString}}<br><br>{{endif}}
				{{endforeach do}}
				<br<br
 			{{endforeach do}}
			<br>
		{{endif}}
		
		{{if showExtraFields}}
		<div id="groupHeader">{{localize 'EXTRA FIELDS'}}</div><br>
			{{if opportunity.extra1}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra1}}:</span> {{opportunity.extra1}}<br>{{endif}}
			{{if opportunity.extra2}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra2}}:</span> {{opportunity.extra2}}<br>{{endif}}
			{{if opportunity.extra3}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra3}}:</span> {{opportunity.extra3}}<br>{{endif}}
			{{if opportunity.extra4}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra4}}:</span> {{opportunity.extra4}}<br>{{endif}}
			{{if opportunity.extra5}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra5}}:</span> {{opportunity.extra5}}<br>{{endif}}
			{{if opportunity.extra6}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra6}}:</span> {{opportunity.extra6}}<br>{{endif}}
			{{if opportunity.extra7}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra7}}:</span> {{opportunity.extra7}}<br>{{endif}}
			{{if opportunity.extra8}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra8}}:</span> {{opportunity.extra8}}<br>{{endif}}
			{{if opportunity.extra9}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra9}}:</span> {{opportunity.extra9}}<br>{{endif}}
			{{if opportunity.extra10}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra10}}:</span> {{opportunity.extra10}}<br>{{endif}}
			{{if opportunity.extra11}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra11}}:</span> {{opportunity.extra11}}<br>{{endif}}
			{{if opportunity.extra12}}<span id="labelHeader">{{opportunity.extraFieldsNames.extra12}}:</span> {{opportunity.extra12}}<br>{{endif}}
		
			{{if opportunity.extraDate1}}<span id="labelHeader">{{opportunity.extraFieldsNames.extraDate1}}:</span> {{opportunity.extraDate1.mcLongDateTime}}<br>{{endif}}
			{{if opportunity.extraDate2}}<span id="labelHeader">{{opportunity.extraFieldsNames.extraDate1}}:</span> {{opportunity.extraDate1.mcLongDateTime}}<br>{{endif}}
			{{if opportunity.extraDate3}}<span id="labelHeader">{{opportunity.extraFieldsNames.extraDate3}}:</span> {{opportunity.extraDate3.mcLongDateTime}}<br>{{endif}}
			{{if opportunity.extraDate4}}<span id="labelHeader">{{opportunity.extraFieldsNames.extraDate4}}:</span> {{opportunity.extraDate4.mcLongDateTime}}<br>{{endif}}
		<br>
		{{endif}}

		{{if opportunity.notes.@count}}
		<div id="groupHeader">{{localize 'NOTES'}}</div><br>
			{{foreach note opportunity.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 opportunity.emails.@count}}
		<div id="groupHeader">{{localize 'EMAILS'}}</div><br>
			{{foreach email opportunity.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>