<ng-container *ngIf="!settingIndividualKpi">
  <div class=" pt-1.5rem mb-2">
    <div class="flex flex-col gap-2">
      <div class="flex flex-col gap-2 w-full">
        <div class="box shadow-md hover:shadow-xl transition m-0" style="border-radius:20px">
          <div class="box-body py-2">
            <div class="flex item-center w-full font-size-18px font-weight-700  text-primary px-5 mt-1 mb-4"
              style="height: 50px;align-items: center;border-width: 1px;background: #eff6fe; border-radius:20px">
              รายชื่อผู้ใต้บังคับบัญชา
            </div>
            <div class="flex w-full mb-4">
              <div class="flex w-1/4 justify-between">
                <div class="flex">
                  <div class="flex items-center">
                    <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
                      [checked]="selectEmp.size-1 > 0">
                    <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
                      {{selectEmp.size-1 < 0 ? 0 : selectEmp.size-1}} Selected</label>
                  </div>
                  <div class="mx-1 flex items-center">
                    <button id='check-boxall' (click)="toggleSelectAll()"
                      class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
                      <i class="fs-l transition-all duration-200"
                        [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !selectEmp.get('selectAll'), 'ri-checkbox-multiple-fill text-primary': selectEmp.get('selectAll')}"></i>
                    </button>
                    <label class="text-sm text-gray-500 ml-2 cursor-pointer" for="check-boxall"
                      (click)="toggleSelectAll()">Select All</label>
                  </div>
                </div>
              </div>
              <div class="flex w-3/4 justify-end">
                <div class="px-1">
                  <div class="relative shadow-md">
                    <input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
                      [placeholder]="'SearchByNoOrName' | translate" [(ngModel)]="search">
                    <div
                      class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
                      <i class="ri-search-line text-gray"></i>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="flex flex-col w-100">
              <div class="overflow-auto rounded-t-md">
                <div id="card-type-1" role="tabpanel" aria-labelledby="card-type-item-1">
                  <div class="overflow-auto shadow-md">
                    <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
                      <thead>
                        <tr>
                          <ng-container
                            *ngFor="let item of ['รหัสพนักงาน','ชื่อพนักงาน','ตำเเหน่งงาน','สถานะ']; let f = first; let l = last; let i = index">
                            <th scope="col"
                              class="relative px-10px py-10px  bg-soft-secondary text-primary !text-center"
                              [ngClass]="{'!p-0':f, '!pl-0':i==1}" [colSpan]="f?2:1">
                              <span class="text-sm">{{ item }}</span>
                              <div *ngIf="!l" class="absolute top-1/2 transform -translate-y-1/2 right-0">
                                <svg class="head-table-icon" xmlns="http://www.w3.org/2000/svg" width="50" height="16"
                                  fill="currentColor" viewBox="0 0 16 16">
                                  <path
                                    d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z">
                                  </path>
                                </svg>
                              </div>
                            </th>
                          </ng-container>
                        </tr>
                      </thead>
                      <tbody *ngIf="subordinate.loading">
                        <tr>
                          <td class="text-center" colspan="100%">
                            <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
                              role="status" aria-label="loading">
                              <span class="sr-only">Loading...</span>
                            </div>
                          </td>
                        </tr>
                      </tbody>
                      <tbody *ngIf="!subordinate.loading&&!subordinateFilter().length">
                        <tr>
                          <td class="text-center" colspan="100%">
                            ไม่พบข้อมูล
                          </td>
                        </tr>
                      </tbody>
                      <tbody *ngIf="!subordinate.loading&&subordinateFilter().length">
                        <tr *ngFor="let item of subordinateFilter();let i = index">
                          <td class="text-center !pr-1"
                            style="font-size: 12px;width: 90px;;min-width: 90px;max-width: 90px;">
                            <div class="flex-col gap-2">
                              <input
                                [disabled]="!(item.apsapproveType.code!='Apsapprove1'&&(item.masfromStatusType.code=='evaluating'||item.masfromStatusType.code=='pending'))"
                                [class.cursor-not-allowed]="!(item.apsapproveType.code!='Apsapprove1'&&(item.masfromStatusType.code=='evaluating'||item.masfromStatusType.code=='pending'))"
                                [class.accent-gray-400]="!(item.apsapproveType.code!='Apsapprove1'&&(item.masfromStatusType.code=='evaluating'||item.masfromStatusType.code=='pending'))"
                                [class.opacity-50]="!(item.apsapproveType.code!='Apsapprove1'&&(item.masfromStatusType.code=='evaluating'||item.masfromStatusType.code=='pending'))"
                                type="checkbox" class="ti-form-checkbox cursor-pointer"
                                [checked]="selectEmp.get(item.apsassessy.employeeId)"
                                (click)="!selectEmp.get(item.apsassessy.employeeId)?selectEmp.set(item.apsassessy.employeeId , true):selectEmp.delete(item.apsassessy.employeeId);checkSelectAll()">
                              &nbsp;
                              <ng-container
                                *ngIf="item.apsapproveType.code!='Apsapprove1'&&(item.masfromStatusType.code=='evaluating'||item.masfromStatusType.code=='pending')">
                                <img
                                  (click)="!selectEmp.get(item.apsassessy.employeeId)?selectEmp.set(item.apsassessy.employeeId , true):selectEmp.delete(item.apsassessy.employeeId);checkSelectAll()"
                                  class="cursor-pointer avatar shadow-none rounded-full !ring-transparent object-cover h-12 w-12"
                                  [src]="item.apsassessy.picture?getImg(item.apsassessy.picture):'./assets/img/users/defaultperson.jpg'"
                                  (error)="onImageError($event)">
                              </ng-container>
                              <ng-container
                                *ngIf="!(item.apsapproveType.code!='Apsapprove1'&&(item.masfromStatusType.code=='evaluating'||item.masfromStatusType.code=='pending'))">
                                <img
                                  class="cursor-pointer avatar shadow-none rounded-full !ring-transparent object-cover h-12 w-12"
                                  [src]="item.apsassessy.picture?getImg(item.apsassessy.picture):'./assets/img/users/defaultperson.jpg'"
                                  (error)="onImageError($event)">
                              </ng-container>
                            </div>
                          </td>
                          <td class="text-left"
                            style="font-size: 12px;width: 90px;min-width: 90px;max-width: 90px;padding-left: 10px;">
                            {{item.apsassessy.employeeId}}
                          </td>
                          <td style="font-size: 12px; width: 175px;">
                            {{item.apsassessy.thFullName}}
                          </td>
                          <td style="font-size: 12px;">{{item.apsassessy.position.tdesc}}</td>
                          <td class="text-center">
                            <div class="flex justify-center">
                              <button type="button" class="ti-btn rounded-sm "
                                [class]="statusButtonClass(item.statusIdp.statusType)"
                                style="height: 30px; width: auto; font-size: 12px; display: flex; align-items: center; justify-content: center;margin-left:4px;"
                                (click)="settingIndividualKpi=true">
                                {{statusCompetencyText(item.statusIdp.statusType)}}
                              </button>
                            </div>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              <nav class="pagination-style-3 my-5" *ngIf="page.length">
                <ul class="ti-pagination">
                  <li>
                    <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                      (click)="currentPage = (currentPage-1 || 1)">
                      <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
                    </a>
                  </li>
                  <li *ngFor="let item of page;let f = first;let l = last">
                    <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
                      <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
                      </a>
                    </ng-container>
                    <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
                      <a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
                        (click)="currentPage=item">{{item}}
                      </a>
                    </ng-container>
                    <ng-container
                      *ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
                      <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
                      </a>
                    </ng-container>
                  </li>
                  <li>
                    <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                      (click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
                      <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
                    </a>
                  </li>
                </ul>
                <ul class="nav-tabs mt-3">
                  <span>Show {{((currentPage-1) * 10)+1}} to {{subordinateFilter().length<10
                      ?subordinateFilter().length: (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10)
                      - subordinateFilter().length) ) :(currentPage * 10) ) }} of {{subordinateFilter().length}}
                      items</span>
                </ul>
              </nav>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</ng-container>
<ng-container *ngIf="settingIndividualKpi">
  <app-setting-individual-kpi [evaluationForm]="'sup'"
    (sendReturnPath)="getBossList();settingIndividualKpi=false"></app-setting-individual-kpi>
</ng-container>