employeehours report

This commit is contained in:
2018-02-21 21:27:23 +01:00
parent 4fbcc6a52a
commit 327f81ea97
3290 changed files with 17984 additions and 747234 deletions
@@ -15,11 +15,21 @@ dbo.monthlyemployeehoursInit = function () {
dbo.monthlyEmployeeHoursModel = {
uniqueEmployees: ko.observableArray( [] ),
sluggy : ko.observable( 'euro' ),
years : ko.observableArray( [] ),
selectedYear : ko.observable(),
currentTab : false,
uniqueEmployees : ko.observableArray( [] ),
uniqueYears : ko.observableArray( [] ),
sluggy : ko.observable( 'euro' ),
years : ko.observableArray( [] ),
selectedYear : ko.observable(),
currentTab : false,
recap : ko.observableArray( [] ),
totalPerEmployee : ko.observableArray( [] ),
totalEmployeeRevenues: ko.observable(),
totalBudget : ko.observable(),
totalCosts : ko.observable(),
totalAvailableBudget : ko.observable(),
totalSaldo : ko.observable(),
totalWorkInProgress : ko.observable(),
totalInvoicedYear : ko.observableArray( [] ),
init: function () {
var vm = dbo.monthlyEmployeeHoursModel;
@@ -38,12 +48,63 @@ dbo.monthlyemployeehoursInit = function () {
initModule: function () {
var vm = dbo.monthlyEmployeeHoursModel;
vm.totalBudget( 0 );
vm.totalCosts( 0 );
vm.totalAvailableBudget( 0 );
vm.totalSaldo( 0 );
vm.totalWorkInProgress( 0 );
vm.totalEmployeeRevenues( 0 );
vm.totalPerEmployee.removeAll();
vm.totalInvoicedYear.removeAll();
dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
vm.uniqueEmployees.removeAll();
$.each( data, function ( i, p ) {
vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) )
} );
} );
dbo.reportsDataService.getRecapProjects( function ( data ) {
vm.recap.removeAll();
vm.uniqueYears.removeAll();
$.each( data, function ( i, p ) {
if ( i == 0 ) {
$.each( p.invoiced, function ( y, q ) {
vm.uniqueYears.push( {year: q.year} );
} );
}
vm.recap.push( new vm.Project( p ) )
} );
vm.totalBudget( dbo.helpers.thousandSeparator( vm.totalBudget() ) );
vm.totalCosts( dbo.helpers.thousandSeparator( vm.totalCosts() ) );
vm.totalAvailableBudget( dbo.helpers.thousandSeparator( vm.totalAvailableBudget() ) );
vm.totalSaldo( dbo.helpers.thousandSeparator( vm.totalSaldo() ) );
vm.totalWorkInProgress( dbo.helpers.thousandSeparator( vm.totalWorkInProgress() ) );
vm.totalEmployeeRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() ) );
_.each( vm.totalPerEmployee(), function ( p ) {
p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
} );
_.each( vm.totalInvoicedYear(), function ( p ) {
p.totalInvoiced( dbo.helpers.thousandSeparator( p.totalInvoiced() ) );
} );
var chartData = [];
var chartLabels = [];
_.each( vm.totalPerEmployee(), function ( p ) {
chartData.push( Number( p.totalRevenue().replace( '.', '' ) ) );
chartLabels.push( p.fullname );
} );
var chartDataProjects = [];
var chartLabelsProjects = [];
var chartDataOwh = [];
var chartColorOwh = [];
_.each( vm.recap(), function ( p ) {
chartDataProjects.push( Number( p.totalEmployeeRevenues.replace( '.', '' ) ) );
chartLabelsProjects.push( p.projectname );
chartDataOwh.push( Number( p.workInProgress.replace( '.', '' ) ) );
chartColorOwh.push( Number( p.workInProgress.replace( '.', '' ) ) < 0 ? '#d53d24' : '#78be4b' );
} );
dbo.charts.drawPie( 'recap-revenues', chartData, chartLabels, 'omzet per medewerker' );
dbo.charts.drawPie( 'recap-revenues-project', chartDataProjects, chartLabelsProjects, 'omzet per project' );
dbo.charts.drawHoursChart( 'recap-owh', chartDataOwh, chartLabelsProjects, 'onderhandenwerk per project', chartColorOwh );
} );
},
refreshTab: function () {
@@ -103,7 +164,6 @@ dbo.monthlyemployeehoursInit = function () {
vm.currentTab.totalTotal( vm.currentTab.totalTotal() + q.totalyear );
vm.currentTab.totalTotalOtheryears( vm.currentTab.totalTotalOtheryears() + q.totalotheryears );
vm.currentTab.totalJanuariRevenue( vm.currentTab.totalJanuariRevenue() + q.januariRevenue );
vm.currentTab.totalFebruariRevenue( vm.currentTab.totalFebruariRevenue() + q.februariRevenue );
vm.currentTab.totalMaartRevenue( vm.currentTab.totalMaartRevenue() + q.maartRevenue );
@@ -149,10 +209,10 @@ dbo.monthlyemployeehoursInit = function () {
setActivetab: function ( tab ) {
var vm = dbo.monthlyEmployeeHoursModel;
console.log( 'inside' );
$.each( vm.uniqueEmployees(), function ( i, p ) {
if ( tab == p.slug ) {
vm.currentTab = p;
vm.refreshTab();
}
} )
@@ -210,6 +270,84 @@ dbo.monthlyemployeehoursInit = function () {
Detail: function ( data ) {
this.test = data;
},
Project: function ( data ) {
var vm = dbo.monthlyEmployeeHoursModel;
var self = this;
self.projectnumber = data.projectnumber;
self.instroom = data.instroom;
self.uitstroom = data.uitstroom;
self.projectname = data.projectname;
self.name = data.name;
self.revenues = dbo.helpers.thousandSeparator( data.budget );
self.hours = data.hours;
self.totalEmpoloyeeRevenues = 0;
self.externCosts = dbo.helpers.thousandSeparator( data.projectcosts );
self.budget = dbo.helpers.thousandSeparator( data.budget );
self.budgetAvailable = dbo.helpers.thousandSeparator( data.budgetAvailable );
self.saldo = dbo.helpers.thousandSeparator( data.saldo );
self.employees = ko.observableArray( [] );
$.each( data.employees, function ( i, p ) {
self.employees.push( new vm.Employee( p ) );
if ( !self.totalEmployeeRevenues ) self.totalEmployeeRevenues = 0;
} );
self.totalEmployeeRevenues = data.projectEuros;
vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
self.totalEmployeeHours = data.projectHours;
self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
self.invoiced = ko.observableArray( [] );
$.each( data.invoiced, function ( i, p ) {
self.invoiced.push( {invoiced: dbo.helpers.thousandSeparator( p.invoiced )} );
} );
vm.setTotals( data );
},
setTotals: function ( data ) {
var vm = dbo.monthlyEmployeeHoursModel;
vm.totalBudget( vm.totalBudget() + Number( data.budget ) );
vm.totalCosts( vm.totalCosts() + Number( data.projectcosts ) );
vm.totalAvailableBudget( vm.totalAvailableBudget() + Number( data.budgetAvailable ) );
vm.totalSaldo( vm.totalSaldo() + Number( data.saldo ) );
vm.totalWorkInProgress( vm.totalWorkInProgress() + Number( data.workInProgress ) );
var hasTotalEmployees = true;
if ( vm.totalPerEmployee().length == 0 ) hasTotalEmployees = false;
_.each( data.employees, function ( p ) {
if ( !hasTotalEmployees ) {
vm.totalPerEmployee.push( {id: p.id, fullname: p.fullname, totalRevenue: ko.observable( 0 )} );
}
var a = _.find( vm.totalPerEmployee(), function ( o ) {
return o.id == p.id
} );
a.totalRevenue( a.totalRevenue() + p.revenues );
} );
var hasTotalsOwpYear = true;
if ( vm.totalInvoicedYear().length == 0 ) hasTotalsOwpYear = false;
_.each( data.invoiced, function ( p ) {
if ( !hasTotalsOwpYear ) {
vm.totalInvoicedYear.push( {year: p.year, totalInvoiced: ko.observable( 0 )} );
}
var a = _.find( vm.totalInvoicedYear(), function ( o ) {
return o.year == p.year
} );
a.totalInvoiced( a.totalInvoiced() + Number( p.invoiced ) );
} );
},
Employee: function ( data ) {
this.fullname = data.fullname;
this.revenues = dbo.helpers.thousandSeparator( data.revenues );
this.hours = data.hours;
this.budget = data.budget;
this.availableHours = data.availableHours;
}
};