<vn-crud-model
    vn-id="model"
    url="/ticket/api/Tickets"
    filter="::$ctrl.filter"
    limit="10"
    data="tickets"
    auto-load="false">
</vn-crud-model>
<div margin-medium>
    <div class="vn-list">
        <vn-card pad-medium-h>
            <vn-searchbar
                panel="vn-ticket-search-panel"
                model="model"
                expr-builder="$ctrl.exprBuilder(param, value)">
            </vn-searchbar>
        </vn-card>
    </div>
    <vn-card margin-medium-v pad-medium>
        <table class="vn-grid">
            <thead>
                <tr>
                    <th translate number>Id</th>
                    <th translate>Salesperson</th>
                    <th translate>Date</th>
                    <th translate>Hour</th>
                    <th translate>Alias</th>
                    <th translate>Province</th>
                    <th translate>State</th>
                    <th translate>Agency</th>
                    <th translate>Warehouse</th>
                    <th translate number>Invoice</th>
                    <th translate number>Route</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="ticket in tickets" 
                    class="{{::$ctrl.compareDate(ticket.shipped)}} clickable"
                    ui-sref="ticket.card.summary({id: {{::ticket.id}}})">
                    <th number>{{::ticket.id}}</th>
                    <td >{{::ticket.client.salesPerson.name | dashIfEmpty}}</td>
                    <td >{{::ticket.shipped | date:'dd/MM/yyyy'}}</td>
                    <td >{{::ticket.shipped | date:'HH:MM'}}</td>
                    <td >{{::ticket.nickname}}</td>
                    <td >{{::ticket.address.province.name}}</td>
                    <td >{{::ticket.tracking.state.name}}</td>
                    <td >{{::ticket.agencyMode.name}}</td>
                    <td >{{::ticket.warehouse.name}}</td>
                    <td number >{{::ticket.refFk | dashIfEmpty}}</td>
                    <td number >{{::ticket.routeFk | dashIfEmpty}}</td>
                    <td>
                        <vn-icon-button
                            ng-click="$ctrl.preview($event, ticket)"
                            vn-tooltip="Preview"
                            icon="desktop_windows">
                        </vn-icon-button>
                    </td>
                </tr>
            </tbody>
        </table>
    </vn-card>
    <vn-pagination
        model="model"
        scroll-selector="ui-view">
    </vn-pagination>
</div>
<a ui-sref="ticket.create" vn-bind="+" fixed-bottom-right>
    <vn-float-button icon="add"></vn-float-button>
</a>
<vn-dialog class="dialog-summary"
    vn-id="dialog-summary-ticket">
    <tpl-body>
        <vn-ticket-summary ticket="$ctrl.ticketSelected"></vn-ticket-summary>
    </tpl-body>
</vn-dialog>