81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
export class EmployeeController {
|
|
static $inject = ['$scope', '$routeParams', '$location', 'asDateFilter', '$uibModal', 'uibDateParser', 'Messages'];
|
|
_employee_JoiningDate: any;
|
|
_employee_LeavingDate: any;
|
|
foName: boolean;
|
|
employee: any;
|
|
costCentres: any;
|
|
|
|
constructor(public $scope, public $routeParams, public $location, public asDate, public $modal, public dateParser, public Messages) {
|
|
this.employee = $scope.$parent.res.employee;
|
|
this.costCentres = $scope.$parent.res.costCentres;
|
|
this._employee_JoiningDate = dateParser.parse(this.employee.JoiningDate, "dd-MMM-yyyy");
|
|
this._employee_LeavingDate = dateParser.parse(this.employee.LeavingDate, "dd-MMM-yyyy");
|
|
this.foName = true;
|
|
}
|
|
|
|
employee_JoiningDate(value) {
|
|
if (arguments.length) {
|
|
this.employee.JoiningDate = this.asDate(value);
|
|
this._employee_JoiningDate = value;
|
|
}
|
|
return this._employee_JoiningDate;
|
|
}
|
|
|
|
employee_LeavingDate(value) {
|
|
if (arguments.length) {
|
|
this.employee.LeavingDate = this.asDate(value);
|
|
this._employee_LeavingDate = value;
|
|
}
|
|
return this._employee_LeavingDate;
|
|
}
|
|
|
|
save() {
|
|
this.employee.$save((u, putResponseHeaders) => {
|
|
this.Messages.push({Type: 'Success', Message: u.Code});
|
|
this.$location.path('/Employees');
|
|
}, (data, status) => {
|
|
this.Messages.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
}
|
|
|
|
delete() {
|
|
this.employee.$delete((u, putResponseHeaders) => {
|
|
this.Messages.push({Type: 'Success', Message: ''});
|
|
this.$location.path('/Employees');
|
|
}, (data, status) => {
|
|
this.Messages.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
}
|
|
|
|
confirm() {
|
|
const modalInstance = this.$modal.open({
|
|
backdrop: true,
|
|
templateUrl: '/template/modal/confirm.html',
|
|
controllerAs: 'vmModal',
|
|
controller: ['$uibModalInstance', class {
|
|
title: any;
|
|
body: any;
|
|
isDelete: boolean;
|
|
|
|
constructor(public $modalInstance) {
|
|
this.title = "Delete Employee";
|
|
this.body = "Are you sure? This cannot be undone.";
|
|
this.isDelete = true;
|
|
}
|
|
|
|
ok() {
|
|
this.$modalInstance.close();
|
|
}
|
|
|
|
cancel() {
|
|
this.$modalInstance.dismiss('cancel');
|
|
}
|
|
}]
|
|
});
|
|
modalInstance.result.then(() => {
|
|
this.delete();
|
|
});
|
|
}
|
|
}
|