{% macro renderAvailableVariablesWidget(entityName, entityChoiceFieldId) %} {% set system = 'oro-email-template-variables-system' %} {% set systemTab = system ~ '-tab' %} {% set entity = 'oro-email-template-variables-entity'%} {% set entityTab = entity ~ '-tab' %} {% set options = { name: 'email-template-variables', entityChoice: '#' ~ entityChoiceFieldId, view: { templateSelector: '#oro-email-template-variables-template', sectionTemplateSelector: '#oro-email-template-variables-{sectionName}-template', sectionContentSelector: '#oro-email-template-variables-{sectionName}', sectionTabSelector: '#oro-email-template-variables-{sectionName}-tab', }, model: { attributes: render(path('oro_api_get_emailtemplate_variables')), entityName: entityName, entityLabel: entityName ? oro_entity_config_value(entityName, 'label')|trans : '', } } %}
{% endmacro %} {# Renders email address owner name as text Parameters: emailAddress - email address entity Oro\Bundle\EmailBundle\Entity\EmailAddress #} {% macro email_address_text(emailAddress) -%} {{ emailAddress.owner|oro_format_name|default('N/A') }} {%- endmacro -%} {# Renders email address owner name as link based on owner type Parameters: emailAddress - email address entity Oro\Bundle\EmailBundle\Entity\EmailAddress label - [optional] A text representation of email address #} {% macro email_address_link(emailAddress, label) -%} {% import _self as emailMacros %} {{ emailMacros.renderEmailAddressLink( label|oro_html_strip_tags|default(emailMacros.email_address_text(emailAddress)), oro_class_name(emailAddress.owner), emailAddress.owner.id) }} {%- endmacro -%} {# Renders email address owner name as link based on owner type Parameters: label - The text representation of email address ownerClass - The class name of email address owner ownerId - The id of email address owner #} {% macro renderEmailAddressLink(label, ownerClass, ownerId) -%} {% set route = oro_entity_route(ownerClass) %} {% if route is not null %} {{ label|oro_html_strip_tags }} {% else %} {{ label|oro_html_strip_tags }} {% endif %} {%- endmacro -%} {# Renders email address name as link based on owner type Parameters: emailAddress - email address entity Oro\Bundle\EmailBundle\Entity\EmailAddress #} {% macro email_address_recipient_link(emailAddress, emailAddressName, label) -%} {% set label = label|oro_html_strip_tags|default(emailAddressName|default('N/A')) %} {% set route = oro_entity_route(oro_class_name(emailAddress.owner)) %} {% if route is not null %} {{ label }} {% else %} {{ label }} {% endif %} {%- endmacro -%} {# Render email address name, owner name or a link to owner view page can be rendered depends on given parameters Parameters: emailAddress - email address entity Oro\Bundle\EmailBundle\Entity\EmailAddress emailAddressName - a string contains an email address. It is used if the email address has no owner noLink - determines whether the rendering of a link to the owner view page is forbidden or not. Default value is false knownOnly - if true renders only emails which have an owner; otherwise, all emails. Default value is false #} {% macro email_address(emailAddress, emailAddressName, noLink, knownOnly) -%} {% import _self as emailMacros %} {% if emailAddress.owner is null -%} {% if not knownOnly|default(false) -%} {{ emailAddressName|oro_html_strip_tags }} {%- endif %} {%- else -%} {% if noLink|default(false) -%} {{ emailMacros.email_address_text(emailAddress) }} {%- else -%} {{ emailMacros.email_address_link(emailAddress)|raw }} {%- endif %} {%- endif %} {%- endmacro %} {# Render email address name a link to owner view page can be rendered depends on given parameters Parameters: emailAddress - email address entity Oro\Bundle\EmailBundle\Entity\EmailAddress emailAddressName - a string contains an email address. It is used if the email address has no owner noLink - determines whether the rendering of a link to the owner view page is forbidden or not. Default value is false knownOnly - if true renders only emails which have an owner; otherwise, all emails. Default value is false #} {% macro email_address_recipient(emailAddress, emailAddressName, noLink, knownOnly) -%} {% import _self as emailMacros %} {% if emailAddress.owner is null -%} {% if not knownOnly|default(false) -%} {{ emailAddressName }} {%- endif %} {%- else -%} {% if noLink|default(false) -%} {{ emailAddressName }} {%- else -%} {{ emailMacros.email_address_recipient_link(emailAddress, emailAddressName)|raw }} {%- endif %} {%- endif %} {%- endmacro %} {# Render email address with title Parameters: email - EmailInterface object or string title (optional) - email title #} {%- macro email_address_simple(email, title) -%} {% if email is not empty %} {% set emailAddress = null %} {# if email is an object implemented EmailInterface #} {% if email.email is defined %} {% if email.email is not empty %} {% set emailAddress = email.email %} {% endif %} {# if email is a string #} {% else %} {% set emailAddress = email %} {% endif %} {% if title is empty %} {% set title = emailAddress %} {% endif %} {% if emailAddress %} {{ title|oro_html_strip_tags }} {% endif %} {% endif %} {%- endmacro -%} {# Render email address with related actions block Parameters: email - EmailInterface object or string entity - related entity record #} {%- macro renderEmailWithActions(email, entity) -%} {% import _self as emailMacros %} {% if email is not empty %} {%- set actions %} {%- placeholder email_actions with {email: email, entity: entity} -%} {% endset -%} {% set actions = actions|trim %} {{ emailMacros.email_address_simple(email) }} {% if actions is not empty -%} {{ actions|raw }} {%- endif %} {% endif %} {%- endmacro -%} {# Render the given email recipients Parameters: recipients - an array of Oro\Bundle\EmailBundle\Entity\EmailRecipients noLink - determines whether the rendering of a link to the owner view page is forbidden or not. Default value is false knownOnly - if true renders only emails which have an owner; otherwise, all emails. Default value is false #} {% macro recipient_email_addresses(recipients, noLink, knownOnly) -%} {% import _self as emailMacros %} {% set addresses = {} -%} {% for recipient in recipients -%} {% set address = emailMacros.email_address_recipient(recipient.emailAddress, recipient.name, noLink, knownOnly) %} {%- if address|length > 0 -%} {% set addresses = addresses|merge([address]) %} {% else %} {% set addresses = addresses|merge([recipient.emailAddress.email]) %} {%- endif %} {%- endfor -%} {% for address in addresses -%} {{ address|oro_html_strip_tags }} {%- if not loop.last %}; {% endif %} {% else %} {{ 'N/A'|trans }} {%- endfor %} {%- endmacro %} {# Render the given email attachments Parameters: attachments - an array target - an object hasGrantReattach - has grants for create attachment entity #} {% macro attachments(attachments, target, hasGrantReattach) -%} {% set galleryUid = random() %} {%- for attachment in attachments -%} {% if attachment.embeddedContentId is null %} {% set canCopyToRecord = (hasGrantReattach and target is defined and oro_can_attache(attachment, target)) ? true : false %} {% set attachmentUrl = path('oro_email_attachment', {id: attachment.id}) %} {% set isImage = oro_type_is_image(attachment.contentType) %} {% set isPreviewAvailable = oro_is_preview_available(attachment.contentType) %} {% set icon = oro_attachment_icon(attachment) %}{{ emailBody.bodyContent }}{%- else -%} {%- endif %} {%- endmacro %} {# Render email participant name or "me" if it is current user, owner name or a link to owner view page can be rendered depends on given parameters Parameters: emailAddress - email address entity Oro\Bundle\EmailBundle\Entity\EmailAddress emailAddressName - a string contains an email address. It is used if the email address has no owner noLink - determines whether the rendering of a link to the owner view page is forbidden or not. Default value is false knownOnly - if true renders only emails which have an owner; otherwise, all emails. Default value is false #} {% macro email_participant_name_or_me(emailAddress, emailAddressName, noLink, knownOnly) -%} {% import _self as emailMacros %} {% if emailAddress.owner is not null and oro_class_name(emailAddress.owner, true) == oro_class_name(app.user, true) and emailAddress.owner.id == app.user.id -%} {% if noLink|default(false) -%} {{ 'Me'|trans|lower }} {%- else -%} {{ emailMacros.email_address_link(emailAddress, 'Me'|trans|lower)|raw }} {%- endif %} {%- else -%} {%- set name = oro_get_email_address_name(emailAddressName)|default(oro_get_email_address(emailAddressName))|oro_html_strip_tags -%} {{ emailMacros.email_address(emailAddress, name, noLink, knownOnly) }} {%- endif %} {%- endmacro %} {# Render list of participants using email_participant_name_or_me macros Parameters: recipients - an array of Oro\Bundle\EmailBundle\Entity\EmailRecipients noLink - determines whether the rendering of a link to the owner view page is forbidden or not. Default value is false knownOnly - if true renders only emails which have an owner; otherwise, all emails. Default value is false #} {% macro email_participants_name(recipients, noLink, knownOnly) -%} {% import _self as emailMacros %} {% set recipientHtmlCollection = [] %} {% for recipient in recipients %} {% set recipientHtml -%} {{ emailMacros.email_participant_name_or_me(recipient.emailAddress, recipient.name, noLink, knownOnly) }} {%- endset %} {% set recipientHtmlCollection = recipientHtmlCollection|merge([recipientHtml]) %} {% endfor %} {{ recipientHtmlCollection|join(', ')|raw }} {%- endmacro %} {# Render date in proper format Parameters: date - DateTime #} {% macro date_smart_format(date) -%} {% if date(date)|oro_format_date == date()|oro_format_date -%} {# same day -- show only time #} {{ date|oro_format_time({'timeZone': oro_timezone()}) }} {%- elseif date(date)|oro_format_date == date('-1days')|oro_format_date -%} {{ 'yesterday'|trans|capitalize }} {%- elseif date(date).format('Y') == date().format('Y') -%} {# same year -- month and daty #} {{ date|oro_format_day({'timeZone': oro_timezone()}) }} {%- else -%} {{ date|oro_format_date({'timeZone': oro_timezone()}) }} {%- endif %} {%- endmacro %} {# Render table with detailed information about all participants, send date and subject Parameters: email - email entity Oro\Bundle\EmailBundle\Entity\Email #} {% macro email_detailed_info_table(email) %} {% set recipientsTo = [] %} {% set recipientsCc = [] %} {% set recipientsBcc = [] %} {% for recipient in email.recipients %} {% set emailAddressName = oro_get_email_address_name(recipient.name)|oro_html_strip_tags %} {% set emailAddress = oro_get_email_address(recipient.name)|oro_html_strip_tags %} {% if emailAddressName == '' and emailAddress == '' %} {% set recipientName = '' %} {% else %} {% set recipientName = emailAddressName ~ ' <' ~ emailAddress ~ '>' %} {% endif %} {% if recipient.type == 'to' %} {% set recipientsTo = recipientsTo|merge([recipientName])%} {% elseif recipient.type == 'cc' %} {% set recipientsCc = recipientsCc|merge([recipientName])%} {% elseif recipient.type == 'bcc' %} {% set recipientsBcc = recipientsBcc|merge([recipientName])%} {% endif %} {% endfor %} {% set fromUserName = oro_get_email_address_name(email.fromName)|oro_html_strip_tags %} {% set fromEmailAddress = '<' ~ oro_get_email_address(email.fromName)|oro_html_strip_tags ~ '>' %} {% set data = [{ label: 'From'|trans, value: fromUserName ? '' ~ fromUserName ~ ' ' ~ fromEmailAddress : '' ~ fromEmailAddress ~ '' , cssClass: 'autor' }, { label: 'To'|trans, value: recipientsTo|join(',
{{ item.label|raw }}:
|
{{ item.value|raw }}
|