<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>{{"Orders" | localize}}</span>
                    </h3>
                    <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                    <span class="kt-subheader__desc">
                        {{"OrderManagement" | 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 (click)="createOrder()" *ngIf="isGranted('Pages.Orders.Create')" class="btn btn-primary btn-elevate btn-pill btn-elevate-air"><i class="fa fa-plus"></i> {{"OrderCreate" | localize}}</button> -->
                        <button (click)="createOrUpdate('/app/sprintship/order-create')"
                            *ngIf="isGranted('Pages.Orders.Create')" class="btn btn-primary btn-elevate btn-pill"><i
                                class="fa fa-plus"></i> {{"OrderCreate" | localize}}</button>

                        <!-- <button (click)="createTag()" *ngIf="isGranted('Pages.Orders.Create')" class="btn btn-primary btn-elevate btn-pill btn-elevate-air"><i class="fa fa-plus"></i> {{"TagCreate" | 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">
                    <form (submit)="getOrders()" autocomplete="off" class="kt-form">
                        <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 name="filterText" [(ngModel)] = "filterText" autoFocus class="form-control m-input"
                                            [placeholder]="l('SearchWithThreeDot')" type="text">
                                        <span class="input-group-btn">
                                            <button 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-2">
                                <div class="form-group">
                                    <label for="NameFilter">{{l("OrderId")}}</label>
                                    <select id="OrderId" data-placeholder="Select Order Id" style="width:100%;"
                                        class="form-control kt-select2" name="orderSelectInput">
                                        <option value="0">Select Order Id</option>
                                        <option *ngFor="let order of filteredOrder" value="{{order.id}}">
                                            {{order.id}}
                                        </option>
                                    </select>

                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="locationSelectInput">{{l("Locations")}}</label>
                                    <select id="locations" data-placeholder="Select Locations" style="width:100%;"
                                        class="form-control kt-select2" name="locationSelectInput">
                                        <option value="0">Select Location</option>
                                        <option *ngFor="let location of filteredLocation" value="{{location.id}}">
                                            {{location.name}}
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label for="NameFilter">{{l("TimeCreated")}}</label>
                                    <input name="PickupEta" type="text" class="form-control" id="PickupEta" bsDatepicker
                                        [(ngModel)]="TimeCreated" readonly="readonly" #PickupEta="ngModel" required />
                                </div>
                            </div>
                            <!-- <div class="col-md-2">
                                <div class="form-group">
                                    <label for="NameFilter">{{l("DeliveryEta")}}</label>
                                    <input name="DeliveryEta" type="text" class="form-control" id="DeliveryEta"
                                        bsDatepicker readonly="readonly" [(ngModel)]="deliveryEta"
                                        #DeliveryEta="ngModel" required />
                                </div>
                            </div> -->
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label for="lastNameFilter">{{l("Actions")}}</label>
                                    <div class="input-group">
                                        <button class="btn btn-primary blue btn-pill"
                                            type="submit">{{'Filter'}}</button>
                                    </div>
                                </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>
                    </form>

                    <!--  <form (submit)="getOrders()" autocomplete="off" class="kt-form" >
                                <div class="row align-items-center mb-4">
                                        <div class="col-xl-6"> -->
                    <!-- <label for="FleetName">{{"Location" | localize}}</label> -->

                    <!-- <select class="form-control kt-select2" style="width:100%" id="FilterByLocation" [(ngModel)]="locationFilter" name="FilterByLocation"  #packageCtrl="ngModel" >
                                                <option *ngFor="let location of filteredLocation"  [(value)]="location.id">
                                                    {{location.name}}
                                                </option>
                                            </select> -->
                    <!-- 
                                            <p-autoComplete [(ngModel)]="locationFilter"
                                                id="FilterByLocation"
                                                [suggestions]="filteredLocation"
                                                (completeMethod)="filterLocation($event)"
                                                field="name"
                                                placeholder="Filter by location...."
                                                [minLength]="1"
                                                name="FilterByLocation"
                                                inputStyleClass="form-control"
                                                styleClass="width-percent-100">
                                            </p-autoComplete> -->
                    <!-- </div> -->
                    <!-- <div class="col-xl-6">
                                            <div class="input-group">
                                                <input id="FilterDatePicker"
                                                    [(ngModel)]="filterDate"
                                                    type="text"
                                                    #SampleDatePicker
                                                    name="FilterDatePicker"
                                                    class="form-control"
                                                    readonly="readonly"
                                                    bsDatepicker
                                                >
                                                <span class="input-group-btn">
                                                    <button class="btn btn-primary" type="submit"><i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i></button>
                                                </span>
                                            </div>
                                        </div> -->
                    <!--      </div>
                            </form> -->

                    <div class="row align-items-center">
                        <!--<Primeng-TurboTable-Start>-->
                        <div class="col-xl-12">
                            <div class="primeng-datatable-container">
                                <p-table #dataTable (onLazyLoad)="getOrders($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: 10%">{{'Actions' | localize}}</th>
                                            <th style="width: 10%" pSortableColumn="id">
                                                {{'Id' | localize}}
                                                <p-sortIcon field="id"></p-sortIcon>
                                            </th>
                                            <th style="width: 15%" pSortableColumn="location.Name">
                                                {{'Location' | localize}}
                                                <p-sortIcon field="location.Name"></p-sortIcon>
                                            </th>
                                            <th style="width: 15%" pSortableColumn="creationTime">
                                                {{'TimeCreated' | localize}}
                                                <p-sortIcon field="creationTime"></p-sortIcon>
                                            </th>
                                            <th style="width: 15%">
                                                {{'LastLogType' | localize}}
                                                <!-- <p-sortIcon field="orderStatus"></p-sortIcon> -->
                                            </th>
                                            <th style="width: 15%">
                                                {{'Packages' | localize}}
                                                <!-- <p-sortIcon field="location.Name"></p-sortIcon> -->
                                            </th>
                                            <th style="width: 15%" pSortableColumn="pickupDetail.contact.firstName">
                                                {{'Customer' | localize}}
                                                <p-sortIcon field="pickupDetail.contact.firstName"></p-sortIcon>
                                            </th>
                                            <!-- <th style="width: 150px" pSortableColumn="pickupDetail.etaStart">
                                                {{'PickupEta' | localize}}
                                                <p-sortIcon field="pickupDetail.etaStart"></p-sortIcon>
                                            </th> -->
                                            <!-- <th style="width: 150px">
                                                {{'TotalPackage' | localize}}
                                            </th> -->
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="body" let-record="$implicit">
                                        <tr>
                                            <td style="width: 10%"
                                                [hidden]="!isGrantedAny('Pages.Orders.Update', 'Pages.Orders.Delete')">
                                                <div class="btn-group dropdown" dropdown container="body">
                                                    <button dropdownToggle
                                                        class="dropdown-toggle btn btn-sm btn-primary btn-elevate btn-pill">
                                                        <i class="fa fa-cog"></i><span class="caret"></span>
                                                        {{"Actions" | localize}}
                                                    </button>
                                                    <ul class="dropdown-menu" *dropdownMenu>
                                                        <li>
                                                            <a href="javascript:;"
                                                                *ngIf="'Pages.Orders.Update' | permission"
                                                                (click)="createOrUpdate('/app/sprintship/order-update',record.id)">{{'Edit' | localize}}</a>
                                                            <!-- <a href="javascript:;" *ngIf="'Pages.Orders.Update' | permission"
                                                                (click)="updateOrderModal.show(record.id)">{{'Edit' | localize}}</a> -->
                                                        </li>
                                                        <li>
                                                            <a href="javascript:;"
                                                                *ngIf="'Pages.Orders.Delete' | permission"
                                                                (click)="deleteOrder(record)">{{'Delete' | localize}}</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </td>
                                            <td style="width: 10%">
                                                <span class="ui-column-title"> {{'Id' | localize}}</span>
                                                {{record.id}}
                                            </td>
                                            <td style="width: 15%">
                                                <span class="ui-column-title"> {{'Location' | localize}}</span>
                                                {{record.location.name}}
                                            </td>
                                            <td style="width: 15%">
                                                <span class="ui-column-title"> {{'TimeCreated' | localize}}</span>
                                                {{record.creationTime | date:'MM/dd/yyyy hh:mm aa'}}
                                            </td>
                                            <td style="width: 15%">
                                                    <span class="ui-column-title"> {{'LastLogType' | localize}}</span>
                                                    <!-- {{record.creationTime | date:'MM/dd/yyyy hh:mm aa'}} -->
                                            </td>
                                            <td style="width: 15%">
                                                    <span class="ui-column-title"> {{'Packages' | localize}}</span>
                                                    {{record.orderPackages.length}}
                                            </td>
                                            <td style="width: 15%">
                                                    <span class="ui-column-title"> {{'Customer' | localize}}</span>
                                                    {{record.pickupDetail.contact.firstName +" "  }}  {{record.pickupDetail.contact.lastName}}
                                            </td>
                                            <!-- <td style="width: 150px">
                                                <span class="ui-column-title"> {{'PickupEta' | localize}}</span>
                                                {{record.pickupDetail.etaEnd | date:'MM/dd/yyyy hh:mm aa'}}
                                            </td>
                                            <td style="width: 150px">
                                                <span class="ui-column-title"> {{'DeliveryEta' | localize}}</span>
                                                {{record.deliveryDetail.etaEnd | date:'MM/dd/yyyy hh:mm aa'}}
                                            </td> -->
                                            <!-- <td style="width: 150px">
                                                <span class="ui-column-title"> {{'TotalPackages' | localize}}</span>
                                                {{record.totalPackages}}
                                            </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)="getOrders($event)"
                                        [totalRecords]="primengTableHelper.totalRecordsCount"
                                        [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

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

        <!-- <createOrderModal #createOrderModal (modalSave)="getOrders()"></createOrderModal>
    <updateOrderModal #updateOrderModal (modalSave)="getOrders()"></updateOrderModal> -->
    </div>
</div>