import { Component, OnInit, Inject } from '@angular/core';
import { MdDialogRef, MD_DIALOG_DATA } from '@angular/material';
import { ContactService } from '../../contact.service';

@Component({
  selector: 'app-vehicle-expense-detail',
  templateUrl: './vehicle-expense-detail.component.html',
  styleUrls: ['./vehicle-expense-detail.component.scss']
})
export class VehicleExpenseDetailComponent implements OnInit {
  payloadObj: any;

  constructor(public dialogRef: MdDialogRef<VehicleExpenseDetailComponent>,@Inject(MD_DIALOG_DATA) public data: any,private contactService: ContactService) { 

    this.payloadObj  = this.data ;
    console.log("this.payloadObj",this.payloadObj); 
  }

  ngOnInit() {
    this.getDetailedExpense()
  }


  expenseData = [];
  getDetailedExpense(){
    this.expenseData = [];
    var pld = {
      user : this.payloadObj.user,
      type : this.payloadObj._id,
      fdate :this.payloadObj.fromDate,
      tdate : this.payloadObj.toDate,
      vehicle: this.payloadObj.vehicle,
    };
    this.contactService.getDetailedExpense(pld).subscribe(res=>{
      this.expenseData = res;
      console.log('this.expenseData=>',this.expenseData);
    },err=>{
      console.log(err);
    })
  }

}
