<vn-watcher
    vn-id="watcher"
    url="InvoiceIns"
    data="$ctrl.invoiceIn"
    insert-mode="true"
    form="form">
</vn-watcher>
<form name="form" vn-http-submit="$ctrl.onSubmit()" class="vn-w-md">
    <div class="vn-w-md">
        <vn-card class="vn-pa-lg">
            <vn-autocomplete
                vn-focus
                vn-id="supplier"
                url="Suppliers"
                label="Supplier"
                search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}, {nif: {like: '%'+ $search +'%'}}]}"
                fields="['nif']"
                show-field="name"
                value-field="id"
                ng-model="$ctrl.invoiceIn.supplierFk"
                order="id"
                vn-focus>
                <tpl-item>{{id}}: {{nif}}: {{name}}</tpl-item>
            </vn-autocomplete>
            <vn-textfield
                vn-one
                label="supplierRef"
                ng-model="$ctrl.invoiceIn.supplierRef">
            </vn-textfield>
            <vn-date-picker 
                label="Issued" 
                ng-model="$ctrl.invoiceIn.issued">
            </vn-date-picker>
            <vn-autocomplete
                vn-one
                label="Company"
                ng-model="$ctrl.companyFk"
                url="companies"
                show-field="code"
                value-field="id">
            </vn-autocomplete>
        </vn-card>
        <vn-button-bar>
            <vn-submit
                disabled="!watcher.dataChanged()"
                label="Create">
            </vn-submit>
            <vn-button
                class="cancel"
                label="Cancel"
                ui-sref="InvoiceIn.index">
            </vn-button>
        </vn-button-bar>
    </div>
</form>