<title>Employees</title>

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6">
      <app-breadcrumb [title]="'Employees'" [active_item]="'Employees'">
      </app-breadcrumb>
    </div>
    <div class="col-sm-6 text-right">
      <div ngbDropdown class="btn-group">
        <div class="ml-2">
          <a href="javascript:;" class="btn btn-sm btn-info filterbtn iconplusbtn" *ngIf="isWritePermission" (click)="addEmployee()"
            title="Insert Employee">
            <i class="fa fa-plus"></i>
          </a>


          <button *ngIf="employee && employee.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" title="Filter Employee" (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="employee && employee.length > 0 else NoDsaData">
            <div class="contentcard example-container mat-elevation-z8">
              <table mat-table [dataSource]="employee"
                class="mat-elevation-z8 table-striped table-vcenter lastcolumntable"
                style="box-shadow: none; min-width: 1700px;" aria-label="">
                <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="code">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_code' | translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.code else NoValue">
                      {{element.code}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="name">
                  <th mat-header-cell *matHeaderCellDef style="width: 12%;">{{ 'lbl_name' | translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width: 12%;">
                    <ng-container *ngIf="element.fullName else NoValue">
                      {{element.fullName}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="contactNo">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_contact_no' | translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.contactNo else NoValue">
                      {{element.contactNo}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>

                <ng-container matColumnDef="dsaCode">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_dsa_code' | translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.teamCode else NoValue">
                      {{element.teamCode}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="city">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_city' | translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.cityName else NoValue">
                      {{element.cityName}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="totalApplication">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_application' | translate}}<br> {{ 'lbl_applied' |
                    translate}}
                  </th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.totalApplicationReceived else NoValue">
                      {{element.totalApplicationReceived}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="loanAmontMonth">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_loan_amount' | translate}}<br>({{ 'lbl_month' |
                    translate}})
                  </th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.thisMonthAmount else NoValue">
                      <span *ngIf="element.thisMonthAmount">
                        {{currency}}{{element.thisMonthAmount| number:'0.2-2'}}
                      </span>
                    </ng-container>
                    <ng-template #NoValue>
                      {{currency}}<span class="text-center">0</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="loanAmount">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_loan_amount' | translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.totalAmount else NoValue">
                      <span *ngIf="element.totalAmount">
                        {{currency}}{{element.totalAmount| number:'0.2-2'}}
                      </span>
                    </ng-container>
                    <ng-template #NoValue>
                      {{currency}}<span class="text-center">0</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="pending">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_pending' | translate}}<br>{{ 'lbl_application' |
                    translate}}
                  </th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.totalPending else NoValue">
                      {{element.totalPending}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="badge">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_badge' | translate}}</th>
                  <td mat-cell *matCellDef="let element; let i = index;">
                    <ng-container *ngIf="element.badgeName else NoValue">
                      {{element.badgeName}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="createdDate">
                  <th mat-header-cell *matHeaderCellDef style="width: 20%;">{{ 'lbl_created_date' | translate}}</th>
                  <td mat-cell *matCellDef="let element; let i = index;" style="width: 20%;">
                    <ng-container *ngIf="element.createdDate else NoValue">
                      {{element.createdDate| date:'medium'}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="status">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_status' | translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <span *ngIf="(element.isDisabled) else Approved" style="color: #ff0000;">
                      {{ 'DisApproved' | translate}}
                    </span>
                    <ng-template #Approved>
                      <span style="color: #0b9d0b;">{{ 'lbl_approved' | translate}}</span>
                    </ng-template>
                  </td>
                </ng-container>
                <!-- <ng-container matColumnDef="isDelete">
                  <th mat-header-cell *matHeaderCellDef>{{ 'lbl_delete' | translate}}</th>
                  <td mat-cell *matCellDef="let element" class="text-center">
                    <span *ngIf="(element.isDelete == '1') else NoDeleted" style="color: #ff0000;">
                      {{ 'lbl_yes' | translate}}
                    </span>
                    <ng-template #NoDeleted>
                      <span style="color: #0b9d0b;">{{ 'lbl_no' | translate}}</span>
                    </ng-template>
                  </td>
                </ng-container> -->
                <ng-container matColumnDef="action" stickyEnd>
                  <th class="text-right" mat-header-cell *matHeaderCellDef>{{ 'lbl_action' | translate}}</th>
                  <td mat-cell *matCellDef="let element" class="text-right">
                    <button mat-button [matMenuTriggerFor]="beforeMenu" (click)="toggleMenuService.toggleMenuStyles()">
                      <a href="javascript:;" class="btn btn-sm btn-info filterbtn"
                        title="{{ 'tooltip_lbl_action' |translate}}">
                        <i class="fa fa-angle-down"></i>
                      </a></button>
                    <mat-menu #beforeMenu="matMenu" xPosition="before">
                      <div *ngIf="!element.isDelete && isEditPermission && element.isDisabled" mat-menu-item
                        class="p-0 mx-2" (click)="verifiedPartner(element,commissionModal)">
                        <a title="Approved/DisApproved Employee" href="javascript:;"
                          class="btn btn-sm btn-info filterbtn">
                          <i class="icon-lock"></i>
                        </a>{{ 'button_lbl_verify' | translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isEditPermission && !element.isDisabled" mat-menu-item
                        class="p-0 mx-2" (click)="verifiedPartner(element,commissionModal)">
                        <a title="Approved/DisApproved Employee" href="javascript:;"
                          class="btn btn-sm btn-info filterbtn">
                          <i class="icon-unlock"></i>
                        </a>{{ 'Unverify' | translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isEditPermission" mat-menu-item class="p-0 mx-2"
                        (click)="editEmployee(element)">
                        <a title="Edit Employee" href="javascript:;" class="btn btn-sm btn-info filterbtn">
                          <i class="icon-pencil"></i>
                        </a>{{ 'lbl_edit' | translate}}
                      </div>
                      <div mat-menu-item class="p-0 mx-2" *ngIf="isReadPermission" (click)="viewDetail(element)">
                        <a title="{{ 'tooltip_lbl_view_detail' |translate}}" href="javascript:;"
                          class="btn btn-sm btn-info filterbtn">
                          <i class="icon-eye"></i>
                        </a>{{ 'lbl_view_detail' | translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isDeletePermission" mat-menu-item class="p-0 mx-2"
                        (click)="warningAlert(element)">
                        <a title="Delete Employee" href="javascript:;" class="btn btn-sm btn-info filterbtn">
                          <i class="fa fa-trash"></i>
                        </a>{{ 'lbl_delete' | translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isEditPermission && !element.isDisabled" mat-menu-item
                        class="p-0 mx-2" (click)="changeBadge(element,commissionModal)">
                        <a title="{{ 'tooltip_lbl_change_badge' |translate}}" href="javascript:;"
                          class="btn btn-sm btn-info filterbtn">
                          <i class="icon-eye"></i>
                        </a>{{ 'lbl_change_badge' | translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isEditPermission && !element.isDisabled" mat-menu-item
                        class="p-0 mx-2" (click)="insertPartnerCommission(commissionModal,element)">
                        <a href="javascript:;" class="btn btn-sm btn-info filterbtn"
                          title="{{ 'tooltip_lbl_insert_dsa_commission' |translate}}">
                          <i class="fa fa-plus"></i>
                        </a>{{ 'lbl_add_commission' | translate}}
                      </div>
                    </mat-menu>
                  </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="dsaColumns; sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: dsaColumns;" class="student-element-row"
                  style="cursor: pointer;"></tr>
              </table>
            </div>
          </ng-container>
          <ng-template #NoDsaData>
            <div class="d-flex vertical-center nodata">
            </div>
          </ng-template>
          <div class="card-footer" *ngIf="employee && employee.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"
                [ngClass]="{ active: paginate.currentPage == page }"><a
                  [ngClass]="{current:paginate.currentPage == page}" class="page-link" 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"><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">
              <label for="search">{{ 'lbl_search' | translate}}</label>
              <input class="form-control" type="text" name="search" [(ngModel)]="searchString" />
            </div>
            <div class="form-group ">
              <label for="statusId">{{ 'lbl_dsa_status' | translate}}</label>
              <ng-select [items]="status" class="js-example-basic-single p-0" bindLabel="name" bindValue="name"
                name="statusId" [(ngModel)]="selectedStatus">
              </ng-select>
            </div>
            <div class="form-group ">
              <label for="badgeId">{{ 'lbl_badge' | translate}}</label>
              <ng-select [items]="badges" class="js-example-basic-single p-0" bindLabel="name" bindValue="id"
                name="badgeId" [(ngModel)]="selectedBadge">
              </ng-select>
            </div>
            <div class="form-group">
              <label for="isDelete">{{ 'lbl_is_Delete' | translate}}</label>
              <div>
                <div class="form-check form-check-inline">
                  <input class="form-check-input" id="radioinline1" type="radio" value="Yes" name="isDelete"
                    [(ngModel)]="isDelete">
                  <label class="form-check-label" for="radioinline1">{{ 'lbl_yes' | translate}}</label>
                </div>
                <div class="form-check form-check-inline">
                  <input class="form-check-input" id="radioinline2" type="radio" value="No" name="isDelete"
                    [(ngModel)]="isDelete">
                  <label class="form-check-label" for="radioinline2">{{ 'lbl_no' | translate}}</label>
                </div>
              </div>
            </div>
            <div>
              <div class="col-form-label">{{ 'lbl_from_date' | translate}}</div>
              <mat-form-field appearance="outline" class="d-block w-100"
                (click)="toggleMenuService.togglePickerStyles()">
                <input matInput [matDatepicker]="filterPickerFrom" [max]="dateTo"
                  placeholder="{{ 'lbl_from_date' |translate}}" [(ngModel)]="dateFrom" name="fromDate" [readonly]="true"
                  (focus)="filterPickerFrom.open()" (click)="toggleMenuService.togglePickerStyles()">
                <mat-datepicker-toggle matSuffix [for]="filterPickerFrom"
                  (click)="toggleMenuService.togglePickerStyles()">
                </mat-datepicker-toggle>
                <mat-datepicker #filterPickerFrom></mat-datepicker>
              </mat-form-field>
            </div>
            <div>
              <div class="col-form-label">{{ 'lbl_to_date' | translate}}</div>
              <mat-form-field appearance="outline" class="d-block w-100 "
                (click)="toggleMenuService.togglePickerStyles()">
                <input matInput [matDatepicker]="FilterPickerTo" [max]="dateTo"
                  placeholder="{{ 'lbl_to_date' |translate}}" [(ngModel)]="dateTo" name="toDate" [readonly]="true"
                  (focus)="FilterPickerTo.open()" (click)="toggleMenuService.togglePickerStyles()">
                <mat-datepicker-toggle matSuffix [for]="FilterPickerTo"
                  (click)="toggleMenuService.togglePickerStyles()">
                </mat-datepicker-toggle>
                <mat-datepicker #FilterPickerTo></mat-datepicker>
              </mat-form-field>
            </div>
          </div>
          <div class="modal-footer p-0" style="margin-bottom: 20px;justify-content: center;">
            <div class="float-right d-inline">
              <button type="button" class="btn 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-info filterbtn" 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>
<ng-template #commissionModal let-modal>
  <div>

    <div class="modal-header">
      <h4 class="modal-title" id="modal-basic-title">{{title}}</h4>
      <button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    <div class="modal-body pd-20" [ngClass]="{documentModal:isCommission}">
      <ng-container *ngIf="isCommission else changeBadge">
        <form [formGroup]="commissionForm">
          <div class="row">
            <div class="col-lg-6">
              <div class="form-group mb-2">
                <label>{{ 'lbl_select_bank' | translate}}</label>
                <ng-select [items]="bank" class="js-example-basic-single p-0" formControlName="bankId"
                  placeholder="{{'lbl_select_bank'| translate}}" bindLabel="name" bindValue="id" name="bank" required
                  (change)="getBankLoanCommission()"></ng-select>
                <mat-error *ngIf=" (commissionForm.get('bankId') && !commissionForm.get('bankId')!.valid &&
                        commissionForm.get('bankId')!.touched) ">
                  {{ 'message_lbl_bank_selection_is_required' | translate}}
                </mat-error>
              </div>
            </div>
            <div class="col-lg-6">
              <div class=" form-group">
                <label>{{ 'lbl_select_service' | translate}}</label>
                <ng-select [items]="services" class="js-example-basic-single p-0" formControlName="serviceId"
                  placeholder="{{'lbl_select_service'| translate}}" bindLabel="displayName" bindValue="id"
                  name="service" required (change)="getBankLoanCommission()">
                </ng-select>
                <mat-error
                  *ngIf="(commissionForm.get('serviceId') && !commissionForm.get('serviceId')!.valid && commissionForm.get('serviceId')!.touched)">
                  {{ 'message_lbl_service_is_required' | translate}}
                </mat-error>
              </div>
            </div>
          </div>
          <div *ngIf="bankGetCommission">
            <p>{{ 'message_lbl_you_get' | translate}}:{{bankGetCommission}}%</p>
          </div>
          <div class="row mx-0 mb-3">

            <div class="col-lg-4 commission mr-2" *ngFor="let commissionTemplate of templates"
              [ngStyle]="{'background-color':commissionTemplate.isSelected?'#dad6ff':'#fff'}">
              <a title="select Template" style="cursor: pointer;" (click)="selectedTemplate(commissionTemplate)">
                <div>
                  <h4>{{commissionTemplate.name}}</h4>
                  {{commissionTemplate.commissiontype}}:
                  {{commissionTemplate.commission}}%
                </div>
              </a>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-6">
              <div class="form-group">
                <label>{{ 'lbl_select_commission_type' | translate}}</label>
                <ng-select [items]="commissionType" class="js-example-basic-single p-0"
                  formControlName="commissionTypeId"
                  placeholder="{{ 'placeholder_lbl_select_commission_type' |translate}}" bindLabel="name" bindValue="id"
                  groupBy="parentName" name="commissionType" required (change)="getBankLoanCommission()"
                  [readonly]="isSelected">
                </ng-select>

                <mat-error
                  *ngIf="(commissionForm.get('commissionTypeId') && !commissionForm.get('commissionTypeId')!.valid && commissionForm.get('commissionTypeId')!.touched)">
                  {{ 'message_lbl_commission_type_is_required' | translate}}
                </mat-error>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group">
                <label for="name">{{ 'lbl_commission_in_percent' | translate}}</label>
                <input class="form-control" type="text" name="commission" formControlName="commission" required
                  (keyup)="calculateCommission()" [readonly]="isSelected" NumberWithDecimal>
                <mat-error
                  *ngIf="(commissionForm.get('commission') && !commissionForm.get('commission')!.valid && commissionForm.get('commission')!.touched)">
                  {{ 'message_lbl_commission_is_required' | translate}}
                </mat-error>
                <mat-error *ngIf="isCommissionError">
                  {{ 'message_lbl_commission_is_not_greater_than_admin_can_get' | translate}}
                </mat-error>
              </div>
            </div>
          </div>


          <div *ngIf="showCommission">
            <p>{{ 'message_lbl_you_give' | translate}}:{{showCommission}}%</p>
          </div>
        </form>
        <div class="col-lg-12">
          <a href="javascript:;" class="btn btn-sm btn-info filterbtn" (click)="addMoreCommission(commissionForm);"
            title="{{ 'tooltip_lbl_add_commission' |translate}}">
            <i class="fa fa-plus"></i>
          </a>
        </div>
        <div class="col-lg-12" *ngIf="commissions && commissions.length > 0">
          <div class="table-responsive border-top userlist-table">
            <table mat-table [dataSource]="commissions"
              class="commissiontable mat-elevation-z8 table-striped table-vcenter" style="box-shadow: none;"
              aria-label="">
              <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">
                  {{i + 1}}
                </td>
              </ng-container>
              <ng-container matColumnDef="bank">
                <th mat-header-cell *matHeaderCellDef style="width:75px">{{ 'lbl_bank_name' | translate}}</th>
                <td mat-cell *matCellDef="let element; let i = index;" style="width:75px">
                  {{element.bankName}}
                </td>
              </ng-container>
              <ng-container matColumnDef="service">
                <th mat-header-cell *matHeaderCellDef style="width:75px">{{ 'lbl_service' | translate}}</th>
                <td mat-cell *matCellDef="let element; let i = index;" style="width:75px">
                  {{element.serviceName}}
                </td>
              </ng-container>
              <ng-container matColumnDef="commissionType">
                <th mat-header-cell *matHeaderCellDef style="width:75px">{{ 'lbl_commission_type' | translate}}</th>
                <td mat-cell *matCellDef="let element; let i = index;" style="width:75px">
                  {{element.commissionType}}
                </td>
              </ng-container>
              <ng-container matColumnDef="commission">
                <th mat-header-cell *matHeaderCellDef style="width:75px">{{ 'lbl_commission' | translate}}</th>
                <td mat-cell *matCellDef="let element; let i = index;" style="width:75px">
                  {{element.commission}}%
                </td>
              </ng-container>

              <ng-container matColumnDef="action">
                <th mat-header-cell *matHeaderCellDef style="width:75px;text-align:right">{{ 'lbl_action' | translate}}
                </th>
                <td mat-cell *matCellDef="let element; let i = index;" style="width:75px;text-align:right">
                  <a href="javascript:;" class="btn btn-sm btn-info filterbtn" (click)="deleteCommission(element,i);"
                    title="{{ 'tooltip_lbl_delete_commission' |translate}}">
                    <i class="fa fa-trash"></i>
                  </a>
                </td>
              </ng-container>
              <tr mat-header-row *matHeaderRowDef="commissionColumn; sticky: true"></tr>
              <tr mat-row *matRowDef="let row; columns: commissionColumn;" class="student-element-row"
                style="cursor: pointer;"></tr>
            </table>
          </div>
        </div>
      </ng-container>
      <ng-template #changeBadge>
        <div class="form-group mb-2">
          <label>{{ 'lbl_select_badge' | translate}}</label>
          <ng-select [items]="badges" class="js-example-basic-single p-0" [formControl]="badgeId" bindLabel="name"
            bindValue="id" name="badge" required></ng-select>
          <mat-error *ngIf=" (badgeId && !badgeId.valid &&
                    badgeId!.touched) ">
            {{ 'message_lbl_badge_selection_is_required' | translate}}
          </mat-error>
        </div>
      </ng-template>
    </div>
    <div class="modal-footer">

      <div class="col-lg-12">

        <ng-container *ngIf="isCommission else saveChangeBadge">
          <button class="btn btn-info filterbtn float-right" (click)="insertCommission(commissionForm)">
            {{ 'button_lbl_save' | translate}}
          </button>
        </ng-container>
        <ng-template #saveChangeBadge>
          <button class="btn btn-info filterbtn float-right" (click)="assignBadge()">
            {{ 'button_lbl_save' | translate}}
          </button>
        </ng-template>

      </div>
    </div>
  </div>
</ng-template>