<div class="container">

    <div class="row">
      <div class="col-12">
        <ul class="list-unstyled titileLi-w">
          <li class="headingText-w">خدمه السكن  </li>
          <li class="headingText-w activeLi-w" style="margin-right:5px">تسجيل معلومات المباني</li>
        </ul>
      </div>
    </div>
  
    <div class="containerContent-w">
      <div class="row">
        <div class="col-12 col-sm-12 col-md-6 col-lg-6">
          <button type="button" class="btn btn-outline-success butttonCreate dashButton-w" (click)="onAdd()" *ngIf="authSer.showAddBtn"><i class="fas fa-plus marginFontAowsome-w"></i>إنشاء جديد</button>
          <button type="button" class="btn btn-outline-danger butttonDelete dashButton-w" (click)="onDelete()" *ngIf="authSer.showDeleteBtn"><i class="fas fa-times marginFontAowsome-w"></i>حذف</button>
        </div>
        <div class="col-12 col-sm-12 col-md-6 col-lg-6">
          <div class="form-group">
            <input type="text" placeholder="البحث (اسم الوحدة او رقم الوحدة)" class="form-control inputSearchTable-w" style="margin-top:13px;" (input)="filtterFunc($event)"/>
            <hr>
          </div>
        </div>
      </div>
      <div class="row" style="margin-bottom: 10px;">
          <div class="col-12 col-sm-12 col-md-12 col-lg-3">
              <div class="form-group">
                <span class="spanSelect-w" style="margin-right:10px;">
                  <select [ngModel]="dataTableNumber" class="form-control selectButton-w" (input)="onGetValue($event)">
                    <option value="5">5</option>
                    <option value="10">10</option>
                    <option value="15">15</option>
                    <option value="20">20</option>
                  </select>
                  من العناصر يتم عرضها
                </span>
              </div>
            </div>
      </div>
  
      <div class="row">
       
          <div class="col-12 col-sm-12 col-md-12 col-lg-3">
              <div class="form-group">
                <span class="spanSelect-w" style="margin-right:10px;">
                  <select [ngModel]="housing_complex_id" class="form-control selectButton-w" (input)="getBuildingsType($event.target.value)">
                    <option *ngFor="let complex of complex_list" [value]="complex.id">{{complex.name}}</option>
                  </select>
                 المجمع السكني
                </span>
              </div>
            </div>
            <div class="col-12 col-sm-12 col-md-12 col-lg-3" *ngIf="isComplex">
                <div class="form-group">
                  <span class="spanSelect-w" style="margin-right:10px;">
                    <select [ngModel]="building_type_id" class="form-control selectButton-w" (input)="getBuilding($event.target.value)">
                    <option *ngFor="let type of building_types" [value]="type.id">{{type.name}}</option>
                    </select>
                     نوع المبنى
                  </span>
                </div>
              </div>

              <div class="col-12 col-sm-12 col-md-12 col-lg-3" *ngIf="isBuildingType">
                  <div class="form-group">
                    <span class="spanSelect-w" style="margin-right:10px;">
                      <select [ngModel]="building_id" class="form-control selectButton-w" (input)="getBuildingID($event.target.value)">
                       <option *ngFor="let building of building" [value]="building.id">{{building.building_name}}</option>
                      </select>
                      اسم المبنى
                    </span>
                  </div>
                </div>  

                <div class="col-12 col-sm-12 col-md-12 col-lg-3" *ngIf="isUnit">
                    <div class="form-group">
                      <span class="spanSelect-w" style="margin-right:10px;">
                        <select [ngModel]="unitId" class="form-control selectButton-w" (input)="unitNum($event.target.value)" >
                         <option *ngFor="let unit of units" [value]="unit.id">{{unit.unit_number}}</option>
                        </select>
                         رقم الوحدة
                      </span>
                    </div>
                  </div>   
          
      </div>
  
      <table class="table table-bordered" *ngIf="this.count != 0">
        <thead class="headBackground-w">
          <tr>
            <th>
              <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input" [(ngModel)]="selectedAll" (change)="selectAll();" id="customCheck" name="example1">
              </div>
            </th>
           
            <th *ngIf="selectedComplex">اسم المجمع السكني</th>
            <th *ngIf="selectedType">نوع المبنى</th>
            <th *ngIf="selectedBuilding">اسم المبنى</th>
            <th *ngIf="selectedUnit">رقم الوحدة </th>        
            <th>تصنيف العهدة</th>
            <th>اسم العهدة</th>   
            <th>العدد</th>
            <th *ngIf="authSer.showEditBtn">تعديل</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of dataList | paginate: { itemsPerPage: perPagePagenation, currentPage: currentPage, totalItems: count }; let i = index ">
            <td>
              <div class="custom-control custom-checkbox centerIneerItem">
                <input type="checkbox" class="custom-control-input" id="{{data.id}}" [(ngModel)]="data.selected" [value]='data' (change)="checkIfAllSelected();">
             
              </div>
            </td>
            <td *ngIf="selectedComplex">{{data.housing_complex_name}}</td>
            <td *ngIf="selectedType">{{data.building_type_name}}</td>
            <td *ngIf="selectedBuilding">{{data.building_information_name}}</td>
            <td *ngIf="selectedUnit">{{data.unit_number}}</td>
            <td>{{data.category_name}}</td>
            <td>{{data.covenant_name}}</td>
            <td>{{data.covenant_amount}}</td>
          <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.unit_id)"><i class="fas fa-edit"></i></button></td>
        </tr>
      </tbody>
    </table>
    <div class="col-12" *ngIf="this.count == 0" style="margin-top: 9px;" >
      <!-- taaaaaaaaaaable -->
      <h2 class="title"> لا يوجد بيانات لعرضها </h2>
  
    </div>
    <pagination-controls nextLabel="التالي" previousLabel="السابق" (pageChange)="onPageChange($event)" *ngIf="this.count != 0"></pagination-controls>
    </div>
  </div>
  