<vn-card class="summary">
    <h5>
        <a 
            ng-if="::$ctrl.travelData.id"
            vn-tooltip="Go to the travel"
            ui-sref="travel.card.summary({id: {{::$ctrl.travelData.id}}})"
            name="goToSummary">
            <vn-icon-button icon="launch"></vn-icon-button>
        </a>
        <span>{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}</span>
        <vn-travel-descriptor-menu travel-id="$ctrl.travel.id"/>
    </h5>
    <vn-horizontal>
        <vn-one>
            <vn-label-value
                label="Shipped" 
                value="{{$ctrl.travelData.shipped | date: 'dd/MM/yyyy'}}">
            </vn-label-value>
            <vn-label-value
                label="Warehouse Out" 
                value="{{$ctrl.travelData.warehouseOut.name}}">
            </vn-label-value>
            <vn-check
                label="Delivered" 
                ng-model="$ctrl.travelData.isDelivered"
                disabled="true">
            </vn-check>
        </vn-one>
        <vn-one>
            <vn-label-value
                label="Landed"
                value="{{$ctrl.travelData.landed | date: 'dd/MM/yyyy'}}">
            </vn-label-value>
            <vn-label-value
                label="Warehouse In"
                value="{{$ctrl.travelData.warehouseIn.name}}">
            </vn-label-value>
            <vn-check
                label="Received" 
                ng-model="$ctrl.travelData.isReceived"
                disabled="true">
            </vn-check>
        </vn-one>
        <vn-one>
            <vn-label-value
                label="Agency"
                value="{{$ctrl.travelData.agency.name}}">
            </vn-label-value>
            <vn-label-value
                label="Reference"
                value="{{$ctrl.travelData.ref}}">
            </vn-label-value>
            <vn-label-value
                label="m³"
                value="{{$ctrl.travelData.m3}}">
            </vn-label-value>
            <vn-label-value
                label="Total entries"
                value="{{$ctrl.travelData.totalEntries}}">
            </vn-label-value>
        </vn-one>
        <vn-auto>
            <h4 translate>Entries</h4>
            <vn-table>
                <vn-thead>
                    <vn-tr>
                        <vn-th shrink>Confirmed</vn-th>
                        <vn-th shrink>Entry Id</vn-th>
                        <vn-th shrink>Supplier</vn-th>
                        <vn-th shrink>Reference</vn-th>
                        <vn-th shrink title="Half box">HB</vn-th>
                        <vn-th shrink>Freight</vn-th>
                        <vn-th shrink>Package</vn-th>
                        <vn-th shrink>CC</vn-th>
                        <vn-th shrink>Pallet</vn-th>
                        <vn-th shrink>m³</vn-th>
                        <vn-th shrink></vn-th>
                    </vn-tr>
                </vn-thead>
                <vn-tbody>
                    <vn-tr ng-repeat="entry in $ctrl.entries">
                        <vn-td shrink>
                            <vn-check 
                                ng-model="entry.isConfirmed"
                                disabled="true">
                            </vn-check>
                        </vn-td>
                        <vn-td shrink>
                            <span class="link"
                                vn-click-stop="entryDescriptor.show($event, entry.id)">
                                {{entry.id}}
                            </span>
                        </vn-td>
                        <vn-td expand>{{entry.supplierName}}</vn-td>
                        <vn-td shrink>{{entry.ref}}</vn-td>
                        <vn-td shrink>{{entry.hb}}</vn-td>
                        <vn-td shrink>{{entry.freightValue | currency: 'EUR': 2}}</vn-td>
                        <vn-td shrink>{{entry.packageValue | currency: 'EUR': 2}}</vn-td>
                        <vn-td shrink>{{entry.cc}}</vn-td>
                        <vn-td shrink>{{entry.pallet}}</vn-td>
                        <vn-td shrink>{{entry.m3}}</vn-td>
                        <vn-td shrink> 
                            <vn-icon
                                ng-if="entry.notes.length"
                                vn-tooltip="{{entry.notes}}"
                                icon="insert_drive_file"
                                class="bright">
                            </vn-icon>
                            <vn-icon
                                ng-if="entry.observation.length"
                                vn-tooltip="{{entry.observation}}"
                                icon="insert_drive_file"
                                class="bright">
                            </vn-icon>
                        </vn-td>
                    </vn-tr>
                </vn-tbody>
                <vn-tfoot>
                    <vn-tr>
                        <vn-td></vn-td>
                        <vn-td></vn-td>
                        <vn-td></vn-td>
                        <vn-td></vn-td>
                        <vn-td shrink><strong>{{$ctrl.total('hb')}}</strong></vn-td>
                        <vn-td shrink><strong>{{$ctrl.total('freightValue') | currency: 'EUR': 2}}</strong></vn-td>
                        <vn-td shrink><strong>{{$ctrl.total('packageValue') | currency: 'EUR': 2}}</strong></vn-td>
                        <vn-td shrink><strong>{{$ctrl.total('cc') | number:2}}</strong></vn-td>
                        <vn-td shrink><strong>{{$ctrl.total('pallet') | number:2}}</strong></vn-td>
                        <vn-td shrink><strong>{{$ctrl.total('m3') | number:2}}</strong></vn-td>
                        <vn-td></vn-td>
                    </vn-tr>
                </vn-tfoot>
            </vn-table>
        </vn-auto>
        <vn-auto ng-if="$ctrl.travelThermographs.length != 0">
            <h4 ng-show="$ctrl.isBuyer">
                <a 
                    ui-sref="travel.card.thermograph.index({id:$ctrl.travelData.id})"
                    target="_self">
                    <span translate vn-tooltip="Go to">Thermograph</span>
                </a>
            </h4>
            <h4 
                translate
                ng-show="!$ctrl.isBuyer">
                Thermograph
            </h4>
            <vn-table>
                <vn-thead>
                    <vn-tr>
                        <vn-th>Code</vn-th>
                        <vn-th>Temperature</vn-th>
                        <vn-th expand>State</vn-th>
                        <vn-th>Destination</vn-th>
                        <vn-th expand>Created</vn-th>
                    </vn-tr>
                </vn-thead>
                <vn-tbody>
                    <vn-tr ng-repeat="thermograph in $ctrl.travelThermographs">
                        <vn-td>{{thermograph.thermographFk}} </vn-td>
                        <vn-td>{{thermograph.temperature}}</vn-td>
                        <vn-td>{{thermograph.result}}</vn-td>
                        <vn-td>{{thermograph.warehouse.name}}</vn-td>
                        <vn-td expand>{{thermograph.created | date: 'dd/MM/yyyy'}}</vn-td>
                    </vn-tr>
                </vn-tbody>
            </vn-table>
        </vn-auto>
    </vn-horizontal>
</vn-card>
<vn-entry-descriptor-popover 
    vn-id="entryDescriptor">
</vn-entry-descriptor-popover>