<app-generic-header *ngIf="!messageSuccess" showBack="true" backLink="/notification/homepage"
    [headerText]="'worklistMain,title' | translate">
</app-generic-header>

<ion-content class="colorBG">
    <div *ngIf="!messageSuccess">
        <!-- add segemnt part -->
        <div class="subjectNotification">{{getPassNotificationDetails?.SUBJECT}}</div>
        <ion-segment mode="md" color="secondary" (ionChange)="segmentChanged($event)" [value]="activeSegment"
            class="ion-segment-all">


            <ion-segment-button value="info" [ngClass]="activeSegment == 'info' ? 'active-Segment' : 'normal-Segment'">
                <ion-label class="padding-zero"> {{'worklistMain, info'| translate}} </ion-label>
            </ion-segment-button>

            <ion-segment-button value="item-req"
                [ngClass]="activeSegment == 'item-req' ? 'active-Segment' : 'normal-Segment'">
                <ion-label class="padding-zero"> {{'worklistMain, details-emp'| translate}}</ion-label>
            </ion-segment-button>

            <ion-segment-button value="action-history"
                [ngClass]="activeSegment == 'action-history' ? 'active-Segment' : 'normal-Segment'">
                <ion-label class="padding-zero"> {{'worklistMain, action' | translate}}</ion-label>
            </ion-segment-button>

            <ion-segment-button value="attach"
                [ngClass]="activeSegment == 'attach' ? 'active-Segment' : 'normal-Segment'">
                <ion-label class="padding-zero"> {{'worklistMain, attach-file' | translate}}</ion-label>
            </ion-segment-button>

        </ion-segment>




        <ion-slides #slides (ionSlideDidChange)="slideChanged($event)">
            <ion-slide>
                <ng-container *ngIf="activeSegment === 'info'">
                    <ion-grid>
                        <ion-row>
                            <ion-col>
                                <div *ngIf="pInformation && pInformation != '' " class="tipsPadding">{{pInformation}}
                                </div>
                            </ion-col>
                        </ion-row>

                        <ion-row>
                            <ion-col>
                                <div *ngIf="notificationBodyRes?.length > 0 ">
                                    <ion-card *ngFor="let item of notificationBodyRes;let i=index; "
                                        style="width: 91%;">
                                        <ion-card-content *ngIf="item.Collection_Notification.length > 0">
                                            <div>
                                                <ion-row *ngIf=" item.Collection_Notification.DISPLAY_FLAG != 'N' ">
                                                    <ion-col class="rowBorder"
                                                        *ngFor="let notificationBody of item.Collection_Notification;"
                                                        size="6" [hidden]="notificationBody.DISPLAY_FLAG == 'N'">
                                                        <label class="colItemReq"
                                                            for="">{{notificationBody.SEGMENT_PROMPT}}</label>
                                                        <br />
                                                        <label for="">{{notificationBody.SEGMENT_VALUE_DSP}}</label>
                                                    </ion-col>
                                                </ion-row>
                                            </div>
                                        </ion-card-content>
                                    </ion-card>
                                </div>
                                <div style="margin: 10px;font-weight: bold; "
                                    *ngIf="subordinatesleaveList != undefined && subordinatesleaveList?.length > 0">
                                    {{ts.trPK('worklistMain','employee-on-leave')}}
                                </div>
                                <ion-item lines="none"
                                    [ngClass]=" direction === 'en' ? 'subOrdinateList' :'subOrdinateList-Ar' "
                                    *ngFor="let List of subordinatesleaveList;">
                                    <ion-grid
                                        [ngClass]=" direction === 'en' ? 'gridSubordinates' :'gridSubordinates-Ar' ">
                                        <div [ngClass]=" direction === 'en' ? 'subOrdinateDiv' :'subOrdinateDiv-Ar' ">
                                            <img *ngIf="List.EMPLOYEE_IMAGE" class="empImgeSub"
                                                style="width: 70px !important; height: 70px !important;"
                                                [src]="'data:image/png;base64,'+List.EMPLOYEE_IMAGE">
                                            <img *ngIf="List.EMPLOYEE_IMAGE == null" class="empImgeSub"
                                                style="width: 70px !important; height: 70px !important;"
                                                src="../assets/imgs/profile.png">
                                        </div>
                                        <ion-row class="rowHeader "
                                            [ngClass]=" direction === 'en' ? 'subOrdinateRow' :'subOrdinateRow-Ar' ">
                                            <ion-col size="9">
                                                <label style="font-weight: bold; " class="label"
                                                    for="">{{List.EMPLOYEE_NAME}}
                                                </label>
                                                <br />
                                                <label class="label" for="">{{List.POSITION_TITLE}} </label><br />
                                                <br>
                                                <label class="label"
                                                    style="font-size: 11px !important; position: absolute; left: 0px; color: #000;"
                                                    for="label">{{List.STATUS}}</label>
                                            </ion-col>
                                            <!-- <ion-col class="status" size="3">
                                                
                                            </ion-col> -->
                                        </ion-row>
                                        <br />
                                        <ion-row
                                            [ngClass]=" direction === 'en' ? 'subOrdinateRow' :'subOrdinateRow-Ar'">
                                            <ion-col>
                                                <label class="label" for="">
                                                    {{ts.trPK('worklistMain','from')}}</label><br />
                                                <label class="label" for="">{{List.DATE_START |date}}</label>
                                            </ion-col>
                                            <ion-col>
                                                <label class="label"
                                                    for="">{{ts.trPK('worklistMain','to')}}</label><br />
                                                <label class="label" for="">{{List.DATE_END | date}}</label>
                                            </ion-col>
                                        </ion-row>
                                    </ion-grid>
                                </ion-item>
                            </ion-col>
                        </ion-row>

                    </ion-grid>
                </ng-container>
            </ion-slide>
            <ion-slide>
                <ng-container *ngIf="activeSegment === 'item-req'">
                    <ion-grid style="width: 1px;">
                        <ion-row>
                            <ion-col>
                                <ion-card class="cardContent">
                                    <ion-card-content>
                                        <div>
                                            <ion-grid style="text-align: left;">
                                                <ion-row class="rowBorder">
                                                    <ion-col
                                                        [ngClass]=" direction === 'en' ? 'colBorder' :'colBorder-ar' ">
                                                        <label class="colItemReq" for="">
                                                            {{ts.trPK('worklistMain','from')}}

                                                        </label>
                                                        <br />
                                                        <label for="">{{getPassNotificationDetails.FROM_USER}}</label>
                                                    </ion-col>
                                                    <ion-col class="">
                                                        <label class="colItemReq"
                                                            for="">{{ts.trPK('worklistMain','to')}}
                                                        </label>
                                                        <br />
                                                        <label for=""> {{getPassNotificationDetails.TO_USER}}</label>
                                                    </ion-col>
                                                </ion-row>

                                                <ion-row class="rowBorder">
                                                    <ion-col
                                                        [ngClass]=" direction === 'en' ? 'colBorder' :'colBorder-ar' ">
                                                        <label class="colItemReq"
                                                            for="">{{ts.trPK('worklistMain','sent')}}
                                                        </label>
                                                        <br />
                                                        <label for="">{{getPassNotificationDetails.BEGIN_DATE}}</label>
                                                    </ion-col>
                                                    <ion-col class="">
                                                        <label class="colItemReq"
                                                            for="">{{ts.trPK('worklistMain','closed')}}
                                                        </label>
                                                        <br />
                                                        <label for="">{{getPassNotificationDetails.END_DATE}}</label>
                                                    </ion-col>
                                                </ion-row>
                                                <ion-row class="">
                                                    <ion-col
                                                        [ngClass]=" direction === 'en' ? 'colBorder' :'colBorder-ar' ">
                                                        <label class="colItemReq"
                                                            for="">{{ts.trPK('worklistMain','id')}}
                                                        </label>
                                                        <br />
                                                        <label
                                                            for="">{{getPassNotificationDetails.NOTIFICATION_ID}}</label>
                                                    </ion-col>
                                                    <ion-col class="">
                                                        <label class="colItemReq"
                                                            for="">{{ts.trPK('worklistMain','responder')}}
                                                        </label>
                                                        <br />
                                                        <label for="">{{getPassNotificationDetails.RESPONDER}} </label>
                                                    </ion-col>
                                                </ion-row>
                                            </ion-grid>

                                        </div>
                                    </ion-card-content>
                                </ion-card>
                            </ion-col>
                        </ion-row>
                        <ion-row>
                            <ion-col>
                                <ion-card *ngIf="submitterInfoRes?.length > 0 ">

                                    <ion-card-content
                                        [ngClass]=" direction === 'en' ?  'cardAlignTextEn' : 'cardAlignTextAr'">
                                        <div style="font-weight: bold;" class="hrTitle">
                                            {{'userProfile, emp-detail' | translate}}</div>

                                        <div *ngFor="let submitterInfo of submitterInfoRes">
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'userProfile, empNo' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{submitterInfo.EMPLOYEE_NUMBER}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'userProfile, name' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{submitterInfo.EMPLOYEE_NAME}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, job-name' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{formatJobName(submitterInfo.POSITION_NAME)}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'userProfile, grade' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{submitterInfo.GRADE_NAME}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, job_cate' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{formatJobName(submitterInfo.POSITION_NAME)}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, category' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{submitterInfo.EMPLOYMENT_CATEGORY_MEANING}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, emp-email' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{submitterInfo.EMPLOYEE_EMAIL_ADDRESS}}</label>
                                                </ion-col>
                                            </ion-row>
                                            <!-- <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, org-name' |
                                                        translate}}</label>
                                                    <br />
                                                    <label for="">{{submitterInfo.ORGANIZATION_NAME}}</label>
                                                </ion-col>
                                            </ion-row> -->

                                            <!-- <ion-row class="rowBorder submitterInfo">
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, loc-name' |
                                                        translate}}</label>
                                                    <br />

                                                    <label for="">{{submitterInfo.LOCATION_NAME}}</label>
                                                </ion-col>
                                            </ion-row> -->
                                            <ion-row>
                                                <ion-col>
                                                    <label class="colItemReq" for="">{{'worklistMain, branch-payrol' |
                                                        translate}}</label>
                                                    <br />

                                                    <label for="">{{submitterInfo.PAYROLL_NAME}}</label>
                                                </ion-col>
                                            </ion-row>
                                        </div>
                                    </ion-card-content>

                                </ion-card>
                            </ion-col>
                        </ion-row>
                    </ion-grid>







                </ng-container>
            </ion-slide>
            <ion-slide>
                <ng-container *ngIf="activeSegment === 'action-history'">

                    <ion-card  class="cardContent action-history" style="width: 100%;">
                        <ion-card-content>

                            <div class="noDataDiv" [hidden]="actionHistoryRes && actionHistoryRes.length > 0">
                                <p>{{ 'general, empty' | translate}}</p>
                            </div>
                            <div *ngIf="actionHistoryRes && actionHistoryRes.length > 0 ">
                                <ion-list class="notification-list ">
                                    <div class="timeline">
                                        <ion-item *ngFor="let actionHistory of actionHistoryRes">

                                            <div class="timeline-item" slot="start">
                                                <div
                                                    [class]="direction == 'en'? 'timeline-thumb-en  timeline-icon': 'timeline-thumb-ar  timeline-icon'">
                                                    <img *ngIf="actionHistory.EMPLOYEE_IMAGE" class="empImge"
                                                        [src]="'data:image/png;base64,'+actionHistory.EMPLOYEE_IMAGE">
                                                    <img *ngIf="actionHistory.EMPLOYEE_IMAGE == null" class="empImge"
                                                        src="../assets/imgs/profile.png">
                                                </div>
                                            </div>
                                            <ion-col size="8">
                                                <ion-label class="name">
                                                    {{actionHistory.NAME}}
                                                </ion-label>

                                                <div *ngIf="actionHistory.NOTE != '' ">
                                                    <div *ngIf="!checkLines(actionHistory.NOTE)">
                                                        <div class="containerNote">
                                                            Note: {{actionHistory.NOTE}}
                                                        </div>
                                                    </div>


                                                    <div *ngIf="checkLines(actionHistory.NOTE)">

                                                        <div class="containerNote"
                                                            [ngClass]="actionHistory.visible ? 'show' : '' ">
                                                            Note: {{actionHistory.NOTE}}


                                                        </div>
                                                        <button class="showMore"
                                                            (click)="actionHistory.visible = !actionHistory.visible">{{
                                                            actionHistory.visible ? 'Show less': 'Show More' }}</button>

                                                    </div>
                                                </div>
                                                <ion-label
                                                    [ngClass]="{'bg-blue-txt' : actionHistory.ACTION_CODE === 'SUBMIT' ,'bg-orange-txt' : actionHistory.ACTION_CODE === 'PENDING' ,'bg-red-txt' : actionHistory.ACTION_CODE === 'REJECT','bg-green-txt' : actionHistory.ACTION_CODE != 'PENDING'  && actionHistory.ACTION_CODE != 'REJECT' && actionHistory.ACTION_CODE != 'SUBMIT'}"
                                                    class=""> {{actionHistory.ACTION}}</ion-label>


                                                <ion-label *ngIf="actionHistory.NOTIFICATION_DATE != ''"
                                                    class="dateActionHistory">
                                                    {{returnDateTime(actionHistory.NOTIFICATION_DATE)}} </ion-label>
                                            </ion-col>
                                            <ion-col size="4">
                                                <img class="req_info" src="assets/imgs/req info.svg"
                                                    (click)="openRequestInfoDel(actionHistory, 'REQUEST_INFO')" />
                                                <img class="req_info deligate" src="assets/imgs/delegate.svg"
                                                    (click)="openRequestInfoDel(actionHistory, 'DELEGATE')" />

                                            </ion-col>
                                            <div class="line"></div>
                                        </ion-item>
                                    </div>
                                </ion-list>
                            </div>

                            <!-- <button ion-button *ngIf="!IsReachEnd" class="itemHISBtn" (click)="loadMoreActionHistory()">
                                {{ 'general, load-more' | translate}}
                            </button> -->

                        </ion-card-content>
                    </ion-card>

                </ng-container>
            </ion-slide>
            <ion-slide>
                <ng-container *ngIf="activeSegment === 'attach'">
                    <ion-card class="cardContent" style="width: 100%;">
                        <ion-card-content>

                            <div class="noDataDiv" [hidden]="attachmentRes && attachmentRes.length > 0">
                                <p>{{ 'general, notAttch' | translate}}</p>
                            </div>



                            <div *ngIf="attachmentRes && attachmentRes.length > 0 ">

                                <ion-grid>
                                    <ion-item class="itemAttch" *ngFor="let attachList of attachmentRes ;let i=index;">
                                        <ion-label style="color: black !important">
                                            {{i+1 }}. {{attachList.FILE_NAME}} </ion-label>

                                        <button float-end class="attachImgBtn"
                                            (click)="OpenAttachFiles(attachList.FILE_DATA,attachList.FILE_CONTENT_TYPE)">
                                            <img class="attachImg" src="../assets/imgs/view.png">
                                        </button>

                                    </ion-item>

                                </ion-grid>


                            </div>
                        </ion-card-content>
                    </ion-card>
                </ng-container>
            </ion-slide>
        </ion-slides>

        <ion-row>
            <ion-col col-12>
                <div id="notificationDynamicFields">
                </div>
            </ion-col>
        </ion-row>
    </div>


    <div *ngIf="messageSuccess" class="succssfullMSG">
        <ion-col size="12">
            <ion-icon class="succssfullIcon" name="checkmark"></ion-icon>
        </ion-col>
        <ion-col size="12">
            <div style="font-size: 30px !important"> {{'worklistMain, Tran_Succ' | translate}} </div>
        </ion-col>
    </div>
