import {Component, OnInit, ChangeDetectionStrategy, Input, OnChanges, ChangeDetectorRef, Output, EventEmitter} from '@angular/core';
import {BaseList} from '../../../../../../core/base/base-list';
import {TestingRegisterService} from '../../../../../../core/service/testing-register/testing-register.service';

@Component({
  selector: 'app-table-summary',
  templateUrl: './table-summary.component.html',
  styleUrls: ['./table-summary.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class TableSummaryComponent  extends BaseList implements OnInit,OnChanges{
  @Input() summaryData: any = [];
  @Output() recieveMoney = new EventEmitter();
  @Output() cancel = new EventEmitter();
  @Output() Onprint = new EventEmitter();
  @Output() Onprintreal = new EventEmitter();
  @Output() onNewRegister = new EventEmitter();
  @Input( ) isPrint = false;
  @Input( ) isHidebutton = false;
  @Input( ) isCancel = false;
  @Input( ) isMoney = false;
  @Input( ) isPaymentBillChild = false;

  paymentList = [];
  column = ['1', '2', '22', '23', '3', '4', '5'];

  constructor(
    private cdr: ChangeDetectorRef,
  ) {
    super()
  }

  ngOnInit(): void {
  }

  ngOnChanges(){
    console.log(this.summaryData != null)

    if (this.summaryData != null){
      this.paymentList = this.updateMatTable(this.summaryData.fee_details ? this.summaryData.fee_details : []);
      console.log(this.paymentList)
      this.cdr.detectChanges();
    }
  }

  recievemoney(type){
    // this.recieveMoney.emit({summaryData : this.summaryData});
    this.recieveMoney.emit(type);
  }

  cancelMoney(){
    this.cancel.emit();
  }

  register(){
    this.summaryData = null;
    this.isPrint = false;
    this.isMoney = false;
    this.isCancel = false;
    this.isHidebutton = false;
    this.isPaymentBillChild = false;
    this.onNewRegister.emit();
  }

  print(){
    // this.recieveMoney.emit({summaryData : this.summaryData});
    // this.Onprint.emit();
    this.Onprintreal.emit();
  }

  changeisPrint(){
    this.isPrint = true;
  }

  changeisCancel(){
    this.isPrint = true;
  }

  resetFornewRegister(){
    this.isPrint = false;
    this.isMoney = false;
    this.isCancel = false;
    this.isPaymentBillChild = false;
  }

}
