<vn-crud-model
    vn-id="model"
    url="greuges"
    filter="::$ctrl.filter"
    link="{clientFk: $ctrl.$params.id}"
    limit="20"
    data="greuges"
    auto-load="true">
</vn-crud-model>
<mg-ajax 
    path="greuges/{{$ctrl.$params.id}}/sumAmount" 
    options="mgEdit">
</mg-ajax>
<vn-data-viewer
    model="model"
    class="vn-w-md">
    <vn-card
        ng-if="model.data.length > 0"
        style="text-align: right;"
        class="vn-mb-md vn-pa-lg">
        <vn-label-value
            label="Total" 
            value="{{edit.model.sumAmount | currency: 'EUR': 2}}">
        </vn-label-value>
    </vn-card>
    <vn-card>
        <vn-vertical>
            <vn-table model="model" auto-load="false">
                <vn-thead>
                    <vn-tr>
                        <vn-th field="shipped" default-order="DESC" expand>Date</vn-th>
                        <vn-th field="description">Comment</vn-th>
                        <vn-th field="greugeTypeFk">Type</vn-th>
                        <vn-th field="amount" number>Amount</vn-th>
                    </vn-tr>
                </vn-thead>
                <vn-tbody>
                    <vn-tr ng-repeat="greuge in greuges">
                        <vn-td expand>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
                        <vn-td>
                            <span title="{{::greuge.description}}">{{::greuge.description}}</span>
                        </vn-td>
                        <vn-td>{{::greuge.greugeType.name}}</vn-td>
                        <vn-td number>{{::greuge.amount | currency: 'EUR': 2}}</vn-td>
                    </vn-tr>
                </vn-tbody>
            </vn-table>
        </vn-vertical>
    </vn-card>
</vn-data-viewer>
<vn-float-button
    icon="add"
    ui-sref="client.card.greuge.create" 
    vn-tooltip="New greuge" 
    vn-acl="salesAssistant,claimManager"
    vn-acl-action="remove"
    vn-bind="+"
    fixed-bottom-right>
</vn-float-button>