<title>Admin Commissions</title>

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6">
      <app-breadcrumb [title]="'Admin Commissions'" [active_item]="'Admin Commissions'">
      </app-breadcrumb>
    </div>
    <div class="col-sm-6 text-right">
      <div ngbDropdown class="btn-group">
        <div class="ml-2">

          <button *ngIf="adminCommission && adminCommission.length > 0" type="button" class="btn btn-info filterbtn"
            title="{{ 'tooltip_lbl_download_csv' |translate}}" (click)="downloadCsv()">
            <i class="icon-download pr-1"></i>
            <span>{{'lbl_downLoad_csv'| translate}}</span>
          </button>
          <button type="button" class="btn btn-info filterbtn filterbtn"
            title="{{ 'admin_commission_tooltip_filter_admin_commission' |translate}}" (click)="drawer.toggle();">
            <i class="icon-filter pr-1"></i>
            <span>{{'button_lbl_filter'| translate}}</span>
          </button>
        </div>
      </div>
    </div>
    <div class="col-sm-12">
      <mat-drawer-container autosize>
        <div class="card">
          <ng-container *ngIf="adminCommission && adminCommission.length > 0 else NoCommission">
            <div class="contentcard table-responsive userlist-table">
              <table mat-table [dataSource]="adminCommission" class="mat-elevation-z8 table-striped table-vcenter"
                style="min-width: 1300px; box-shadow: none;" aria-label="admincommission">
                <ng-container matColumnDef="id">
                  <th mat-header-cell *matHeaderCellDef style="width:75px">#</th>
                  <td mat-cell *matCellDef="let element; let i = index;" style="width:75px">
                    {{(paginate.currentPage - 1) * paginate.pageSize + i + 1}}
                  </td>
                </ng-container>
                <ng-container matColumnDef="commission">
                  <th mat-header-cell *matHeaderCellDef>{{'lbl_commission'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <div *ngIf="element.commission else NoValue">
                      {{element.commission | currency:'INR'}}
                    </div>
                    <ng-template #NoValue>
                      --
                    </ng-template>
                  </td>
                </ng-container>

                <ng-container matColumnDef="serviceName">
                  <th mat-header-cell *matHeaderCellDef>{{'lbl_service'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <div *ngIf="element.serviceName else NoService">
                      {{element.serviceName}}
                    </div>
                    <ng-template #NoService>
                      --
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="bankName">
                  <th mat-header-cell *matHeaderCellDef>{{'lbl_bank'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <div *ngIf="element.bankName else NoBank">
                      {{element.bankName}}
                    </div>
                    <ng-template #NoBank>
                      --
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="customerName">
                  <th mat-header-cell *matHeaderCellDef colspan="2">{{'lbl_customer_name'| translate}}
                  </th>
                  <td mat-cell *matCellDef="let element" colspan="2">
                    <div *ngIf="element.amountDisbursed else NoDetail">
                      {{element.fullName}}
                    </div>
                    <ng-template #NoDetail>
                      --
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="customerContactNo">
                  <th mat-header-cell *matHeaderCellDef colspan="2">{{'lbl_customer_contact_no'|
                    translate}}</th>
                  <td mat-cell *matCellDef="let element" colspan="2">
                    <div *ngIf="element.amountDisbursed else NoDetail">
                      {{element.contactNo}}
                    </div>
                    <ng-template #NoDetail>
                      --
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="loanAmount">
                  <th mat-header-cell *matHeaderCellDef colspan="2">{{'lbl_loan_amount'| translate}}</th>
                  <td mat-cell *matCellDef="let element" colspan="2">
                    <div *ngIf="element.amountDisbursed else NoDetail">
                      {{currency}}{{element.amountDisbursed}}
                    </div>
                    <ng-template #NoDetail>
                      --
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="date">
                  <th mat-header-cell *matHeaderCellDef>{{'lbl_transaction_date'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    {{element.createdDate | date:'medium'}}

                  </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="displayHistoryColumns; sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: displayHistoryColumns;" class="student-element-row"
                  style="cursor: pointer;" (click)="navigateLoanDetail(row)">
                </tr>
              </table>
            </div>
          </ng-container>

          <ng-template #NoCommission>
            <div class="d-flex vertical-center nodata">

            </div>
          </ng-template>

          <div class="card-footer" *ngIf="adminCommission && adminCommission.length > 0">
            <ul class="pagination mb-0 float-right">
              <li [ngClass]="{ disabled: paginate.currentPage == 1 }" class="page-item page-prev">
                <a class="page-link" href="javascript:;" tabindex="-1" (click)="setPage(paginate.currentPage - 1)">
                  <span>{{'button_lbl_prev'| translate}}</span>
                </a>
              </li>
              <li *ngFor="let page of paginate.pages" class="page-item active info"
                [ngClass]="{ active: paginate.currentPage == page }"><a
                  [ngClass]="{current:paginate.currentPage == page}" class="page-link info" href="javascript:;"
                  (click)="setPage(page)">{{page}}</a></li>
              <li [ngClass]="{ disabled: paginate.currentPage === paginate.totalPages}"
                (click)="setPage(paginate.currentPage + 1)" class="page-item page-next">
                <a class="page-link" href="javascript:;"><span>{{'button_lbl_next'| translate}}</span></a>
              </li>
            </ul>
          </div>

        </div>
        <mat-drawer #drawer class="example-sidenav" mode="over" position="end">
          <div class="col-lg-12 px-3 pt-3">
            <div class="d-inline" style="width: 100%;"><i class="fa fa-filter pr-1"><span
                  class="ml-1">{{'button_lbl_filter'|
                  translate}}</span></i>
              <button v class="close" aria-label="Close" (click)="drawer.toggle();">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
          </div>
          <hr>
          <div class="position px-3">
            <div class="form-group mb-2">
              <label>{{'lbl_select_bank'| translate}}</label>
              <ng-select [items]="bank" class="js-example-basic-single p-0" [(ngModel)]="selectedBank"
                placeholder="{{'lbl_select_bank'| translate}}" bindLabel="name" bindValue="id" name="bank">
              </ng-select>

            </div>
            <div class="form-group">
              <label>{{'lbl_select_service'| translate}}</label>
              <ng-select [items]="services" class="js-example-basic-single p-0" [(ngModel)]="selectedService"
                placeholder="{{ 'lbl_select_service' |translate}}" bindLabel="displayName" bindValue="id"
                name="service">
              </ng-select>

            </div>
          </div>
          <div class="modal-footer px-3" style="padding-bottom: 35px;justify-content: center;">
            <div class="float-right d-inline">
              <button type="button" class="btn btn-sm btn-secondary  filterbtn"
                title="{{ 'tooltip_lbl_clear_filter' |translate}}" (click)="drawer.toggle();clearSearch();">
                <span>{{'button_lbl_clear'| translate}}</span>
              </button>
              <button type="button" class="btn btn-sm btn-info  filterbtn"
                style="margin-right: 5px;border-radius: 10px; padding:8px 14px"
                title="{{ 'tooltip_lbl_filter_loans' |translate}}" (click)="drawer.toggle();setPage(1);">
                <span>{{'lbl_search'| translate}}</span>
              </button>
            </div>
          </div>
          <div class="px-3">
          </div>
        </mat-drawer>
      </mat-drawer-container>
    </div>
  </div>
</div>