<title>{{'Customers'|translate}}</title>

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6">
      <app-breadcrumb [title]="'Customers'" [active_item]="'Customers'">
      </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" (click)="addCustomer()"
            *ngIf="isWritePermission" title="{{ 'tooltip_lbl_insert_customer' |translate}}">
            <i class="fa fa-plus"></i>
          </a>
        </div>

        <button *ngIf="customers && customers.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="{{ 'tooltip_lbl_filter_customer' |translate}}"
          (click)="drawer.toggle();">
          <i class="icon-filter pr-1"></i>
          <span>{{'button_lbl_filter' | translate}}</span>
        </button>
      </div>
    </div>
    <div class="col-sm-12">
      <mat-drawer-container autosize>
        <div class="card">

          <ng-container *ngIf="customers && isFlag else NoCustomerData">
            <div class="contentcard example-container mat-elevation-z8">
              <table mat-table [dataSource]="customers"
                class="mat-elevation-z8 table-striped table-vcenter lastcolumntable"
                style="min-width: 1900px; box-shadow: none;" aria-label="customer">
                <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 colspan="2" style="width: 9%;">{{'lbl_code'| translate}}</th>
                  <td mat-cell *matCellDef="let element" colspan="2" style="width: 9%;">
                    <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 colspan="2" style="width: 15%;">{{'lbl_name'|
                    translate}}</th>
                  <td mat-cell *matCellDef="let element" colspan="2" style="width: 15%;">
                    <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="contact">
                  <th mat-header-cell *matHeaderCellDef style="width: 9%;">
                    {{'lbl_contact_no'| translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width: 9%;">
                    <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="city">
                  <th mat-header-cell *matHeaderCellDef style="width: 12%;">
                    {{'lbl_city'| translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width: 12%;">
                    <ng-container *ngIf="element.city else NoValue">
                      {{element.city}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="state">
                  <th mat-header-cell *matHeaderCellDef style="width: 12%;">
                    {{'lbl_state'| translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width: 12%;">
                    <ng-container *ngIf="element.state else NoValue">
                      {{element.state}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="birthDate">
                  <th mat-header-cell *matHeaderCellDef style="width: 12%;">
                    {{'lbl_birthdate'| translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width: 12%;">
                    <ng-container *ngIf="element.birthdate else NoValue">
                      {{element.birthdate | date}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="gender">
                  <th mat-header-cell *matHeaderCellDef>{{'lbl_gender'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.gender else NoGender">
                      {{element.gender}}
                    </ng-container>
                    <ng-template #NoGender>
                      <span>--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="customerGroup">
                  <th mat-header-cell *matHeaderCellDef style="width:9%">{{'lbl_group'| translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width:9%">
                    <ng-container *ngIf="element.customerGroup else NoCustomerGroup">
                      {{element.customerGroup}}
                    </ng-container>
                    <ng-template #NoCustomerGroup>
                      <span>--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="partner">
                  <th mat-header-cell *matHeaderCellDef style="width: 12%;">{{'lbl_partner'| translate}}
                  </th>
                  <td mat-cell *matCellDef="let element" style="width: 12%;"
                    (click)="navigatePartnerViewDetail(element)">
                    <ng-container *ngIf="element.customerGroup != 'CUSTOMERS' else NoPartner">
                      {{element.partnerName}}-{{element.partnerContactNo}}
                    </ng-container>
                    <ng-template #NoPartner>
                      <span>--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="createdDate">
                  <th colspan="2" mat-header-cell *matHeaderCellDef style="width:20%">{{'lbl_created_date'| translate}}
                  </th>
                  <td colspan="2" mat-cell *matCellDef="let element" style="width:20%">
                    {{element.createdDate | date:'medium'}}
                  </td>
                </ng-container>
                <!-- <ng-container matColumnDef="isDelete">
                  <th mat-header-cell *matHeaderCellDef style="width:6%">{{'lbl_delete'| translate}}</th>
                  <td mat-cell *matCellDef="let element" style="width:6%">
                    <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 class="text-right" mat-cell *matCellDef="let element">
                    <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 && isWritePermission" mat-menu-item class="p-0 mx-2"
                        (click)="selectServiceModal(element,serviceModal)">
                        <a href="javascript:;" class="btn btn-sm btn-info filterbtn"
                          title="{{ 'tooltip_lbl_insert_loan' |translate}}">
                          <i class="fa fa-plus"></i>
                        </a>{{'lbl_add'| translate}}
                      </div>
                      <div mat-menu-item class="p-0 mx-2" *ngIf="isReadPermission"
                        (click)="navigateViewDetail(element)">
                        <a href="javascript:;" class="btn btn-sm btn-info filterbtn"
                          title="{{ 'tooltip_lbl_view_customer' |translate}}">
                          <i class="fa fa-eye"></i>
                        </a>{{'lbl_view_detail'| translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isEditPermission" mat-menu-item class="p-0 mx-2"
                        (click)="navigateEditCustomer(element)">
                        <a href="javascript:;" class="btn btn-sm btn-info filterbtn"
                          title="{{ 'tooltip_lbl_edit_customer' |translate}}">
                          <i class="fa fa-pen"></i>
                        </a>{{'lbl_edit'| translate}}
                      </div>
                      <div *ngIf="!element.isDelete && isDeletePermission" mat-menu-item class="p-0 mx-2"
                        (click)="warningAlert(element)">
                        <a title="{{ 'tooltip_lbl_delete_dsa' |translate}}" href="javascript:;"
                          class="btn btn-sm btn-info filterbtn">
                          <i class="fa fa-trash"></i>
                        </a>{{'lbl_delete'| translate}}
                      </div>
                    </mat-menu>
                  </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="customerColumns; sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: customerColumns;" class="student-element-row"
                  style="cursor: pointer;"></tr>
              </table>
            </div>
          </ng-container>

          <ng-template #NoCustomerData>
            <div class="d-flex vertical-center nodata">
            </div>
          </ng-template>
          <div class="card-footer" *ngIf="customers && customers.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="fullName">{{'lbl_search'| translate}}</label>
              <input class="form-control" type="text" name="search" [(ngModel)]="searchString" />
            </div>
            <div class="form-group">
              <label for="cityId">{{'lbl_select_role'| translate}}</label>
              <ng-select [items]="roles" class="js-example-basic-single p-0" bindLabel="name" bindValue="id"
                name="statusId" [(ngModel)]="selectedRoles" name="roleId" [multiple]="true">
              </ng-select>
            </div>
            <div class="form-group">
              <label for="pincode">{{'lbl_pincode'| translate}}</label>
              <input class="form-control" type="text" name="pincode" [(ngModel)]="pincode"
                (keyup)="onKeyUpEvent($event,true,true)" />
            </div>
            <div class="form-group" *ngIf="filterCities &&  filterCities.length > 0">
              <label for="cityId">{{'lbl_select_city'| translate}}</label>
              <ng-select [items]="filterCities" class="js-example-basic-single p-0" bindLabel="name" bindValue="id"
                name="cityId" [(ngModel)]="cityIds" [multiple]="true">
              </ng-select>
            </div>
            <div class="form-group">
              <label for="cityId">{{'customer_lbl_select_state'| translate}}</label>
              <ng-select [items]="states" class="js-example-basic-single p-0" bindLabel="name" bindValue="id"
                name="stateId" [(ngModel)]="stateIds" [multiple]="true">
              </ng-select>
            </div>
            <div class="form-group">
              <label for="cityId">{{'lbl_select_loan_type'| translate}}</label>
              <ng-select [items]="services" class="js-example-basic-single p-0" bindLabel="name" bindValue="id"
                name="serviceId" [(ngModel)]="serviceIds" [multiple]="true">
              </ng-select>
            </div>
            <div class="form-group">
              <label for="cityId">{{'lbl_select_status'| translate}}</label>
              <ng-select [items]="statuses" class="js-example-basic-single p-0" bindLabel="status" bindValue="id"
                name="statusId" [(ngModel)]="statusIds" [multiple]="true">
              </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 class="mt-3" style="padding-bottom: 15px;">
              <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" 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();filterCustomer();">
                <span>{{'lbl_search'| translate}}</span>
              </button>
            </div>
          </div>
          <div class="px-3">
          </div>

        </mat-drawer>
      </mat-drawer-container>
    </div>
  </div>
</div>

<ng-template #serviceModal let-modal>
  <div>
    <div class="modal-header">
      <h4 class="modal-title" id="modal-basic-title">{{'lbl_select_service'| translate}}</h4>
      <ng-container *ngIf="!isCreditCardService else creditCard">
        <a *ngIf="(isListService && ((customerServices && customerServices.length == 0) || (isListService && customerServices[0].basicDetail.isDelete == 1))) || (isListService && customerServices[0].basicDetail.status == 'COMPLETED') "
          href="javascript:;" class="btn btn-sm btn-info filterbtn" (click)="navigateAddLoanPage(serviceModal)"
          title="{{ 'tooltip_lbl_insert_loan' |translate}}">
          <i class="fa fa-plus"></i>
        </a>
      </ng-container>
      <ng-template #creditCard>
        <a *ngIf="(isListService && customerServices && customerServices.length == 0) || (isListService && customerServices[0].status == 'COMPLETED')"
          href="javascript:;" class="btn btn-sm btn-info filterbtn" (click)="navigateAddLoanPage(serviceModal)"
          title="{{ 'tooltip_lbl_insert_credit_card' |translate}}">
          <i class="fa fa-plus"></i>
        </a>
      </ng-template>
      <a *ngIf="isListServiceType" href="javascript:;" class="btn btn-sm btn-info filterbtn"
        (click)="modalOpen(basicmodal)" title="{{ 'tooltip_lbl_insert_loan' |translate}}">
        <i class="fa fa-plus"></i>
      </a>

    </div>
    <div class="modal-body p-0">
      <ng-container *ngIf="isSelectService">
        <ul>
          <li *ngFor="let service of services" class="service" (click)="getList(service,serviceModal)">
            {{service.name}}
          </li>
          <li *ngFor="let serviceType of serviceTypes" class="service"
            (click)="getListServiceType(serviceType,serviceModal)">
            {{serviceType.name}}
          </li>
        </ul>
      </ng-container>
      <ng-container *ngIf="isListService">
        <ng-container *ngIf="!isCreditCardService else creditCardData">
          <ng-container *ngIf="customerServices && customerServices.length > 0 else NoLoan">
            <ng-container *ngIf="isAllowAddNewService else remainingDays">
              <div class="table-responsive border-top userlist-table">
                <table mat-table [dataSource]="customerServices"
                  class="customerTable listTable mat-elevation-z8 table-striped table-vcenter" style="box-shadow: none;"
                  aria-label="customerService">
                  <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="LoanAmount">
                    <th mat-header-cell *matHeaderCellDef>{{'lbl_loan_amount'| translate}}</th>
                    <td mat-cell *matCellDef="let element">
                      <ng-container *ngIf="element.basicDetail?.loanAmount else NoValue">
                        {{currency}}{{element.basicDetail?.loanAmount | number:'0.2-2'}}
                      </ng-container>
                      <ng-template #NoValue>
                        {{currency}}<span class="text-center">0</span>
                      </ng-template>

                    </td>
                  </ng-container>
                  <ng-container matColumnDef="Employment">
                    <th mat-header-cell *matHeaderCellDef>{{'lbl_employment'| translate}}</th>
                    <td mat-cell *matCellDef="let element">
                      <ng-container *ngIf="element.basicDetail?.employmentType else NoValue">
                        {{element.basicDetail?.employmentType}}
                      </ng-container>
                      <ng-template #NoValue>
                        <span class="text-center">--</span>
                      </ng-template>

                    </td>
                  </ng-container>
                  <ng-container matColumnDef="Income">
                    <th mat-header-cell *matHeaderCellDef>{{'lbl_monthly_salary'| translate}}</th>
                    <td mat-cell *matCellDef="let element">
                      <ng-container *ngIf="element.basicDetail?.monthlyIncome else NoValue">
                        {{element.basicDetail?.monthlyIncome | number:'0.2-2'}}
                      </ng-container>
                      <ng-template #NoValue>
                        {{currency}}<span class="text-center">0</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">
                      <ng-container *ngIf="element.basicDetail && element.basicDetail.status else NoValue">
                        <span
                          *ngIf="(element.basicDetail && element.basicDetail.status == 'PENDING' || element.basicDetail.status == 'REJECTED' ) else NoPending"
                          style="color: #ff0000;">
                          {{element.basicDetail?.status}}
                        </span>
                        <ng-template #NoPending>
                          <span style="color: #0b9d0b;">{{element.basicDetail?.status}}</span>
                        </ng-template>
                      </ng-container>
                      <ng-template #NoValue>
                        <span class="text-center">{{'customer_lbl_under_editing'| translate}}</span>
                      </ng-template>
                    </td>
                  </ng-container>
                  <ng-container matColumnDef="DSACode">
                    <th mat-header-cell *matHeaderCellDef>{{'DSACode'| translate}}</th>
                    <td mat-cell *matCellDef="let element">
                      <ng-container *ngIf="element.basicDetail?.dsaCode else NoValue">
                        {{element.basicDetail?.dsaCode}}
                      </ng-container>
                      <ng-template #NoValue>
                        <span class="text-center">--</span>
                      </ng-template>

                    </td>
                  </ng-container>
                  <ng-container matColumnDef="rmFullName">
                    <th mat-header-cell *matHeaderCellDef>{{'lbl_assigned_rm'| translate}}</th>
                    <td mat-cell *matCellDef="let element">
                      <ng-container *ngIf="element.basicDetail?.rmFullName else NoValue">
                        {{element.basicDetail?.rmFullName}}
                      </ng-container>
                      <ng-template #NoValue>
                        <span class="text-center">--</span>
                      </ng-template>
                    </td>
                  </ng-container>

                  <ng-container matColumnDef="Action">
                    <th mat-header-cell *matHeaderCellDef class="text-right">{{'lbl_action'| translate}}
                    </th>
                    <td mat-cell *matCellDef="let element" class="text-right">
                      <a *ngIf="(element.basicDetail && element.basicDetail.status == 'PENDING' || element.basicDetail.status == 'RM ASSIGNED' || !element.basicDetail.status) && (element.basicDetail.createBy == userId)"
                        href="javascript:;" class="btn btn-sm btn-info filterbtn"
                        (click)="navigateEditLoanPage(element)" title="{{ 'tooltip_lbl_insert_loan' |translate}}">
                        <i class="fa fa-pen"></i>
                      </a>
                    </td>
                  </ng-container>
                  <tr mat-header-row *matHeaderRowDef="displayColumns; sticky: true"></tr>
                  <tr mat-row *matRowDef="let row; columns: displayColumns;" class="student-element-row"
                    style="cursor: pointer;"></tr>
                </table>
              </div>
            </ng-container>
            <ng-template #remainingDays>
              <div class="absolute text-center m-auto">
                <img src="../../../assets/admin/images/calendarclock.jpg" style="height:170px;width:170px" alt="">
                <h2>{{remainingString}} Days Remaining For Applying Fresh Loan!!</h2>
              </div>
            </ng-template>
          </ng-container>
          <ng-template #NoLoan>
            <div class="d-flex vertical-center nodata" style="height:calc(100vh - 420px)">
            </div>
          </ng-template>
        </ng-container>
        <ng-template #creditCardData>
          <ng-container *ngIf="customerServices && customerServices.length > 0 else NoLoan">
            <div class="table-responsive border-top userlist-table">
              <table mat-table [dataSource]="customerServices"
                class=" customerTable 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="employmentType">
                  <th mat-header-cell *matHeaderCellDef>Employment Type</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element?.employmentType else NoValue">
                      {{element.employmentType}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>

                  </td>
                </ng-container>
                <ng-container matColumnDef="panCardNo">
                  <th mat-header-cell *matHeaderCellDef>PanCardNo</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="panCardNo else NoValue">
                      {{panCardNo}}
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">--</span>
                    </ng-template>
                  </td>
                </ng-container>
                <ng-container matColumnDef="applyDate">
                  <th mat-header-cell *matHeaderCellDef>Apply Date</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.creditCardTransactionDate else NoValue">
                      {{element.creditCardTransactionDate | date}}
                    </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">
                    <ng-container *ngIf="element.status else NoValue">
                      <span *ngIf="(element.status == 'PENDING' || element.status == 'REJECTED' ) else NoPending"
                        style="color: #ff0000;">
                        {{element?.status}}
                      </span>
                      <ng-template #NoPending>
                        <span style="color: #0b9d0b;">{{element?.status}}</span>
                      </ng-template>
                    </ng-container>
                    <ng-template #NoValue>
                      <span class="text-center">{{ 'customer_lbl_under_editing' |translate}}</span>
                    </ng-template>
                  </td>
                </ng-container>

                <ng-container matColumnDef="action">
                  <th mat-header-cell *matHeaderCellDef class="text-right">{{ 'lbl_action' |translate}}</th>
                  <td mat-cell *matCellDef="let element" class="text-right">
                    <a *ngIf="(element.status == 'PENDING' || !element.status)" href="javascript:;"
                      class="btn btn-sm btn-info filterbtn" (click)="navigateEditCreditCardPage(element)"
                      title="{{ 'tooltip_lbl_insert_loan' |translate}}">
                      <i class="fa fa-pen"></i>
                    </a>
                  </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="displayCreditCardColumns; sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: displayCreditCardColumns;" class="student-element-row"
                  style="cursor: pointer;"></tr>
              </table>
            </div>
          </ng-container>
          <ng-template #NoLoan>
            <div class="d-flex vertical-center nodata" style="height:calc(100vh - 420px)">
            </div>
          </ng-template>
        </ng-template>
      </ng-container>

      <ng-container *ngIf="isListServiceType">
        <ng-container *ngIf="otherservices && otherservices.length > 0 else NoLoan">
          <div class="table-responsive border-top userlist-table">
            <table mat-table [dataSource]="otherservices"
              class=" customerTable 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="aadhaarCardNo">
                <th mat-header-cell *matHeaderCellDef>{{ 'lbl_aadhar_card_no' |translate}}</th>
                <td mat-cell *matCellDef="let element">
                  <ng-container *ngIf="element.aadhaarCardNo else NoValue">
                    {{element.aadhaarCardNo}}
                  </ng-container>
                  <ng-template #NoValue>
                    <span class="text-center">--</span>
                  </ng-template>
                </td>
              </ng-container>
              <ng-container matColumnDef="panCardNo">
                <th mat-header-cell *matHeaderCellDef>{{ 'lbl_pan_card_no' |translate}}</th>
                <td mat-cell *matCellDef="let element">
                  <ng-container *ngIf="element.panCardNo else NoValue">
                    {{element.panCardNo}}
                  </ng-container>
                  <ng-template #NoValue>
                    <span class="text-center">--</span>
                  </ng-template>
                </td>
              </ng-container> -->
              <ng-container matColumnDef="pincode">
                <th mat-header-cell *matHeaderCellDef>{{ 'lbl_pincode' |translate}}</th>
                <td mat-cell *matCellDef="let element">
                  <ng-container *ngIf="element.pincode else NoValue">
                    {{element.pincode}}
                  </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.city else NoValue">
                    {{element.city}}
                  </ng-container>
                  <ng-template #NoValue>
                    <span class="text-center">--</span>
                  </ng-template>
                </td>
              </ng-container>
              <ng-container matColumnDef="monthlyincome">
                <th mat-header-cell *matHeaderCellDef>{{ 'lbl_monthly_income' |translate}}</th>
                <td mat-cell *matCellDef="let element">
                  <ng-container *ngIf="element.monthlyincome else NoValue">
                    {{currency}}{{element.monthlyincome}}
                  </ng-container>
                  <ng-template #NoValue>
                    <span class="text-center">--</span>
                  </ng-template>
                </td>
              </ng-container>
              <ng-container matColumnDef="birthdate">
                <th mat-header-cell *matHeaderCellDef>{{ 'lbl_birthdate' |translate}}</th>
                <td mat-cell *matCellDef="let element">
                  <ng-container *ngIf="element.birthdate else NoValue">
                    {{element.birthdate | date}}
                  </ng-container>
                  <ng-template #NoValue>
                    <span class="text-center">--</span>
                  </ng-template>
                </td>
              </ng-container>
              <ng-container matColumnDef="Action">
                <th mat-header-cell *matHeaderCellDef class="text-right">{{ 'lbl_action' |translate}}</th>
                <td mat-cell *matCellDef="let element" class="text-right">
                  <a title="{{ 'tooltip_lbl_edit_reward_coin' |translate}}" href="javascript:;"
                    class="btn btn-sm btn-info filterbtn" (click)="editDialog(element,basicmodal)">
                    <i class="icon-pencil"></i>
                  </a>
                </td>
              </ng-container>
              <tr mat-header-row *matHeaderRowDef="displayColumnsServiceType; sticky: true"></tr>
              <tr mat-row *matRowDef="let row; columns: displayColumnsServiceType;" class="student-element-row"
                style="cursor: pointer;"></tr>
            </table>
          </div>
        </ng-container>
        <ng-template #NoLoan>
          <div class="d-flex vertical-center nodata">
          </div>
        </ng-template>
      </ng-container>


    </div>
    <div class="modal-footer">
      <button class="btn btn-secondary filterbtn" (click)="closeDialog()">
        {{ 'button_lbl_cancel' |translate}}
      </button>
    </div>
  </div>
</ng-template>

<ng-template #basicmodal let-modal>
  <div>
    <form [formGroup]="otherLoanform">
      <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 p-20">
        <div class="form-row">
          <div class="form-group col-lg-4">
            <label for="fullName">{{ 'lbl_full_name' |translate}}</label>
            <input class="form-control" type="text" name="fullName" formControlName="fullName" onlyAlphabets required>
            <mat-error
              *ngIf="(otherLoanform.get('fullName') && !otherLoanform.get('fullName')!.valid && otherLoanform.get('fullName')!.touched)">
              {{ 'message_lbl_full_name_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="birthdate">{{ 'lbl_date_of_birth' |translate}}</label>
            <mat-form-field appearance="outline" class=" w-100" style="margin-top: -0.25em;"
              (click)="toggleMenuService.togglePickerStyles()">
              <input matInput [matDatepicker]="filterPickerFrom" placeholder="Select Birthdate"
                formControlName="birthdate" name="birthdate" [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>
            <mat-error
              *ngIf="(otherLoanform.get('birthdate') && !otherLoanform.get('birthdate')!.valid && otherLoanform.get('birthdate')!.touched)">
              {{ 'customer_message_lbl_date_of_birth_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="contactNo">{{ 'lbl_contact_no' | translate}}</label>
            <input class="form-control" type="text" name="contactNo" formControlName="contactNo" ContactNo required>
            <mat-error
              *ngIf="(otherLoanform.get('contactNo') && !otherLoanform.get('contactNo')!.valid  && otherLoanform.get('contactNo')!.touched)">
              <span *ngIf="otherLoanform.get('contactNo')!.errors!['required']">
                {{ 'message_lbl_contact_no_is_required' |translate}}</span>
              <span *ngIf="otherLoanform.get('contactNo')!.errors!['minlength']">{{'message_lbl_enter_valid_contact_no'
                |translate}}</span>
            </mat-error>
          </div>
        </div>

        <!-- <div class="form-row"> -->
        <form [formGroup]="customFieldForm">
          <div class="row mx-0">
            <ng-container *ngFor="let controlName of customFieldForm?.controls | keyvalue;let i = index">
              <div class="col-md-4 pl-0">
                <div class="form-group">
                  <label>{{ controlName.key | titlecase }}</label>
                  <ng-container *ngIf="hints[i]">
                    <a class="systooltip"><i class="fa fa-info-circle w-4 h-4 ml-1" style="margin-top:4px"></i>
                      <span class="tooltiptext">{{hints[i]
                        }}</span>
                    </a>
                  </ng-container>
                  <input class="form-control" [formControlName]="controlName.key" type="text">
                  <mat-error
                    *ngIf="(customFieldForm.get(controlName.key) && !customFieldForm.get(controlName.key)!.valid  && customFieldForm.get(controlName.key)!.touched)">
                    <span *ngIf="customFieldForm.get(controlName.key)!.errors?.['required']">{{controlName.key}}
                      is required</span>
                    <span *ngIf="customFieldForm.get(controlName.key)!.errors?.['pattern']">{{controlName.key}}
                      is invalid</span>
                  </mat-error>
                </div>
              </div>
            </ng-container>
          </div>
        </form>
        <!-- <div class="form-group col-lg-4">
            <label for="panCardNo">{{ 'lbl_pan_card_no' |translate}}</label>
            <input class="form-control" type="text" name="panCardNo" formControlName="panCardNo" maxlength="10" required
              oninput="this.value = this.value.toUpperCase()">
            <mat-error
              *ngIf="(otherLoanform.get('panCardNo') && !otherLoanform.get('panCardNo')!.valid && otherLoanform.get('panCardNo')!.touched)">
              <span *ngIf="otherLoanform.get('panCardNo').errors['required']">{{'message_lbl_pan_card_no_is_required'
                |translate}}</span>
              <span *ngIf="otherLoanform.get('panCardNo')!.errors?.['pattern']">{{'message_lbl_enter_valid_pan_card'
                |translate}}</span>
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="aadhaarCardNo">{{ 'lbl_aadhar_card_no' |translate}}</label>
            <input class="form-control" type="text" name="aadhaarCardNo" formControlName="aadhaarCardNo" maxlength="12"
              onlyNumbers required>
            <mat-error
              *ngIf="(otherLoanform.get('aadhaarCardNo') && !otherLoanform.get('aadhaarCardNo')!.valid && otherLoanform.get('aadhaarCardNo')!.touched)">
              <span *ngIf="otherLoanform.get('aadhaarCardNo')!.errors!['required']">
                {{ 'message_lbl_aadhar_card_no_is_required' |translate}}</span>
              <span *ngIf="otherLoanform.get('aadhaarCardNo')!.errors?.['pattern']">{{'message_lbl_enter_valid_aadhar_card_no'
                |translate}}</span>
            </mat-error>
          </div> -->

        <!-- </div> -->

        <div class="form-row">
          <div class="form-group col-lg-4">
            <label for="email">{{ 'lbl_email' |translate}}</label>
            <input class="form-control" type="text" name="email" formControlName="email" required>
            <mat-error
              *ngIf="(otherLoanform.get('email') && !otherLoanform.get('email')!.valid && otherLoanform.get('email')!.touched)">
              {{ 'message_lbl_email_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="employmentTypeId">{{ 'lbl_employment_type' |translate}}</label>
            <ng-select [items]="employments" class="js-example-basic-single p-0"
              placeholder="{{ 'placeholder_lbl_select_employment_type' |translate}}" bindLabel="name" bindValue="id"
              formControlName="employmentTypeId" name="employmentTypeId">
            </ng-select>
            <mat-error
              *ngIf="(otherLoanform.get('employmentTypeId') && !otherLoanform.get('employmentTypeId')?.valid && otherLoanform.get('employmentTypeId')?.touched)">
              {{ 'message_lbl_employment_type_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="serviceId">{{ 'lbl_service_name' |translate}}</label>
            <ng-select [items]="service" class="js-example-basic-single p-0"
              placeholder="{{ 'lbl_select_loan_type' |translate}}" bindLabel="name" bindValue="id"
              formControlName="serviceId" name="serviceId">
            </ng-select>
            <mat-error
              *ngIf="(otherLoanform.get('serviceId') && !otherLoanform.get('serviceId')?.valid && otherLoanform.get('serviceId')?.touched)">
              {{ 'message_lbl_loan_type_is_required' |translate}}
            </mat-error>
          </div>
        </div>

        <div class="form-row">
          <div class="form-group col-md-6">
            <label for="addressline1">{{ 'lbl_address_line1' |translate}}</label>
            <input class="form-control" type="text" id="addressline1" formControlName="addressline1"
              placeholder="{{'lbl_type_here'| translate}}" name="addressline1" required />
            <mat-error
              *ngIf="(otherLoanform.get('addressline1') && !otherLoanform.get('addressline1')?.valid && otherLoanform.get('addressline1')?.touched)">
              {{ 'message_lbl_address_line_1_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-md-6">
            <label for="addressline2">{{ 'lbl_address_line_2' |translate}}</label>
            <input class="form-control" type="text" id="addressline2" formControlName="addressline2"
              placeholder="{{'lbl_type_here'| translate}}" name="addressline2" />

          </div>
        </div>

        <div class="form-row">
          <div class="form-group col-lg-4">
            <label for="pincode">{{ 'lbl_pincode' |translate}}</label>
            <input class="form-control" type="text" id="pincode" formControlName="pincode"
              placeholder="{{'lbl_type_here'| translate}}" maxlength="6" onlyNumbers
              (keyup)="onKeyUpEvent($event, true,false)" required>
            <mat-error
              *ngIf="(otherLoanform.get('pincode') && !otherLoanform.get('pincode')?.valid && otherLoanform.get('pincode')?.touched)">
              {{ 'message_lbl_pincode_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="cityId">{{ 'lbl_city' }}</label>
            <ng-select [items]="cities" class="js-example-basic-single p-0"
              placeholder="{{ 'lbl_select_city' |translate}}" bindLabel="name" bindValue="id" formControlName="cityId"
              name="cityId">
            </ng-select>
            <mat-error
              *ngIf="(otherLoanform.get('cityId') && !otherLoanform.get('cityId')?.valid && otherLoanform.get('cityId')?.touched)">
              {{ 'message_lbl_city_is_required' |translate}}
            </mat-error>
          </div>
          <div class="form-group col-lg-4">
            <label for="monthlyincome">{{ 'lbl_monthly_income' |translate}}</label>
            <input class="form-control" type="text" name="monthlyincome" formControlName="monthlyincome" required
              onlyNumbers>
            <mat-error
              *ngIf="(otherLoanform.get('monthlyincome') && !otherLoanform.get('monthlyincome')!.valid && otherLoanform.get('monthlyincome')!.touched)">
              {{ 'message_lbl_monthly_income_is_required' |translate}}
            </mat-error>
          </div>
        </div>

      </div>
      <div class="modal-footer">
        <button class="btn btn-sm btn-info filterbtn" (click)="insertUpdateotherLoan()">
          {{ 'button_lbl_save' |translate}}
        </button>
        <button class="btn btn-sm btn-secondary filterbtn" (click)="cancelUser()">
          {{ 'button_lbl_cancel' |translate}}
        </button>
      </div>
    </form>
  </div>
</ng-template>