rapportrage dbois
This commit is contained in:
@@ -17,10 +17,22 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
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();
|
||||
},
|
||||
|
||||
@@ -29,18 +41,76 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
|
||||
vm.uniqueEmployees.removeAll();
|
||||
$.each( data, function ( i, p ) {
|
||||
vm.uniqueEmployees.push(new vm.UniqueEmployee(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){
|
||||
UniqueEmployee: function ( data ) {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
var self = this;
|
||||
|
||||
@@ -48,15 +118,28 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
self.fullname = data.fullname;
|
||||
self.slug = data.slug;
|
||||
|
||||
self.myData = ko.observableArray([]);
|
||||
self.tarif = ko.observable( 0 );
|
||||
|
||||
for(var i=1; i<5; i++){
|
||||
self.myData.push( new vm.Detail(data.fullname));
|
||||
}
|
||||
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){
|
||||
console.log( data );
|
||||
Detail: function ( data ) {
|
||||
this.test = data;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user