<div class="header-title-type">
    <div class="flex justify-between">
     <div class="flex pr-2">
         <!-- Content ของ div แรก -->
            <div class="px-1">
                <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md">
                    <i class="ri-add-line"></i>
                    นำเข้าข้อมูล
                </button>

                <a class="mx-2 justify-center  -mb-px  inline-flex items-center gap-2 text-sm font-medium text-center text-secondary border-secondary border-b-2 dark:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-gray-300 align-items-end"
                    href="javascript:void(0);">
                    ดาวโหลดตัวอย่างไฟล์
                </a>
            </div>
     </div>
         <div class="flex justify-end">
             <div class="px-1">
                <div class="relative shadow-md">
                    <input type="text" id="hs-leading-icon" name="hs-leading-icon"
                        class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
                        [(ngModel)]="bu4Table.search" (ngModelChange)="onBu4TableSearchChange()">
        
                    <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 class="px-1">
                <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
                    (click)="currentModal='add';selectBu3();selectBu4()" data-hs-overlay="#sub-department-one-modal-add">
                    <i class="ri-add-line"></i>
                    Add
                </button>
            </div>
            <div class="px-1">
                <button href="javascript:void(0);" class="ti-btn ti-btn-soft-info h-45px m-0 shadow-md">
                    <i class="ri-printer-line"></i>
                    Print
                </button>
            </div>
            <div class="px-1">
                <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
                    <i class="ti ti-book fs-l"></i>
                    Help
                </button>
            </div>
         </div>
     </div>
 </div>

<div class="page px-rem">
        <div class="overflow-auto shadow-md rounded-t-md">
            <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
                <thead>
                    <tr>
                        <ng-container
                            *ngFor="let item of ['ลำดับ','รหัสส่วนย่อยที่1','รายละเอียดส่วนย่อยที่1 (ไทย)','รายละเอียดส่วนย่อยที่1 (อังกฤษ)','การจัดการ']; let f = first; let l = last">
                            <th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
                                [class.!text-center]="f||l">
                                <span class="!text-sm">{{ item }}</span>
                                <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
                                    <i class="ti ti-dots-vertical fs-l"></i>
                                </div>
                            </th>
                        </ng-container>
                    </tr>
                </thead>
                <tbody *ngIf="!filterBu4Table().length">
                    <tr>
                        <td class="text-center" colspan="100%">
                            ไม่พบข้อมูล
                        </td>
                    </tr>
                </tbody>
                <tbody *ngIf="filterBu4Table().length">
                    <tr
                        *ngFor="let item of filterBu4Table() | slice:((bu4Table.currentPage-1) * 10) : (((bu4Table.currentPage-1) * 10) + 10);let i = index">
                        <td class="flex justify-center">
                            {{((bu4Table.currentPage-1) * 10)+(i+1)}}
                        </td>
                        <td>{{item.bu4id}}</td>
                        <td>{{item.tdesc}}</td>
                        <td>{{item.edesc}}</td>
                        <td class="flex justify-center">
                            <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
                                (click)="selectBu4(item);currentModal='edit'"
                                data-hs-overlay="#sub-department-one-modal-edit"></i>
                            <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="deleteBu4(item)" data-hs-overlay="#sub-department-one-alert-delete-modal"></i>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu4Table.page.length">
            <ul class="ti-pagination">
                <li>
                    <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                        (click)="bu4Table.currentPage = (bu4Table.currentPage-1 || 1)">
                        <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
                    </a>
                </li>
                <li *ngFor="let item of bu4Table.page;let f = first;let l = last">
                    <ng-container *ngIf="item==3&&bu4Table.currentPage!=1&&bu4Table.currentPage!=2&&bu4Table.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==bu4Table.currentPage-1||item==bu4Table.currentPage||item==bu4Table.currentPage+1)">
                        <a class="page-link" href="javascript:void(0);" [class.active]="item==bu4Table.currentPage"
                            (click)="bu4Table.currentPage=item">{{item}}
                        </a>
                    </ng-container>
                    <ng-container
                        *ngIf="item==bu4Table.page.length-2&&bu4Table.currentPage!=bu4Table.page.length&&bu4Table.currentPage!=bu4Table.page.length-1&&bu4Table.currentPage!=bu4Table.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)="bu4Table.currentPage = (bu4Table.currentPage > bu4Table.page.length-1 ? bu4Table.currentPage: bu4Table.currentPage+1 )">
                        <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
                    </a>
                </li>
            </ul>
        </nav>
