import { Component, OnInit } from '@angular/core';
import {FormsModule} from '@angular/forms';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Http,Headers,RequestOptions} from '@angular/http';
import { Observable} from 'rxjs';
import { map } from 'rxjs/operators';

@Component({
  selector: 'app-fees-master',
  templateUrl: './fees-master.component.html',
  styleUrls: ['./fees-master.component.scss']
})
export class FeesMasterComponent implements OnInit {
  model: any = {};
  fees: any = {};
  msg = 'Hello world';
  api="http://localhost/apollosc/api/";
  constructor(public http:Http,public RequestOption:RequestOptions) { 
    
  }

  ngOnInit() {
           this.getfees();
  }
  onSubmit() {

  

  //var fees = JSON.stringify(this.model);
  this.feessend(JSON.stringify(this.model));

 
     






  }

  feessend(fees){
   
  let Token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNb2JpbGVOdW1iZXIiOiI5ODc2NTQzMjEwIiwiaWF0IjoxNTM3NDQ4Njg3LCJleHAiOjE1NDAwNDA2ODd9.xQrICK4i-67qziTZee5AWQofHQvynoOLjLrR6PeKlH4';
  let header  =new Headers({'content-Type':'apploication/json','Token':Token,'Authorization':'apollo123'});
  let options = new RequestOptions({headers: header});
  this.http.post(this.api+'addFees',fees,options).pipe(map(data => {})).subscribe(result => {
    });
  }
  getfees(){
   console.log('hai');
  let Token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNb2JpbGVOdW1iZXIiOiI5ODc2NTQzMjEwIiwiaWF0IjoxNTM3NDQ4Njg3LCJleHAiOjE1NDAwNDA2ODd9.xQrICK4i-67qziTZee5AWQofHQvynoOLjLrR6PeKlH4';
  let header  =new Headers({'content-Type':'apploication/json','Token':Token,'Authorization':'apollo123'});
  let options = new RequestOptions({headers: header});
  return this.http.get(this.api+'getFees',options).pipe(map(data => {})).subscribe(result => {
 
  console.log(result);   
  });
 
  }
  
}
