<div [@routerTransition]>

    <div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor">
        <div class="kt-subheader kt-grid__item">
            <div [class]="containerClass">
                <div class="kt-subheader__main">
                    <h3 class="kt-subheader__title">
                        <span>{{"Vendor" | localize}}</span>
                    </h3>
                    <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                    <span class="kt-subheader__desc">
                        {{"VendorManagement" | localize}}
                    </span>
                </div>
                <div class="kt-subheader__toolbar">
                    <div class="kt-subheader__wrapper">
                        <button (click)="exportToExcel()" class="btn btn-outline-success btn-pill"><i
                                class="fa fa-file-excel"></i> {{l("ExportToExcel")}}</button>
                        <button class="btn btn-primary btn-pill"
                            (click)="createOrEditVendor('/app/sprintship/create-vendor')"><i class="fa fa-plus"></i>
                            {{"CreateNewVendor" | localize}}</button>
                    </div>
                </div>
            </div>
        </div>
        <div [class]="containerClass + ' kt-grid__item kt-grid__item--fluid'">
            <div class="kt-portlet kt-portlet--mobile">
                <div class="kt-portlet__body">
                    <div class="row align-items-center">
                        <div class="col-md-12">
                            <form class="kt-form" autocomplete="off">
                                <div>
                                    <div class="row align-items-center">
                                        <div class="col-xl-12">
                                            <div class="form-group m-form__group align-items-center">
                                                <div class="input-group">
                                                    <input [(ngModel)]="filters.filter" name="nameFilter" autoFocus
                                                        class="form-control m-input"
                                                        [placeholder]="l('SearchWithThreeDot')" type="text">
                                                    <span class="input-group-btn">
                                                        <button (click)="getContact()" class="btn btn-primary btn-pill"
                                                            type="submit"><i class="flaticon-search-1"></i></button>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row" [hidden]="!advancedFiltersAreShown">
                                        <div class="col-md-12">
                                            <div class="kt-separator kt-separator--border-dashed"></div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="NameFilter">{{l("FirstName")}}</label>
                                                <input type="text" class="form-control" id="NameFilter" name="firstName"
                                                    [(ngModel)]="filters.firstName">
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("LastName")}}</label>
                                                <input type="text" class="form-control" id="lastNameFilter"
                                                    name="lastNameFilter" [(ngModel)]="filters.lastName">
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("EmailAddress")}}</label>
                                                <input type="text" class="form-control" id="lastNameFilter"
                                                    name="lastNameFilter" [(ngModel)]="filters.emailAddress">
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("PhoneNumber")}}</label>
                                                <input type="text" class="form-control" id="lastNameFilter"
                                                    name="lastNameFilter" [(ngModel)]="filters.phoneNumber">
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("Address")}}</label>
                                                <input type="text" class="form-control" id="lastNameFilter"
                                                    name="lastNameFilter" [(ngModel)]="filters.addressLine1">
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("City")}}</label>
                                                <select id = "citySelectInput" data-placeholder="Select City" class="form-control kt-select2" style="width:100%;" name="citySelectInput">
                                                    <option value="0">Select City</option>
                                                    <option *ngFor="let city of filteredCities" value= "{{city.city}}">
                                                        {{city.city}}
                                                    </option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("State")}}</label>
                                                <select id = "stateSelectInput" data-placeholder="Select State" style="width:100%;" class="form-control kt-select2" name="stateSelectInput">
                                                    <option value="0">Select State</option>
                                                    <option *ngFor="let state of filteredStates" value="{{state.state}}">
                                                        {{state.state}}
                                                    </option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="NameFilter">{{l("PostalCode")}}</label>
                                                <select id="postalCodeInput" data-placeholder="Select State"
                                                    style="width:100%;" class="form-control kt-select2"
                                                    name="stateSelectInput">
                                                    <option value="0">Select Postal Code</option>
                                                    <option *ngFor="let postal of filteredPostal" value="{{postal.value}}">
                                                        {{postal.value}}
                                                    </option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("AddressType")}}</label>
                                                <select id = "addressTypeSelectInput" data-placeholder="Select Address Type" style="width:100%;" class="form-control kt-select2" name="addressTypeSelectInput">
                                                    <option value="0">Select Address Type</option>
                                                    <option *ngFor="let addressType of filteredAddressType" value= "{{addressType.name}}" >
                                                        {{addressType.name}}
                                                    </option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-2">
                                            <div class="form-group">
                                                <label for="lastNameFilter">{{l("Actions")}}</label>
                                                <div class="input-group">
                                                        <button (click)="getContact()" class="btn btn-primary blue btn-pill"
                                                            type="submit">{{'Filter'}}</button>
                                                    </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row mb-2">
                                        <div class="col-sm-12">
                                            <span class="clickable-item text-muted" *ngIf="!advancedFiltersAreShown"
                                                (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i
                                                    class="fa fa-angle-down"></i> {{l("ShowAdvancedFilters")}}</span>
                                            <span class="clickable-item text-muted" *ngIf="advancedFiltersAreShown"
                                                (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i
                                                    class="fa fa-angle-up"></i> {{l("HideAdvancedFilters")}}</span>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="col-md-12">
                            <!--<Primeng-TurboTable-Start>-->
                            <div class="primeng-datatable-container">
                                <p-table #dataTable (onLazyLoad)="getContact($event)"
                                    [value]="primengTableHelper.records"
                                    rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false"
                                    [lazy]="true" [scrollable]="true" ScrollWidth="100%"
                                    [responsive]="primengTableHelper.isResponsive"
                                    [resizableColumns]="primengTableHelper.resizableColumns">
                                    <ng-template pTemplate="header">
                                        <tr>
                                            <th style="width: 130px">
                                                {{'Actions' | localize}}
                                            </th>
                                            <th style="width: 150px" pSortableColumn="user.name">
                                                {{'FirstName' | localize}}
                                                <p-sortIcon field="user.name"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px" pSortableColumn="user.surname">
                                                {{'LastName' | localize}}
                                                <p-sortIcon field="user.surname"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px" pSortableColumn="user.emailAddress">
                                                {{'EmailAddress' | localize}}
                                                <p-sortIcon field="user.emailAddress"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px" pSortableColumn="user.phoneNumber">
                                                {{'PhoneNumber' | localize}}
                                                <p-sortIcon field="user.phoneNumber"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px" pSortableColumn="address.addressLine1">
                                                {{'Address' | localize}}
                                                <p-sortIcon field="address.addressLine1"></p-sortIcon>
                                            </th>
                                            <!-- <th style="width: 150px" pSortableColumn="address.addressLine2">
                                                {{'AddressLine2' | localize}}
                                                <p-sortIcon field="address.addressLine2"></p-sortIcon>
                                            </th> -->
                                            <th style="width: 150px" pSortableColumn="address.city.name">
                                                {{'City' | localize}}
                                                <p-sortIcon field="address.city.name"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px" pSortableColumn="address.state.name">
                                                {{'State' | localize}}
                                                <p-sortIcon field="address.state.name"></p-sortIcon>
                                            </th>
                                            <!-- <th style="width: 150px" pSortableColumn="address.country.name">
                                                {{'Country' | localize}}
                                                <p-sortIcon field="address.country.name"></p-sortIcon>
                                            </th> -->
                                            <th style="width: 150px" pSortableColumn="address.postalCode.name">
                                                {{'PostalCode' | localize}}
                                                <p-sortIcon field="address.postalCode.name"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px" pSortableColumn="address.addressType.name">
                                                {{'AddressType' | localize}}
                                                <p-sortIcon field="address.addressType.name"></p-sortIcon>
                                            </th>
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="body" let-record="$implicit">
                                        <tr>
                                            <td style="width: 130px">
                                                <div class="btn-group dropdown" dropdown container="body">
                                                    <button dropdownToggle
                                                        class="dropdown-toggle btn btn-sm btn-primary btn-pill">
                                                        <i class="fa fa-cog"></i><span class="caret"></span>
                                                        {{"Actions" | localize}}
                                                    </button>
                                                    <ul class="dropdown-menu" *dropdownMenu>
                                                        <li>
                                                            <a href="javascript:;"
                                                                (click)="createOrEditVendor('/app/sprintship/edit-vendor',record.id)">{{'Edit' | localize}}</a>
                                                        </li>
                                                        <li>
                                                            <a href="javascript:;"
                                                                *ngIf="'Pages.Shipping.Contacts.Delete' | permission"
                                                                (click)="deleteContact(record)">{{'Delete' | localize}}</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'FirstName' | localize}}</span>
                                                {{record.firstName}}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'LastName' | localize}}</span>
                                                {{record.lastName}}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'EmailAddress' | localize}}</span>
                                                {{record.user.emailAddress == undefined ? 'n/a' : record.user.emailAddress }}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'PhoneNumber' | localize}}</span>
                                                {{record.user.phoneNumber == undefined ? 'n/a' : record.user.phoneNumber }}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'AddressLine1' | localize}}</span>
                                                {{record.address.addressLine1 == undefined ? 'n/a' : record.address.addressLine1 +","}}
                                                {{record.address.addressLine2 == undefined ? '' : record.address.addressLine2}}
                                            </td>
                                            <!-- <td style="width: 150px">
                                                <span class="ui-column-title"> {{'AddressLine2' | localize}}</span>
                                                {{record.address.addressLine2 == undefined ? 'n/a' : record.address.addressLine2 }}
                                            </td> -->
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'City' | localize}}</span>
                                                {{record.address.postalCode.city == undefined ? 'n/a' : record.address.postalCode.city }}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'State' | localize}}</span>
                                                {{record.address.postalCode.state == undefined ? 'n/a' : record.address.postalCode.state }}
                                            </td>
                                            <!-- <td style="width: 150px">
                                                <span class="ui-column-title"> {{'Country' | localize}}</span>
                                                {{record.address.postalCode.country == undefined ? 'n/a' : record.address.postalCode.country }}
                                            </td> -->
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'PostalCode' | localize}}</span>
                                                {{record.address.postalCode.value == undefined ? 'n/a' : record.address.postalCode.value }}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'AddressType' | localize}}</span>
                                                {{record.address.addressType == undefined ? 'n/a' : record.address.addressType.name }}
                                            </td>
                                        </tr>
                                    </ng-template>
                                </p-table>
                                <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                                    {{'NoData' | localize}}
                                </div>
                                <div class="primeng-paging-container">
                                    <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                        (onPageChange)="getContact($event)"
                                        [totalRecords]="primengTableHelper.totalRecordsCount"
                                        [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

                                    </p-paginator>
                                    <span class="total-records-count">
                                        {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                                    </span>
                                </div>
                            </div>
                            <!--<Primeng-TurboTable-End>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>