<div class="ng-card custom-shadow mb-0">
    <div class="ng-cardHead">
        <div class="ng-cardLabel">
            <h3 class="ng-cardTitle">Hotel Zones Search</h3>
        </div>
        <button class="btn btn-primary" [routerLink]="['/ActivityConfiguration/HotelZone/Add']">Add Hotel Zone</button>
    </div>
    <div class="ng-searchBody" [formGroup]="hotelZoneSearchForm">
        <div class="row">
             <div class="col-lg-4">
                <div class="formControlWrapper">
                    <label class="formLabel">Zone Name</label>
                    <input class="formInput" formControName="ZoneName" type="text" />
                </div>
            </div>
             <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="HotelName">
                        <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">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">
                        <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">
                        <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>
    </div>
    <div class="ng-searchFooter">
        <button class="btn btn-secondary mr-10 ResetBtn" (click)="Reset()">Reset</button>
        <button class="btn btn-primary SearchBtn" (click)="Search()">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]="[
    'zoneName',
    'country',
    'city',
    'hotels',
    'status',
    'Custom_created_on',
    'updatedBy',
    'Custom_updated_on',
    'createdBy',
]" 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" >
                    <button type="button" pButton class="btn-secondary mr-10" pTooltip="CSV" tooltipPosition="bottom"
                        (click)="dt.exportCSV()">CSV</button>
                    <button type="button" pButton class="btn-secondary mr-10" pTooltip="XLS" tooltipPosition="bottom"
                        (click)="commonMasterSer.exportExcel(Result,cols,'Hotel Zone')">Excel</button>
                    <button type="button" pButton class="btn-secondary mr-10" pTooltip="PDF" tooltipPosition="bottom"
                        (click)="commonMasterSer.exportPdf(Result,cols,'Hotel Zone')">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="zoneName">
                    Zone Name
                    <p-sortIcon field="zoneName" 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="hotels">
                    Number of Hotel
                    <p-sortIcon field="hotels" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="hotelZoneId">
                    Zone Id
                    <p-sortIcon field="hotelZoneId" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="status">
                    Status
                    <p-sortIcon field="status" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="createdBy">
                    Created By
                    <p-sortIcon field="createdBy" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="createdOn">
                    Created On
                    <p-sortIcon field="createdOn" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="updatedBy">
                    Updated By
                    <p-sortIcon field="updatedBy" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="updatedOn">
                    Updated On
                    <p-sortIcon field="updatedOn" class="p-sort-icon"></p-sortIcon>
                </th>
                <th>Action</th>
            </tr>
        </ng-template>
        <ng-template pTemplate="body" let-data>
            <tr>
                <td>
                    {{data.zoneName}}
                </td>
                <td>{{data.country}}</td>
                <td>{{data.city}}</td>
                <td>{{data.hotels}}</td>
                <td>{{data.hotelZoneId}}</td>
                <td>
                    <span class="status"
                    [ngClass]="{'status-success':data.isActive,'status-failed':data.isActive == false}">
                    {{data.status}}
                </span>
                </td>
                <td>{{data.createdBy}}</td>
                <td>{{data.Custom_created_on}}</td>
                <td>{{data.updatedBy}}</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)="Edit(data.hotelZoneId)">
                            <span class="flex-center">
                                <span> Edit </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 
                        (click)="updateStatus(data.hotelZoneId,data.isActive)">
                            <span class="flex-center">
                                <span> {{ !data.isActive ? '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>