<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">
          <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 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>
  
      <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>رقم الوحدة </th>
            <th>رمز الوحدة</th>
            <th>اسم الوحدة </th>
            <!-- <th>عدد غرف النوم</th>
            <th>عدد الحمامات</th>
            <th>عدد غرف الجلوس</th> -->
            <!-- <th>مطبخ مستقل</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();">
                <!-- <label class="custom-control-label disblayBlock-w" for="{{tab.id}}" style="color:#2a2a2a"></label> -->
              </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>{{data.unit_number}}</td>
            <td>{{data.unit_code}}</td>
            <td>{{data.unit_name}}</td>
            <!-- <td>{{data.bedrooms_number}}</td>
            <td>{{data.bathrooms_number}}</td>
            <td>{{data.sittingrooms_number}}</td> -->
            <!-- <td>{{data.independent_kitchen == 'yes' ? 'نعم' :  data.independent_kitchen == 'no' ? 'لا' : 'notFound'}}</td> -->
            <td>{{data.unit_status == 'new' ? 'جديد' : data.unit_status == 'old' ? 'قديم' : 'NotFound'}}</td>
            <!-- <td>{{data.description}}</td> -->
            <td>{{data.status == '0' ? 'غير فعال' : data.status == '1' ? ' فعال' : 'not found'}}</td>
          <td *ngIf="authSer.showEditBtn"><button type="button" class="btn btn-outline-secondary" (click)="onEdit(data.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>
  