{% extends 'creme_core/bricks/base/paginated-table.html' %} {% load i18n creme_bricks creme_ctype creme_perms creme_widgets %} {% load and_op 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 %} {% with link_perm=user|has_perm_to_link:object opp_creation_perm=user|has_perm_to_create:opp_ct opp_link_perm=user|has_perm_to_link:opp_ct %} {% 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 %} {% endwith %} {% 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 %} {% with link_perm=user|has_perm_to_link:object unlink_perm=user|has_perm_to_unlink:object del_rel_url='creme_core__delete_similar_relations'|url %} {% for opp in page.object_list %} {% widget_entity_hyperlink opp user %} {% if user|has_perm_to_view:opp %} {{opp.sales_phase}} {{opp.estimated_sales|default:'—'}} {{opp.made_sales|default:'—'}} {% else %} {{HIDDEN_VALUE}} {{HIDDEN_VALUE}} {{HIDDEN_VALUE}} {% endif %} {% with opp_unlink_perm=user|has_perm_to_unlink:opp %} {% 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 %} {% endwith %} {% endfor %} {% endwith %} {% translate 'Total' %} {{object.get_estimated_sales}} {{object.get_made_sales}}   {% endblock %} {% block brick_table_empty %} {% translate 'No related opportunity for the moment' %} {% endblock %}