<vn-crud-model
    vn-id="model"
    url="/client/api/greuges"
    filter="::$ctrl.filter"
    link="{clientFk: $ctrl.$stateParams.id}"
    limit="20"
    data="greuges" auto-load="true">
</vn-crud-model>
<mg-ajax 
    path="/client/api/greuges/{{$ctrl.$stateParams.id}}/sumAmount" 
    options="mgEdit">
</mg-ajax>
<vn-vertical compact>
    <vn-card pad-large>
        <vn-horizontal>
            <div class="totalBox" ng-if="model.data.length > 0">
                <vn-label-value label="Total" 
                    value="{{edit.model.sumAmount | currency: 'EUR': 2}}">
                </vn-label-value>
            </div>
        </vn-horizontal>
        <vn-vertical>
            <vn-table model="model" auto-load="false">
                <vn-thead>
                    <vn-tr>
                        <vn-th field="shipped" default-order="DESC">Date</vn-th>
                        <vn-th field="description">Comment</vn-th>
                        <vn-th field="amount" >Amount</vn-th>
                        <vn-th field="greugeTypeFk">Type</vn-th>
                    </vn-tr>
                </vn-thead>
                <vn-tbody>
                    <vn-tr ng-repeat="greuge in greuges">
                        <vn-td>{{::greuge.shipped | dateTime:'dd/MM/yyyy HH:mm' }}</vn-td>
                        <vn-td>{{::greuge.description}}</vn-td>
                        <vn-td>{{::greuge.amount | currency: 'EUR': 2}}</vn-td>
                        <vn-td>{{::greuge.greugeType.name}}</vn-td>
                    </vn-tr>
                </vn-tbody>
            </vn-table>
        </vn-vertical>
        <vn-pagination model="model"></vn-pagination>
    </vn-card>
</vn-vertical>

<vn-float-button icon="add" fixed-bottom-right
    ui-sref="client.card.greuge.create" 
    vn-tooltip="New greuge" 
    vn-acl="salesAssistant"
    vn-acl-action="remove"
    vn-bind="+">
</vn-float-button>