{{fscript globals setOpportunitiesForDisplay:selectedObjects. }}

{{localize 'Opportunities'}}

{{foreach opportunity opportunitiesForDisplay do}}
{{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:''.]. }}

{{opportunity.name}}

{{if opportunity.opportunityStateString}}{{localize 'State'}}: {{opportunity.opportunityStateString}}
{{endif}} {{if opportunity.opportunityStateReason}}{{localize 'State Reason'}}: {{opportunity.opportunityStateReason.name}}
{{endif}} {{if opportunity.opportunityType}}{{localize 'Type'}}: {{opportunity.opportunityType.name}}
{{endif}} {{if opportunity.dueDate}}{{localize 'Forecasted Date'}}: {{opportunity.dueDate.mcLongDateTime}}
{{endif}} {{if opportunity.startDate}}{{localize 'Start Date'}}: {{opportunity.startDate.mcLongDateTime}}
{{endif}} {{if opportunity.completeDate}}{{localize 'Complete Date'}}: {{opportunity.completeDate.mcLongDateTime}}
{{endif}}
{{if opportunity.probability}}{{localize 'Probability'}}: {{opportunity.probability}}%
{{endif}} {{if opportunity.cachedTotalAmount}}{{localize 'Total'}}: {{opportunity.cachedTotalAmount}}

{{endif}} {{if opportunity.category}}{{localize 'Category'}}: {{opportunity.category.name}}
{{endif}} {{if opportunity.keywordsString}}{{localize 'Keywords'}}: {{opportunity.keywordsString}}
{{endif}}
{{if opportunity.currentPipeline}}{{localize 'Current Pipeline'}}: {{opportunity.currentPipeline.name}}
{{endif}} {{if opportunity.currentPipelineStage}}{{localize 'Current Pipeline Stage'}}: {{opportunity.currentPipelineStage.name}}

{{endif}} {{if opportunity.details}}{{localize 'Details'}}:
{{opportunity.details}}

{{endif}} {{if opportunity.contactRoles.@count}}
{{localize 'CONTACTS'}}

{{foreach role opportunity.contactRoles do}} {{role.contact.firstname}} {{role.contact.lastname}}
{{if role.roleType.name}}{{localize 'Role Type'}}: {{role.roleType.name}}
{{endif}} {{if role.name}}{{localize 'Title'}}: {{role.name}}
{{endif}} {{if role.contact.defaultPhone}}{{localize 'Default Phone'}}: {{role.contact.defaultPhone.phoneNumber}}
{{endif}}
{{endforeach do}} {{endif}} {{if opportunity.organizationRoles.@count}}
{{localize 'COMPANIES'}}

{{foreach role opportunity.organizationRoles do}} {{role.organization.name}}
{{if role.roleType.name}}{{localize 'Role Type'}}: {{role.roleType.name}}
{{endif}} {{if role.name}}{{localize 'Title'}}: {{role.name}}
{{endif}} {{if role.contact.defaultPhone}}{{localize 'Default Phone'}}: {{role.organization.defaultPhone.phoneNumber}}
{{endif}}
{{endforeach do}} {{endif}} {{if opportunity.nextPendingTask}}
{{localize 'NEXT TASK'}}

{{opportunity.nextPendingTask.title}}
{{localize 'Status'}}: {{opportunity.nextPendingTask.statusString}}
{{if opportunity.nextPendingTask.dueDate}}{{localize 'Due'}}: {{opportunity.nextPendingTask.dueDate.mcShortDate}}
{{endif}} {{if opportunity.nextPendingTask.startDate}}{{localize 'Start Date'}}: {{opportunity.nextPendingTask.startDate.mcLongDate}}
{{endif}} {{if opportunity.nextPendingTask.completeDate}}{{localize 'End Date'}}: {{opportunity.nextPendingTask.completeDate.mcLongDate}}
{{endif}} {{if opportunity.nextPendingTask.priorityString}}{{localize 'Priority'}}: {{opportunity.nextPendingTask.priorityString}}
{{endif}}
{{endif}} {{if opportunity.timeblocks.@count}}
{{localize 'APPOINTMENTS'}}

{{foreach appointment opportunity.timeblocks do}} {{appointment.subject}}
{{localize 'Status'}}: {{appointment.statusString}}
{{localize 'Time'}}: {{appointment.startDate.mcLongDate}} at {{appointment.startDate.mcShortTime}} - {{appointment.endDate.mcShortTime}}
{{if appointment.details}}{{localize 'Details'}}: {{appointment.details}}
{{endif}}
{{endforeach do}}

{{endif}} {{if opportunity.tasks.@count}}
{{localize 'TASKS'}}

