2017-06-26 17:36:48 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
|
|
|
|
import { Http, Response } from '@angular/http';
|
|
|
|
import { ApiService } from '../providers/api-service';
|
|
|
|
import 'rxjs/add/operator/map';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: 'add-data.component.html',
|
|
|
|
providers: [ApiService]
|
|
|
|
})
|
|
|
|
export class AddDataComponent {
|
2017-06-29 15:33:11 +00:00
|
|
|
payrollForm: FormGroup;
|
|
|
|
suppliersForm: FormGroup;
|
|
|
|
singleSupplierForm: FormGroup;
|
|
|
|
employeeForm: FormGroup;
|
2017-08-25 11:18:14 +00:00
|
|
|
payrollFormStatus: any;
|
|
|
|
suppliersFormStatus: any;
|
|
|
|
singleSupplierFormStatus: any;
|
|
|
|
employeeFormStatus: any;
|
2017-06-26 17:36:48 +00:00
|
|
|
|
2017-06-29 15:33:11 +00:00
|
|
|
constructor(
|
|
|
|
private http: Http,
|
|
|
|
private formBuilder: FormBuilder,
|
|
|
|
private api: ApiService,
|
|
|
|
) {
|
|
|
|
this.payrollForm = this.formBuilder.group({
|
|
|
|
entryperiod: ['', [Validators.required]],
|
|
|
|
employeeamount: ['', [Validators.required]],
|
|
|
|
localemployeeamount: ['', [Validators.required]],
|
|
|
|
grosspayroll: ['', [Validators.required]],
|
|
|
|
payrollincometax: [''],
|
|
|
|
payrollemployeeni: [''],
|
|
|
|
payrollemployerni: [''],
|
|
|
|
payrolltotalpension: [''],
|
|
|
|
payrollotherbenefit: [''],
|
|
|
|
});
|
|
|
|
this.suppliersForm = this.formBuilder.group({
|
|
|
|
entryperiod: ['', [Validators.required]],
|
|
|
|
grossspend: ['', [Validators.required]],
|
|
|
|
suppliersamount: ['', [Validators.required]],
|
|
|
|
localsuppliersamount: ['', [Validators.required]],
|
|
|
|
});
|
|
|
|
this.singleSupplierForm = this.formBuilder.group({
|
2017-07-03 16:20:48 +00:00
|
|
|
entryperiod: ['', [Validators.required]],
|
2017-06-29 15:33:11 +00:00
|
|
|
supplierbusinessname: [''],
|
|
|
|
postcode: [''],
|
|
|
|
monthlyspend: [''],
|
|
|
|
});
|
|
|
|
this.employeeForm = this.formBuilder.group({
|
2017-07-03 16:20:48 +00:00
|
|
|
entryperiod: ['', [Validators.required]],
|
2017-06-29 15:33:11 +00:00
|
|
|
employeeno: [''],
|
|
|
|
employeeincometax: [''],
|
|
|
|
employeegrosswage: [''],
|
|
|
|
employeeni: [''],
|
|
|
|
employeepension: [''],
|
|
|
|
employeeotherbenefit: [''],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmitPayroll() {
|
|
|
|
console.log(this.payrollForm.value);
|
|
|
|
|
|
|
|
this.api
|
|
|
|
.login(this.payrollForm.value)
|
|
|
|
.subscribe(
|
|
|
|
result => {
|
|
|
|
console.log('data submitted!');
|
2017-08-25 11:18:14 +00:00
|
|
|
this.payrollFormStatus = "success";
|
|
|
|
console.log(this.payrollFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.log( error._body );
|
2017-08-25 11:18:14 +00:00
|
|
|
this.payrollFormStatus = "send_failed";
|
|
|
|
console.log(this.payrollFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmitSuppliers() {
|
|
|
|
console.log(this.suppliersForm.value);
|
|
|
|
|
|
|
|
this.api
|
|
|
|
.login(this.suppliersForm.value)
|
|
|
|
.subscribe(
|
|
|
|
result => {
|
|
|
|
console.log('data submitted!');
|
2017-08-25 11:18:14 +00:00
|
|
|
this.suppliersFormStatus = "success";
|
|
|
|
console.log(this.suppliersFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.log( error._body );
|
2017-08-25 11:18:14 +00:00
|
|
|
this.suppliersFormStatus = "send_failed";
|
|
|
|
console.log(this.suppliersFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmitSingleSupplier() {
|
|
|
|
console.log(this.singleSupplierForm.value);
|
|
|
|
|
|
|
|
this.api
|
|
|
|
.login(this.singleSupplierForm.value)
|
|
|
|
.subscribe(
|
|
|
|
result => {
|
|
|
|
console.log('data submitted!');
|
2017-08-25 11:18:14 +00:00
|
|
|
this.singleSupplierFormStatus = "success";
|
|
|
|
console.log(this.singleSupplierFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.log( error._body );
|
2017-08-25 11:18:14 +00:00
|
|
|
this.singleSupplierFormStatus = "send_failed";
|
|
|
|
console.log(this.singleSupplierFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmitEmployee() {
|
|
|
|
console.log(this.employeeForm.value);
|
|
|
|
|
|
|
|
this.api
|
|
|
|
.login(this.employeeForm.value)
|
|
|
|
.subscribe(
|
|
|
|
result => {
|
|
|
|
console.log('data submitted!');
|
2017-08-25 11:18:14 +00:00
|
|
|
this.employeeFormStatus = "success";
|
|
|
|
console.log(this.employeeFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.log( error._body );
|
2017-08-25 11:18:14 +00:00
|
|
|
this.employeeFormStatus = "send_failed";
|
|
|
|
console.log(this.employeeFormStatus);
|
2017-06-29 15:33:11 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2017-06-26 17:36:48 +00:00
|
|
|
|
|
|
|
}
|