153 lines
6.7 KiB
JavaScript
153 lines
6.7 KiB
JavaScript
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 08/02/2018
|
|
* Time: 15:32
|
|
*/
|
|
|
|
dbo.monthlyemployeehoursInit = function () {
|
|
|
|
if ( dbo.monthlyEmployeeHoursModel !== undefined ) {
|
|
|
|
dbo.monthlyEmployeeHoursModel.initModule();
|
|
|
|
} else {
|
|
|
|
dbo.monthlyEmployeeHoursModel = {
|
|
|
|
uniqueEmployees: ko.observableArray( [] ),
|
|
sluggy : ko.observable( 'euro' ),
|
|
years : ko.observableArray( [] ),
|
|
selectedYear : ko.observable(),
|
|
currentTab : false,
|
|
|
|
init: function () {
|
|
var vm = dbo.monthlyEmployeeHoursModel;
|
|
|
|
dbo.reportsDataService.getUsedYears( function ( data ) {
|
|
vm.years.removeAll();
|
|
$.each( data, function ( i, p ) {
|
|
vm.years.push( {id: p.year, year: p.year} );
|
|
} );
|
|
|
|
vm.selectedYear( (new Date()).getFullYear() );
|
|
} );
|
|
|
|
vm.initModule();
|
|
},
|
|
|
|
initModule: function () {
|
|
var vm = dbo.monthlyEmployeeHoursModel;
|
|
dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
|
|
vm.uniqueEmployees.removeAll();
|
|
$.each( data, function ( i, p ) {
|
|
vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) )
|
|
} );
|
|
} );
|
|
},
|
|
|
|
refreshTab: function () {
|
|
var vm = dbo.monthlyEmployeeHoursModel;
|
|
|
|
if ( vm.currentTab == false ) return;
|
|
|
|
console.log( vm.currentTab );
|
|
|
|
dbo.reportsDataService.getEmployeeHours( vm.currentTab.id, vm.selectedYear(), function ( data ) {
|
|
vm.currentTab.myData( data );
|
|
vm.currentTab.totalJanuari( 0 );
|
|
vm.currentTab.totalFebruari( 0 );
|
|
vm.currentTab.totalMaart( 0 );
|
|
vm.currentTab.totalApril( 0 );
|
|
vm.currentTab.totalMei( 0 );
|
|
vm.currentTab.totalJuni( 0 );
|
|
vm.currentTab.totalJuli( 0 );
|
|
vm.currentTab.totalAugustus( 0 );
|
|
vm.currentTab.totalSeptember( 0 );
|
|
vm.currentTab.totalOktober( 0 );
|
|
vm.currentTab.totalNovember( 0 );
|
|
vm.currentTab.totalDecember( 0 );
|
|
vm.currentTab.totalTotal( 0 );
|
|
vm.currentTab.totalTotalOtheryears( 0 );
|
|
var totalHoursChart = [];
|
|
var projectChart = [];
|
|
$.each( vm.currentTab.myData(), function ( i, q ) {
|
|
vm.currentTab.tarif( q.tarif );
|
|
vm.currentTab.totalJanuari( vm.currentTab.totalJanuari() + q.januari );
|
|
vm.currentTab.totalFebruari( vm.currentTab.totalFebruari() + q.februari );
|
|
vm.currentTab.totalMaart( vm.currentTab.totalMaart() + q.maart );
|
|
vm.currentTab.totalApril( vm.currentTab.totalApril() + q.april );
|
|
vm.currentTab.totalMei( vm.currentTab.totalMei() + q.mei );
|
|
vm.currentTab.totalJuni( vm.currentTab.totalJuni() + q.juni );
|
|
vm.currentTab.totalJuli( vm.currentTab.totalJuli() + q.juli );
|
|
vm.currentTab.totalAugustus( vm.currentTab.totalAugustus() + q.augustus );
|
|
vm.currentTab.totalSeptember( vm.currentTab.totalSeptember() + q.september );
|
|
vm.currentTab.totalOktober( vm.currentTab.totalOktober() + q.oktober );
|
|
vm.currentTab.totalNovember( vm.currentTab.totalNovember() + q.november );
|
|
vm.currentTab.totalDecember( vm.currentTab.totalDecember() + q.december );
|
|
vm.currentTab.totalTotal( vm.currentTab.totalTotal() + q.totalyear );
|
|
vm.currentTab.totalTotalOtheryears( vm.currentTab.totalTotalOtheryears() + q.totalotheryears );
|
|
totalHoursChart.push(q.totalhours);
|
|
projectChart.push(q.projectname)
|
|
} );
|
|
var chartData = [vm.currentTab.totalJanuari(), vm.currentTab.totalFebruari(), vm.currentTab.totalMaart(), vm.currentTab.totalApril(), vm.currentTab.totalMei(), vm.currentTab.totalJuni(), vm.currentTab.totalJuli(), vm.currentTab.totalAugustus(), vm.currentTab.totalSeptember(), vm.currentTab.totalOktober(), vm.currentTab.totalNovember(), vm.currentTab.totalDecember()]
|
|
dbo.charts.drawHoursChart( 'hours-per-month-' + vm.currentTab.slug, chartData, dbo.charts.monthLabels, 'uren per maand', '#f28f25' );
|
|
dbo.charts.drawHoursChart( 'hours-per-project-' + vm.currentTab.slug, totalHoursChart, projectChart, 'uren per project', '#0daef0' );
|
|
} );
|
|
},
|
|
|
|
setActivetab: function ( tab ) {
|
|
var vm = dbo.monthlyEmployeeHoursModel;
|
|
|
|
$.each( vm.uniqueEmployees(), function ( i, p ) {
|
|
if ( tab == p.slug ) {
|
|
vm.currentTab = p;
|
|
|
|
vm.refreshTab();
|
|
}
|
|
} )
|
|
|
|
vm.sluggy( tab );
|
|
},
|
|
|
|
UniqueEmployee: function ( data ) {
|
|
var vm = dbo.monthlyEmployeeHoursModel;
|
|
var self = this;
|
|
|
|
self.id = data.id;
|
|
self.fullname = data.fullname;
|
|
self.slug = data.slug;
|
|
|
|
self.tarif = ko.observable( 0 );
|
|
|
|
self.totalJanuari = ko.observable( 0 );
|
|
self.totalFebruari = ko.observable( 0 );
|
|
self.totalMaart = ko.observable( 0 );
|
|
self.totalApril = ko.observable( 0 );
|
|
self.totalMei = ko.observable( 0 );
|
|
self.totalJuni = ko.observable( 0 );
|
|
self.totalJuli = ko.observable( 0 );
|
|
self.totalAugustus = ko.observable( 0 );
|
|
self.totalSeptember = ko.observable( 0 );
|
|
self.totalOktober = ko.observable( 0 );
|
|
self.totalNovember = ko.observable( 0 );
|
|
self.totalDecember = ko.observable( 0 );
|
|
self.totalTotal = ko.observable( 0 );
|
|
self.totalOtheryears = ko.observable( 0 );
|
|
self.totalTotalOtheryears = ko.observable( 0 );
|
|
|
|
self.myData = ko.observableArray( [] );
|
|
},
|
|
|
|
Detail: function ( data ) {
|
|
this.test = data;
|
|
}
|
|
};
|
|
|
|
dbo.monthlyEmployeeHoursModel.init();
|
|
|
|
ko.applyBindings( dbo.monthlyEmployeeHoursModel, document.getElementById( "MONTHLYEMPLOYEEHOURS" ) );
|
|
}
|
|
|
|
|
|
} |