<vn-card class="summary">
    <h5>
        <a ng-if="::$ctrl.summary.route.id"
            vn-tooltip="Go to the route"
            ui-sref="route.card.summary({id: {{::$ctrl.summary.route.id}}})"
            name="goToSummary">
            <vn-icon-button icon="launch"></vn-icon-button>
        </a>
        <span>{{$ctrl.summary.route.id}} - {{$ctrl.summary.route.description}}</span>
    </h5>
    <vn-horizontal>
        <vn-one>
            <vn-label-value label="Id"
                value="{{$ctrl.summary.route.id}}">
            </vn-label-value>
            <vn-label-value label="Date"
                value="{{$ctrl.summary.route.created | date: 'dd/MM/yyyy'}}">
            </vn-label-value>
            <vn-label-value label="Agency"
                value="{{$ctrl.summary.route.agencyMode.name}}">
            </vn-label-value>
            <vn-label-value label="Vehicle"
                value="{{$ctrl.summary.route.vehicle.numberPlate}}">
            </vn-label-value>
            <vn-label-value label="Driver">
                <span
                    ng-click="workerDescriptor.show($event, $ctrl.summary.route.workerFk)"
                    class="link">
                    {{$ctrl.summary.route.worker.user.name}}
                </span>
            </vn-label-value>
            <vn-label-value label="Cost"
                value="{{$ctrl.summary.route.cost | currency: 'EUR':2}}">
            </vn-label-value>
        </vn-one>
        <vn-one>
            <vn-label-value label="Starting time"
                value="{{$ctrl.summary.route.time | date: 'HH:MM'}}">
            </vn-label-value>
            <vn-label-value label="Finishing time"
                value="{{$ctrl.summary.route.finished | date: 'HH:MM'}}">
            </vn-label-value>
            <vn-label-value label="Km Start"
                value="{{$ctrl.summary.route.kmStart}}">
            </vn-label-value>
            <vn-label-value label="Km End"
                value="{{$ctrl.summary.route.kmEnd}}">
            </vn-label-value>
            <vn-label-value label="Volume"
                value="{{$ctrl.summary.route.m3 | dashIfEmpty}} / {{$ctrl.summary.route.vehicle.m3  | dashIfEmpty}} m³">
            </vn-label-value>
            <vn-label-value label="Packages"
                value="{{$ctrl.packagesTotal}}">
            </vn-label-value>
        </vn-one>
        <vn-one>
            <vn-textarea
                disabled="true"
                label="Description"
                ng-model="$ctrl.summary.route.description">
            </vn-textarea>
        </vn-one>
        <vn-auto>
            <h4 ng-show="$ctrl.isDelivery">
                <a
                    ui-sref="route.card.tickets({id:$ctrl.route.id})"
                    target="_self">
                    <span translate vn-tooltip="Go to">Ticket</span>
                </a>
            </h4>
            <h4
                translate
                ng-show="!$ctrl.isDelivery">
                Ticket
            </h4>
            <vn-table model="model">
                <vn-thead>
                    <vn-tr>
                        <vn-th shrink>Order</vn-th>
                        <vn-th>Street</vn-th>
                        <vn-th>City</vn-th>
                        <vn-th shrink>PC</vn-th>
                        <vn-th>Client</vn-th>
                        <vn-th>Warehouse</vn-th>
                        <vn-th number shrink>Packages</vn-th>
                        <vn-th shrink>m³</vn-th>
                        <vn-th shrink>Packaging</vn-th>
                        <vn-th number>Ticket</vn-th>
                        <vn-th shrink></vn-th>
                    </vn-tr>
                </vn-thead>
                <vn-tbody>
                    <vn-tr ng-repeat="ticket in $ctrl.summary.tickets">
                        <vn-td shrink>{{ticket.priority | dashIfEmpty}}</vn-td>
                        <vn-td expand title="{{ticket.address.street}}">{{ticket.street}}</vn-td>
                        <vn-td
                            expand
                            ng-click="$ctrl.goToBuscaman(ticket)"
                            class="link"
                            vn-tooltip="Open buscaman"
                            tooltip-position="up">
                            {{::ticket.city}}
                        </vn-td>
                        <vn-td shrink>{{ticket.postalCode}}</vn-td>
                        <vn-td>
                            <span
                                ng-click="clientDescriptor.show($event, ticket.clientFk)"
                                class="link">
                                {{ticket.nickname}}
                            </span>
                       </vn-td>
                       <vn-td>{{ticket.warehouseName}}</vn-td>
                        <vn-td number shrink>{{ticket.packages}}</vn-td>
                        <vn-td shrink>{{ticket.volume}}</vn-td>
                        <vn-td shrink>{{ticket.ipt}}</vn-td>
                        <vn-td number>
                            <span
                                ng-click="ticketDescriptor.show($event, ticket.id)"
                                class="link">
                                {{ticket.id}}
                            </span>
                        </vn-td>
                        <vn-td>
                            <vn-icon-button
                                ng-if="::ticket.description"
                                vn-tooltip="{{::ticket.description}}"
                                icon="icon-notes"
                                tabindex="-1">
                            </vn-icon-button>
                        </vn-td>
                    </vn-tr>
                </vn-tbody>
            </vn-table>
        </vn-auto>
    </vn-horizontal>
</vn-card>
<vn-ticket-descriptor-popover
    vn-id="ticketDescriptor">
</vn-ticket-descriptor-popover>
<vn-client-descriptor-popover
    vn-id="clientDescriptor">
</vn-client-descriptor-popover>
<vn-worker-descriptor-popover
    vn-id="workerDescriptor">
</vn-worker-descriptor-popover>