</div>



<div id="sub-department-one-modal-add" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
        <div class="max-h-full overflow-hidden ti-modal-content">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    เพิ่มข้อมูลทะเบียนส่วนย่อย 1
                </h3>
                <div class="flex justify-end">
                    <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-modal-add">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-center">
                <div class="flex justify-end" style="padding-right: 1rem;">
                    <div class="px-1">
                        <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
                            (click)="selectBu3();selectBu4()">
                            <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
                                xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
                                transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
                                <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
                                <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
                                <g id="SVGRepo_iconCarrier">
                                    <path d="M15 49A24 24 0 0 1 32 8"></path>
                                    <path d="M49 15a24 24 0 0 1-17 41"></path>
                                    <polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
                                    <polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
                                </g>
                            </svg>
                            Clear
                        </button>
                    </div>
                    <div class="px-1">
                        <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
                            <i class="ti ti-book fs-l"></i>
                            Help
                        </button>
                    </div>
                </div>
            </div>
            <div class="ti-modal-body">
                <label class="ti-form-label">อยู่ภายใต้หน่วยงาน</label>
                <div class="flex">
                    <div class="relative flex rounded-md">
                        <input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
                         [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
                        <div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
                            <button type="button" class="flex items-center text-red-500"  (click)="selectBu3()">
                                <i class="ti ti-circle-x cursor-pointer"></i>
                            </button>
                            <button type="button" class="flex items-center text-gray-500 dark:text-white/70"  data-hs-overlay="#sub-department-one-bu3-table-modal">
                                <i class="ri-search-line cursor-pointer text-gray"></i>
                            </button>
                        </div>
                    </div>
                    <div class="flex rounded-md w-1/2 pl-1rem">
                        <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
                            readonly [value]="bu3.tdesc">
                    </div>
                </div>
                <label class="ti-form-label mt-2rem">ส่วนย่อย1</label>
                <div class="relative flex rounded-md w-1/2">
                    <input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
                     [(ngModel)]="bu4.bu4id" (ngModelChange)="bu4idChange()">
                    <div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
                        <button type="button" class="flex items-center text-red-500"  (click)="selectBu4()">
                            <i class="ti ti-circle-x cursor-pointer"></i>
                        </button>
                        <button type="button" class="flex items-center text-gray-500 dark:text-white/70"  data-hs-overlay="#sub-department-one-bu4-table-modal">
                            <i class="ri-search-line cursor-pointer text-gray"></i>
                        </button>
                    </div>
                </div>
                <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label>
                <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu4.tdesc">
                <label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
                <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu4.edesc">
                <div class="flex justify-end mt-2rem mb-1rem space-x-4">
                    <button type="button"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-add">
                        ย้อนกลับ
                    </button>
                    <a class="ti-btn ti-btn-success" href="javascript:void(0);"
                        data-hs-overlay="#sub-department-one-alert-modal">
                        บันทึกข้อมูล
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="sub-department-one-modal-edit" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
        <div class="max-h-full overflow-hidden ti-modal-content">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    แก้ไขข้อมูลทะเบียนส่วนย่อย 1
                </h3>
                <div class="flex justify-end">
                    <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-center">
                <div class="flex justify-end" style="padding-right: 1rem;">
                    <div class="px-1">
                        <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
                            (click)="selectBu3();bu4.tdesc='';bu4.edesc=''">
                            <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
                                xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
                                transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
                                <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
                                <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
                                <g id="SVGRepo_iconCarrier">
                                    <path d="M15 49A24 24 0 0 1 32 8"></path>
                                    <path d="M49 15a24 24 0 0 1-17 41"></path>
                                    <polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
                                    <polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
                                </g>
                            </svg>
                            Clear
                        </button>
                    </div>
                    <div class="px-1">
                        <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
                            <i class="ti ti-book fs-l"></i>
                            Help
                        </button>
                    </div>
                </div>
            </div>
            <div class="ti-modal-body">
                <label for="hs-trailing-button-add-on-with-icon"
                    class="ti-form-label ">อยู่ภายใต้หน่วยงาน</label>
                    <div class="flex">
                        <div class="relative flex rounded-md">
                            <input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
                             [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
                            <div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
                                <button type="button" class="flex items-center text-red-500"  (click)="selectBu3()">
                                    <i class="ti ti-circle-x cursor-pointer"></i>
                                </button>
                                <button type="button" class="flex items-center text-gray-500 dark:text-white/70"  data-hs-overlay="#sub-department-one-bu3-table-modal">
                                    <i class="ri-search-line cursor-pointer text-gray"></i>
                                </button>
                            </div>
                        </div>
                        <div class="flex rounded-md w-1/2 pl-1rem">
                            <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
                                readonly [value]="bu3.tdesc">
                        </div>
                    </div>
                <label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย1</label>
                <div class="sm:grid grid-cols-2 gap-1">
                    <div class="relative w-full">
                        <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
                            readonly [value]="bu4.bu4id">
                    </div>
                </div>
                <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label>
                <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu4.tdesc">
                <label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
                <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu4.edesc">
                <div class="flex justify-end mt-2rem mb-1rem space-x-4 ">
                    <button type="button"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        ย้อนกลับ
                    </button>
                    <a class="ti-btn ti-btn-success" href="javascript:void(0);"
                        data-hs-overlay="#sub-department-one-alert-edit-modal">
                        บันทึกข้อมูล
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="sub-department-one-bu3-table-modal" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
        <div class="max-h-full overflow-hidden ti-modal-content">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    ข้อมูลทะเบียนส่วน
                </h3>
                <div class="flex justify-end">
                    <button *ngIf="currentModal=='add'" type="button"
                        class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-modal-add">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                    <button *ngIf="currentModal=='edit'" type="button"
                        class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-body">
                <div class="flex justify-end pb-1rem">
                    <div class="px-1">
                        <div class="relative shadow-md">
                            <input type="text" id="hs-leading-icon" name="hs-leading-icon"
                                class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
                                placeholder="Search by No. or Name" [(ngModel)]="bu3Modal.search"
                                (ngModelChange)="onBu3ModalSearchChange()">
                            <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 class="overflow-auto border">
                    <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">
                                    <th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
                                        [class.!text-center]="f">
                                        <span class="text-sm">{{ item }}</span>
                                        <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
                                            <i class="ti ti-dots-vertical fs-l"></i>
                                        </div>
                                    </th>
                                </ng-container>
                            </tr>
                        </thead>
                        <tbody *ngIf="!filterBu3Modal().length">
                            <tr>
                                <td class="text-center" colspan="100%">
                                    ไม่พบข้อมูล
                                </td>
                            </tr>
                        </tbody>
                        <tbody *ngIf="filterBu3Modal().length">
                            <ng-container *ngIf="currentModal=='add'">
                                <tr *ngFor="let item of filterBu3Modal() | slice:((bu3Modal.currentPage-1) * 10) : (((bu3Modal.currentPage-1) * 10) + 10);let i = index"
                                    class="cursor-pointer" (click)="selectBu3(item)"
                                    data-hs-overlay="#sub-department-one-modal-add">
                                    <td class="flex justify-center">
                                        {{((bu3Modal.currentPage-1) * 10)+(i+1)}}
                                    </td>
                                    <td>{{item.bu3id}}</td>
                                    <td>{{item.tdesc}}</td>
                                    <td>{{item.edesc}}</td>
                                </tr>
                            </ng-container>
                            <ng-container *ngIf="currentModal=='edit'">
                                <tr *ngFor="let item of filterBu3Modal() | slice:((bu3Modal.currentPage-1) * 10) : (((bu3Modal.currentPage-1) * 10) + 10);let i = index"
                                    class="cursor-pointer" (click)="selectBu3(item)"
                                    data-hs-overlay="#sub-department-one-modal-edit">
                                    <td class="flex justify-center">
                                        {{((bu3Modal.currentPage-1) * 10)+(i+1)}}
                                    </td>
                                    <td>{{item.bu3id}}</td>
                                    <td>{{item.tdesc}}</td>
                                    <td>{{item.edesc}}</td>
                                </tr>
                            </ng-container>
                        </tbody>
                    </table>
                </div>
                <nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu3Modal.page.length">
                    <ul class="ti-pagination">
                        <li>
                            <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                                (click)="bu3Modal.currentPage = (bu3Modal.currentPage-1 || 1)">
                                <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
                            </a>
                        </li>
                        <li *ngFor="let item of bu3Modal.page">
                            <a class="page-link" href="javascript:void(0);" [class.active]="item==bu3Modal.currentPage"
                                (click)="bu3Modal.currentPage=item">{{item}}
                            </a>
                            <!-- <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
                            </a> -->
                        </li>
                        <li>
                            <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                                (click)="bu3Modal.currentPage = (bu3Modal.currentPage > bu3Modal.page.length-1 ? bu3Modal.currentPage: bu3Modal.currentPage+1 )">
                                <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="flex justify-end mt-2rem mb-1rem space-x-4">
                    <button type="button" *ngIf="currentModal=='add'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-add">
                        ย้อนกลับ
                    </button>
                    <button type="button" *ngIf="currentModal=='edit'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        ย้อนกลับ
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="sub-department-one-bu4-table-modal" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
        <div class="max-h-full overflow-hidden ti-modal-content">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    ข้อมูลทะเบียนส่วนย่อยที่ 1
                </h3>
                <div class="flex justify-end">
                    <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-modal-add">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-body">
                <div class="flex justify-end pb-1rem">
                    <div class="px-1">
                        <div class="relative shadow-md">
                            <input type="text" id="hs-leading-icon" name="hs-leading-icon"
                                class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
                                placeholder="Search by No. or Name" [(ngModel)]="bu4Modal.search"
                                (ngModelChange)="onBu4ModalSearchChange()">
                            <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 class="overflow-auto border">
                    <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
                        <thead>
                            <tr>
                                <ng-container
                                    *ngFor="let item of ['ลำดับ','รหัสส่วนย่อยที่1','รายละเอียดส่วนย่อยที่1 (ไทย)','รายละเอียดส่วนย่อยที่1 (อังกฤษ)']; let f = first; let l = last">
                                    <th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
                                        [class.!text-center]="f">
                                        <span class="text-sm">{{ item }}</span>
                                        <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
                                            <i class="ti ti-dots-vertical fs-l"></i>
                                        </div>
                                    </th>
                                </ng-container>
                            </tr>
                        </thead>
                        <tbody *ngIf="!filterBu4Modal().length">
                            <tr>
                                <td class="text-center" colspan="100%">
                                    ไม่พบข้อมูล
                                </td>
                            </tr>
                        </tbody>
                        <tbody *ngIf="filterBu4Modal().length">
                            <tr *ngFor="let item of filterBu4Modal() | slice:((bu4Modal.currentPage-1) * 10) : (((bu4Modal.currentPage-1) * 10) + 10);let i = index"
                                class="cursor-pointer" (click)="selectBu4(item)"
                                data-hs-overlay="#sub-department-one-modal-add">
                                <td class="flex justify-center">
                                    {{((bu4Modal.currentPage-1) * 10)+(i+1)}}
                                </td>
                                <td>{{item.bu4id}}</td>
                                <td>{{item.tdesc}}</td>
                                <td>{{item.edesc}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu4Modal.page.length">
                    <ul class="ti-pagination">
                        <li>
                            <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                                (click)="bu4Modal.currentPage = (bu4Modal.currentPage-1 || 1)">
                                <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
                            </a>
                        </li>
                        <li *ngFor="let item of bu4Modal.page">
                            <a class="page-link" href="javascript:void(0);" [class.active]="item==bu4Modal.currentPage"
                                (click)="bu4Modal.currentPage=item">{{item}}
                            </a>
                            <!-- <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
                            </a> -->
                        </li>
                        <li>
                            <a aria-label="anchor" class="page-link" href="javascript:void(0);"
                                (click)="bu4Modal.currentPage = (bu4Modal.currentPage > bu4Modal.page.length-1 ? bu4Modal.currentPage: bu4Modal.currentPage+1 )">
                                <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="flex justify-end mt-2rem mb-1rem space-x-4">
                    <button type="button"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-add">
                        ย้อนกลับ
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="sub-department-one-alert-modal" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
        <div class="max-h-full overflow-hidden ti-modal-content w-full">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    แจ้งเตือน
                </h3>
                <div class="flex justify-end">
                    <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-alert-modal">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-body ">
                <p class="mt-1 text-gray-800 dark:text-white/70">
                    ยืนยันการบันทึกข้อมูลหรือไม่
                </p>

                <div class="flex justify-end mt-2rem mb-1rem">
                    <button type="button" *ngIf="currentModal=='add'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-add">
                        ย้อนกลับ
                    </button>
                    <button type="button" *ngIf="currentModal=='edit'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        ย้อนกลับ
                    </button>
                    <a class="ti-btn ti-btn-success" href="javascript:void(0);"
                        data-hs-overlay="#sub-department-one-alert-modal" (click)="addBu4();showSuccess()">
                        บันทึกข้อมูล
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="sub-department-one-alert-edit-modal" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
        <div class="max-h-full overflow-hidden ti-modal-content w-full">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    แจ้งเตือน
                </h3>
                <div class="flex justify-end">
                    <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-alert-edit-modal">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-body ">
                <p class="mt-1 text-gray-800 dark:text-white/70">
                    ยืนยันการเเก้ไขข้อมูลหรือไม่
                </p>

                <div class="flex justify-end mt-2rem mb-1rem">
                    <button type="button" *ngIf="currentModal=='add'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-add">
                        ย้อนกลับ
                    </button>
                    <button type="button" *ngIf="currentModal=='edit'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        ย้อนกลับ
                    </button>
                    <a class="ti-btn ti-btn-success" href="javascript:void(0);"
                        data-hs-overlay="#sub-department-one-alert-edit-modal" (click)="addBu4();showSuccessEdit()">
                        บันทึกข้อมูล
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="sub-department-one-alert-delete-modal" class="hs-overlay hidden ti-modal">
    <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
        <div class="max-h-full overflow-hidden ti-modal-content w-full">
            <div class="ti-modal-header">
                <h3 class="text-xxl font-bold text-primary">
                    แจ้งเตือน
                </h3>
                <div class="flex justify-end">
                    <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
                        data-hs-overlay="#sub-department-one-alert-delete-modal">
                        <span class="sr-only">Close</span>
                        <i class="ti ti-circle-x fs-xxl"></i>
                    </button>
                </div>
            </div>
            <div class="ti-modal-body ">
                <p class="mt-1 text-gray-800 dark:text-white/70">
                    ยืนยันการลบข้อมูลหรือไม่
                </p>

                <div class="flex justify-end mt-2rem mb-1rem">
                    <button type="button" *ngIf="currentModal=='add'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-add">
                        ย้อนกลับ
                    </button>
                    <button type="button" *ngIf="currentModal=='edit'"
                        class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
                        data-hs-overlay="#sub-department-one-modal-edit">
                        ย้อนกลับ
                    </button>
                    <a class="ti-btn ti-btn-success" href="javascript:void(0);"
                        data-hs-overlay="#sub-department-one-alert-delete-modal" (click)="addBu4();showSuccessDelete()">
                        ลบข้อมูล
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>