<div class="ng-card mb-0 mt-20">
    <div class="ng-cardHead">
        <div class="ng-cardLabel">
            <h3 class="ng-cardTitle">Offers</h3>
        </div>
        <button [routerLink]="['/Services/Hotel/HotelManage/AddOffer/'+Extranet_Hotel_Id]" class="btn btn-primary"> Add
            Offers </button>
    </div>
    <div class="ng-searchBody" [formGroup]="OfferSearchForm">
        <div class="row">
            <div class="col-lg-3">
                <div class="formControlWrapper">
                    <label class="formLabel">Room Name</label>
                    <ng-select #OriginNg class="is-invalid" formControlName="extranet_room_id" placeholder="Select">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Room Name</h4>
                                    </div>
                                    <button matRipple (click)="OriginNg.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 AllRoomsData" [value]="data.extranet_room_id">{{data.room_name + (data.room_view_name ? ', ' : '')  +
                            data.room_view_name}}</ng-option>
                    </ng-select>
                </div>
            </div>
       <!-- <div class="col-lg-3">
                <div class="formControlWrapper">
                    <label class="formLabel">Contract Id </label>
                    <input class="formInput" type="text" />
                </div>
            </div> -->
            <div class="col-lg-3">
                <div class="formControlWrapper">
                    <label class="formLabel">Offer Name
                    </label>
                    <input class="formInput" type="text" formControlName="offer_name" />
                </div>
            </div>
            <div class="col-lg-3">
                <div class="formControlWrapper">
                    <label class="formLabel">Offer Type</label>
                    <ng-select #OfferTNg class="is-invalid" placeholder="Select" formControlName="offer_type">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Offer Type</h4>
                                    </div>
                                    <button matRipple (click)="OfferTNg.close()" class="temp_mobileBackButton">
                                        <i class="material-icons"> close </i>
                                    </button>
                                </div>
                            </div>
                        </ng-template>
                        <ng-option>Select</ng-option>
                        <ng-option value="EARLYBIRD"> Early Bird</ng-option>
                        <ng-option value="STAYPAY"> Stay Pay</ng-option>
                        <ng-option value="LONGSTAY">Long Stay</ng-option>
                        <ng-option value="DISCOUNT">Discount</ng-option>
                        <ng-option value="CONTRACTREMARK">Contract Remark</ng-option>
                    </ng-select>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="formControlWrapper">
                    <label class="formLabel">Discount Code
                    </label>
                    <input class="formInput" formControlName="discount_code" type="text" />
                </div>
            </div>
            <div class="col-lg-3">
                <div class="formControlWrapper">
                    <label class="formLabel">Combinable Offer</label>
                    <ng-select #ExtraBed class="is-invalid" placeholder="Select" formControlName="is_combinable_offer">
                        <ng-template ng-header-tmp>
                            <div class="temp_mobileBack">
                                <div class="temp_mobileHead">
                                    <div class="temp_mobileTitle">
                                        <h4>Combinable Offer</h4>
                                    </div>
                                    <button matRipple (click)="ExtraBed.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">Yes</ng-option>
                        <ng-option value="2">No</ng-option>
                    </ng-select>
                </div>
            </div>
        </div>
        <!-- <div class="app-mainGrid4 mt-15">
            <div>
                <mat-checkbox formControlName="is_combinable_offer">Combinable Offer</mat-checkbox>
            </div>
        </div> -->
    </div>
    <div class="ng-searchFooter">
        <button type="button" (click)="Reset()" class="btn btn-secondary mr-10 ResetBtn">Reset</button>
        <button type="button" (click)="Search()" class="btn btn-primary SearchBtn">Search</button>
    </div>
</div>
<div class="dataTable actionButtonSticky custom-shadow">
    <p-table #dt [resizableColumns]="true" [rowsPerPageOptions]="[10, 25, 50, 100]" [columns]="cols"
        [value]="Result" styleClass="p-datatable-gridlines" [rows]="10" 
        responsiveLayout="scroll" selectionMode="multiple" [paginator]="true" [rowHover]="true" dataKey="id"
        [globalFilterFields]="[
    'offer_name',
    'offer_type',
    'room_name',
    'is_combinable_offer',
    'discount_code',
    'offer_days',
    'extranet_offer_id',
    'Custom_multi_day',
    'currency_code',
    '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.MenuTabList.HotelOffers.Download">
                    <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)="_commonService.exportExcel(Result,cols,'Offers')">Excel</button>
                    <button type="button" pButton class="btn-secondary mr-10" pTooltip="PDF"
                        tooltipPosition="bottom"
                        (click)="_commonService.exportPdf(Result,cols,'Offers')">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="offer_name">
                    Offer Name
                    <p-sortIcon field="offer_name" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="offer_type">
                    Offer Type
                    <p-sortIcon field="offer_type" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="room_name">
                    Room Name
                    <p-sortIcon field="room_name" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="is_combinable_offer">
                    Combinable Offer
                    <p-sortIcon field="is_combinable_offer" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="discount_code">
                    Discount Code
                    <p-sortIcon field="discount_code" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="offer_days">
                    Offer days
                    <p-sortIcon field="offer_days" class="p-sort-icon"></p-sortIcon>
                </th>
                <th pSortableColumn="extranet_offer_id">
                    Offer Id
                    <p-sortIcon field="extranet_offer_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.offer_name}}</td>
                <td>{{data.offer_type}}</td>
                <td>{{data.room_name}}</td>
                <td>{{data.is_combinable_offer}}</td>
                <td>{{data.discount_code}}</td>
                <td>{{data.offer_days}}</td>
                <td>{{data.extranet_offer_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>
                    <div class="actionButton">
                        <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.extranet_offer_id)">
                                <span class="flex-center">
                                    <span> Edit </span>
                                </span>
                            </button>
                            <button mat-menu-item *ngIf="_commonService.MenuTabList.HotelOffers.IsActive"
                            (click)="updateStatus(data.extranet_offer_id,data.is_active)">
                                <span class="flex-center">
                                    <span> {{ !data.is_active ? 'Active' : 'Deactive'}}</span>
                                </span>
                            </button>
                        </mat-menu>
                    </div>
                </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>