employeehours
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 05/01/2018
|
||||
* Time: 15:54
|
||||
*/
|
||||
|
||||
|
||||
dbo.employeehoursInit = function () {
|
||||
|
||||
if ( dbo.employeehoursModel !== undefined ) {
|
||||
dbo.employeehoursModel.refreshHours();
|
||||
} else {
|
||||
dbo.employeehoursModel = {
|
||||
|
||||
employeehours: ko.observableArray( [] ),
|
||||
archive : ko.observable( false ),
|
||||
months : ko.observableArray( [] ),
|
||||
years : ko.observableArray( [] ),
|
||||
hourtypes : ko.observableArray( [] ),
|
||||
employees : ko.observableArray( [] ),
|
||||
selectedYear : ko.observable(),
|
||||
selectedMonth: ko.observable(),
|
||||
busy : false,
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
vm.createMonths();
|
||||
vm.createYears();
|
||||
|
||||
var d = new Date();
|
||||
vm.selectedMonth( d.getMonth() + 1 );
|
||||
vm.selectedYear( d.getFullYear() );
|
||||
|
||||
dbo.employeehoursDataService.getHourtypes( function ( data ) {
|
||||
vm.hourtypes( data );
|
||||
dbo.userDataService.getAllUsers( 'F', function ( data ) {
|
||||
vm.employees( data );
|
||||
|
||||
vm.refreshEmployeehours();
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
newEmployeehour: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
var employeehour = {
|
||||
id : 0,
|
||||
employee_id: null,
|
||||
hourdate : null,
|
||||
hourtype_id: null,
|
||||
hours : 0,
|
||||
inEdit : true
|
||||
};
|
||||
|
||||
vm.employeehours.push( new vm.Employeehour( employeehour ) );
|
||||
},
|
||||
|
||||
toggleArchive: function () {
|
||||
var vm = dbo.employeeemployeehoursModel;
|
||||
|
||||
vm.archive( !vm.archive() );
|
||||
|
||||
vm.refreshHours();
|
||||
},
|
||||
|
||||
saveEmployeehours: function () {
|
||||
var self = this;
|
||||
|
||||
if ( !self.employee_id() ) return;
|
||||
if ( !self.hourtype_id() ) return;
|
||||
if ( !self.hourdate() ) return;
|
||||
|
||||
var submitDATA = {
|
||||
id : self.id,
|
||||
employee_id: self.employee_id(),
|
||||
hourdate : self.hourdate(),
|
||||
hourtype_id: self.hourtype_id(),
|
||||
hours : self.hours()
|
||||
};
|
||||
|
||||
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
|
||||
self.id = data.employeehourID;
|
||||
} );
|
||||
},
|
||||
|
||||
editEmployeehour: function () {
|
||||
this.inEdit( !this.inEdit() );
|
||||
},
|
||||
|
||||
removeEmployeehour: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
var self = this;
|
||||
|
||||
tellMe( {
|
||||
title : 'verwijderen uren',
|
||||
message : 'weet u zeker dat u deze uren wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||
notify : true,
|
||||
noText : 'nee verwijder de uren niet',
|
||||
yesText : 'ja verwijder de uren',
|
||||
modalClass: 'modal-warning'
|
||||
}, function ( response ) {
|
||||
if ( response ) {
|
||||
dbo.employeehoursDataService.removeEmployeehour( self.id, function ( data ) {
|
||||
if ( data.result ) {
|
||||
vm.refreshEmployeehours();
|
||||
} else {
|
||||
tellMe( {
|
||||
title : 'fout bij verwijderen uren',
|
||||
message : 'de uren konden niet worden verwijderd',
|
||||
modalClass: 'modal-danger'
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
createMonths: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
var months = [
|
||||
{id: 1, monthName: 'januari'},
|
||||
{id: 2, monthName: 'februari'},
|
||||
{id: 3, monthName: 'maart'},
|
||||
{id: 4, monthName: 'april'},
|
||||
{id: 5, monthName: 'mei'},
|
||||
{id: 6, monthName: 'juni'},
|
||||
{id: 7, monthName: 'juli'},
|
||||
{id: 8, monthName: 'augustus'},
|
||||
{id: 9, monthName: 'september'},
|
||||
{id: 10, monthName: 'oktober'},
|
||||
{id: 11, monthName: 'november'},
|
||||
{id: 12, monthName: 'december'},
|
||||
]
|
||||
|
||||
vm.months( months );
|
||||
},
|
||||
|
||||
createYears: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
var years = [{id: 2015}, {id: 2016}, {id: 2017}, {id: 2018}];
|
||||
|
||||
vm.years( years );
|
||||
},
|
||||
|
||||
refreshEmployeehours: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
vm.employeehours.removeAll();
|
||||
dbo.employeehoursDataService.getEmployeehours( vm.selectedMonth(), vm.selectedYear(), function ( data ) {
|
||||
$.each( data, function ( i, p ) {
|
||||
vm.employeehours.push( new vm.Employeehour( p ) );
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
validateNumber: function ( field ) {
|
||||
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
|
||||
},
|
||||
|
||||
Employeehour: function ( data ) {
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
this.id = data.id;
|
||||
this.employee_id = ko.observable( data.employee_id );
|
||||
this.hourtype_id = ko.observable( data.hourtype_id );
|
||||
this.hourdate = ko.observable( data.hourdate );
|
||||
this.hours = ko.observable( data.hours );
|
||||
this.inEdit = ko.observable( data.inEdit || false );
|
||||
}
|
||||
};
|
||||
|
||||
dbo.employeehoursModel.init();
|
||||
|
||||
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
dbo.projectsInit = function () {
|
||||
|
||||
if ( dbo.projectsModel !== undefined ) {
|
||||
|
||||
dbo.projectsModel.refreshProjects();
|
||||
} else {
|
||||
dbo.projectsModel = {
|
||||
|
||||
@@ -129,10 +129,9 @@ dbo.projectsInit = function () {
|
||||
self.revenues = ko.observableArray( [] );
|
||||
$.each( data.offers, function ( i, p ) {
|
||||
if ( p.accepteddate ) {
|
||||
self.totalOwnrevenue += p.totalOwnrevenue;
|
||||
self.totalOtherrevenue += p.totalOtherrevenue;
|
||||
self.totalOwnrevenue += Number( p.own_revenue );
|
||||
self.totalOtherrevenue += Number( p.other_revenue );
|
||||
}
|
||||
self.revenues.push( new vm.Revenue( p ) );
|
||||
} );
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user