<vn-auto-search
    model="model">
</vn-auto-search>
<vn-travel-search-panel
    model="model">
</vn-travel-search-panel>
<vn-crud-model
    vn-id="model"
    url="Travels/filter"
    limit="20"
    order="shipped DESC, landed DESC">
</vn-crud-model>
<vn-data-viewer
    model="model"
    class="vn-mb-xl vn-w-xl">
    <vn-card>
    <vn-table model="model">
        <vn-thead>
            <vn-tr>
                <vn-th field="ref">Reference</vn-th>
                <vn-th field="agencyModeFk">Agency</vn-th>
                <vn-th field="warehouseOutFk">Warehouse Out</vn-th>
                <vn-th field="shipped" center shrink-date>Shipped</vn-th>
                <vn-th shrink></vn-th>
                <vn-th field="warehouseInFk">Warehouse In</vn-th>
                <vn-th field="landed" center shrink-date>Landed</vn-th>
                <vn-th shrink></vn-th>
                <vn-th shrink field="totalEntries">Total entries</vn-th>
                <vn-th shrink></vn-th>
            </vn-tr>
        </vn-thead>
        <vn-tbody>
            <a ng-repeat="travel in model.data"
                class="clickable vn-tr search-result"
                ui-sref="travel.card.summary({id: {{::travel.id}}})">
                <vn-td>{{::travel.ref}}</vn-td>
                <vn-td>{{::travel.agencyModeName}}</vn-td>
                <vn-td>{{::travel.warehouseOutName}}</vn-td>
                <vn-td center shrink-date>
                    <span class="chip {{$ctrl.compareDate(travel.shipped)}}">
                        {{::travel.shipped | date:'dd/MM/yyyy'}}
                    </span>
                </vn-td>
                <vn-td shrink>
                    <vn-icon
                        icon="flight_takeoff"
                        translate-attr="{title: 'Delivered'}"
                        ng-class="{active: travel.isDelivered}">
                    </vn-icon>
                </vn-td>
                <vn-td expand>{{::travel.warehouseInName}}</vn-td>
                <vn-td center shrink-date>
                    <span class="chip {{$ctrl.compareDate(travel.landed)}}">
                        {{::travel.landed | date:'dd/MM/yyyy'}}
                    </span>
                </vn-td>
                <vn-td shrink>
                    <vn-icon
                        icon="flight_land"
                        translate-attr="{title: 'Received'}"
                        ng-class="{active: travel.isReceived}">
                    </vn-icon>
                </vn-td>
                <vn-td shrink>{{::travel.totalEntries}}</vn-td>
                <vn-td shrink>
                    <vn-horizontal class="buttons">
                        <vn-icon-button
                            vn-click-stop="clone.show(travel)"
                            vn-tooltip="Clone"
                            icon="icon-clone">
                        </vn-icon-button>
                        <vn-icon-button
                            vn-anchor="::{state: 'entry.create', params: {travelFk: travel.id}}"
                            vn-tooltip="Add entry"
                            icon="icon-ticket">
                        </vn-icon-button>
                        <vn-icon-button
                            vn-click-stop="$ctrl.preview(travel)"
                            vn-tooltip="Preview"
                            icon="preview">
                        </vn-icon-button>
                    </vn-horizontal>
                </vn-td>
            </a>
        </vn-tbody>
    </vn-table>
</vn-data-viewer>
    </vn-card>
<vn-popup vn-id="summary">
    <vn-travel-summary
        travel="$ctrl.travelSelected">
    </vn-travel-summary>
</vn-popup>
<a ui-sref="travel.create"
    vn-tooltip="New travel"
    vn-bind="+"
    vn-acl="buyer"
    fixed-bottom-right>
    <vn-float-button icon="add"></vn-float-button>
</a>
<vn-confirm
    vn-id="clone"
    on-accept="$ctrl.onCloneAccept($data)"
    question="Do you want to clone this travel?"
    message="All it's properties will be copied">
</vn-confirm>