{{foreach task opportunity.tasks do}} {{task.title}}
{{localize 'Status'}}: {{task.statusString}}
{{if task.dueDate}}{{localize 'Due'}}: {{task.dueDate.mcLongDate}}
{{endif}} {{if task.startDate}}{{localize 'Start Date'}}: {{task.startDate.mcLongDate}}{{endif}} {{if task.completeDate}}{{localize 'End Date'}}: {{task.completeDate.mcLongDate}}{{endif}} {{if task.priorityString}}{{localize 'Priority'}}: {{task.priorityString}}
{{endif}}
{{endforeach do}} {{endif}} {{if opportunity.groups.@count}}
{{localize 'GROUPS'}}

{{foreach group opportunity.groups do}} {{group.name}}
{{if group.startDate}}{{localize 'Start Date'}}: {{group.startDate.mcLongDate}}
{{endif}} {{if group.endDate}}{{localize 'End Date'}}: {{group.endDate.mcLongDate}}
{{endif}}
{{endforeach do}} {{endif}} {{if opportunity.customRecordSets.@count}}
{{localize 'FORMS'}}

{{foreach recordSet opportunity.customRecordSets do}} {{recordSet.customRecordSetDefinition.name}}
{{foreach record recordSet.customRecords do}} {{if record.displayString}}{{record.customRecordDefinition.name}}
{{record.displayString}}

{{endif}} {{endforeach do}} {{endif}} {{if showExtraFields}}
{{localize 'EXTRA FIELDS'}}

{{if opportunity.extra1}}{{opportunity.extraFieldsNames.extra1}}: {{opportunity.extra1}}
{{endif}} {{if opportunity.extra2}}{{opportunity.extraFieldsNames.extra2}}: {{opportunity.extra2}}
{{endif}} {{if opportunity.extra3}}{{opportunity.extraFieldsNames.extra3}}: {{opportunity.extra3}}
{{endif}} {{if opportunity.extra4}}{{opportunity.extraFieldsNames.extra4}}: {{opportunity.extra4}}
{{endif}} {{if opportunity.extra5}}{{opportunity.extraFieldsNames.extra5}}: {{opportunity.extra5}}
{{endif}} {{if opportunity.extra6}}{{opportunity.extraFieldsNames.extra6}}: {{opportunity.extra6}}
{{endif}} {{if opportunity.extra7}}{{opportunity.extraFieldsNames.extra7}}: {{opportunity.extra7}}
{{endif}} {{if opportunity.extra8}}{{opportunity.extraFieldsNames.extra8}}: {{opportunity.extra8}}
{{endif}} {{if opportunity.extra9}}{{opportunity.extraFieldsNames.extra9}}: {{opportunity.extra9}}
{{endif}} {{if opportunity.extra10}}{{opportunity.extraFieldsNames.extra10}}: {{opportunity.extra10}}
{{endif}} {{if opportunity.extra11}}{{opportunity.extraFieldsNames.extra11}}: {{opportunity.extra11}}
{{endif}} {{if opportunity.extra12}}{{opportunity.extraFieldsNames.extra12}}: {{opportunity.extra12}}
{{endif}} {{if opportunity.extraDate1}}{{opportunity.extraFieldsNames.extraDate1}}: {{opportunity.extraDate1.mcLongDateTime}}
{{endif}} {{if opportunity.extraDate2}}{{opportunity.extraFieldsNames.extraDate1}}: {{opportunity.extraDate1.mcLongDateTime}}
{{endif}} {{if opportunity.extraDate3}}{{opportunity.extraFieldsNames.extraDate3}}: {{opportunity.extraDate3.mcLongDateTime}}
{{endif}} {{if opportunity.extraDate4}}{{opportunity.extraFieldsNames.extraDate4}}: {{opportunity.extraDate4.mcLongDateTime}}
{{endif}}
{{endif}} {{if opportunity.notes.@count}}
{{localize 'NOTES'}}

{{foreach note opportunity.notesSortedByCreateDateDescending do}} {{localize 'Title'}}: {{note.title}}
{{localize 'Create Date'}}: {{note.createDate.mcLongDateTime}}
{{localize 'Content'}}: {{note.attachmentFreeTextRepresentation}}


{{endforeach do}} {{endif}} {{if opportunity.emails.@count}}
{{localize 'EMAILS'}}

{{foreach email opportunity.emails do}} {{localize 'Subject'}}: {{email.subject}}
{{localize 'Sender'}}: {{email.fromString}}
{{localize 'Create Date'}}: {{email.createDate.mcLongDateTime}}
{{localize 'Content'}}: {{email.largeData.plainTextRepresentation}}


{{endforeach do}} {{endif}}



{{endforeach do}}
{{localize 'Generated by %@ on %@', objectContext.user.contact.cachedName, date}}.