<div class="ng-card custom-shadow mb-0">
    <div class="ng-cardHead">
        <div class="ng-cardLabel">
            <h3 class="ng-cardTitle">Hotel Search</h3>
        </div>
        <button (click)="btnClick()" class="btn btn-primary"> Add Hotel </button>
    </div>
    <div class="ng-searchBody">
        <div class="row" [formGroup]="HotelSearchForm">
            <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">Hotel Name</label>
                    <ng-select #OriginNg class="is-invalid" placeholder="Search" (keyup)="GetHotels($event.target)"
                        (close)="HotelList = []" notFoundText="Please enter 2 or more characters"
                        [loading]="ddLoader['hotel_list']" formControlName="hotel_code_mapping">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Hotel Name</h4>
                                    </div>
                                    <button matRipple (click)="OriginNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option *ngFor="let item of HotelList" [value]="item.hotelId">
                            {{item.hotelName }} {{item.cityName }}, {{item.countryName }}
                        </ng-option>
                    </ng-select>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">Vendor Name</label>
                    <ng-select #VendorNg class="is-invalid" placeholder="Select" formControlName="vendor_id">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Vendor Name</h4>
                                    </div>
                                    <button matRipple (click)="VendorNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option value="">Select</ng-option>
                        <ng-option *ngFor="let data of AllVendors"
                            [value]="data.extranet_vendor_id">{{data.vendor_name}}</ng-option>
                    </ng-select>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">Star Rating</label>
                    <ng-select #StarRNg class="is-invalid" placeholder="Select" formControlName="star_rating">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Star Rating</h4>
                                    </div>
                                    <button matRipple (click)="StarRNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option value="">Select</ng-option>
                        <ng-option value="1">1 Star</ng-option>
                        <ng-option value="2">2 Star</ng-option>
                        <ng-option value="3">3 Star</ng-option>
                        <ng-option value="4">4 Star</ng-option>
                        <ng-option value="5">5 Star</ng-option>
                    </ng-select>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">Country</label>
                    <ng-select #CountryNg class="is-invalid" placeholder="Search" (keyup)="getCountryList($event.target)"
                        (close)="CountryList = []" notFoundText="Please enter 2 or more characters"
                        [loading]="ddLoader.Country" formControlName="country_code">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Country</h4>
                                    </div>
                                    <button matRipple (click)="CountryNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option *ngFor="let item of CountryList" [value]="item.country_code">
                            {{item.country_name }}
                        </ng-option>
                    </ng-select>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">City</label>
                    <ng-select #CityNg class="is-invalid" placeholder="Search" (keyup)="getHotelCitySearch($event.target)"
                        (close)="CityList = []" notFoundText="Please enter 2 or more characters" [loading]="ddLoader.city"
                        formControlName="city_code">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>City</h4>
                                    </div>
                                    <button matRipple (click)="CityNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option *ngFor="let item of CityList" [value]="item.cityCode">
                            {{item.cityName }}, {{item.countryName }}
                        </ng-option>
                    </ng-select>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">Status</label>
                    <ng-select #StatusNg class="is-invalid" placeholder="Select" formControlName="is_active">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Status</h4>
                                    </div>
                                    <button matRipple (click)="StatusNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option value="">Select</ng-option>
                        <ng-option value="1">Active</ng-option>
                        <ng-option value="2">Deactive</ng-option>
                    </ng-select>
                </div>
            </div>
        </div>
    </div>
    <div class="ng-searchFooter">
        <button (click)="Reset()" class="btn btn-secondary mr-10 ResetBtn">Reset</button>
        <button (click)="Search()" class="btn btn-primary SearchBtn">Search</button>
    </div>
