{% extends 'creme_core/bricks/base/paginated-table.html' %} {% load i18n creme_widgets creme_bricks creme_ctype %} {% load and_op has_perm_to url from creme_core_tags %} {% block brick_extra_class %}{{block.super}} commercial-opportunities-brick{% endblock %} {% block brick_header_title %} {% brick_header_title title=_('{count} Related opportunity') plural=_('{count} Related opportunities') empty=_('Opportunities') icon='opportunity' %} {% endblock %} {% block brick_header_actions %} {% if relation_type.enabled %} {% ctype_for_swappable 'OPPORTUNITIES_OPPORTUNITY_MODEL' as opp_ct %} {% has_perm_to link object as link_perm %}{% has_perm_to create opp_ct as opp_creation_perm %}{% has_perm_to link opp_ct.model_class as opp_link_perm %} {% brick_header_action id='add' url='commercial__create_opportunity'|url:object.id label=_('Create a linked opportunity') enabled=link_perm|and_op:opp_creation_perm|and_op:opp_link_perm %} {% brick_header_action id='add-relationships' label=_('Link to an existing opportunity') icon='link' enabled=link_perm __subject_id=object.id __rtype_id=relation_type.id __ctype_id=opp_ct.id __multiple=True %} {% endif %} {% endblock %} {% block brick_before_content %} {% if not relation_type.enabled %}
{% blocktranslate with predicate=relation_type.predicate %}Beware: the relationship type «{{predicate}}» is disabled. You should re-enable it if it's still useful, or remove this block{% endblocktranslate %}
{% endif %} {% endblock %} {% block brick_table_columns %} {% brick_table_column title=_('Name') status='primary nowrap' %} {% brick_table_column title=_('Sales phase') %} {% brick_table_column title=_('Estimated sales') data_type='money' %} {% brick_table_column title=_('Made sales') data_type='money' %} {% brick_table_column title=_('Unlink') status='action' %} {% endblock %} {% block brick_table_rows %} {% has_perm_to link object as link_perm %}{% has_perm_to unlink object as unlink_perm %} {% url 'creme_core__delete_similar_relations' as del_rel_url %} {% for opp in page.object_list %}{% has_perm_to view opp as opp_view_perm %}{% has_perm_to unlink opp as opp_unlink_perm %} {% widget_entity_hyperlink opp user %} {% if opp_view_perm %} {{opp.sales_phase}} {{opp.estimated_sales|default:'—'}} {{opp.made_sales|default:'—'}} {% else %} {{HIDDEN_VALUE}} {{HIDDEN_VALUE}} {{HIDDEN_VALUE}} {% endif %} {% brick_table_action id='delete' url=del_rel_url __subject_id=object.pk __type=relation_type.id __object_id=opp.id icon='unlink' enabled=unlink_perm|and_op:opp_unlink_perm %} {% endfor %} {% translate 'Total' %} {{object.get_estimated_sales}} {{object.get_made_sales}}   {% endblock %} {% block brick_table_empty %} {% translate 'No related opportunity for the moment' %} {% endblock %}