klein0r/affiliate-dashboard

View on GitHub
src/AffiliateDashboardBundle/Resources/views/Blogpost/index.html.twig

Summary

Maintainability
Test Coverage
{% extends 'base.html.twig' %}

{% block body %}
    <div class="page-header">
        <h1>{% trans %}Blogposts{% endtrans %}</h1>
    </div>

    <table class="table table-hover table-condensed">
        <thead>
            <tr>
                <th>{% trans %}Title{% endtrans %}</th>
                <th>{% trans %}Published at{% endtrans %}</th>
                <th>{% trans %}Tag{% endtrans %}</th>
                <th>{% trans %}Sales{% endtrans %}</th>
                <th>{% trans %}Assigned{% endtrans %}</th>
                <th>{% trans %}Users{% endtrans %}</th>
                <th>{% trans %}Actions{% endtrans %}</th>
            </tr>
        </thead>
        <tbody>
        {% for blogpost in blogposts %}
            <tr {% if (blogpost.blogpostUser|propertySum('percentage') != 100) %}class="danger"{% endif %}>
                <td><a href="{{ blogpost.url }}">{{ blogpost.title }}</a></td>
                <td>{% if blogpost.publishedAt %}{{ blogpost.publishedAt|localizeddate('medium', 'none') }}{% endif %}</td>
                <td>{{ blogpost.affiliateTag }}</td>
                <td>
                    <span class="label label-default">{{ blogpost.affiliateTag.sales|length }} {% trans %}Sales{% endtrans %}</span>
                    <span class="label label-success">{{ blogpost.affiliateTag.sales|propertySum('earnings')|localizedcurrency('EUR') }} {% trans %}earned{% endtrans %}</span>
                </td>
                <td>
                    {{ blogpost.blogpostUser|propertySum('percentage') }}%
                </td>
                <td>
                    {% for bu in blogpost.blogpostUser %}
                        <span class="label label-default">{{ bu.user.name }} - {{ bu.percentage }}%</span>
                    {% endfor %}
                </td>
                <td>
                    <a class="btn btn-primary btn-sm" href="{{ path('blogpost_show', { 'id': blogpost.id }) }}">{% trans %}show{% endtrans %}</a>
                    <a class="btn btn-info btn-sm" href="{{ path('blogpost_edit', { 'id': blogpost.id }) }}">{% trans %}edit{% endtrans %}</a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endblock %}