</ion-content>



<ion-footer class="footerSearchBtn" *ngIf="!messageSuccess">



    <!-- <ion-row class="rowBtn" *ngIf="notificationButtonRes?.length >0">
              *ngFor="let notificationButtons of notificationButtonRes; let i=index;"> 
                                
                        <ion-button   class="actionBtn" (click)="actionButton(notificationButtons.BUTTON_ACTION)"
                        *ngFor="let notificationButtons of notificationButtonRes | slice:0:3; let i=index;" >
                        {{notificationButtons.BUTTON_LABEL}}
                       </ion-button>
        
                    <ion-button  style="--background:orange" class="actionBtn" (click)="nextNotfification()">
                            {{'worklistMain, skip' | translate}}
            
                        </ion-button>
                        <ion-button style="--background:#cccccc;"  class="actionBtn" (click)="openMoreActions()">
                            more
                
                            </ion-button>
        
                          
                                   
        </ion-row> -->
    <!-- <div class="centerDiv">
        <ion-button color="customnavy" class="gridBtn" (click)="actionButton()"> {{ts.trPK('general','submit')}}
        </ion-button>
    </div>
    <div class="centerDiv">
        <ion-button color="customnavy" class="gridBtn" (click)="nextNotfification()">
            {{'worklistMain, skip' | translate}}</ion-button>
    </div> -->

    <ion-row class="rowBtn" *ngIf="notificationButtonRes?.length >0">

        <ion-tabs>

            <ion-tab-bar class="tabBar" slot="bottom" style="height: 100% !important;">
                <ion-tab-button *ngIf="approveDis" (click)="actionButton('APPROVED')">
                    <img src="../assets/imgs/mohemm-action/Approve.png">
                    <!-- <ion-label>  {{'worklistMain, approve' | translate}}</ion-label> -->
                    <ion-label class="action-btn"> {{approve_label}}</ion-label>

                </ion-tab-button>
                <ion-tab-button *ngIf="closeDis" (click)="actionButton('CLOSE')">
                    <img src="../assets/imgs/mohemm-action/Approve.png">
                    <!-- <ion-label>  {{'worklistMain, approve' | translate}}</ion-label> -->
                    <ion-label class="action-btn"> {{close_label}}</ion-label>

                </ion-tab-button>

                <ion-tab-button *ngIf="rejectDis" (click)="actionButton('REJECTED')">
                    <img src="../assets/imgs/mohemm-action/Reject.png">
                    <!-- <ion-label >  {{'worklistMain, reject' | translate}}</ion-label> -->
                    <ion-label class="action-btn"> {{reject_label}}</ion-label>

                </ion-tab-button>

                <ion-tab-button *ngIf="requestDis" (click)="actionButton('REQUEST_INFO')">
                    <img src="../assets/imgs/mohemm-action/info.png">
                    <!-- <ion-label >  {{'worklistMain, request' | translate}}</ion-label> -->
                    <ion-label class="action-btn"> {{reqInfo_label}}</ion-label>

                </ion-tab-button>
                <ion-tab-button (click)="nextNotfification()">
                    <img src="../assets/imgs/mohemm-action/Skip.png">
                    <ion-label class="action-btn"> {{'worklistMain, skip' | translate}}</ion-label>
                </ion-tab-button>

                <ion-tab-button [disabled]="moreDisabled" (click)="openMoreActions()">
                    <img src="../assets/imgs/mohemm-action/More.png">
                    <ion-label class="action-btn"> {{'worklistMain, more' | translate}}</ion-label>
                </ion-tab-button>



            </ion-tab-bar>
        </ion-tabs>

    </ion-row>


</ion-footer>