</div>
<div class="dataTable actionButtonSticky custom-shadow">
    <p-table #dt [resizableColumns]="true" [columns]="cols" [value]="Result" [rowsPerPageOptions]="[10, 25, 50, 100]"
        styleClass="p-datatable-gridlines" [rows]="10" 
        responsiveLayout="scroll" [paginator]="true" [rowHover]="true" dataKey="id" [globalFilterFields]="[
    'extranet_hotel_id',
    'hotel_code_mapping',
    'vendor_name',
    'star_rating',
    'country',
    'city',
    'destination',
    'status',
    'hotel_name',
    'contracted_cabin_class',
    'contracted_pax_type',
    'Custom_multi_day',
    'currency_code',
    'Custom_created_on',
    'currency',
    'updated_by',
    'Custom_updated_on',
    'status',
]" currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [showCurrentPageReport]="true">
        <ng-template pTemplate="caption">
            <p-toolbar *ngIf="Result && Result.length > 0">
                <ng-template pTemplate="left" *ngIf="_commonService.DownloadFilesAllowed">
                    <button type="button" pButton class="btn btn-grey mr-10" pTooltip="CSV" tooltipPosition="bottom"
                        (click)="dt.exportCSV()">CSV</button>
                    <button type="button" pButton class="btn btn-grey mr-10" pTooltip="XLS" tooltipPosition="bottom"
                        (click)="_commonService.exportExcel(Result,cols,'Hotel Detail')">Excel</button>
                    <button type="button" pButton class="btn btn-grey mr-10" pTooltip="PDF" tooltipPosition="bottom"
                        (click)="_commonService.exportPdf(Result,cols,'Hotel Detail')">PDF</button>
                </ng-template>
                <ng-template pTemplate="right">
                    <div class="p-d-flex p-ai-center">
                        <span class="p-input-icon-left">
                            <i class="pi pi-search"></i>
                            <input pInputText type="search" #searchInp
                                (input)="dt.filterGlobal(searchInp.value, 'contains')" placeholder="Search" />
                        </span>
                    </div>
                </ng-template>
            </p-toolbar>
        </ng-template>
        <ng-template pTemplate="header">
            <tr>
                <th pSortableColumn="status">
                    Status
                    <p-sortIcon field="status" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="hotel_name">
                    Hotel Name
                    <p-sortIcon field="hotel_name" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="hotel_code_mapping">
                    Hotel Mapping Code
                    <p-sortIcon field="hotel_code_mapping" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="vendor_name">
                    Vendor Name
                    <p-sortIcon field="vendor_name" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="star_rating">
                    Star Rating
                    <p-sortIcon field="star_rating" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="country">
                    Country
                    <p-sortIcon field="country" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="city">
                    City
                    <p-sortIcon field="city" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="currency">
                    Currency
                    <p-sortIcon field="currency" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="extranet_hotel_id">
                    Extranet Hotel Id
                    <p-sortIcon field="extranet_hotel_id" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="created_by">
                    Created By
                    <p-sortIcon field="created_by" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="created_on">
                    Created On
                    <p-sortIcon field="created_on" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="updated_by">
                    Updated By
                    <p-sortIcon field="updated_by" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="updated_on">
                    Updated On
                    <p-sortIcon field="updated_on" class="p-sort-icon"></p-sortIcon>
                </th>
                <th>Action</th>
            </tr>
        </ng-template>
        <ng-template pTemplate="body" let-data>
            <tr>
                <td>
                    <span class="status"
                        [ngClass]="{'status-success':data.is_active,'status-failed':data.is_active == false}">
                        {{data.status}}
                    </span>
                </td>
                <td>{{data.hotel_name}}</td>
                <td>{{data.hotel_code_mapping}}</td>
                <td>{{data.vendor_name}}</td>
                <td>{{data.star_rating}}</td>
                <td>{{data.country}}</td>
                <td>{{data.city}}</td>
                <td>{{data.currency}}</td>
                <td>{{data.extranet_hotel_id}}</td>
                <td>{{data.created_by}}</td>
                <td>{{data.Custom_created_on}}</td>
                <td>{{data.updated_by}}</td>
                <td>{{data.Custom_updated_on}}</td>
                <td>
                    <button mat-icon-button [matMenuTriggerFor]="menu">
                        <span class="material-icons"> more_horiz </span>
                    </button>
                    <mat-menu #menu="matMenu">
                        <button mat-menu-item (click)="ManageHotel(data.extranet_hotel_id)">
                            <span class="flex-center">
                                <span> Manage </span>
                            </span>
                        </button>
                        <!-- <button mat-menu-item >
                            <a class="mr-10" [href]="Cdn_url + 'Extranet/Hotel/Contract/HotelContractExcelUploadFormat.xlsx'">Download Sample File</a>
                        </button>
                        <button mat-menu-item >
                            <p-fileUpload class="bulkUpload" #file [showUploadButton]="false" [showCancelButton]="false" chooseLabel="Upload Contract File"
                            (onSelect)="SelectImage($event, file, data.extranet_hotel_id)" accept=".xlsx"></p-fileUpload>
                        </button> -->
                        <button mat-menu-item *ngIf="_commonService.ChangeStatusAllowed"
                        (click)="updateStatus(data.extranet_hotel_id,data.is_active)">
                            <span class="flex-center">
                                <span> {{ !data.is_active ? 'Active' : 'Deactive'}}</span>
                            </span>
                        </button>
                    </mat-menu>
                </td>
            </tr>
        </ng-template>
        <ng-template pTemplate="emptymessage">
            <tr *ngIf="Result === null || Result" class="resultNotFound">
                <td> No data found </td>
            </tr>
        </ng-template>
    </p-table>
</div>