{% extends 'creme_core/bricks/base/paginated-table.html' %} {% load i18n creme_bricks creme_cells creme_ctype creme_perms creme_widgets %} {% load and_op format_amount get_hidden_fields inner_edition_uri listify url from creme_core_tags %} {% block brick_extra_class %}{{block.super}} opportunities-opportunities-brick{% endblock %} {% block brick_header_title %} {% if object.entity_type == 'PERSONS_ORGANISATION_MODEL'|ctype_for_swappable %} {% brick_header_title title=_('{count} Opportunity which targets the organisation') plural=_('{count} Opportunities which target the organisation') empty=_('Opportunities') icon='opportunity' %} {% elif object.entity_type == 'PERSONS_CONTACT_MODEL'|ctype_for_swappable %} {% brick_header_title title=_('{count} Opportunity which targets the contact') plural=_('{count} Opportunities which target the contact') empty=_('Opportunities') icon='opportunity' %} {% else %} {% brick_header_title title=_('{count} Opportunity which targets the entity') plural=_('{count} Opportunities which target the entity') empty=_('Opportunities') icon='opportunity' %} {% endif %} {% endblock %} {% block brick_header_actions %} {% with link_perm=user|has_perm_to_link:object creation_perm=user|has_perm_to_create:objects_ctype %} {% brick_header_action id='add' url='opportunities__create_related_opportunity_popup'|url:object.id label=_('Create an opportunity') enabled=creation_perm|and_op:link_perm %} {% endwith %} {% endblock %} {% block brick_table_columns %} {% brick_table_column_for_field ctype=objects_ctype field='name' title=_('Name') status='primary' %} {% brick_table_column title=_('Sales phase') %} {% get_hidden_fields objects_ctype as hidden_fields %} {% if 'estimated_sales' not in hidden_fields %} {% brick_table_column_for_field ctype=objects_ctype field='estimated_sales' data_type='money' %} {% endif %} {% if 'made_sales' not in hidden_fields %} {% brick_table_column_for_field ctype=objects_ctype field='made_sales' data_type='money' %} {% endif %} {% brick_table_column title=_('Actions') status='action' colspan=2 %} {% endblock %} {% block brick_table_rows %} {% get_hidden_fields objects_ctype as hidden_fields %} {% with unlink_perm=user|has_perm_to_unlink:object delete_multi_url='creme_core__delete_entities'|url %} {% for opportunity in page.object_list %} {% widget_entity_hyperlink opportunity user %} {% if user|has_perm_to_view:opportunity %} {{opportunity.sales_phase}} {% if 'estimated_sales' not in hidden_fields %} {# TODO: factorise with opportunity-hat-card.html #} {% if opportunity.estimated_sales is None %} — {% else %} {{opportunity.estimated_sales|format_amount:opportunity.currency}} {% endif %} {% endif %} {% if 'made_sales' not in hidden_fields %} {% if opportunity.made_sales is None %} — {% else %} {{opportunity.made_sales|format_amount:opportunity.currency}} {% endif %} {% endif %} {% else %} {{HIDDEN_VALUE}} {{HIDDEN_VALUE}} {{HIDDEN_VALUE}} {% endif %} {% cell_4_regularfield model=opportunity field="name" as name_cell %} {% cell_4_regularfield model=opportunity field="sales_phase" as phase_cell %} {% cell_4_regularfield model=opportunity field="estimated_sales" as est_sales_cell %} {% cell_4_regularfield model=opportunity field="made_sales" as made_sales_cell %} {% listify name_cell phase_cell est_sales_cell made_sales_cell as cells %} {% inner_edition_uri instance=opportunity cells=cells as edition_uri %} {% brick_table_action id='edit' url=edition_uri comeback=True label=_('Edit this opportunity') enabled=user|has_perm_to_change:opportunity %} {% with opp_unlink_perm=user|has_perm_to_unlink:opportunity %} {% brick_table_action id='delete' url=delete_multi_url __ids=opportunity.id enabled=unlink_perm|and_op:opp_unlink_perm %} {% endwith %} {% endfor %} {% endwith %} {% endblock %} {% block brick_table_empty %} {% translate 'No opportunity for the moment' %} {% endblock %}