<vn-watcher
    vn-id="watcher"
    url="Entries"
    data="$ctrl.entry"
    insert-mode="true"
    form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-icon color-marginal
            icon="info"
            vn-tooltip="Required fields (*)">
        </vn-icon>
        <vn-horizontal>
            <vn-autocomplete
                label="Supplier"
                ng-model="$ctrl.entry.supplierFk"
                url="Suppliers"
                show-field="nickname"
                search-function="{or: [{id: $search}, {nickname: {like: '%'+ $search +'%'}}]}"
                order="nickname"
                required="true">
                <tpl-item>
                    <div>{{::nickname}}</div>
                    <div class="text-secondary text-caption">#{{::id}}</div>
                </tpl-item>
            </vn-autocomplete>
        </vn-horizontal>
        <vn-horizontal>
            <vn-autocomplete
                label="Travel"
                ng-model="$ctrl.entry.travelFk"
                url="Travels/filter"
                search-function="$ctrl.searchFunction($search)"
                show-field="warehouseInName"
                order="id"
                required="true">
                <tpl-item>
                    <div>
                        {{::agencyModeName}}
                         - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}})
                        &#x2192; {{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}})
                    </div>
                    <div class="text-secondary text-caption">#{{::id}}</div>
                </tpl-item>
            </vn-autocomplete>
        </vn-horizontal>
        <vn-horizontal>
            <vn-autocomplete
                label="Company"
                ng-model="$ctrl.entry.companyFk"
                url="Companies"
                show-field="code"
                required="true">
            </vn-autocomplete>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Create">
        </vn-submit>
        <vn-button
            class="cancel"
            label="Cancel"
            ui-sref="entry.index"></vn-button>
        </vn-button>
    </vn-button-bar>
</form>